6230 Commits

Author SHA1 Message Date
Yoshihiro Furudera
4f61d7fdcb gpio: dwapb: Add ACPI HID for DWAPB GPIO controller on Fujitsu MONAKA
This patch enables DWAPB GPIO controller support on Fujitsu MONAKA.

Signed-off-by: Yoshihiro Furudera <fj5100bi@fujitsu.com>
Link: https://lore.kernel.org/r/20241018015640.2924794-1-fj5100bi@fujitsu.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-31 13:37:54 +01:00
Bartosz Golaszewski
37d5a6d6f4 gpio: sysfs: demote warning messages on invalid user input to debug
We should not emit a non-ratelimited warning everytime a user passes an
invalid value to /sys/class/gpio/export as it's an easy way to spam the
kernel log. Change the relevant messages to pr_debug_ratelimited().

Link: https://lore.kernel.org/r/20241021185717.96449-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-31 13:34:13 +01:00
Bartosz Golaszewski
01aab9fd0a gpiolib: remove leftover spinlock bits
We no longer use any spinlocks in gpiolib.c. Stop including
linux/spinlock.h and remove an outdated comment.

Link: https://lore.kernel.org/r/20241024191532.78304-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-31 13:32:37 +01:00
Bartosz Golaszewski
1f4a640e9a gpiolib: fix a NULL-pointer dereference when setting direction
For optional GPIOs we may pass NULL to gpiod_direction_(input|output)().
With the call to the notifier chain added by commit 07c61d4da43f
("gpiolib: notify user-space about in-kernel line state changes") we
will now dereference a NULL pointer in this case. The reason for that is
the fact that the expansion of the VALIDATE_DESC() macro (which returns
0 for NULL descriptors) was moved into the nonotify variants of the
direction setters.

Move them back to the top-level interfaces as the nonotify ones are only
ever called from inside the GPIO core and are always passed valid GPIO
descriptors. This way we'll never call the line_state notifier chain
with non-valid descs.

Fixes: 07c61d4da43f ("gpiolib: notify user-space about in-kernel line state changes")
Reported-by: Mark Brown <broonie@kernel.org>
Closes: https://lore.kernel.org/all/d6601a31-7685-4b21-9271-1b76116cc483@sirena.org.uk/
Tested-by: Klara Modin <klarasmodin@gmail.com>
Tested-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20241024133834.47395-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-24 20:51:09 +02:00
Dan Carpenter
4295f4ccfe gpio: mb86s7x: remove some dead code in mb86s70_gpio_to_irq()
The platform_get_irq() function never returns zero so delete this check.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/b7f3a78b-7163-42a0-bd09-8b3184f29661@stanley.mountain
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-24 10:37:51 +02:00
Andy Shevchenko
101b259bce gpio: xgene-sb: don't use "proxy" headers
Update header inclusions to follow IWYU (Include What You Use)
principle.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20241018134550.2071101-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-22 09:21:12 +02:00
Andy Shevchenko
6ebbe789fe gpio: xgene-sb: Tidy up ACPI and OF ID tables
Tidy up the ACPI and OF ID tables:
- remove explicit driver_data initializer
- drop comma in the terminator entry

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20241018134550.2071101-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-22 09:21:12 +02:00
Andy Shevchenko
33319f6d34 gpio: xgene-sb: Drop ACPI_PTR() and CONFIG_ACPI guards
The complexity of config guards needed for ACPI_PTR() is not worthwhile
for the small amount of saved data. This example was doing it correctly
but I am proposing dropping this so as to reduce chance of cut and paste
where it is done wrong.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20241018134550.2071101-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-22 09:21:12 +02:00
Andy Shevchenko
8b26b8e8be gpio: xgene-sb: Remove unneeded definitions for properties
There are three definitions for the property names. Remove them as:
1) each of them is only used once;
2) in all cases the definition is longer than the value.

In the result code is better and grepping on the property immediately
gets the function in which is being used which helps to guess the type
of the value.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20241018134550.2071101-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-22 09:21:12 +02:00
Kent Gibson
9eb1e82761 gpiolib: cdev: remove redundant store of debounce_period_us
debounce_setup() stores the debounce_period_us if the driver supports
debounce, but the debounce_period_us is also stored where debounce_setup()
is called, independent of whether the debounce is being perfomed by
hardware or software.

Remove the redundant storing of the debounce_period_us in
debounce_setup().

Signed-off-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20241020115238.170994-1-warthog618@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-22 09:15:30 +02:00
Bartosz Golaszewski
3aba840291 gpio: grgpio: remove remove()
Use devres to automatically manage resources and remove the remove()
callback.

Link: https://lore.kernel.org/r/20241015131832.44678-4-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-22 09:04:35 +02:00
Bartosz Golaszewski
d036ae41ce gpio: grgpio: use a helper variable to store the address of ofdev->dev
Instead of dereferencing the platform device pointer repeatedly, just
store its address in a helper variable.

Link: https://lore.kernel.org/r/20241015131832.44678-3-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-22 09:04:03 +02:00
Bartosz Golaszewski
537ec282f5 gpio: grgpio: order headers alphabetically
For easier maintenance: order all included headers alphabetically.

Link: https://lore.kernel.org/r/20241015131832.44678-2-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-22 09:03:59 +02:00
Bartosz Golaszewski
bc40668def gpio: grgpio: drop Kconfig dependency on OF_GPIO
This driver has no build-time dependency on gpiolib-of so remove the
Kconfig switch.

Link: https://lore.kernel.org/r/20241015131832.44678-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-22 09:03:59 +02:00
Bartosz Golaszewski
07c61d4da4 gpiolib: notify user-space about in-kernel line state changes
We currently only notify user-space about line config changes that are
made from user-space. Any kernel config changes are not signalled.

Let's improve the situation by emitting the events closer to the source.
To that end let's call the relevant notifier chain from the functions
setting direction, gpiod_set_config(), gpiod_set_consumer_name() and
gpiod_toggle_active_low(). This covers all the options that we can
inform the user-space about. We ignore events which don't have
corresponding flags exported to user-space on purpose - otherwise the
user would see a config-changed event but the associated line-info would
remain unchanged.

gpiod_direction_output/input() can be called from any context.
Fortunately, we now emit line state events using an atomic notifier
chain, so it's no longer an issue.

Let's also add non-notifying wrappers around the direction setters in
order to not emit superfluous reconfigure events when requesting the
lines as the initial config should be part of the request notification.

Use gpio_do_set_config() instead of gpiod_set_debounce() for configuring
debouncing via hardware from the character device code to avoid multiple
reconfigure events.

Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20241018-gpio-notify-in-kernel-events-v5-8-c79135e58a1c@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-22 08:59:09 +02:00
Bartosz Golaszewski
fcc8b637c5 gpiolib: switch the line state notifier to atomic
With everything else ready, we can now switch to using the atomic
notifier for line state events which will allow us to notify user-space
about direction changes from atomic context.

Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20241018-gpio-notify-in-kernel-events-v5-7-c79135e58a1c@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-22 08:59:09 +02:00
Bartosz Golaszewski
40b7c49950 gpio: cdev: put emitting the line state events on a workqueue
In order to allow line state notifications to be emitted from atomic
context (for instance: from gpiod_direction_input/output()), we must
stop calling any sleeping functions in lineinfo_changed_notify(). To
that end let's use the new workqueue.

Let's atomically allocate small structures containing the required data
and fill it with information immediately upon being notified about the
change except for the pinctrl state which will be retrieved later from
process context. We can pretty reliably do this as pin functions are
typically set once per boot.

Let's make sure to bump the reference count of GPIO device and the GPIO
character device file descriptor to keep both alive until the event was
queued.

Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20241018-gpio-notify-in-kernel-events-v5-6-c79135e58a1c@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-22 08:59:09 +02:00
Bartosz Golaszewski
7b9b77a8bb gpiolib: add a per-gpio_device line state notification workqueue
In order to prepare the line state notification mechanism for working in
atomic context as well, add a dedicated, high-priority, ordered
workqueue to GPIO device which will be used to queue the events fron any
context for them to be emitted always in process context.

Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20241018-gpio-notify-in-kernel-events-v5-5-c79135e58a1c@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-22 08:59:08 +02:00
Bartosz Golaszewski
8c44447bd7 gpio: cdev: prepare gpio_desc_to_lineinfo() for being called from atomic
In order to prepare gpio_desc_to_lineinfo() to being called from atomic
context, add a new argument - bool atomic - which, if set, indicates
that no sleeping functions must be called (currently: only
pinctrl_gpio_can_use_line()).

Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20241018-gpio-notify-in-kernel-events-v5-4-c79135e58a1c@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-22 08:59:08 +02:00
Bartosz Golaszewski
81625f3624 gpio: cdev: go back to storing debounce period in the GPIO descriptor
This effectively reverts commits 9344e34e7992 ("gpiolib: cdev: relocate
debounce_period_us from struct gpio_desc") and d8543cbaf979 ("gpiolib:
remove debounce_period_us from struct gpio_desc") and goes back to
storing the debounce period in microseconds in the GPIO descriptor

We're doing it in preparation for notifying the user-space about
in-kernel line config changes.

Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20241018-gpio-notify-in-kernel-events-v5-3-c79135e58a1c@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-22 08:59:08 +02:00
Bartosz Golaszewski
dd26ffaa4d gpiolib: unduplicate chip guard in set_config path
We don't need to guard the GPIO chip until its first dereference in
gpio_do_set_config().

First: change the prototype of gpio_do_set_config() to take the GPIO
line descriptor as argument, then move the gpio_chip protection into it
and drop it in two places where it's done too early.

This has the added benefit of making gpio_go_set_config() safe to use
from outside of this compilation unit without taking the gdev SRCU read
lock and will come in handy when we'll want to make it available to the
character device code.

Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20241018-gpio-notify-in-kernel-events-v5-2-c79135e58a1c@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-22 08:59:08 +02:00
Bartosz Golaszewski
49182c87af gpiolib: notify user-space when a driver requests its own desc
We notify user-space about lines being requested from user-space or by
drivers calling gpiod_get() but not when drivers request their own lines
so add the missing call to gpiod_line_state_notify().

Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20241018-gpio-notify-in-kernel-events-v5-1-c79135e58a1c@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-22 08:59:08 +02:00
Bartosz Golaszewski
57e0e71887 gpio: max730x: use devres to shrink and simplify code
Use managed variants of gpiochip_add_data() and mutex_init() to drop a
label and lose a couple LOC.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241017121447.73754-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-21 09:23:47 +02:00
Bartosz Golaszewski
68d51a0207 gpio: ftgpio010: shrink code
Use devm_clk_get_enabled() to drop the goto label from probe() and the
entire remove() callback. Drop platform_set_drvdata() as it's no longer
needed. Drop log noise on success.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241017123044.75531-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-21 09:23:34 +02:00
Bartosz Golaszewski
dacd8ed24c gpio: 74x164: shrink code
Use managed helpers to drop the goto label from probe() and shrink the
remove() callback.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241017150835.105676-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-21 09:23:20 +02:00
Uwe Kleine-König
678eefc1ca gpio: Switch back to struct platform_driver::remove()
After commit 0edb555a65d1 ("platform: Make platform_driver::remove()
return void") .remove() is (again) the right callback to implement for
platform drivers.

Convert all platform drivers below drivers/gpio/ to use .remove(), with
the eventual goal to drop struct platform_driver::remove_new(). As
.remove() and .remove_new() have the same prototypes, conversion is done
by just changing the structure member name in the driver initializer.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/20241016152435.38149-2-u.kleine-koenig@baylibre.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-17 09:00:48 +02:00
Bartosz Golaszewski
3bd13ae04c gpio: menz127: simplify error path and remove remove()
Use devres to drop all goto labels from probe() and remove the driver
remove() callback. While at it: drop the unnecessary dev_info() message
as not only should the driver be quiet when successful, the message is
also wrong: the device was probed at this point, the driver had been
registered earlier.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241014092227.78886-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-17 08:53:49 +02:00
Bartosz Golaszewski
9a94580120 gpio: amdpt: remove remove()
Use the managed variant of gpiochip_add_data() and remove the remove()
callback.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241014092909.90607-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-17 08:53:34 +02:00
Bartosz Golaszewski
3dcf0643fa gpio: fold the Kconfig prompt into the option type for GPIO CDEV
The 'if !EXPERT' bit will work fine if it follows the 'bool "foobar"'
declaration. No need to have separate entries for it.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241014110707.101320-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-17 08:53:19 +02:00
Bartosz Golaszewski
b6f7aeaf1b gpio: sysfs: constify gpio class
All class functions used here take a const pointer to the class
structure. We can constify gpio_class.

While at it: remove a stray newline and use a tab in the struct
definition for consistency with the line above.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241014121831.106532-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-17 08:53:02 +02:00
Bartosz Golaszewski
476f18c089 gpio: ljca: use devm_mutex_init() to simplify the error path and remove()
Destroying the mutexes is done at the end of remove() so switching to
devres does not constitute a functional change. Use devm_mutex_init()
and remove repetitions of mutex_destroy().

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241008162416.85111-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-14 10:30:36 +02:00
Bartosz Golaszewski
a937ee6d7e gpio: mpc8xxx: use generic device_is_compatible()
This driver doesn't need to include of.h and use OF-specific interfaces.
Use generic property helpers instead.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241009162910.33477-2-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-14 10:30:11 +02:00
Bartosz Golaszewski
2707a028c9 gpio: mpc8xxx: use a helper variable to store the address of pdev->dev
Instead of repeatedly dereferencing pdev, just store the address of the
embedded struct device in a local variable and use it instead for
improved readability.

While at it: rearrange variable declarations.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241009162910.33477-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-14 10:30:11 +02:00
Bartosz Golaszewski
1b35c124f9 gpio: vf610: use generic device_get_match_data()
There's no need to use the OF-specific variant to get the match data.
Switch to using device_get_match_data() and with that remove the of.h
include. Also remove of_irq.h as none of its interfaces is used here and
order the includes in alphabetical order.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241007102549.34926-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-14 10:29:11 +02:00
Bartosz Golaszewski
1396470c11 gpio: eic-sprd: use generic device_get_match_data()
There's no need to use the OF-specific variant to get the match data.
Switch to using device_get_match_data() instead.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241007102859.35602-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-14 10:28:56 +02:00
Bartosz Golaszewski
5dfdcd9e73 gpio: davinci: use generic device properties
OF-specific routines should not be used unless necessary. Generic device
properties are preferred so switch to using them in the driver code.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241007103440.38416-2-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-14 10:28:40 +02:00
Bartosz Golaszewski
56d6ff4b8f gpio: davinci: allow building the module with COMPILE_TEST=y
Make it possible to build the module when COMPILE_TEST is enabled for
better build coverage. Stop using of_match_ptr() to avoid build warnings.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241007103440.38416-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-14 10:28:39 +02:00
Bartosz Golaszewski
16de489e3a gpio: ts4900: use generic device properties
There's no reason to use OF-specific variants of property getters.
Switch to using the preferred, generic device property helpers.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241007104052.39374-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-14 10:28:21 +02:00
Bartosz Golaszewski
3a5ca23bb6 gpio: mvebu: drop dependency on OF_GPIO
This driver doesn't really depend on interfaces from OF_GPIO so the
Kconfig dependency can be dropped.

Suggested-by: Uwe Kleine-König <ukleinek@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Uwe Kleine-König <ukleinek@kernel.org>
Link: https://lore.kernel.org/r/20241008081555.23465-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-14 10:28:01 +02:00
Mary Strodl
c46a74ff05 gpio: add support for FTDI's MPSSE as GPIO
FTDI FT2232H is a USB to GPIO chip. Sealevel produces some devices
with this chip. FT2232H presents itself as a composite device with two
interfaces (each is an "MPSSE"). Each MPSSE has two banks (high and low)
of 8 GPIO each. I believe some MPSSE's have only one bank, but I don't
know how to identify them (I don't have any for testing) and as a result
are unsupported for the time being.

Additionally, this driver provides software polling-based interrupts for
edge detection. For the Sealevel device I have to test with, this works
well because there is hardware debouncing. From talking to Sealevel's
people, this is their preferred way to do edge detection.

Signed-off-by: Mary Strodl <mstrodl@csh.rit.edu>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241009131131.1618329-1-mstrodl@csh.rit.edu
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-14 09:07:32 +02:00
Billy Tsai
b2e861bd1e gpio: aspeed: Support G7 Aspeed gpio controller
In the 7th generation of the SoC from Aspeed, the control logic of the
GPIO controller has been updated to support per-pin control. Each pin now
has its own 32-bit register, allowing for individual control of the pin's
value, direction, interrupt type, and other settings. The permission for
coprocessor access is supported by the hardware but hasn't been
implemented in the current patch.

Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au>
Link: https://lore.kernel.org/r/20241008081450.1490955-8-billy_tsai@aspeedtech.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-14 09:04:02 +02:00
Billy Tsai
79fc9a2fcc gpio: aspeed: Create llops to handle hardware access
Add low-level operations (llops) to abstract the register access for GPIO
registers and the coprocessor request/release. With this abstraction
layer, the driver can separate the hardware and software logic, making it
easier to extend the driver to support different hardware register
layouts.

Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au>
Tested-by: Andrew Jeffery <andrew@codeconstruct.com.au> # AST2600
Link: https://lore.kernel.org/r/20241008081450.1490955-6-billy_tsai@aspeedtech.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-14 09:04:02 +02:00
Billy Tsai
d787289589 gpio: aspeed: Remove the name for bank array
The bank array name is only used to determine if the GPIO offset is valid,
and this condition can be replaced by checking if the offset exceeds the
ngpio property.

Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au>
Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Link: https://lore.kernel.org/r/20241008081450.1490955-5-billy_tsai@aspeedtech.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-14 09:04:02 +02:00
Billy Tsai
f1bc03e7e9 gpio: aspeed: Change the macro to support deferred probe
Use module_platform_driver() to replace module_platform_driver_probe().
The former utilizes platform_driver_register(), which allows the driver to
defer probing when it doesn't acquire the necessary resources due to probe
order. In contrast, the latter uses __platform_driver_probe(), which
includes the comment "Note that this is incompatible with deferred
probing." Since our GPIO driver requires access to the clock resource, the
former is more suitable.

Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au>
Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Link: https://lore.kernel.org/r/20241008081450.1490955-4-billy_tsai@aspeedtech.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-14 09:04:02 +02:00
Bartosz Golaszewski
bebb45743d Linux 6.12-rc3
-----BEGIN PGP SIGNATURE-----
 
 iQFSBAABCAA8FiEEq68RxlopcLEwq+PEeb4+QwBBGIYFAmcMPK0eHHRvcnZhbGRz
 QGxpbnV4LWZvdW5kYXRpb24ub3JnAAoJEHm+PkMAQRiGw5kH/0GukMc4uUytezog
 7UxIxa0G1zvwJwAhJpNCZR90e8GQ7YCvJFUOxjX3bVqjxZlCjEJ3YWC3fZNdx8YS
 fOjbuZlGiTmyKg91aVYlby5l23N+r2u6gCDBdPfJD0japiIbayBKjrL+hdEicmf3
 w6qToMY20mdvRQ6SUd+Y9nrc//TONru4EhabqRU2Sf1sDzQd1qj4WPtDLSKp3YG9
 hpFR7YeJaSYDjwRz1vF8tEnQVJ4I2Df3lXJZYsoSsqiQhQ1Lasp4a09ppVPysj6x
 oQCza6xeR3jwKib23pZIbNAF4xPMdN1OMOiYELkgHo7YGc6kxniXqSVSrP3LAvkA
 b92bQpc=
 =T5hJ
 -----END PGP SIGNATURE-----

Merge tag 'v6.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux into gpio/for-next

Linux 6.12-rc3
2024-10-14 09:03:34 +02:00
Bartosz Golaszewski
ea7f2dfd13 Immutable branch between MFD, GPIO, I2C and Watchdog due for the v6.13 merge window
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAmcHkrwACgkQUa+KL4f8
 d2EEeBAAoJio/mzf8zoc6dAygiT1xeWDIHQKIzKCT0RFzyfjTQnaajtNalYOS9Rx
 16R3zVpElAwFSzafa/nARj//D68tdQOF47QFHE6necuhzY3HKHAFM6xxRmHt71e1
 4SY6UU3Go741m/jZuXkicRAv52rOQteTy7XwSVREX3O1tld6ggwZYiiEdHHCQ4Tn
 caFQLchOJezpm4rfwcqMDhguODE+p1VVXybSrl/ellGt6G6ADi0E3gW8vaF7d6GO
 frNPNIRVFejOgAy0O6GT8T1m7qZnhACYRJSubKNMrB3UeKKLVL5YzWuPw0Mnl5GQ
 64wK/qblFnHIhdifIJZYwn0xtoxjO7ooC5bK5aTJJhbg3e91ZuI2b3aqIQw/DWkk
 Fitl1XS2icRDsY4IkL1/MDD5HXQifFAEYLRWfn+rBSC3bILDck7tzSkWtUOrgtgJ
 z0wInRhfzkV4sFIHt0susqH+434CqPcjJ5jb+JpekFBUU5DTOO692x5sWBL7p4Qp
 qWm1fTfuX0kYPOHiChHw7NzSBrjdB/LOfNXNp7zZHpB0Vr3ds1XTHI0CBaxcGAYi
 msC/qEkZHyWCOiXy03gZEsloJGL7aS0jZ2g1fX6QxQV07bwiaTKj09wCxbckPkTb
 uCnFq2sZt4Bt5cYdaYopc4TF+bnS0mYUHgRm9CzVL/lZLN4F6Y0=
 =vhYn
 -----END PGP SIGNATURE-----

Merge tag 'ib-mfd-gpio-i2c-watchdog-v6.13' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/lee/mfd into gpio/for-next

Immutable branch between MFD, GPIO, I2C and Watchdog due for the v6.13 merge window
2024-10-10 11:12:47 +02:00
Thomas Richard
4342bf63b6 gpio: Congatec Board Controller gpio driver
Add gpio support for the Congatec Board Controller.
This Board Controller has 14 GPIO pins.

The driver is probed by the Congatec Board Controller MFD driver.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Link: https://lore.kernel.org/r/20241001-congatec-board-controller-v3-2-39ceceed5c47@bootlin.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 16:32:04 +01:00
Billy Tsai
a6191a3d18 gpio: aspeed: Use devm_clk api to manage clock source
Replace of_clk_get with devm_clk_get_enabled to manage the clock source.

Fixes: 5ae4cb94b313 ("gpio: aspeed: Add debounce support")
Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au>
Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Link: https://lore.kernel.org/r/20241008081450.1490955-3-billy_tsai@aspeedtech.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-08 16:01:58 +02:00
Billy Tsai
1bb5a99e1f gpio: aspeed: Add the flush write to ensure the write complete.
Performing a dummy read ensures that the register write operation is fully
completed, mitigating any potential bus delays that could otherwise impact
the frequency of bitbang usage. E.g., if the JTAG application uses GPIO to
control the JTAG pins (TCK, TMS, TDI, TDO, and TRST), and the application
sets the TCK clock to 1 MHz, the GPIO's high/low transitions will rely on
a delay function to ensure the clock frequency does not exceed 1 MHz.
However, this can lead to rapid toggling of the GPIO because the write
operation is POSTed and does not wait for a bus acknowledgment.

Fixes: 361b79119a4b ("gpio: Add Aspeed driver")
Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au>
Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Link: https://lore.kernel.org/r/20241008081450.1490955-2-billy_tsai@aspeedtech.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-08 16:01:58 +02:00
Bartosz Golaszewski
b7adfb6076 gpio: cdev: update flags at once when reconfiguring from user-space
Make updating the descriptor flags when reconfiguring from user-space
consistent with the rest of the codebase: read the current state
atomically, update it according to user's instructions and write it back
atomically as well.

Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20241004-gpio-notify-in-kernel-events-v1-3-8ac29e1df4fe@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-08 10:21:46 +02:00