aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
Commit message (Collapse)AuthorAgeFilesLines
* refactor(gpio): change set functions to return intsaturneric2025-10-171-2/+3
| | | | | | | * Update `bgpio_set_direct` and `bgpio_set_multiple_direct` to return an integer instead of void for better error handling. * This change allows the caller to check for success or failure of the operations.
* Merge tag 'v6.17'saturneric2025-10-16160-1107/+2353
|\ | | | | | | Linux 6.17
| * gpio: regmap: fix memory leak of gpio_regmap structureIoana Ciornei2025-09-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The gpio_regmap structure is leaked on the error path. Fix this by jumping to the appropriate kfree instead of returning directly. Fixes: db305161880a ("gpio: regmap: Allow ngpio to be read from the property") Signed-off-by: Ioana Ciornei <[email protected]> Suggested-by: Michael Walle <[email protected]> Reviewed-by: Michael Walle <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| * gpiolib: Extend software-node support to support secondary software-nodesHans de Goede2025-09-221-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a software-node gets added to a device which already has another fwnode as primary node it will become the secondary fwnode for that device. Currently if a software-node with GPIO properties ends up as the secondary fwnode then gpiod_find_by_fwnode() will fail to find the GPIOs. Add a new gpiod_fwnode_lookup() helper which falls back to calling gpiod_find_by_fwnode() with the secondary fwnode if the GPIO was not found in the primary fwnode. Fixes: e7f9ff5dc90c ("gpiolib: add support for software nodes") Cc: [email protected] Signed-off-by: Hans de Goede <[email protected]> Reviewed-by: Dmitry Torokhov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| * Merge tag 'intel-gpio-v6.17-1' of ↵Bartosz Golaszewski2025-09-162-2/+21
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/andy/linux-gpio-intel into gpio/for-current intel-gpio fixes for v6.17-rc7 * Fix a regression to make GpioInt() by index work again * Ingnore spurious wakeups from touchpad on GPD G1619-05 * Accept debounce from GpioIo() resources
| | * gpiolib: acpi: initialize acpi_gpio_info structSébastien Szymanski2025-09-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since commit 7c010d463372 ("gpiolib: acpi: Make sure we fill struct acpi_gpio_info"), uninitialized acpi_gpio_info struct are passed to __acpi_find_gpio() and later in the call stack info->quirks is used in acpi_populate_gpio_lookup. This breaks the i2c_hid_cpi driver: [ 58.122916] i2c_hid_acpi i2c-UNIW0001:00: HID over i2c has not been provided an Int IRQ [ 58.123097] i2c_hid_acpi i2c-UNIW0001:00: probe with driver i2c_hid_acpi failed with error -22 Fix this by initializing the acpi_gpio_info pass to __acpi_find_gpio() Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220388 Fixes: 7c010d463372 ("gpiolib: acpi: Make sure we fill struct acpi_gpio_info") Signed-off-by: Sébastien Szymanski <[email protected]> Tested-by: Hans de Goede <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Acked-by: Mika Westerberg <[email protected]> Tested-By: Calvin Owens <[email protected]> Cc: [email protected] Signed-off-by: Andy Shevchenko <[email protected]>
| | * gpiolib: acpi: Ignore touchpad wakeup on GPD G1619-05Antheas Kapenekakis2025-09-011-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Same issue as G1619-04 in commit 805c74eac8cb ("gpiolib: acpi: Ignore touchpad wakeup on GPD G1619-04"), Strix Point lineup uses 05. Signed-off-by: Antheas Kapenekakis <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]>
| | * gpiolib: acpi: Program debounce when finding GPIOMario Limonciello (AMD)2025-08-211-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When soc-button-array looks up the GPIO to use it calls acpi_find_gpio() which will parse _CRS. acpi_find_gpio.cold (drivers/gpio/gpiolib-acpi-core.c:953) gpiod_find_and_request (drivers/gpio/gpiolib.c:4598 drivers/gpio/gpiolib.c:4625) gpiod_get_index (drivers/gpio/gpiolib.c:4877) The GPIO is setup basically, but the debounce information is discarded. The platform will assert what debounce should be in _CRS, so program it at the time it's available. Reviewed-by: Mika Westerberg <[email protected]> Signed-off-by: Mario Limonciello (AMD) <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]>
| * | gpio: fix GPIO submenu in KconfigBartosz Golaszewski2025-09-021-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit a86240a37d43 ("gpiolib: enable CONFIG_GPIOLIB_LEGACY even for !GPIOLIB") accidentally pulled all items from within the GPIOLIB submenu into the main driver menu. Put them back under the top-level GPIO entry. Suggested-by: Rob Herring <[email protected]> Fixes: a86240a37d43 ("gpiolib: enable CONFIG_GPIOLIB_LEGACY even for !GPIOLIB") Reported-by: Rob Herring <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Reviewed-by: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| * | Merge tag 'gpio-fixes-for-v6.17-rc4' of ↵Linus Torvalds2025-08-311-1/+1
| |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux Pull gpio fixes from Bartosz Golaszewski: - fix an off-by-one bug in interrupt handling in gpio-timberdale - update MAINTAINERS * tag 'gpio-fixes-for-v6.17-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: MAINTAINERS: Change Altera-PIO driver maintainer gpio: timberdale: fix off-by-one in IRQ type boundary check
| | * | gpio: timberdale: fix off-by-one in IRQ type boundary checkJunjie Cao2025-08-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | timbgpio_irq_type() currently accepts offset == ngpio, violating gpiolib's [0..ngpio-1] contract. This can lead to undefined behavior when computing '1 << offset', and it is also inconsistent with users that iterate with for_each_set_bit(..., ngpio). Tighten the upper bound to reject offset == ngpio. No functional change for in-range offsets. Signed-off-by: Junjie Cao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| * | | Merge tag 'pinctrl-v6.17-2' of ↵Linus Torvalds2025-08-251-0/+14
| |\ \ \ | | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl Pull pin control fixes from Linus Walleij: - Module macro parameter fix for the meson driver so that it actually modprobes - ACPI quirk for the ASUS ProArt PX13 - Build dependency for the STMFX driver - Proper return value for the pinconf callbacks in the Airhoa driver * tag 'pinctrl-v6.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl: pinctrl: airoha: Fix return value in pinconf callbacks pinctrl: STMFX: add missing HAS_IOMEM dependency gpiolib: acpi: Add quirk for ASUS ProArt PX13 pinctrl: meson: Fix typo in device table macro
| | * | gpiolib: acpi: Add quirk for ASUS ProArt PX13Mario Limonciello (AMD)2025-08-191-0/+14
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ASUS ProArt PX13 has a spurious wakeup event from the touchpad a few moments after entering hardware sleep. This can be avoided by preventing the touchpad from being a wake source. Add to the wakeup ignore list. Reported-by: Amit Chaudhari <[email protected]> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4482 Tested-by: Amit Chaudhari <[email protected]> Signed-off-by: Mario Limonciello (AMD) <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
| * | gpio: mlxbf3: use platform_get_irq_optional()David Thompson2025-08-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The gpio-mlxbf3 driver interfaces with two GPIO controllers, device instance 0 and 1. There is a single IRQ resource shared between the two controllers, and it is found in the ACPI table for device instance 0. The driver should not use platform_get_irq(), otherwise this error is logged when probing instance 1: mlxbf3_gpio MLNXBF33:01: error -ENXIO: IRQ index 0 not found Cc: [email protected] Fixes: cd33f216d241 ("gpio: mlxbf3: Add gpio driver support") Signed-off-by: David Thompson <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/ce70b98a201ce82b9df9aa80ac7a5eeaa2268e52.1754928650.git.davthompson@nvidia.com Signed-off-by: Bartosz Golaszewski <[email protected]>
| * | Revert "gpio: mlxbf3: only get IRQ for device instance 0"David Thompson2025-08-121-34/+18
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 10af0273a35ab4513ca1546644b8c853044da134. While this change was merged, it is not the preferred solution. During review of a similar change to the gpio-mlxbf2 driver, the use of "platform_get_irq_optional" was identified as the preferred solution, so let's use it for gpio-mlxbf3 driver as well. Cc: [email protected] Fixes: 10af0273a35a ("gpio: mlxbf3: only get IRQ for device instance 0") Signed-off-by: David Thompson <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/8d2b630c71b3742f2c74242cf7d602706a6108e6.1754928650.git.davthompson@nvidia.com Signed-off-by: Bartosz Golaszewski <[email protected]>
| * treewide: rename GPIO set callbacks back to their original namesBartosz Golaszewski2025-08-07135-177/+177
| | | | | | | | | | | | | | | | | | | | | | The conversion of all GPIO drivers to using the .set_rv() and .set_multiple_rv() callbacks from struct gpio_chip (which - unlike their predecessors - return an integer and allow the controller drivers to indicate failures to users) is now complete and the legacy ones have been removed. Rename the new callbacks back to their original names in one sweeping change. Signed-off-by: Bartosz Golaszewski <[email protected]>
| * gpio: remove legacy GPIO line value setter callbacksBartosz Golaszewski2025-08-071-21/+6
| | | | | | | | | | | | | | | | With no more users of the legacy GPIO line value setters - .set() and .set_multiple() - we can now remove them from the kernel. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| * gpio: mlxbf2: use platform_get_irq_optional()David Thompson2025-08-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The gpio-mlxbf2 driver interfaces with four GPIO controllers, device instances 0-3. There are two IRQ resources shared between the four controllers, and they are found in the ACPI table for instances 0 and 3. The driver should not use platform_get_irq(), otherwise this error is logged when probing instances 1 and 2: mlxbf2_gpio MLNXBF22:01: error -ENXIO: IRQ index 0 not found Fixes: 2b725265cb08 ("gpio: mlxbf2: Introduce IRQ support") Cc: [email protected] Signed-off-by: David Thompson <[email protected]> Reviewed-by: Shravan Kumar Ramani <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| * Revert "gpio: pxa: Make irq_chip immutable"Bartosz Golaszewski2025-08-031-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 20117cf426b6 ("gpio: pxa: Make irq_chip immutableas") as it caused a regression on samsung coreprimevelte and we've not been able to fix it so far. Cc: [email protected] # v6.16 Fixes: 20117cf426b6 ("gpio: pxa: Make irq_chip immutableas") Reported-by: Duje Mihanović <[email protected]> Closes: https://lore.kernel.org/all/3367665.aeNJFYEL58@radijator/ Tested-by: Duje Mihanović <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| * Merge tag 'gpio-updates-for-v6.17-rc1' of ↵Linus Torvalds2025-07-29103-1056/+2288
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux Pull gpio updates from Bartosz Golaszewski: "There's one new driver (Apple SMC) and extensions to existing drivers for supporting new HW models. A lot of different impovements across drivers and in core GPIO code. Details on that are in the signed tag as usual. We managed to remove some of the legacy APIs. Arnd Bergmann started to work on making the legacy bits optional so that we may compile them only for older platforms that still really need them. Rob Herring has done a lot of work to convert legacy .txt dt-bindings for GPIO controllers to YAML. There are only a few left now in the GPIO tree. A big part of the commits in this PR concern the conversion of GPIO drivers to using the new line value setter callbacks. This conversion is now complete treewide (unless I've missed something) and once all the changes from different trees land in mainline, I'll send you another PR containing a commit dropping the legacy callbacks from the tree. As the quest to pay back technical dept never really ends, we're starting another set of interface conversions, this time it's about moving fields specific to only a handful of drivers using the gpio-mmio helper out of the core gpio_chip structure that every controller implements and uses. This cycle we introduce a new set of APIs and convert a few drivers under drivers/gpio/, next cycle we'll convert remaining modules treewide (in gpio, pinctrl and mfd trees) and finally remove the old interfaces and move the gpio-mmio fields into their own structure wrapping gpio_chip. One last change I should mention here is the rework of the sysfs interface. In 2016, we introduced the GPIO character device as the preferred alternative to the sysfs class under /sys/class/gpio. While it has seen a wide adoption with the help of its user-space counterpart - libgpiod - there are still users who prefer the simplicity of sysfs. As far as the GPIO subsystem is concerned, the problem is not the existince of the GPIO class as such but rather the fact that it exposes the global GPIO numbers to the user-space, stopping us from ever being able to remove the numberspace from the kernel. To that end, this release we introduced a parallel, limited sysfs interface that doesn't expose these numbers and only implements a subset of features that are relevant to the existing users. This is a result of several discussions over the course of last year and should allow us to remove the legacy part some time in the future. Summary: GPIOLIB core: - introduce a parallel, limited sysfs user ABI that doesn't expose the global GPIO numbers to user-space while maintaining backward compatibility with the end goal of it completely replacing the existing interface, allowing us to remove it - remove the legacy devm_gpio_request() routine which has no more users - start the process of allowing to compile-out the legacy parts of the GPIO core for users who don't need it by introducing a new Kconfig option: GPIOLIB_LEGACY - don't use global GPIO numbers in debugfs output from the core code (drivers still do it, the work is ongoing) - start the process of moving the fields specific to the gpio-mmio helper out of the core struct gpio_chip into their own structure that wraps it: create a new header with modern interfaces and convert several drivers to using it - remove the platform data structure associated with the gpio-mmio helper from the kernel after having converted all remaining users to generic device properties - remove legacy struct gpio definition as it has no more users New drivers: - add the GPIO driver for the Apple System Management Controller Driver improvements: - add support for new models to gpio-adp5585, gpio-tps65219 and gpio-pca953x - extend the interrupt support in gpio-loongson-64bit - allow to mark the simulated GPIO lines as invalid in gpio-sim - convert all remaining GPIO drivers to using the new GPIO value setter callbacks - convert gpio-rcar to using simple device power management ops callbacks - don't check if current direction of a line is output before setting the value in gpio-pisosr and ti-fpc202: the GPIO core already handles that - also drop unneeded GPIO range checks in drivers, the core already makes sure we're within bounds when calling driver callbacks - use dev_fwnode() where applicable across GPIO drivers - set line value in gpio-zynqmp-modepin and gpio-twl6040 when the user wants to change direction of the pin to output even though these drivers don't need to do anything else to actually set the direction, otherwise a call like gpiod_direction_output(d, 1) will not result in the line driver high - remove the reduntant call to pm_runtime_mark_last_busy() from gpio-arizona - use lock guards in gpio-cadence and gpio-mxc - check the return values of regmap functions in gpio-wcd934x and gpio-tps65912 - use better regmap interfaces in gpio-wcove and gpio-pca953x - remove dummy GPIO chip callbacks from several drivers in cases where the GPIO core can already handle their absence - allow building gpio-palmas as a module Fixes: - use correct bit widths (according to the documentation) in gpio-virtio Device-tree bindings: - convert several of the legacy .txt documents for many different devices to YAML, improving automatic validation - create a "trivial" GPIO DT schema that covers a wide range of simple hardware that share a set of basic GPIO properties - document new HW: Apple MAC SMC GPIO block and adp5589 I/O expander - document a new model for pca95xx - add and/or remove properties in YAML documents for gpio-rockchip, fsl,qoriq-gpio, arm,pl061 and gpio-xilinx Misc: - some minor refactoring in several places, adding/removing forward declarations, moving defines to better places, constify the arguments in some functions, remove duplicate includes, etc. - documentation updates" * tag 'gpio-updates-for-v6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: (202 commits) MIPS: alchemy: gpio: use new GPIO line value setter callbacks for the remaining chips gpiolib: enable CONFIG_GPIOLIB_LEGACY even for !GPIOLIB gpio: virtio: Fix config space reading. gpiolib: make legacy interfaces optional dt-bindings: gpio: rockchip: Allow use of a power-domain gpiolib: of: add forward declaration for struct device_node power: reset: macsmc-reboot: Add driver for rebooting via Apple SMC gpio: Add new gpio-macsmc driver for Apple Macs mfd: Add Apple Silicon System Management Controller soc: apple: rtkit: Make shmem_destroy optional dt-bindings: mfd: Add Apple Mac System Management Controller dt-bindings: power: reboot: Add Apple Mac SMC Reboot Controller dt-bindings: gpio: Add Apple Mac SMC GPIO block gpio: cadence: Remove duplicated include in gpio-cadence.c gpio: tps65219: Add support for TI TPS65214 PMIC gpio: tps65219: Update _IDX & _OFFSET macro prefix gpio: sysfs: Fix an end of loop test in gpiod_unexport() dt-bindings: gpio: Convert qca,ar7100-gpio to DT schema dt-bindings: gpio: Convert maxim,max3191x to DT schema dt-bindings: gpio: fsl,qoriq-gpio: Add missing mpc8xxx compatibles ...
| | * gpiolib: enable CONFIG_GPIOLIB_LEGACY even for !GPIOLIBArnd Bergmann2025-07-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A few drivers that use the legacy GPIOLIB interfaces can be enabled even when GPIOLIB is disabled entirely. With my previous patch this now causes build failures like: drivers/nfc/s3fwrn5/uart.c: In function 's3fwrn82_uart_parse_dt': drivers/nfc/s3fwrn5/uart.c:100:14: error: implicit declaration of function 'gpio_is_valid'; did you mean 'uuid_is_valid'? [-Werror=implicit-function-declaration] These did not show up in my randconfig tests because randconfig almost always has GPIOLIB selected by some other driver, and I did most of the testing with follow-up patches that address the failures properly. Move the symbol outside of the 'if CONFIG_GPIOLIB' block for the moment to avoid the build failures. It can be moved back and turned off by default once all the driver specific changes are merged. Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Fixes: 678bae2eaa81 ("gpiolib: make legacy interfaces optional") Signed-off-by: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * gpio: virtio: Fix config space reading.Harald Mommer2025-07-251-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Quote from the virtio specification chapter 4.2.2.2: "For the device-specific configuration space, the driver MUST use 8 bit wide accesses for 8 bit wide fields, 16 bit wide and aligned accesses for 16 bit wide fields and 32 bit wide and aligned accesses for 32 and 64 bit wide fields." Signed-off-by: Harald Mommer <[email protected]> Cc: [email protected] Fixes: 3a29355a22c0 ("gpio: Add virtio-gpio driver") Acked-by: Viresh Kumar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * gpiolib: make legacy interfaces optionalArnd Bergmann2025-07-242-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The traditional interfaces are only used on a small number of ancient boards. Make these optional now so they can be disabled by default. Signed-off-by: Arnd Bergmann <[email protected]> Reviewed-by: Alexander Sverdlin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * Merge tag 'ib-mfd-gpio-power-soc-v6.17' of ↵Bartosz Golaszewski2025-07-243-0/+303
| | |\ | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd into gpio/for-next Immutable branch between MFD, GPIO, Power and SoC due for the v6.17 merge window
| | | * gpio: Add new gpio-macsmc driver for Apple MacsHector Martin2025-07-243-0/+303
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This driver implements the GPIO service on top of the SMC framework on Apple Mac machines. In particular, these are the GPIOs present in the PMU IC which are used to control power to certain on-board devices. Although the underlying hardware supports various pin config settings (input/output, open drain, etc.), this driver does not implement that functionality and leaves it up to the firmware to configure things properly. We also don't yet support interrupts/events. This is sufficient for device power control, which is the only thing we need to support at this point. More features will be implemented when needed. To our knowledge, only Apple Silicon Macs implement this SMC feature. Signed-off-by: Hector Martin <[email protected]> Reviewed-by: Bartosz Golaszewski <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Reviewed-by: Sven Peter <[email protected]> Signed-off-by: "Russell King (Oracle)" <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Neal Gompa <[email protected]> Signed-off-by: Sven Peter <[email protected]> Acked-by: Bartosz Golaszewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
| | * | gpiolib: of: add forward declaration for struct device_nodeAndrei Lalaev2025-07-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 08a149c40bdb ("gpiolib: Clean up headers") added a forward declaration for struct device. Later, commit 07445ae1c263 ("gpiolib: of: change of_find_gpio() to accept device node") changed the function signature to accept a struct device_node instead of a struct device. Replace forward declaration of struct device with struct device_node to match the updated function signature. Signed-off-by: Andrei Lalaev <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: cadence: Remove duplicated include in gpio-cadence.cYang Li2025-07-231-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The header files linux/gpio/driver.h is included twice in gpio-cadence.c, so one inclusion of each can be removed. Reported-by: Abaci Robot <[email protected]> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=22931 Signed-off-by: Yang Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: tps65219: Add support for TI TPS65214 PMICShree Ramamoorthy2025-07-231-6/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for the TI TPS65214 PMIC with the addition of an id_table, separate TPS65214 template_chip, and device-specific _change_direction functions. - Use platform_get_device_id() to assign dev-specific information. - Use different change_direction() functions since TPS65214's GPIO configuration bits are changeable during device operation through bit GPIO_CONFIG in GENERAL_CONFIG register. - Remove MODULE_ALIAS since it is now generated by MODULE_DEVICE_TABLE. Reviewed-by: Jonathan Cormier <[email protected]> Tested-by: Jonathan Cormier <[email protected]> Signed-off-by: Shree Ramamoorthy <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: tps65219: Update _IDX & _OFFSET macro prefixShree Ramamoorthy2025-07-231-10/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TPS65215 and TPS65219 are overlapping PMIC devices. While their regulator features differe, the GPIO features are the same. In the TPS65219 MFD driver, the 2 PMICs share the same "tps65219-gpio" compatible string to limit support for TPS65215 in this GPIO driver to comments. The TPS6521X_GPIO0_IDX and TPS6521X_GPIO0_OFFSET macro name prefixes are updated to indicate these macros apply to both PMICs. Reviewed-by: Roger Quadros <[email protected]> Acked-by: Linus Walleij <[email protected]> Reviewed-by: Jonathan Cormier <[email protected]> Signed-off-by: Shree Ramamoorthy <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: sysfs: Fix an end of loop test in gpiod_unexport()Dan Carpenter2025-07-191-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The test for "if (!desc_data)" does not work correctly because the list iterator in a list_for_each_entry() loop is always non-NULL. If we don't exit via a break, then it points to invalid memory. Instead, use a tmp variable for the list iterator and only set the "desc_data" when we have found a match. Fixes: 1cd53df733c2 ("gpio: sysfs: don't look up exported lines as class devices") Signed-off-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: xilinx: convert set_multiple() to the new API as wellBartosz Golaszewski2025-07-181-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The patch converting the driver to using new GPIO line value setters only converted the set() callback and missed set_multiple(). Fix it now. Fixes: 1919ea19a4ff ("gpio: xilinx: use new GPIO line value setter callbacks") Acked-by: Michal Simek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: loongson-64bit: Extend GPIO irq supportBinbin Zhou2025-07-161-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the interrupt enable register offset (inten_offset) so that GPIO interrupts can be enabled normally on more models. According to the latest interface specifications, the definition of GPIO interrupts in ACPI is similar to that in FDT. The GPIO interrupts are listed one by one according to the GPIO number, and the corresponding interrupt number can be obtained directly through the GPIO number specified by the consumer. Signed-off-by: Xi Ruoyao <[email protected]> Signed-off-by: Binbin Zhou <[email protected]> Reviewed-by: Huacai Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] [Bartosz: tweaked the commit message] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: viperboard: Unlock on error in vprbrd_gpiob_direction_output()Dan Carpenter2025-07-161-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unlock before returning if vprbrd_gpiob_setdir() fails. Fixes: 55e2d1eec110 ("gpio: viperboard: use new GPIO line value setter callbacks") Signed-off-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: TODO: remove the task for the sysfs reworkBartosz Golaszewski2025-07-161-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the completed task tracking the rework of the sysfs interface and add a new task to track the removal of the legacy bits and pieces. Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: sysfs: allow disabling the legacy parts of the GPIO sysfs interfaceBartosz Golaszewski2025-07-162-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a Kconfig switch allowing to disable the legacy parts of the GPIO sysfs interface. This means that even though we keep the /sys/class/gpio/ directory, it no longer contains the global export/unexport attribute pair (instead, the user should use the per-chip export/unpexport) nor the gpiochip$BASE entries. This option default to y if GPIO sysfs is enabled but we'll default it to n at some point in the future. Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: sysfs: export the GPIO directory locally in the gpiochip<id> directoryBartosz Golaszewski2025-07-161-1/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As a way to allow the user-space to stop referring to GPIOs by their global numbers, introduce a parallel group of line attributes for exported GPIO that live inside the GPIO chip class device and are referred to by their HW offset within their parent chip. Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: sysfs: don't look up exported lines as class devicesBartosz Golaszewski2025-07-161-16/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In preparation for adding a parallel, per-chip attribute group for exported GPIO lines, stop using class device APIs to refer to it in the code. When unregistering the chip, don't call class_find_device() but instead store exported lines in a linked list inside the GPIO chip data object and look it up there. Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: sysfs: don't use driver data in sysfs callbacks for line attributesBartosz Golaszewski2025-07-161-40/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently each exported GPIO is represented in sysfs as a separate class device. This allows us to simply use dev_get_drvdata() to retrieve the pointer passed to device_create_with_groups() from sysfs ops callbacks. However, we're preparing to add a parallel set of per-line sysfs attributes that will live inside the associated gpiochip group. They are not registered as class devices and so have the parent device passed as argument to their callbacks (the GPIO chip class device). Put the attribute structs inside the GPIO descriptor data and dereference the relevant ones using container_of() in the callbacks. This way, we'll be able to reuse the same code for both the legacy and new GPIO attributes. Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: sysfs: rename the data variable in gpiod_(un)export()Bartosz Golaszewski2025-07-161-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In preparation for future commits which will make use of descriptor AND GPIO-device data in the same functions rename the former from data to desc_data separately which will make future changes smaller and easier to read. Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: sysfs: pass gpiod_data directly to internal GPIO sysfs functionsBartosz Golaszewski2025-07-161-12/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't use any fields from struct device in gpio_sysfs_request_irq(), gpio_sysfs_free_irq() and gpio_sysfs_set_active_low(). We only use the dev argument to get the associated struct gpiod_data pointer with dev_get_drvdata(). To make the transition to not using dev_get_drvdata() across line callbacks for sysfs attributes easier, pass gpiod_data directly to these functions instead of having it wrapped in struct device. Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: sysfs: only get the dirent reference for the value attr onceBartosz Golaszewski2025-07-161-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's no reason to retrieve the reference to the sysfs dirent every time we request an interrupt, we can as well only do it once when exporting the GPIO. Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: sysfs: add a parallel class device for each GPIO chip using device IDsBartosz Golaszewski2025-07-161-48/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to enable moving away from the global GPIO numberspace-based exporting of lines over sysfs: add a parallel, per-chip entry under /sys/class/gpio/ for every registered GPIO chip, denoted by device ID in the file name and not its base GPIO number. Compared to the existing chip group: it does not contain the "base" attribute as the goal of this change is to not refer to GPIOs by their global number from user-space anymore. It also contains its own, per-chip export/unexport attribute pair which allow to export lines by their hardware offset within the chip. Caveat #1: the new device cannot be a link to (or be linked to by) the existing "gpiochip<BASE>" entry as we cannot create links in /sys/class/xyz/. Caveat #2: the new entry cannot be named "gpiochipX" as it could conflict with devices whose base is statically defined to a low number. Let's go with "chipX" instead. While at it: the chip label is unique so update the untrue statement when extending the docs. Acked-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: sysfs: use gpiod_is_equal() to compare GPIO descriptorsBartosz Golaszewski2025-07-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a dedicated comparator for GPIO descriptors that performs additional checks and hides the implementation detail of whether the same GPIO can be associated with two separate struct gpio_desc objects. Use it in sysfs code Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: wcove: use new GPIO line value setter callbacksBartosz Golaszewski2025-07-161-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them. Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/20250715-gpiochip-set-rv-gpio-remaining-v2-2-072b4cf06330@linaro.org Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: wcove: use regmap_assign_bits() in .set()Bartosz Golaszewski2025-07-161-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace the if-else with a direct call to the regmap_assign_bits() helper and save a couple lines of code. Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/20250715-gpiochip-set-rv-gpio-remaining-v2-1-072b4cf06330@linaro.org Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: pca953x: use regmap_update_bits() to improve performanceHugo Villeneuve2025-07-151-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using regmap_update_bits() allows to reduce the number of I2C transfers when updating bits that haven't changed on non-volatile registers. For example on a PCAL6416, when changing a GPIO direction from input to output, the number of I2C transfers can be reduced from 4 to just 1 if the pull resistors configuration hasn't changed and the output value is the same as before. Signed-off-by: Hugo Villeneuve <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: zynqmp-modepin: set line value in .direction_output()Bartosz Golaszewski2025-07-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's ok to not do anything specific when setting direction but the callback should still respect the line value the user requests. Link: https://lore.kernel.org/r/20250709-gpiochip-set-rv-gpio-remaining-v1-19-b8950f69618d@linaro.org Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: zynqmp-modepin: use new GPIO line value setter callbacksBartosz Golaszewski2025-07-151-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them. Link: https://lore.kernel.org/r/20250709-gpiochip-set-rv-gpio-remaining-v1-18-b8950f69618d@linaro.org Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: zynq: use new GPIO line value setter callbacksBartosz Golaszewski2025-07-151-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them. Link: https://lore.kernel.org/r/20250709-gpiochip-set-rv-gpio-remaining-v1-17-b8950f69618d@linaro.org Signed-off-by: Bartosz Golaszewski <[email protected]>
| | * | gpio: zevio: use new GPIO line value setter callbacksBartosz Golaszewski2025-07-151-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them. Link: https://lore.kernel.org/r/20250709-gpiochip-set-rv-gpio-remaining-v1-16-b8950f69618d@linaro.org Signed-off-by: Bartosz Golaszewski <[email protected]>