From: Anders Berg <[email protected]>

Use DT alias to allow the gpio base to be selected. This solves compatibility
with user-space programs that expects a fixed numbering scheme from non-DT
system. If an alias for the device node is not defined in device tree, the
fallback is to use the dynamically allocated number.

Signed-off-by: Anders Berg <[email protected]>
---
 drivers/gpio/gpio-pl061.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
index c13f8d1..d1c3b15 100644
--- a/drivers/gpio/gpio-pl061.c
+++ b/drivers/gpio/gpio-pl061.c
@@ -298,7 +298,11 @@ static int pl061_probe(struct device *dev,
                if (irq_base <= 0)
                        return -ENODEV;
        } else if (dev->of_node) {
-               chip->gc.base = -1;
+               int id = of_alias_get_id(dev->of_node, "gpio");
+               if (id < 0)
+                       chip->gc.base = -1;
+               else
+                       chip->gc.base = id * PL061_GPIO_NR;
                irq_base = 0;
        } else {
                if (retchip)
-- 
1.8.1.4

-- 
_______________________________________________
linux-yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/linux-yocto

Reply via email to