Gpio-ranges property is useful to represent which GPIOs correspond
to which pins on which pin controllers. But there may be some gpios
without pinctrl operation. So check whether gpio-ranges property
exists in device node first.

Signed-off-by: Yunlei He <[email protected]>
Signed-off-by: Xinwei Kong <[email protected]>
Signed-off-by: Haojian Zhuang <[email protected]>
---
 Documentation/devicetree/bindings/gpio/pl061-gpio.txt | 2 +-
 drivers/gpio/gpio-pl061.c                             | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/gpio/pl061-gpio.txt 
b/Documentation/devicetree/bindings/gpio/pl061-gpio.txt
index a2c416b..577bcf7 100644
--- a/Documentation/devicetree/bindings/gpio/pl061-gpio.txt
+++ b/Documentation/devicetree/bindings/gpio/pl061-gpio.txt
@@ -7,4 +7,4 @@ Required properties:
   - bit 0 specifies polarity (0 for normal, 1 for inverted)
 - gpio-controller : Marks the device node as a GPIO controller.
 - interrupts : Interrupt mapping for GPIO IRQ.
-
+- gpio-ranges : Interaction with the PINCTRL subsystem
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
index 84b49cf..01875d1 100644
--- a/drivers/gpio/gpio-pl061.c
+++ b/drivers/gpio/gpio-pl061.c
@@ -24,6 +24,7 @@
 #include <linux/slab.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/pm.h>
+#include <linux/of_address.h>
 
 #define GPIODIR 0x400
 #define GPIOIS  0x404
@@ -263,9 +264,11 @@ static int pl061_probe(struct amba_device *adev, const 
struct amba_id *id)
                return PTR_ERR(chip->base);
 
        spin_lock_init(&chip->lock);
+       if (of_get_property(dev->of_node, "gpio-ranges", NULL)) {
+               chip->gc.request = pl061_gpio_request;
+               chip->gc.free = pl061_gpio_free;
+       }
 
-       chip->gc.request = pl061_gpio_request;
-       chip->gc.free = pl061_gpio_free;
        chip->gc.direction_input = pl061_direction_input;
        chip->gc.direction_output = pl061_direction_output;
        chip->gc.get = pl061_get_value;
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to