brcm63xx: implement gpio_to_irq for bcm63xx-gpio
authorJonas Gorski <jonas.gorski@gmail.com>
Sun, 18 Dec 2016 12:54:17 +0000 (13:54 +0100)
committerJonas Gorski <jonas.gorski@gmail.com>
Thu, 9 Feb 2017 13:30:43 +0000 (14:30 +0100)
Add support for mapping some GPIO lines to IRQs. GPIO to IRQ mappings
were found out through experimentation, helped by having the GPIO as
output still toggling the IRQ input.

Based-on: http://patchwork.ozlabs.org/patch/660534/
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
target/linux/brcm63xx/dts/bcm6318.dtsi
target/linux/brcm63xx/dts/bcm63268.dtsi
target/linux/brcm63xx/dts/bcm6328.dtsi
target/linux/brcm63xx/dts/bcm6348.dtsi
target/linux/brcm63xx/dts/bcm6358.dtsi
target/linux/brcm63xx/dts/bcm6362.dtsi
target/linux/brcm63xx/dts/bcm6368.dtsi
target/linux/brcm63xx/patches-4.4/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch

index 776698068d4ee3367447602d50af439d96305648..037161797814fb3a48f3056909a11718e55d7dff 100644 (file)
                        #gpio-cells = <2>;
 
                        ngpios = <18>;
+
+                       interrupt-parent = <&ext_intc>;
+                       interrupts = <0 0>, <1 0>;
+                       interrupt-names = "gpio1", "gpio2";
                };
 
                gpio0: gpio-controller@10000084 {
index 47894f8b42e745b91cd78947a9cc209f6a783852..5a0a909563d1e883966b83021a3b163b6f23181d 100644 (file)
                        #gpio-cells = <2>;
 
                        ngpios = <20>;
+
+                       interrupt-parent = <&periph_intc>;
+                       interrupts = <0 0>, <1 0>, <2 0>, <3 0>;
+                       interrupt-names = "gpio0", "gpio1", "gpio2", "gpio3";
                };
 
                gpio0: gpio-controller@100000c4 {
index b49958a7b67b2b9f31831732ca3c4fad914731cf..5eec6dec3a574a6489c41cfc7cadfe89a44cc8b1 100644 (file)
 
                        gpio-controller;
                        #gpio-cells = <2>;
+
+                       interrupt-parent = <&ext_intc>;
+                       interrupts = <3 0>, <2 0>, <0 0>, <1 0>;
+                       interrupt-names = "gpio12", "gpio15",
+                                         "gpio23", "gpio24";
                };
        };
 };
index 7edda30845ec5148547b243e47578d56785b8ee4..d1219c031ff472b614021cd3c80d39a18e427d48 100644 (file)
                        #gpio-cells = <2>;
 
                        ngpios = <5>;
+
+                       interrupt-parent = <&ext_intc>;
+                       interrupts = <0 0>, <1 0>, <2 0>, <3 0>;
+                       interrupt-names = "gpio0", "gpio1", "gpio2", "gpio3";
                };
 
                gpio0: gpio-controller@fffe0404 {
index fa0b5b8a6ebc0d2479b2fa51b557736245a9732b..9d95849b3ae820064b1e78b8b9cfff8d9fbc95ae 100644 (file)
                        #gpio-cells = <2>;
 
                        ngpios = <8>;
+
+                       interrupts-extended = <&ext_intc1 0 0>,
+                                             <&ext_intc1 1 0>,
+                                             <&ext_intc0 0 0>,
+                                             <&ext_intc0 1 0>,
+                                             <&ext_intc0 2 0>,
+                                             <&ext_intc0 3 0>;
+                       interrupt-names = "gpio0", "gpio1", "gpio2", "gpio3",
+                                         "gpio4", "gpio5";
                };
 
                gpio0: gpio-controller@fffe0084 {
index 40f6b9ec29e181ca4812866913e99dd638490b21..a6a5c1f1d02f08f666a02c422997724406298a78 100644 (file)
 
                        gpio-controller;
                        #gpio-cells = <2>;
+
+                       interrupt-parent = <&ext_intc>;
+                       interrupts = <0 0>, <1 0>, <2 0>, <3 0>;
+                       interrupt-names = "gpio24", "gpio25",
+                                         "gpio26", "gpio27";
                };
        };
 };
index 52bcec4466edafd087807a179f2480492678d960..59ef41af47a5fe01df4d6ad67e1c9b4b06783d7b 100644 (file)
                        #gpio-cells = <2>;
 
                        ngpios = <6>;
+
+                       interrupts-extended = <&ext_intc1 0 0>,
+                                             <&ext_intc1 1 0>,
+                                             <&ext_intc0 0 0>,
+                                             <&ext_intc0 1 0>,
+                                             <&ext_intc0 2 0>,
+                                             <&ext_intc0 3 0>;
+                       interrupt-names = "gpio0", "gpio1", "gpio2", "gpio3",
+                                         "gpio4", "gpio5";
                };
 
                gpio0: gpio-controller@10000084 {
index 28930d0f9f52a22b0c2066c35cc43441098391a3..cd613f5e7b38250bbc55f074a30dc8cfa9ab9010 100644 (file)
@@ -40,7 +40,7 @@ Signed-off-by: Jonas Gorski <jogo@openwrt.org>
  obj-$(CONFIG_GPIO_CLPS711X)   += gpio-clps711x.o
 --- /dev/null
 +++ b/drivers/gpio/gpio-bcm63xx.c
-@@ -0,0 +1,122 @@
+@@ -0,0 +1,134 @@
 +/*
 + * Driver for BCM63XX memory-mapped GPIO controllers, based on
 + * Generic driver for memory-mapped GPIO controllers.
@@ -73,8 +73,17 @@ Signed-off-by: Jonas Gorski <jogo@openwrt.org>
 +#include <linux/mod_devicetable.h>
 +#include <linux/basic_mmio_gpio.h>
 +#include <linux/of.h>
++#include <linux/of_irq.h>
 +#include <linux/of_gpio.h>
 +
++static int bcm63xx_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
++{
++      char irq_name[7]; /* "gpioXX" */
++
++      sprintf(irq_name, "gpio%d", gpio);
++      return of_irq_get_byname(chip->of_node, irq_name);
++}
++
 +static int bcm63xx_gpio_probe(struct platform_device *pdev)
 +{
 +      struct device *dev = &pdev->dev;
@@ -126,6 +135,9 @@ Signed-off-by: Jonas Gorski <jogo@openwrt.org>
 +              if (!of_property_read_u32(dev->of_node, "ngpios", &ngpios))
 +                      bgc->gc.ngpio = ngpios;
 +
++              if (of_get_property(dev->of_node, "interrupt-names", NULL))
++                      bgc->gc.to_irq = bcm63xx_gpio_to_irq;
++
 +      } else if (pdata) {
 +              bgc->gc.base = pdata->base;
 +              if (pdata->ngpio > 0)