aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@linaro.org>2013-10-22 12:42:55 +0800
committerHaojian Zhuang <haojian.zhuang@linaro.org>2013-10-22 12:45:22 +0800
commitdea0f6d4ae2a05dc3a0f3112bbe36a8ff4697801 (patch)
tree5b681bbcc0b2459a610002fdf920f7cb6ce39052
parentc40340bd6f1319dacb3d1f8b187d99fa3084f11e (diff)
gpio: pl061: add new property for gpio base
If gpio base number isn't specified, the gpio base will be find from the end of gpio number. In order to keep with schematics, add a new property "linux,gpio-base" to specify the gpio number in DTS file. Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
-rw-r--r--Documentation/devicetree/bindings/gpio/gpio-pl061.txt33
-rw-r--r--drivers/gpio/gpio-pl061.c15
2 files changed, 47 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/gpio/gpio-pl061.txt b/Documentation/devicetree/bindings/gpio/gpio-pl061.txt
new file mode 100644
index 000000000000..687206727bd3
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/gpio-pl061.txt
@@ -0,0 +1,33 @@
+PL061 GPIO controller bindings
+
+Required properties:
+- compatible:
+ - "arm,pl061", "arm,primecell".
+- #gpio-cells : Should be two.
+ - first cell is the gpio pin number
+ - second cell is used to specify the gpio polarity:
+ 0 = active high
+ 1 = active low
+- gpio-controller : Marks the device node as a GPIO controller.
+- interrupt-controller : Marks the device node as an interrupt controller.
+- #interrupt-cells : Should be two.
+ - first cell is the hw irq number
+ - second cell is used to specify the interrupt type:
+ 0 = default, unspecified type
+ 1 = rising edge triggered
+ 2 = falling edge triggered
+ 4 = high level triggered
+ 8 = low level triggered
+- linux,gpio-base : Should be the global GPIO number.
+
+Example:
+ gpio0: gpio@fc806000 {
+ compatible = "arm,pl061", "arm,primecell";
+ reg = <0xfc806000 0x1000>;
+ interrupts = <0 64 0x4>;
+ gpio-controller;
+ #gpio-cells = <2>;
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ linux,gpio-base = <0>;
+ };
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
index 4274e2e70ef8..cb5510bd070a 100644
--- a/drivers/gpio/gpio-pl061.c
+++ b/drivers/gpio/gpio-pl061.c
@@ -256,6 +256,19 @@ static const struct irq_domain_ops pl061_domain_ops = {
.xlate = irq_domain_xlate_twocell,
};
+/* Parse gpio base from DT */
+static int pl061_parse_gpio_base(struct device *dev)
+{
+ struct device_node *np = dev->of_node;
+ int ret;
+
+ if (of_property_read_u32(np, "linux,gpio-base", &ret))
+ return -ENOENT;
+ if (ret >= 0)
+ return ret;
+ return -EINVAL;
+}
+
static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
{
struct device *dev = &adev->dev;
@@ -273,7 +286,7 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
if (irq_base <= 0)
return -ENODEV;
} else {
- chip->gc.base = -1;
+ chip->gc.base = pl061_parse_gpio_base(dev);
irq_base = 0;
}