From dea0f6d4ae2a05dc3a0f3112bbe36a8ff4697801 Mon Sep 17 00:00:00 2001 From: Haojian Zhuang Date: Tue, 22 Oct 2013 12:42:55 +0800 Subject: 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 --- .../devicetree/bindings/gpio/gpio-pl061.txt | 33 ++++++++++++++++++++++ drivers/gpio/gpio-pl061.c | 15 +++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-pl061.txt 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; } -- cgit v1.2.3 From 514354ce55affa52bae4b64e4d9d1f64250fb9f5 Mon Sep 17 00:00:00 2001 From: Haojian Zhuang Date: Tue, 22 Oct 2013 12:44:16 +0800 Subject: ARM: dts: add gpio base property in hi3620 Signed-off-by: Haojian Zhuang --- arch/arm/boot/dts/hi3620.dtsi | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/arm/boot/dts/hi3620.dtsi b/arch/arm/boot/dts/hi3620.dtsi index 9829c9cca12e..1c8d31b67bb7 100644 --- a/arch/arm/boot/dts/hi3620.dtsi +++ b/arch/arm/boot/dts/hi3620.dtsi @@ -1083,6 +1083,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk0>; clock-names = "apb_pclk"; + linux,gpio-base = <0>; status = "disable"; }; @@ -1099,6 +1100,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk1>; clock-names = "apb_pclk"; + linux,gpio-base = <8>; status = "disable"; }; @@ -1115,6 +1117,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk2>; clock-names = "apb_pclk"; + linux,gpio-base = <16>; status = "disable"; }; @@ -1131,6 +1134,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk3>; clock-names = "apb_pclk"; + linux,gpio-base = <24>; status = "disable"; }; @@ -1147,6 +1151,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk4>; clock-names = "apb_pclk"; + linux,gpio-base = <32>; status = "disable"; }; @@ -1163,6 +1168,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk5>; clock-names = "apb_pclk"; + linux,gpio-base = <40>; status = "disable"; }; @@ -1179,6 +1185,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk6>; clock-names = "apb_pclk"; + linux,gpio-base = <48>; status = "disable"; }; @@ -1195,6 +1202,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk7>; clock-names = "apb_pclk"; + linux,gpio-base = <56>; status = "disable"; }; @@ -1211,6 +1219,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk8>; clock-names = "apb_pclk"; + linux,gpio-base = <64>; status = "disable"; }; @@ -1227,6 +1236,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk9>; clock-names = "apb_pclk"; + linux,gpio-base = <72>; status = "disable"; }; @@ -1242,6 +1252,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk10>; clock-names = "apb_pclk"; + linux,gpio-base = <80>; status = "disable"; }; @@ -1258,6 +1269,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk11>; clock-names = "apb_pclk"; + linux,gpio-base = <88>; status = "disable"; }; @@ -1274,6 +1286,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk12>; clock-names = "apb_pclk"; + linux,gpio-base = <96>; status = "disable"; }; @@ -1290,6 +1303,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk13>; clock-names = "apb_pclk"; + linux,gpio-base = <104>; status = "disable"; }; @@ -1306,6 +1320,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk14>; clock-names = "apb_pclk"; + linux,gpio-base = <112>; status = "disable"; }; @@ -1322,6 +1337,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk15>; clock-names = "apb_pclk"; + linux,gpio-base = <120>; status = "disable"; }; @@ -1338,6 +1354,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk16>; clock-names = "apb_pclk"; + linux,gpio-base = <128>; status = "disable"; }; @@ -1354,6 +1371,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk17>; clock-names = "apb_pclk"; + linux,gpio-base = <136>; status = "disable"; }; @@ -1370,6 +1388,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk18>; clock-names = "apb_pclk"; + linux,gpio-base = <144>; status = "disable"; }; @@ -1385,6 +1404,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk19>; clock-names = "apb_pclk"; + linux,gpio-base = <152>; status = "disable"; }; @@ -1400,6 +1420,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk20>; clock-names = "apb_pclk"; + linux,gpio-base = <160>; status = "disable"; }; @@ -1414,6 +1435,7 @@ #interrupt-cells = <2>; clocks = <&gpioclk21>; clock-names = "apb_pclk"; + linux,gpio-base = <168>; status = "disable"; }; -- cgit v1.2.3