[PATCH 07/11] gpio: dw: support numbering via aliases

David Picard david.picard at clermont.in2p3.fr
Wed Sep 17 08:22:10 PDT 2025


From: Ahmad Fatoum <a.fatoum at pengutronix.de>

This device driver is OF-only, so reflect that in the Kconfig and have
it parse aliases if available to derive its id.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 drivers/gpio/Kconfig   | 1 +
 drivers/gpio/gpio-dw.c | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 7caa1aa96eb3c65982f7ecea3af07c8388bf7349..17d5587ea8cf46b1c356d5c11e1ea2c35ba8f269 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -201,6 +201,7 @@ config GPIO_TEGRA
 
 config GPIO_DESIGNWARE
 	tristate "Synopsys DesignWare GPIO driver"
+	depends on OF_GPIO
 	help
 	  Say Y or M here to build support for the Synopsys DesignWare APB
 	  GPIO block.
diff --git a/drivers/gpio/gpio-dw.c b/drivers/gpio/gpio-dw.c
index e6eba6b423f5e997960ea39aff641718a8b0af42..98668c0a2d548e8dbac6e88180da25d28ae108e4 100644
--- a/drivers/gpio/gpio-dw.c
+++ b/drivers/gpio/gpio-dw.c
@@ -114,6 +114,8 @@ static int dw_gpio_add_port(struct device *dev, struct device_node *node,
 	chip = xzalloc(sizeof(*chip));
 
 	chip->chip.ops = &dw_gpio_ops;
+
+	dev->id = of_alias_get_id(dev->device_node, "gpio");
 	if (dev->id < 0)
 		chip->chip.base = DEVICE_ID_DYNAMIC;
 	else
@@ -181,7 +183,7 @@ MODULE_DEVICE_TABLE(of, dwgpio_match);
 static struct driver dwgpio_driver = {
 	.name = "dw-apb-gpio",
 	.probe = dw_gpio_probe,
-	.of_compatible = DRV_OF_COMPAT(dwgpio_match),
+	.of_compatible = dwgpio_match,
 };
 
 postcore_platform_driver(dwgpio_driver);

-- 
2.43.0




More information about the barebox mailing list