Implement "to_irq" in the GPIO driver. A few GPIOs in bcm63xx SoCs have IRQs. They are known in this target as external IRQs. This patch adds the function "to_irq" for allowing to use the generic GPIO lib function gpio_to_irq(). This function just returns the IRQ number at the GPIO line.
Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com> diff --git a/target/linux/brcm63xx/patches-4.4/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch b/target/linux/brcm63xx/patches-4.4/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch index 92b0e71..0d6f8ce 100644 --- a/target/linux/brcm63xx/patches-4.4/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch +++ b/target/linux/brcm63xx/patches-4.4/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch @@ -40,7 +40,7 @@ Signed-off-by: Jonas Gorski <j...@openwrt.org> obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o --- /dev/null +++ b/drivers/gpio/gpio-bcm63xx.c -@@ -0,0 +1,122 @@ +@@ -0,0 +1,178 @@ +/* + * Driver for BCM63XX memory-mapped GPIO controllers, based on + * Generic driver for memory-mapped GPIO controllers. @@ -75,6 +75,58 @@ Signed-off-by: Jonas Gorski <j...@openwrt.org> +#include <linux/of.h> +#include <linux/of_gpio.h> + ++#include <bcm63xx_irq.h> ++ ++static int bcm63xx_gpio_to_irq(struct gpio_chip *chip, unsigned gpio) ++{ ++ unsigned int i; ++ int irq2gpio[6] = { -1, -1, -1, -1, -1, -1 }; ++ ++ switch (bcm63xx_get_cpu_id()) { ++ case BCM6328_CPU_ID: ++ irq2gpio[0] = 23; ++ irq2gpio[1] = 24; ++ irq2gpio[2] = 15; ++ irq2gpio[3] = 12; ++ break; ++ case BCM6348_CPU_ID: ++ case BCM63268_CPU_ID: ++ if (chip->ngpio < 32) ++ { ++ irq2gpio[0] = 0; ++ irq2gpio[1] = 1; ++ irq2gpio[2] = 2; ++ irq2gpio[3] = 3; ++ } ++ else ++ return -EINVAL; ++ break; ++ case BCM6358_CPU_ID: ++ case BCM6368_CPU_ID: ++ if (chip->ngpio < 32) ++ { ++ irq2gpio[0] = 2; ++ irq2gpio[1] = 3; ++ irq2gpio[2] = 4; ++ irq2gpio[3] = 5; ++ irq2gpio[4] = 0; ++ irq2gpio[5] = 1; ++ } ++ else ++ return -EINVAL; ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ for (i = 0; i < 6; i++) { ++ if (irq2gpio[i] == gpio) ++ return i + IRQ_EXTERNAL_BASE; ++ } ++ ++ return -EINVAL; ++} ++ +static int bcm63xx_gpio_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; @@ -85,6 +137,7 @@ Signed-off-by: Jonas Gorski <j...@openwrt.org> + int err; + struct bgpio_chip *bgc; + struct bgpio_pdata *pdata = dev_get_platdata(dev); ++ struct gpio_chip *chip; + + dirout_r = platform_get_resource(pdev, IORESOURCE_MEM, 0); + dat_r = platform_get_resource(pdev, IORESOURCE_MEM, 1); @@ -131,8 +184,11 @@ Signed-off-by: Jonas Gorski <j...@openwrt.org> + if (pdata->ngpio > 0) + bgc->gc.ngpio = pdata->ngpio; + } ++ ++ chip = &bgc->gc; ++ chip->to_irq = bcm63xx_gpio_to_irq; + -+ return gpiochip_add(&bgc->gc); ++ return gpiochip_add(chip); +} + +static int bcm63xx_gpio_remove(struct platform_device *pdev) _______________________________________________ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev