JIRA: https://issues.redhat.com/browse/RHEL-57766
commit 7e92061f1e9d1f6d3bfa6113719534f2c773b041
Author: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Date: Wed Jun 12 20:48:21 2024 +0200
gpiolib: put gpio_suffixes in a single compilation unit
The gpio_suffixes array is defined in the gpiolib.h header. This means
the array is stored in .rodata of every compilation unit that includes
it. Put the definition for the array in gpiolib.c and export just the
symbol in the header. We need the size of the array so expose it too.
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Link: https://lore.kernel.org/r/20240612184821.58053-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Izabela Bakollari <ibakolla@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-41085
commit 98ac9e4fc07f101c435f1ab6b395b6245b096a68
Author: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>
Date: Fri Aug 25 15:21:57 2023 +0530
mmc: atmel-mci: Move card detect gpio polarity quirk to gpiolib
The polarity of the card detection gpio is handled by the "cd-inverted"
property in the device tree. Move this inversion logic to gpiolib to avoid
reading the gpio raw value.
Signed-off-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>
Suggested-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20230825095157.76073-4-balamanikandan.gunasundar@microchip.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Lucas Karpinski <lkarpins@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit 380c7ba3923c6e471aff0f951a6cf42e8dec2c79
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Wed Feb 8 19:07:28 2023 +0200
gpiolib: Clean up headers
There is a few things done:
- include only the headers we are direct user of
- when pointer is in use, provide a forward declaration
- add missing headers
- group generic headers and subsystem headers
- sort each group alphabetically
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
Conflicts:
drivers/soc/fsl/qe/gpio.c
Minor contextual conflict.
commit a99cc66807d6c854a7f65f962766c530c91be149
Author: Arnd Bergmann <arnd@arndb.de>
Date: Tue Feb 7 16:29:47 2023 +0200
gpiolib: split of_mm_gpio_chip out of linux/of_gpio.h
This is a rarely used feature that has nothing to do with the
client-side of_gpio.h.
Split it out with a separate header file and Kconfig option
so it can be removed on its own timeline aside from removing
the of_gpio consumer interfaces.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit eed5a3bfafe6840494f7752b5cecd2a610b54fef
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Thu Jan 12 16:51:40 2023 +0200
gpiolib: of: Move enum of_gpio_flags to its only user
GPIO library for OF is the only user for enum of_gpio_flags.
Move it there.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Rob Herring <robh@kernel.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit 70d0fc4288dabd65025fde7774b4f9262afa9034
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Wed Dec 28 11:20:44 2022 +0200
gpiolib: Get rid of not used of_node member
All new drivers should use fwnode and / or parent to provide the
necessary information to the GPIO library.
Cc: Thierry Reding <treding@nvidia.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit 40fc56ee608cdb20022c225ac6f1e4b7ba63f8f1
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Mon Dec 19 11:20:15 2022 -0800
gpiolib: of: remove of_get_gpio[_flags]() and of_get_named_gpio_flags()
There are no more users of these APIs in the mainline kernel, remove
them. This leaves of_get_named_gpio() as the only legacy OF-specific
API.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit f9792ba054f86b9eee1fab017294554914837ab5
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Mon Dec 19 11:20:14 2022 -0800
gpiolib: of: remove obsolete comment for of_gpio_get_count()
The function is only being called form the main gpiolib module, so
remove comment saying that it is also used by external callers.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit c7835652a85df183c967f574d1999505ebf80b88
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Mon Dec 19 11:20:13 2022 -0800
gpiolib: of: stop exporting of_gpio_named_count()
The only user of this function is gpiolib-of.c so move it there.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit b8f9301c91bff54570181db9dffa9b5716c3c75d
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Fri Jan 13 23:53:52 2023 +0200
Revert "gpiolib: of: Introduce hook for missing gpio-ranges"
This reverts commit 3550bba25d5587a701e6edf20e20984d2ee72c78.
No users for this one, revert it for good.
The ->add_pin_ranges() can be used instead.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Link: https://lore.kernel.org/r/20230113215352.44272-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit ddf07bd874be791a63fca5ac0e3def1e15f2338f
Author: Thierry Reding <treding@nvidia.com>
Date: Fri Nov 11 12:37:32 2022 +0100
gpiolib: of: Use correct fwnode for DT-probed chips
The OF node store in chip->fwnode is used to explicitly override the FW
node for a GPIO chip. For chips that use the default FW node (i.e. that
of their parent device), this will be NULL and cause the chip not to be
fully registered.
Instead, use the GPIO device's FW node, which is set to either the node
of the parent device or the explicit override in chip->fwnode.
Fixes: 8afe82550240 ("gpiolib: of: Prepare of_gpiochip_add() / of_gpiochip_remove() for fwnode")
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Robert Marko <robimarko@gmail.com>
Tested-by: Andrew Halaney <ahalaney@redhat.com>
Reviewed-by: Brian Masney <bmasney@redhat.com>
Tested-by: Brian Masney <bmasney@redhat.com>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit a431803852de00d8d3c143b19f5690254225538f
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Mon Nov 14 20:46:26 2022 +0200
gpiolib: of: Drop redundant check in of_mm_gpiochip_remove()
The callers never call the function with invalid pointer.
Moreover, compiler quite likely dropped that check anyway
because we use that pointer before the check.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit 07445ae1c26367928311e13f2a821ae94410da7e
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Tue Nov 15 11:16:24 2022 +0100
gpiolib: of: change of_find_gpio() to accept device node
In preparation of switching all OF-based GPIO lookups to go through
of_find_gpio() let's change it to accept device node as its argument as
we do not always have access to device structure.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit b8b80348c57b360019071e17380298619c5d8066
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Sat Oct 29 21:40:47 2022 -0700
gpiolib: of: add polarity quirk for Freescale PCIe controller
Bindings for Freescale PCIe controller use a separate property called
"reset-gpio-active-high" to control polarity of its reset line, add it
to the list of quirks in gpiolib so that gpiod API can be used in the
driver.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit 34cb9352b62366038fd2d5b9d9f393f35d0be1e0
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Sat Oct 29 21:40:46 2022 -0700
gpiolib: of: factor out quirk setting polarity via separate property
Several legacy bindings use a separate property to specify polarity of
GPIOs instead of specifying it directly in the GPIO property. Factor
out this code to make it easier to add more such cases.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit d59fdbc7164a6b2a0ed45c13387deac8efeed5a2
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Thu Nov 3 22:30:05 2022 +0200
gpiolib: of: Make use of device_match_of_node()
Make use of device_match_of_node() instead of open coding its
functionality.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit 99d18d42c942854a073191714a311dc2420ec7d3
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Mon Oct 17 22:41:11 2022 -0700
gpiolib: of: add a quirk for reset line polarity for Himax LCDs
Existing DTS that use legacy (non-standard) property name for the reset
line "gpios-reset" also specify incorrect polarity (0 which maps to
"active high"). Add a quirk to force polarity to "active low" so that
once driver is converted to gpiod API that pays attention to line
polarity it will work properly.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit b02c85c9458cdd15e2c43413d7d2541a468cde57
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Mon Oct 17 22:41:10 2022 -0700
gpiolib: of: add quirk for phy reset polarity for Freescale Ethernet
Bindings for Freescale Fast Ethernet Controller use a separate
property "phy-reset-active-high" to specify polarity of its phy
gpio line. To allow converting the driver to gpiod API we need
to add this quirk to gpiolib.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit e3186e36925fc18384492491ebcf3da749780a30
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Mon Oct 17 22:41:09 2022 -0700
gpiolib: of: factor out code overriding gpio line polarity
There are several instances where we use a separate property to
override polarity specified in gpio property. Factor it out into
a separate function.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit eaf1a29665cda1c767cac0d523828892bd77a842
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Mon Oct 17 22:41:08 2022 -0700
gpiolib: of: add a quirk for legacy names in MOXA ART RTC
The driver is using non-standard "gpio-rtc-data", "gpio-rtc-sclk", and
"gpio-rtc-reset" names for properties describing its gpios. In
preparation to converting to the standard naming ("rtc-*-gpios") and
switching the driver to gpiod API add a quirk to gpiolib to keep
compatibility with existing DTSes.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit 944004eb56dc977ad5f882ca4338f45396052317
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Mon Oct 17 22:41:07 2022 -0700
gpiolib: of: add a quirk for reset line for Cirrus CS42L56 codec
The controller is using non-standard "cirrus,gpio-nreset" name for its
reset gpio property, whereas gpiod API expects "<name>-gpios".
Add a quirk so that gpiod API will still work on unmodified DTSes.
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit 9c2cc7171e08eef52110d272fdf2225d6dcd81b6
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Mon Oct 17 22:41:06 2022 -0700
gpiolib: of: add a quirk for reset line for Marvell NFC controller
The controller is using non-standard "reset-n-io" name for its reset
gpio property, whereas gpiod API expects "<name>-gpios". Add a quirk
so that gpiod API will still work on unmodified DTSes.
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit fbbbcd177a27508a47c5136b31de5cf4c8d0ab1c
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Mon Oct 17 22:41:05 2022 -0700
gpiolib: of: add quirk for locating reset lines with legacy bindings
Some legacy mappings used "gpio[s]-reset" instead of "reset-gpios",
add a quirk so that gpiod API will still work on unmodified DTSes.
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit b311c5cba779a87e85525d351965bbd2c18111de
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Mon Oct 17 22:41:03 2022 -0700
gpiolib: of: consolidate simple renames into a single quirk
This consolidates all quirks doing simple renames (either allowing
suffix-less names or trivial renames, when index changes are not
required) into a single quirk.
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit 326c3753a6358ffab607749ea0aa95d1d0ad79b0
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Mon Oct 17 22:41:02 2022 -0700
gpiolib: of: add a quirk for legacy names in Mediatek mt2701-cs42448
The driver is using non-standard "i2s1-in-sel-gpio1" and
"i2s1-in-sel-gpio2" names to describe its gpios. In preparation to
converting to the standard naming (i2s1-in-sel-gpios) and switching the
driver to gpiod API add a quirk to gpiolib to keep compatibility with
existing DTSes.
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit d9e7f0e320516c660d6f33e6c16a3d99970eb14e
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Wed Sep 7 22:39:49 2022 -0700
gpiolib: of: factor out conversion from OF flags
There are several places where we need to convert from OF flags to
"normal" GPIO_* flags, so let's introduce a helper and use it.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit 984914ec4f4bfa9ee8f067b06293bc12bef20137
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Wed Sep 7 22:39:47 2022 -0700
gpiolib: of: make Freescale SPI quirk similar to all others
There is no need for of_find_spi_cs_gpio() to be different from other
quirks: the only variant of property actually used in DTS is "gpios"
(plural) so we can use of_get_named_gpiod_flags() instead of recursing
into of_find_gpio() again.
This will allow us consolidate quirk handling down the road.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit 98c3c940ea5c3957056717e8b77a91c7d94536ad
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Wed Sep 7 22:39:46 2022 -0700
gpiolib: of: do not ignore requested index when applying quirks
We should not ignore index passed into of_find_gpio() when handling
quirks. While in practice this change will not have any effect, it
will allow consolidate quirk handling.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit 31bea23119cda87088c6bd4085a1e442c6c5974c
Author: Nuno Sá <nuno.sa@analog.com>
Date: Wed Jul 13 15:14:19 2022 +0200
gpiolib: of: support bias pull disable
On top of looking at PULL_UP and PULL_DOWN flags, also look at
PULL_DISABLE and set the appropriate GPIO flag. The GPIO core will then
pass down this to controllers that support it.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/2183344
commit 5d07a692f9562f9c06e62cce369e9dd108173a0f
Author: Liang He <windhl@126.com>
Date: Mon Jul 11 20:52:38 2022 +0800
gpio: gpiolib-of: Fix refcount bugs in of_mm_gpiochip_add_data()
We should use of_node_get() when a new reference of device_node
is created. It is noted that the old reference stored in
'mm_gc->gc.of_node' should also be decreased.
This patch is based on the fact that there is a call site in function
'qe_add_gpiochips()' of src file 'drivers\soc\fsl\qe\gpio.c'. In this
function, of_mm_gpiochip_add_data() is contained in an iteration of
for_each_compatible_node() which will automatically increase and
decrease the refcount. So we need additional of_node_get() for the
reference escape in of_mm_gpiochip_add_data().
Fixes: a19e3da5bc ("of/gpio: Kill of_gpio_chip and add members directly to gpio_chip")
Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071835
Tested: This is one of a series of patch sets to enable Arm SystemReady IR
support in the kernel for NXP i.MX8 platforms. This set updates GPIO
support. It has been tested via simple boot tests and by using the
kernel GPIO tools to verify pins are being identified and can be used.
commit e75f88efac05bf4e107e4171d8db6d8c3937252d
Author: Andrei Lalaev <andrei.lalaev@emlid.com>
Date: Fri Apr 15 10:07:11 2022 +0300
gpiolib: of: fix bounds check for 'gpio-reserved-ranges'
Gpiolib interprets the elements of "gpio-reserved-ranges" as "start,size"
because it clears "size" bits starting from the "start" bit in the according
bitmap. So it has to use "greater" instead of "greater or equal" when performs
bounds check to make sure that GPIOs are in the available range.
Previous implementation skipped ranges that include the last GPIO in
the range.
I wrote the mail to the maintainers
(https://lore.kernel.org/linux-gpio/20220412115554.159435-1-andrei.lalaev@emlid.com/T/#u)
of the questioned DTSes (because I couldn't understand how the maintainers
interpreted this property), but I haven't received a response.
Since the questioned DTSes use "gpio-reserved-ranges = <0 4>"
(i.e., the beginning of the range), this patch doesn't affect these DTSes at all.
TBH this patch doesn't break any existing DTSes because none of them
reserve gpios at the end of range.
Fixes: 726cb3ba49 ("gpiolib: Support 'gpio-reserved-ranges' property")
Signed-off-by: Andrei Lalaev <andrei.lalaev@emlid.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
(cherry picked from commit e75f88efac05bf4e107e4171d8db6d8c3937252d)
Signed-off-by: Al Stone <ahs3@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071835
Tested: This is one of a series of patch sets to enable Arm SystemReady IR
support in the kernel for NXP i.MX8 platforms. This set updates GPIO
support. It has been tested via simple boot tests and by using the
kernel GPIO tools to verify pins are being identified and can be used.
commit 3550bba25d5587a701e6edf20e20984d2ee72c78
Author: Stefan Wahren <stefan.wahren@i2se.com>
Date: Sat Apr 9 11:51:28 2022 +0200
gpiolib: of: Introduce hook for missing gpio-ranges
Since commit 2ab73c6d83 ("gpio: Support GPIO controllers without pin-ranges")
the device tree nodes of GPIO controller need the gpio-ranges property to
handle gpio-hogs. Unfortunately it's impossible to guarantee that every new
kernel is shipped with an updated device tree binary.
In order to provide backward compatibility with those older DTB, we need a
callback within of_gpiochip_add_pin_range() so the relevant platform driver
can handle this case.
Fixes: 2ab73c6d83 ("gpio: Support GPIO controllers without pin-ranges")
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Bartosz Golaszewski <brgl@bgdev.pl>
Link: https://lore.kernel.org/r/20220409095129.45786-2-stefan.wahren@i2se.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 3550bba25d5587a701e6edf20e20984d2ee72c78)
Signed-off-by: Al Stone <ahs3@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071835
Tested: This is one of a series of patch sets to enable Arm SystemReady IR
support in the kernel for NXP i.MX8 platforms. This set updates GPIO
support. It has been tested via simple boot tests and by using the
kernel GPIO tools to verify pins are being identified and can be used.
commit 57017edd46f835c85642fe8299f13b0db61d4c31
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Fri Apr 8 21:18:50 2022 +0300
gpiolib: Embed iterator variable into for_each_gpio_desc_with_flag()
The iterator loop is used exclusively to get a descriptor, which in its
turn is what is being used by the caller. Embed the iterator variable
into the loop in the for_each_gpio_desc_with_flag() macro helper.
Suggested-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
(cherry picked from commit 57017edd46f835c85642fe8299f13b0db61d4c31)
Signed-off-by: Al Stone <ahs3@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071835
Tested: This is one of a series of patch sets to enable Arm SystemReady IR
support in the kernel for NXP i.MX8 platforms. This set updates GPIO
support. It has been tested via simple boot tests and by using the
kernel GPIO tools to verify pins are being identified and can be used.
commit 80c78fbeef10121a0fbba3fd2ed333f5de118f6d
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Tue Feb 1 17:27:56 2022 +0200
gpiolib: Introduce for_each_gpio_desc_with_flag() macro
In a few places we are using a loop against all GPIO descriptors
with a given flag for a given device. Replace it with a consolidated
for_each type of macro.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
(cherry picked from commit 80c78fbeef10121a0fbba3fd2ed333f5de118f6d)
Signed-off-by: Al Stone <ahs3@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071835
Tested: This is one of a series of patch sets to enable Arm SystemReady IR
support in the kernel for NXP i.MX8 platforms. This set updates GPIO
support. It has been tested via simple boot tests and by using the
kernel GPIO tools to verify pins are being identified and can be used.
commit ac627260cf525300d5d13e67279a89911f1ad928
Author: Bartosz Golaszewski <brgl@bgdev.pl>
Date: Tue Dec 7 10:34:08 2021 +0100
gpiolib: of: make fwnode take precedence in struct gpio_chip
If the driver sets the fwnode in struct gpio_chip, let it take
precedence over the of_node. This only affects OF-based systems,
ACPI needs to be converted separately.
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit ac627260cf525300d5d13e67279a89911f1ad928)
Signed-off-by: Al Stone <ahs3@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071835
Tested: This is one of a series of patch sets to enable Arm SystemReady IR
support in the kernel for NXP i.MX8 platforms. This set updates GPIO
support. It has been tested via simple boot tests and by using the
kernel GPIO tools to verify pins are being identified and can be used.
commit 8990899d84d7f46c0c1cd3f41135707b26d0eeaa
Author: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Date: Wed Jul 28 16:42:29 2021 +0200
gpiolib: of: constify few local device_node variables
gpiolib does not modify struct device_node, so few local pointers can
point to a const data.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
(cherry picked from commit 8990899d84d7f46c0c1cd3f41135707b26d0eeaa)
Signed-off-by: Al Stone <ahs3@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071840
Tested: This is one of a series of patch sets to enable Arm SystemReady IR
support in the kernel for NXP i.MX8 platforms. At this stage, this
has been tested by ensuring we can survive the CI/CD loop -- i.e.,
that we have not broken anything else, and a simple boot test. When
sufficient drivers have been brought in for i.MX8M, we will be able
to run further tests.
commit e6ae9a833ef4043b940954b8dcac31493706b9d6
Author: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Date: Wed Jul 28 16:42:28 2021 +0200
gpiolib: constify passed device_node pointer
Several gpiolib functions receive pointer to struct device_node which is
later passed to OF functions. These OF functions accept already pointer
to const, so gpiolib can follow similar approach to indicate they are
not modifying the struct device_node.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
(cherry picked from commit e6ae9a833ef4043b940954b8dcac31493706b9d6)
Signed-off-by: Al Stone <ahs3@redhat.com>
The initial value of the OF node based on presence of parent, but
at the same time this operation somehow appeared separately from others
that handle the OF case. On the other hand there is no need to assign
dev->fwnode in the OF case if code properly retrieves fwnode, i.e.
via dev_fwnode() helper.
Amend gpiolib.c and gpiolib-of.c code in order to group OF operations.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
There are multiple instances of GPIO device tree nodes of the form:
foo {
compatible = "acme,foo";
...
gpio0: gpio0@xxxxxxxx {
compatible = "acme,bar";
...
gpio-controller;
};
gpio1: gpio1@xxxxxxxx {
compatible = "acme,bar";
...
gpio-controller;
};
...
}
bazz {
my-gpios = <&gpio0 ...>;
}
Case 1: The driver for "foo" populates struct device for these gpio*
nodes and then probes them using a driver that binds with "acme,bar".
This driver for "acme,bar" then registers the gpio* nodes with gpiolib.
This lines up with how DT nodes with the "compatible" property are
typically converted to struct devices and then registered with driver
core to probe them. This also allows the gpio* devices to hook into all
the driver core capabilities like runtime PM, probe deferral,
suspend/resume ordering, device links, etc.
Case 2: The driver for "foo" doesn't populate struct devices for these
gpio* nodes before registering them with gpiolib. Instead it just loops
through its child nodes and directly registers the gpio* nodes with
gpiolib.
Drivers that follow case 2 cause problems with fw_devlink=on. This is
because fw_devlink will prevent bazz from probing until there's a struct
device that has gpio0 as its fwnode (because bazz lists gpio0 as a GPIO
supplier). Once the struct device is available, fw_devlink will create a
device link with gpio0 device as the supplier and bazz device as the
consumer. After this point, since the gpio0 device will never bind to a
driver, the device link will prevent bazz device from ever probing.
Finding and refactoring all the instances of drivers that follow case 2
will cause a lot of code churn and it is not something that can be done
in one shot. In some instances it might not even be possible to refactor
them cleanly. Examples of such instances are [1] [2].
This patch works around this problem and avoids all the code churn by
simply setting the fwnode of the gpio_device and creating a stub driver
to bind to the gpio_device. This allows all the consumers to continue
probing when the driver follows case 2.
[1] - https://lore.kernel.org/lkml/20201014191235.7f71fcb4@xhacker.debian/
[2] - https://lore.kernel.org/lkml/e28e1f38d87c12a3c714a6573beba6e1@kernel.org/
Fixes: e590474768 ("driver core: Set fw_devlink=on by default")
Cc: Marc Zyngier <maz@kernel.org>
Cc: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Saravana Kannan <saravanak@google.com>
Link: https://lore.kernel.org/r/20210122193600.1415639-1-saravanak@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Use named item instead of plain integer for enum gpiod_flags
to make it clear that even 0 has its own meaning.
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Several places in the code are using same idiom, i.e.
IS_ERR(desc) && PTR_ERR(desc) == -ENOENT
which meaning is GPIO description is not found.
For better readability extract gpiod_not_found() helper and use it.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
devprop_gpiochip_set_names() is overly complicated with taking the
fwnode argument (which requires using dev_fwnode() & of_fwnode_handle()
in ACPI and OF GPIO code respectively). Let's just switch to using the
generic device properties.
This allows us to pull the code setting line names directly into
gpiochip_add_data_with_key() instead of handling it separately for
ACPI and OF.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>