summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpiolib-of.c
AgeCommit message (Collapse)Author
2024-04-26gpio: of: support gpio-ranges for multiple gpiochip devicesDoug Berger
Some drivers (e.g. gpio-mt7621 and gpio-brcmstb) have multiple gpiochip banks within a single device. Unfortunately, the gpio-ranges property of the device node was being applied to every gpiochip of the device with device relative GPIO offset values rather than gpiochip relative GPIO offset values. This commit makes use of the gpio_chip offset value which can be non-zero for such devices to split the device node gpio-ranges property into GPIO offset ranges that can be applied to each of the relevant gpiochips of the device. Signed-off-by: Doug Berger <opendmb@gmail.com> Acked-by: Florian Fainelli <florian.fainelli@broadcom.com> Link: https://lore.kernel.org/r/20240424185039.1707812-3-opendmb@gmail.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-03-01gpio: of: Make of_gpio_get_count() take firmware node as a parameterAndy Shevchenko
Make of_gpio_get_count() take firmware node as a parameter in order to be aligned with other functions and decouple from unused device pointer. The latter helps to create a common fwnode_gpio_count() in the future. While at it, rename to be of_gpio_count() to be aligned with the others. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-02-20gpio: constify of_phandle_args in of_find_gpio_device_by_xlate()Krzysztof Kozlowski
Pointer to the struct of_phandle_args can be made const after gpio_device_find() arguments got constified. This should be part of commit 4a92857d6e83 ("gpio: constify opaque pointer "data" in gpio_device_find()"). Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-02-12gpio: of: assign and read the hog pointer atomicallyBartosz Golaszewski
The device nodes representing GPIO hogs cannot be deleted without unregistering the GPIO chip so there's no need to serialize their access. However we must ensure that users can get the right address so write and read it atomically. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2024-02-12gpio: constify opaque pointer in gpio_device_find() match functionKrzysztof Kozlowski
The match function used in gpio_device_find() should not modify the contents of passed opaque pointer, because such modification would not be necessary for actual matching and it could lead to quite unreadable, spaghetti code. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> [Bartosz: fix coding style in header] Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-01-22gpio: legacy: mark old interfaces as deprecated in kernel docsBartosz Golaszewski
We've recently had someone try to use of_get_named_gpio() in new code. Mark legacy interfaces as deprecated in kernel docs to avoid any confusion. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-12-13backlight: hx8357: Convert to agnostic GPIO APIAndy Shevchenko
The of_gpio.h is going to be removed. In preparation of that convert the driver to the agnostic API. Fixes: fbbbcd177a27 ("gpiolib: of: add quirk for locating reset lines with legacy bindings") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20231207161513.3195509-2-andriy.shevchenko@linux.intel.com Signed-off-by: Lee Jones <lee@kernel.org>
2023-11-02Merge tag 'sound-6.7-rc1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound Pull sound updates from Takashi Iwai: "Most of changes at this time are for ASoC, spread over ASoC core and drivers due to the API prefix standardization. Other than that, there have little change wrt API, rather lots of driver-specific updates and fixes. Some highlight below: ASoC: - Standardization of API prefix - GPIO API usage improvements - Support for HDA patches - Lots of work on SOF, including crash dump support - Fixes for noise when stopping some Sounwire CODECs - Support for AMD platforms with es83xx, AMD ACP 6.3 and 7.0, Awinc AT87390 and AW88399, many Intel platforms, many Mediatek platforms, Qualcomm SM6115 and SC7180 platforms, Richtek RTQ9128 and Texas Instruments TAS575x HD-audio and USB-audio: - Deferred probe support of audio component binding - More fixes and enhancements for Cirrus subcodecs - USB Scarlett2 mixer and McIntosh DSD quirk Others: - More enhancement of snd-aloop driver - Update MAINTAINERS entry for linux-sound mailing list" * tag 'sound-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (485 commits) ALSA: hda: cs35l41: Fix missing error code in cs35l41_smart_amp() ALSA: hda: cs35l41: mark cs35l41_verify_id() static ASoC: codecs: wsa883x: make use of new mute_unmute_on_trigger flag ASoC: soc-dai: add flag to mute and unmute stream during trigger ASoC: ams-delta.c: use component after check ASoC: amd: acp: select SND_SOC_AMD_ACP_LEGACY_COMMON for ACP63 ASoC: codecs: aw88399: fix typo in Kconfig select ASoC: amd: acp: add ACPI dependency ASoC: Intel: avs: Add rt5514 machine board ASoC: Intel: avs: Add rt5514 machine board ALSA: scarlett2: Add missing check with firmware version control ALSA: virtio: use ack callback ALSA: scarlett2: Remap Level Meter values ALSA: scarlett2: Allow passing any output to line_out_remap() ALSA: scarlett2: Add support for reading firmware version ALSA: scarlett2: Rename Gen 3 config sets ALSA: scarlett2: Rename scarlett_gen2 to scarlett2 ASoC: cs35l41: Detect CSPL errors when sending CSPL commands ALSA: hda: cs35l41: Check CSPL state after loading firmware ALSA: hda: cs35l41: Do not unload firmware before reset in system suspend ...
2023-10-09gpiolib: of: Add quirk for mt2701-cs42448 ASoC soundLinus Walleij
These gpio names are due to old DT bindings not following the "-gpio"/"-gpios" conventions. Handle it using a quirk so the driver can just look up the GPIOs. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20231006-descriptors-asoc-mediatek-v1-1-07fe79f337f5@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
2023-10-04gpio: of: replace gpiochip_find_* with gpio_device_find_*Bartosz Golaszewski
We're porting all users of gpiochip_find() to using gpio_device_find(). Update the OF GPIO code. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
2023-10-02gpiolib: of: Allow "trigger-sources" to reference a GPIOLinus Walleij
The "trigger-sources" phandle used for LED triggers are special: the DT bindings mandate that such triggers have the same phandle references no matter what the trigger is. A GPIO is just another kind of device that can trigger a LED. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-09-27mtd: rawnand: ingenic: move the GPIO quirk to gpiolib-of.cBartosz Golaszewski
We have a special place for OF polarity quirks in gpiolib-of.c. Let's move this over there so that it doesn't pollute the driver. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Paul Cercueil <paul@crapouillou.net> Reviewed-by: Andy Shevchenko <andy@kernel.org>
2023-09-11gpio: of: correct notifier return codesBartosz Golaszewski
According to the comments in linux/notifier.h, the code to return when a notifications is "not for us" is NOTIFY_DONE, not NOTIFY_OK. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
2023-08-29Merge tag 'gpio-updates-for-v6.6' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux Pull gpio updates from Bartosz Golaszewski: "We have a lot of code refactoring using common helpers and ended up removing more lines then we're adding this release cycle. Nothing really stands out, just small updates all over the place. Core GPIOLIB updates: - wake-up poll() in user-space on device unbind - improve fwnode usage - interrupt domain handling improvements - correctly handle the ngpios property in gpio-mmio Driver cleanups: - remove unneeded calls to platform_set_drvdata() all around the place - remove unneeded of_match_ptr() expansions whenever a driver depends on CONFIG_OF - remove redundant calls to dev_err_probe() from gpio-omap and gpio-davinci Driver improvements: - use autopointers and guards from cleanup.h in gpio-sim - shrink code in gpio-sim using some common helpers - convert the idio family of drivers to using gpio-regmap - convert gpio-ws16c48 to using gpio-regmap - use devres to simplify code in gpio-pisosr and gpio-mxc - update gpio-sifive: support IRQ wake, improve interrupt handling, allow building as module - make gpio-ge and gpio-bcm-kona OF-independent (plus some minor tweaks) - add support for new models in gpio-pca953x and gpio-ds4520 - add runtime PM support to gpio-mxc - fix a build warning in gpio-mxs - add support for adding pin ranges to gpio-mlxbf3 - add counter/timer support to gpio-104-dio-48e - switch to dynamic GPIO base allocation in gpio-vf610 - minor oneliners here and there Device-tree bindings updates: - enable the gpio-line-names property in snps,dw-apb and STMPE GPIO - document new models in fsl-imx-gpio, ds4520 and pca95xx - convert the bindings for brcm,kona-gpio to YAML" * tag 'gpio-updates-for-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: (94 commits) gpio: pca953x: add support for TCA9538 dt-bindings: gpio: pca95xx: document new tca9538 chip gpio: pca953x: Use i2c_get_match_data() gpio: mlxbf3: use capital "OR" for multiple licenses in SPDX gpio: pcf857x: Extend match data support for OF tables gpio: vf610: switch to dynamic allocat GPIO base gpiolib: provide and use gpiod_line_state_notify() gpio: cdev: wake up lineevent poll() on device unbind gpio: cdev: wake up linereq poll() on device unbind gpio: cdev: wake up chardev poll() on device unbind gpiolib: add a second blocking notifier to struct gpio_device gpio: cdev: open-code to_gpio_chardev_data() gpiolib: rename the gpio_device notifier gpio: mlxbf3: Support add_pin_ranges() gpio: mxc: Use helper function devm_clk_get_optional_enabled() gpio: pca9570: fix kerneldoc gpio: sim: simplify code with cleanup helpers gpio: sim: replace memmove() + strstrip() with skip_spaces() + strim() gpio: sim: simplify gpio_sim_device_config_live_store() gpio: mxc: release the parent IRQ in runtime suspend ...
2023-08-25mmc: atmel-mci: Move card detect gpio polarity quirk to gpiolibBalamanikandan Gunasundar
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>
2023-07-10gpiolib: of: Don't use GPIO chip fwnode in of_gpiochip_*()Andy Shevchenko
GPIO library should rely only on the GPIO device's fwnode. Hence, replace GPIO chip fwnode usage by respective OF node of the GPIO device. JFYI, this is partial revert of 8afe82550240 ("gpiolib: of: Prepare of_gpiochip_add() / of_gpiochip_remove() for fwnode"). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Benjamin Tissoires <bentiss@kernel.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-03-06gpiolib: Clean up headersAndy Shevchenko
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>
2023-03-06gpiolib: split of_mm_gpio_chip out of linux/of_gpio.hArnd Bergmann
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>
2023-02-22Merge tag 'pinctrl-v6.3-1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl Pull pin control updates from Linus Walleij: "Nothing special, notably a lot of new Qualcomm hardware is supported, a RISC-V reference SoC and then some cleanups both in code and device tree bindings. Core changes: - Add PINCTRL_PINFUNCTION() macro and use it in several drivers New drivers: - New driver for the StarFive JH7110 SoC "sys" and "aon" (always-on) pin controllers. (RISC-V.) - New subdriver for the Qualcomm QDU1000/QRU1000 SoC pin controller - New subdrivers for the Qualcomm SM8550 SoC and LPASS pin controllers - New subdriver for the Qualcomm SA8775P SoC pin controller - New subdriver for the Qualcomm IPQ5332 SoC pin controller - New (trivial) support for Qualcomm PM8550 and PMR735D PMIC pin control - New subdriver for the Mediatek MT7981 SoC pin controller Improvements: - Several cleanups and refactorings to the Intel drivers - Add 4KOhm bias support to the Intel driver - Use the NOIRQ_SYSTEM_SLEEP_PM_OPS for the AT91 driver - Support general purpose clocks in the Qualcomm MSM8226 SoC - Several conversions to use the new I2C .probe_new() call - Massive clean-up of the Qualcomm Device Tree YAML schemas - Add VIN[45] pins, groups and functions to the Renesas r8a77950 SoC driver" * tag 'pinctrl-v6.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl: (118 commits) pinctrl: qcom: Add support for i2c specific pull feature pinctrl: starfive: Add StarFive JH7110 aon controller driver pinctrl: starfive: Add StarFive JH7110 sys controller driver dt-bindings: pinctrl: Add StarFive JH7110 aon pinctrl dt-bindings: pinctrl: Add StarFive JH7110 sys pinctrl pinctrl: add mt7981 pinctrl driver dt-bindings: pinctrl: add bindings for MT7981 SoC dt-bindings: pinctrl: rockchip,pinctrl: mark gpio sub nodes of pinctrl as deprecated pinctrl: qcom: Introduce IPQ5332 TLMM driver dt-bindings: pinctrl: qcom: add IPQ5332 pinctrl dt-bindings: pinctrl: qcom: lpass-lpi: correct GPIO name pattern pinctrl: qcom: pinctrl-sm8550-lpass-lpi: add SM8550 LPASS dt-bindings: pinctrl: qcom,sm8550-lpass-lpi-pinctrl: add SM8550 LPASS pinctrl: at91: use devm_kasprintf() to avoid potential leaks dt-bindings: pinctrl: qcom: correct gpio-ranges in examples dt-bindings: pinctrl: qcom,msm8994: correct number of GPIOs dt-bindings: pinctrl: qcom,sdx55: correct GPIO name pattern dt-bindings: pinctrl: qcom,msm8953: correct GPIO name pattern dt-bindings: pinctrl: qcom,sm6375: correct GPIO name pattern and example dt-bindings: pinctrl: qcom,msm8909: correct GPIO name pattern and example ...
2023-01-30gpiolib: of: Move enum of_gpio_flags to its only userAndy Shevchenko
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>
2023-01-30gpiolib: Get rid of not used of_node memberAndy Shevchenko
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>
2023-01-30gpiolib: of: remove [devm_]gpiod_get_from_of_node() APIsDmitry Torokhov
Now that everyone is using [devm_]fwnode_gpiod_get[_index]() APIs, remove OF-specific [devm_]gpiod_get_from_of_node(). 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>
2023-01-30gpiolib: of: remove of_get_gpio[_flags]() and of_get_named_gpio_flags()Dmitry Torokhov
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>
2023-01-30gpiolib: of: remove obsolete comment for of_gpio_get_count()Dmitry Torokhov
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>
2023-01-30gpiolib: of: stop exporting of_gpio_named_count()Dmitry Torokhov
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>
2023-01-26Revert "gpiolib: of: Introduce hook for missing gpio-ranges"Andy Shevchenko
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>
2022-11-15gpiolib: of: Use correct fwnode for DT-probed chipsThierry Reding
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>
2022-11-15gpiolib: of: Drop redundant check in of_mm_gpiochip_remove()Andy Shevchenko
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>
2022-11-15gpiolib: of: Prepare of_mm_gpiochip_add_data() for fwnodeAndy Shevchenko
GPIO library is getting rid of of_node, fwnode should be utilized instead. Prepare of_mm_gpiochip_add_data() for fwnode. 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>
2022-11-15gpiolib: of: change of_find_gpio() to accept device nodeDmitry Torokhov
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>
2022-11-09gpiolib: of: Integrate of_gpiochip_init_valid_mask() into ↵Andy Shevchenko
gpiochip_init_valid_mask() In preparation to complete fwnode switch, integrate of_gpiochip_init_valid_mask() into gpiochip_init_valid_mask(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2022-11-09gpiolib: of: Prepare of_gpiochip_add() / of_gpiochip_remove() for fwnodeAndy Shevchenko
GPIO library is getting rid of of_node, fwnode should be utilized instead. Prepare of_gpiochip_add() / of_gpiochip_remove() for fwnode. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2022-11-04gpiolib: of: add polarity quirk for Freescale PCIe controllerDmitry Torokhov
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>
2022-11-04gpiolib: of: factor out quirk setting polarity via separate propertyDmitry Torokhov
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>
2022-11-04gpiolib: of: Make use of device_match_of_node()Andy Shevchenko
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>
2022-10-20gpiolib: of: add a quirk for reset line polarity for Himax LCDsDmitry Torokhov
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>
2022-10-20gpiolib: of: add quirk for phy reset polarity for Freescale EthernetDmitry Torokhov
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>
2022-10-20gpiolib: of: factor out code overriding gpio line polarityDmitry Torokhov
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>
2022-10-20gpiolib: of: add a quirk for legacy names in MOXA ART RTCDmitry Torokhov
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>
2022-10-20gpiolib: of: add a quirk for reset line for Cirrus CS42L56 codecDmitry Torokhov
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>
2022-10-20gpiolib: of: add a quirk for reset line for Marvell NFC controllerDmitry Torokhov
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>
2022-10-20gpiolib: of: add quirk for locating reset lines with legacy bindingsDmitry Torokhov
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>
2022-10-20gpiolib: of: tighten selection of gpio renaming quirksDmitry Torokhov
Tighten selection of legacy gpio renaming quirks so that they only considered on more relevant configurations. Suggested-by: Daniel Thompson <daniel.thompson@linaro.org> 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>
2022-10-20gpiolib: of: consolidate simple renames into a single quirkDmitry Torokhov
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>
2022-10-20gpiolib: of: add a quirk for legacy names in Mediatek mt2701-cs42448Dmitry Torokhov
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>
2022-09-20gpiolib: fix OOB access in quirk callbacksMichael Walle
Commit a2b5e207cade ("gpiolib: rework quirk handling in of_find_gpio()") introduced an array of quirk functions which get iterated over. But a sentinal value is missing. Add it. Fixes: a2b5e207cade ("gpiolib: rework quirk handling in of_find_gpio()") Signed-off-by: Michael Walle <michael@walle.cc> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Tested-by: Conor Dooley <conor.dooley@microchip.com> Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Biju Das <biju.das.jz@bp.renesas.com> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
2022-09-15gpiolib: of: factor out conversion from OF flagsDmitry Torokhov
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>
2022-09-15gpiolib: rework quirk handling in of_find_gpio()Dmitry Torokhov
Instead of having a string of "if" statements let's put all quirks into an array and iterate over them. 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>
2022-09-15gpiolib: of: make Freescale SPI quirk similar to all othersDmitry Torokhov
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>
2022-09-15gpiolib: of: do not ignore requested index when applying quirksDmitry Torokhov
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>