Re: [OpenWrt-Devel] [PATCH 1/3] brcm63xx: add bcm6345-gpio driver
2014-12-12 6:33 GMT-08:00 Jonas Gorski j...@openwrt.org: On Fri, Dec 12, 2014 at 3:17 PM, John Crispin blo...@openwrt.org wrote: On 12/12/2014 15:12, Jonas Gorski wrote: or the gpio-base problem, we should be able to register appropriate platform data for it as OF_DEV_AUXDATA() in of_platform_populate. e.g. struct bgpio_pdata gpio0_pdata = { .base = 0, }; struct bgpio_pdata gpio1_pdata = { .base = 32, }; tried it for ralink and lantiq and it got nak'ed by LinusW i keep that part of the code as a small patch inside owrt on top of the stuff i sent upstream. Wasn't the objection on putting the gpio base into the dts(i) file itself? I explicitly try to avoid that here, as gpio-base is something linux internal. Right that is typically the objection, but with the new gpio descriptor based API, we should not have that problem anymore, right? But It doesn't matter much for now as not even basic DT support is upstream, so these won't go anywhere soon. -- Florian ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 1/3] brcm63xx: add bcm6345-gpio driver
On Thu, Dec 11, 2014 at 12:51 AM, Álvaro Fernández Rojas nolt...@gmail.com wrote: Signed-off-by: Álvaro Fernández Rojas nolt...@gmail.com --- diff --git a/target/linux/brcm63xx/config-3.14 b/target/linux/brcm63xx/config-3.14 index dd27f47..f94c567 100644 --- a/target/linux/brcm63xx/config-3.14 +++ b/target/linux/brcm63xx/config-3.14 @@ -76,6 +76,7 @@ CONFIG_GENERIC_IRQ_SHOW=y CONFIG_GENERIC_PCI_IOMAP=y CONFIG_GENERIC_SMP_IDLE_THREAD=y CONFIG_GPIOLIB=y +CONFIG_GPIO_BCM6345=y CONFIG_GPIO_DEVRES=y CONFIG_GPIO_SYSFS=y # CONFIG_HAMRADIO is not set diff --git a/target/linux/brcm63xx/config-3.18 b/target/linux/brcm63xx/config-3.18 index e3cf020..7957d02 100644 --- a/target/linux/brcm63xx/config-3.18 +++ b/target/linux/brcm63xx/config-3.18 @@ -80,6 +80,7 @@ CONFIG_GENERIC_IRQ_SHOW=y CONFIG_GENERIC_PCI_IOMAP=y CONFIG_GENERIC_SMP_IDLE_THREAD=y CONFIG_GPIOLIB=y +CONFIG_GPIO_BCM6345=y CONFIG_GPIO_DEVRES=y CONFIG_GPIO_SYSFS=y # CONFIG_HAMRADIO is not set diff --git a/target/linux/brcm63xx/patches-3.14/374-GPIO-DT-add-bcm6345-driver.patch b/target/linux/brcm63xx/patches-3.14/374-GPIO-DT-add-bcm6345-driver.patch new file mode 100644 index 000..a6c775b --- /dev/null +++ b/target/linux/brcm63xx/patches-3.14/374-GPIO-DT-add-bcm6345-driver.patch @@ -0,0 +1,244 @@ +--- /dev/null b/drivers/gpio/gpio-bcm6345.c +@@ -0,0 +1,216 @@ ++/* ++ * This file is subject to the terms and conditions of the GNU General Public ++ * License. See the file COPYING in the main directory of this archive ++ * for more details. ++ * ++ * Copyright (C) 2008 Maxime Bizon mbi...@freebox.fr ++ * Copyright (C) 2008-2011 Florian Fainelli flor...@openwrt.org ++ * Copyright (C) 2014 Álvaro Fernández Rojas nolt...@gmail.com ++ */ ++ ++#include linux/kernel.h ++#include linux/module.h ++#include linux/spinlock.h ++#include linux/platform_device.h ++#include linux/gpio.h ++ ++enum bcm6345_gpio_reg { ++ GPIO_REG_CTL_HI = 0, ++ GPIO_REG_CTL_LO, ++ GPIO_REG_DATA_HI, ++ GPIO_REG_DATA_LO, ++ GPIO_REG_MAX ++}; ++ ++struct bcm6345_gpio_chip { ++ struct gpio_chip chip; ++ u8 regs[GPIO_REG_MAX]; I think we could replace the whole driver with e.g. bcm6345: gpio0: gpio-controller@fffe0404 { compatible = basic-mmio-gpio-be; regs = 0xfffe0404 0x4 0xfffe0408 0x2 reg-names = dirin, dat; gpio-controller; #gpio-cells = 2; }; and for the ones with 32 gpios: gpio0: gpio-controller@1084 { compatible = basic-mmio-gpio-be; regs = 0x1084 0x4 0x108c 0x4 reg-names = dirin, dat; gpio-controller; #gpio-cells = 2; }; gpio1: gpio-controller@180 { compatible = basic-mmio-gpio-be; regs = 0x1080 0x4 0x108c 0x4 reg-names = dirin, dat; gpio-controller; #gpio-cells = 2; }; Maybe add support for setting ngpios through DT, or make it a usable-mask or so. For the gpio-base problem, we should be able to register appropriate platform data for it as OF_DEV_AUXDATA() in of_platform_populate. e.g. struct bgpio_pdata gpio0_pdata = { .base = 0, }; struct bgpio_pdata gpio1_pdata = { .base = 32, }; struct of_dev_auxdata auxdata[] = { OF_DEV_AUXDATA(basic-mmio-gpio-be,0xfffe0400, NULL, gpio1_pdata), OF_DEV_AUXDATA(basic-mmio-gpio-be,0xfffe0404, NULL, gpio0_pdata), OF_DEV_AUXDATA(basic-mmio-gpio-be,0xfffe0080, NULL, gpio1_pdata), OF_DEV_AUXDATA(basic-mmio-gpio-be,0xfffe0084, NULL, gpio0_pdata), OF_DEV_AUXDATA(basic-mmio-gpio-be,0x1080, NULL, gpio1_pdata), OF_DEV_AUXDATA(basic-mmio-gpio-be,0x1084, NULL, gpio0_pdata), }; ... of_platform_populate(... auxdata, ); Jonas ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 1/3] brcm63xx: add bcm6345-gpio driver
On 12/12/2014 15:12, Jonas Gorski wrote: or the gpio-base problem, we should be able to register appropriate platform data for it as OF_DEV_AUXDATA() in of_platform_populate. e.g. struct bgpio_pdata gpio0_pdata = { .base = 0, }; struct bgpio_pdata gpio1_pdata = { .base = 32, }; tried it for ralink and lantiq and it got nak'ed by LinusW i keep that part of the code as a small patch inside owrt on top of the stuff i sent upstream. John ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 1/3] brcm63xx: add bcm6345-gpio driver
On Fri, Dec 12, 2014 at 3:17 PM, John Crispin blo...@openwrt.org wrote: On 12/12/2014 15:12, Jonas Gorski wrote: or the gpio-base problem, we should be able to register appropriate platform data for it as OF_DEV_AUXDATA() in of_platform_populate. e.g. struct bgpio_pdata gpio0_pdata = { .base = 0, }; struct bgpio_pdata gpio1_pdata = { .base = 32, }; tried it for ralink and lantiq and it got nak'ed by LinusW i keep that part of the code as a small patch inside owrt on top of the stuff i sent upstream. Wasn't the objection on putting the gpio base into the dts(i) file itself? I explicitly try to avoid that here, as gpio-base is something linux internal. But It doesn't matter much for now as not even basic DT support is upstream, so these won't go anywhere soon. Jonas ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 1/3] brcm63xx: add bcm6345-gpio driver
On 12/12/2014 15:33, Jonas Gorski wrote: On Fri, Dec 12, 2014 at 3:17 PM, John Crispin blo...@openwrt.org wrote: On 12/12/2014 15:12, Jonas Gorski wrote: or the gpio-base problem, we should be able to register appropriate platform data for it as OF_DEV_AUXDATA() in of_platform_populate. e.g. struct bgpio_pdata gpio0_pdata = { .base = 0, }; struct bgpio_pdata gpio1_pdata = { .base = 32, }; tried it for ralink and lantiq and it got nak'ed by LinusW i keep that part of the code as a small patch inside owrt on top of the stuff i sent upstream. Wasn't the objection on putting the gpio base into the dts(i) file itself? I explicitly try to avoid that here, as gpio-base is something linux internal. i think it was in general but might be wrong i'll dig into my mails when i go on the next kernel spree But It doesn't matter much for now as not even basic DT support is upstream, so these won't go anywhere soon. Jonas ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 1/3] brcm63xx: add bcm6345-gpio driver
Signed-off-by: Álvaro Fernández Rojas nolt...@gmail.com --- diff --git a/target/linux/brcm63xx/config-3.14 b/target/linux/brcm63xx/config-3.14 index dd27f47..f94c567 100644 --- a/target/linux/brcm63xx/config-3.14 +++ b/target/linux/brcm63xx/config-3.14 @@ -76,6 +76,7 @@ CONFIG_GENERIC_IRQ_SHOW=y CONFIG_GENERIC_PCI_IOMAP=y CONFIG_GENERIC_SMP_IDLE_THREAD=y CONFIG_GPIOLIB=y +CONFIG_GPIO_BCM6345=y CONFIG_GPIO_DEVRES=y CONFIG_GPIO_SYSFS=y # CONFIG_HAMRADIO is not set diff --git a/target/linux/brcm63xx/config-3.18 b/target/linux/brcm63xx/config-3.18 index e3cf020..7957d02 100644 --- a/target/linux/brcm63xx/config-3.18 +++ b/target/linux/brcm63xx/config-3.18 @@ -80,6 +80,7 @@ CONFIG_GENERIC_IRQ_SHOW=y CONFIG_GENERIC_PCI_IOMAP=y CONFIG_GENERIC_SMP_IDLE_THREAD=y CONFIG_GPIOLIB=y +CONFIG_GPIO_BCM6345=y CONFIG_GPIO_DEVRES=y CONFIG_GPIO_SYSFS=y # CONFIG_HAMRADIO is not set diff --git a/target/linux/brcm63xx/patches-3.14/374-GPIO-DT-add-bcm6345-driver.patch b/target/linux/brcm63xx/patches-3.14/374-GPIO-DT-add-bcm6345-driver.patch new file mode 100644 index 000..a6c775b --- /dev/null +++ b/target/linux/brcm63xx/patches-3.14/374-GPIO-DT-add-bcm6345-driver.patch @@ -0,0 +1,244 @@ +--- /dev/null b/drivers/gpio/gpio-bcm6345.c +@@ -0,0 +1,216 @@ ++/* ++ * This file is subject to the terms and conditions of the GNU General Public ++ * License. See the file COPYING in the main directory of this archive ++ * for more details. ++ * ++ * Copyright (C) 2008 Maxime Bizon mbi...@freebox.fr ++ * Copyright (C) 2008-2011 Florian Fainelli flor...@openwrt.org ++ * Copyright (C) 2014 Álvaro Fernández Rojas nolt...@gmail.com ++ */ ++ ++#include linux/kernel.h ++#include linux/module.h ++#include linux/spinlock.h ++#include linux/platform_device.h ++#include linux/gpio.h ++ ++enum bcm6345_gpio_reg { ++ GPIO_REG_CTL_HI = 0, ++ GPIO_REG_CTL_LO, ++ GPIO_REG_DATA_HI, ++ GPIO_REG_DATA_LO, ++ GPIO_REG_MAX ++}; ++ ++struct bcm6345_gpio_chip { ++ struct gpio_chip chip; ++ u8 regs[GPIO_REG_MAX]; ++ ++ spinlock_t lock; ++ void __iomem *membase; ++}; ++ ++static inline struct bcm6345_gpio_chip *to_bcm6345_gpio(struct gpio_chip *chip) ++{ ++ struct bcm6345_gpio_chip *bg; ++ ++ bg = container_of(chip, struct bcm6345_gpio_chip, chip); ++ ++ return bg; ++} ++ ++static inline u32 bc_gpio_r32(struct bcm6345_gpio_chip *bg, u8 reg) ++{ ++ return ioread32be(bg-membase + bg-regs[reg]); ++} ++ ++static inline void bc_gpio_w32(struct bcm6345_gpio_chip *bg, u8 reg, u32 val) ++{ ++ iowrite32be(val, bg-membase + bg-regs[reg]); ++} ++ ++static void bcm6345_gpio_set(struct gpio_chip *chip, unsigned gpio, int value) ++{ ++ struct bcm6345_gpio_chip *bg = to_bcm6345_gpio(chip); ++ unsigned long flags; ++ u32 mask, val; ++ u8 reg; ++ ++ if (gpio 32) { ++ reg = GPIO_REG_DATA_LO; ++ mask = BIT(gpio); ++ } else { ++ reg = GPIO_REG_DATA_HI; ++ mask = BIT(gpio - 32); ++ } ++ ++ spin_lock_irqsave(bg-lock, flags); ++ val = bc_gpio_r32(bg, reg); ++ if (value) ++ val |= mask; ++ else ++ val = ~mask; ++ bc_gpio_w32(bg, reg, val); ++ spin_unlock_irqrestore(bg-lock, flags); ++} ++ ++static int bcm6345_gpio_get(struct gpio_chip *chip, unsigned gpio) ++{ ++ struct bcm6345_gpio_chip *bg = to_bcm6345_gpio(chip); ++ u32 mask; ++ u8 reg; ++ ++ if (gpio 32) { ++ reg = GPIO_REG_DATA_LO; ++ mask = BIT(gpio); ++ } else { ++ reg = GPIO_REG_DATA_HI; ++ mask = BIT(gpio - 32); ++ } ++ ++ return !!(bc_gpio_r32(bg, reg) mask); ++} ++ ++static int bcm6345_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) ++{ ++ struct bcm6345_gpio_chip *bg = to_bcm6345_gpio(chip); ++ unsigned long flags; ++ u32 mask, val; ++ u8 reg; ++ ++ if (gpio 32) { ++ reg = GPIO_REG_CTL_LO; ++ mask = BIT(gpio); ++ } else { ++ reg = GPIO_REG_CTL_HI; ++ mask = BIT(gpio - 32); ++ } ++ ++ spin_lock_irqsave(bg-lock, flags); ++ val = bc_gpio_r32(bg, reg) ~mask; ++ bc_gpio_w32(bg, reg, val); ++ spin_unlock_irqrestore(bg-lock, flags); ++ ++ return 0; ++} ++ ++static int bcm6345_gpio_direction_output(struct gpio_chip *chip, unsigned gpio) ++{ ++ struct bcm6345_gpio_chip *bg = to_bcm6345_gpio(chip); ++ unsigned long flags; ++ u32 mask, val; ++ u8 reg; ++ ++ if (gpio 32) { ++ reg = GPIO_REG_CTL_LO; ++ mask = BIT(gpio); ++ } else { ++ reg = GPIO_REG_CTL_HI; ++ mask = BIT(gpio - 32); ++ } ++ ++ spin_lock_irqsave(bg-lock, flags); ++ val = bc_gpio_r32(bg, reg) | mask; ++ bc_gpio_w32(bg, reg, val); ++ spin_unlock_irqrestore(bg-lock, flags); ++ ++ return 0; ++} ++ ++int __init