[PATCH v1 0/2] GPIO: improve and fix pmic gpios behavior

First patch makes support of PMIC GPIO children with no dedicated GPIO node simpler (just add select PMIC_GPIO to PMIC GPIO driver)
Second fixes getting device if correct one was found among PMIC children.
Svyatoslav Ryhel (2): gpio: add PMIC_GPIO Kconfig option gpio: fix request of PMIC GPIO child
drivers/gpio/Kconfig | 8 ++++++++ drivers/gpio/gpio-uclass.c | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-)

Add more generic Kconfig option to be enabled by the PMIC drivers which do not have dedicated GPIO node and use same phandle to refer to both core driver and GPIO child.
Signed-off-by: Svyatoslav Ryhel clamor95@gmail.com --- drivers/gpio/Kconfig | 8 ++++++++ drivers/gpio/gpio-uclass.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 92a8597420a..b7a3dd7b221 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -255,6 +255,7 @@ config MAX7320_GPIO config MAX77663_GPIO bool "MAX77663 GPIO cell of PMIC driver" depends on DM_GPIO && DM_PMIC_MAX77663 + select PMIC_GPIO help GPIO driver for MAX77663 PMIC from Maxim Semiconductor. MAX77663 PMIC has 8 pins that can be configured as GPIOs @@ -474,6 +475,13 @@ config PIC32_GPIO help Say yes here to support Microchip PIC32 GPIOs.
+config PMIC_GPIO + bool "PMIC without exposed GPIO node" + depends on DM_GPIO + help + Choose this option if your PMIC does not have dedicated GPIO node + and phandle of the PMIC itself is used as a GPIO phandle. + config OCTEON_GPIO bool "Octeon II/III/TX/TX2 GPIO driver" depends on DM_GPIO && PCI && (ARCH_OCTEON || ARCH_OCTEONTX || ARCH_OCTEONTX2) diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 0213271e3a6..e776906fe73 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -1142,7 +1142,7 @@ static int gpio_request_tail(int ret, const char *nodename, ret = uclass_get_device_by_ofnode(UCLASS_GPIO, args->node, &desc->dev); if (ret) { -#if CONFIG_IS_ENABLED(MAX77663_GPIO) || CONFIG_IS_ENABLED(PALMAS_GPIO) +#if CONFIG_IS_ENABLED(PMIC_GPIO) struct udevice *pmic; ret = uclass_get_device_by_ofnode(UCLASS_PMIC, args->node, &pmic);

On Fri, Dec 06, 2024 at 05:40:49PM +0200, Svyatoslav Ryhel wrote:
Add more generic Kconfig option to be enabled by the PMIC drivers which do not have dedicated GPIO node and use same phandle to refer to both core driver and GPIO child.
Signed-off-by: Svyatoslav Ryhel clamor95@gmail.com
drivers/gpio/Kconfig | 8 ++++++++ drivers/gpio/gpio-uclass.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 92a8597420a..b7a3dd7b221 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -255,6 +255,7 @@ config MAX7320_GPIO config MAX77663_GPIO bool "MAX77663 GPIO cell of PMIC driver" depends on DM_GPIO && DM_PMIC_MAX77663
- select PMIC_GPIO help GPIO driver for MAX77663 PMIC from Maxim Semiconductor. MAX77663 PMIC has 8 pins that can be configured as GPIOs
@@ -474,6 +475,13 @@ config PIC32_GPIO help Say yes here to support Microchip PIC32 GPIOs.
+config PMIC_GPIO
- bool "PMIC without exposed GPIO node"
- depends on DM_GPIO
- help
Choose this option if your PMIC does not have dedicated GPIO node
and phandle of the PMIC itself is used as a GPIO phandle.
We shouldn't prompt for this, and instead select it (like you do above) when required. So please drop the prompt text and change the help to star with "Select this option ..." thanks!

If correct PMIC child was found it should be requested as well.
Signed-off-by: Svyatoslav Ryhel clamor95@gmail.com --- drivers/gpio/gpio-uclass.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index e776906fe73..e6c00c48722 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -1160,6 +1160,14 @@ static int gpio_request_tail(int ret, const char *nodename, /* if loop exits without GPIO device return error */ if (device_get_uclass_id(desc->dev) != UCLASS_GPIO) goto err; + + ret = uclass_get_device_by_name(UCLASS_GPIO, desc->dev->name, + &desc->dev); + if (ret) { + log_debug("%s: getting GPIO device failed %d\n", + __func__, ret); + goto err; + } #else debug("%s: uclass_get_device_by_ofnode failed\n", __func__);
participants (2)
-
Svyatoslav Ryhel
-
Tom Rini