1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-07-05 01:14:13 +03:00

[brcm47xx]: update gpio patches

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@33462 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
hauke 2012-09-19 10:17:51 +00:00
parent 3eccd5d2f9
commit 11e47465cc
3 changed files with 145 additions and 170 deletions

View File

@ -16,7 +16,6 @@ CONFIG_BCMA=y
CONFIG_BCMA_BLOCKIO=y CONFIG_BCMA_BLOCKIO=y
CONFIG_BCMA_DEBUG=y CONFIG_BCMA_DEBUG=y
CONFIG_BCMA_DRIVER_GMAC_CMN=y CONFIG_BCMA_DRIVER_GMAC_CMN=y
CONFIG_BCMA_DRIVER_GPIO=y
CONFIG_BCMA_DRIVER_MIPS=y CONFIG_BCMA_DRIVER_MIPS=y
CONFIG_BCMA_DRIVER_PCI_HOSTMODE=y CONFIG_BCMA_DRIVER_PCI_HOSTMODE=y
CONFIG_BCMA_HOST_PCI=y CONFIG_BCMA_HOST_PCI=y

View File

@ -1,168 +1,140 @@
--- a/drivers/bcma/Kconfig --- a/drivers/bcma/driver_chipcommon.c
+++ b/drivers/bcma/Kconfig +++ b/drivers/bcma/driver_chipcommon.c
@@ -39,6 +39,11 @@ config BCMA_HOST_SOC @@ -57,6 +57,8 @@ void bcma_core_chipcommon_init(struct bc
depends on BCMA_DRIVER_MIPS (leddc_off << BCMA_CC_GPIOTIMER_OFFTIME_SHIFT)));
select USB_HCD_BCMA if USB_EHCI_HCD || USB_OHCI_HCD }
+config BCMA_DRIVER_GPIO + spin_lock_init(&cc->gpio_lock);
+ bool
+ depends on BCMA_DRIVER_MIPS
+ default y
+ +
config BCMA_SFLASH cc->setup_done = true;
bool }
depends on BCMA_DRIVER_MIPS
--- a/drivers/bcma/Makefile
+++ b/drivers/bcma/Makefile
@@ -6,6 +6,7 @@ bcma-y += driver_pci.o
bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o
bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o
bcma-$(CONFIG_BCMA_DRIVER_GMAC_CMN) += driver_gmac_cmn.o
+bcma-$(CONFIG_BCMA_DRIVER_GPIO) += driver_gpio.o
bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o
bcma-$(CONFIG_BCMA_HOST_SOC) += host_soc.o
obj-$(CONFIG_BCMA) += bcma.o
--- /dev/null
+++ b/drivers/bcma/driver_gpio.c
@@ -0,0 +1,90 @@
+/*
+ * Broadcom specific AMBA
+ * GPIO driver for SoCs
+ *
+ * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
+ *
+ * Licensed under the GNU/GPL. See COPYING for details.
+ */
+
+#include <linux/export.h>
+#include <linux/bcma/bcma.h>
+#include <linux/bcma/bcma_driver_gpio.h>
+
+u32 bcma_gpio_in(struct bcma_bus *bus, u32 mask)
+{
+ unsigned long flags;
+ u32 res = 0;
+
+ spin_lock_irqsave(&bus->gpio_lock, flags);
+ res = bcma_chipco_gpio_in(&bus->drv_cc, mask);
+ spin_unlock_irqrestore(&bus->gpio_lock, flags);
+
+ return res;
+}
+EXPORT_SYMBOL(bcma_gpio_in);
+
+u32 bcma_gpio_out(struct bcma_bus *bus, u32 mask, u32 value)
+{
+ unsigned long flags;
+ u32 res = 0;
+
+ spin_lock_irqsave(&bus->gpio_lock, flags);
+ res = bcma_chipco_gpio_out(&bus->drv_cc, mask, value);
+ spin_unlock_irqrestore(&bus->gpio_lock, flags);
+
+ return res;
+}
+EXPORT_SYMBOL(bcma_gpio_out);
+
+u32 bcma_gpio_outen(struct bcma_bus *bus, u32 mask, u32 value)
+{
+ unsigned long flags;
+ u32 res = 0;
+
+ spin_lock_irqsave(&bus->gpio_lock, flags);
+ res = bcma_chipco_gpio_outen(&bus->drv_cc, mask, value);
+ spin_unlock_irqrestore(&bus->gpio_lock, flags);
+
+ return res;
+}
+EXPORT_SYMBOL(bcma_gpio_outen);
+
+u32 bcma_gpio_control(struct bcma_bus *bus, u32 mask, u32 value)
+{
+ unsigned long flags;
+ u32 res = 0;
+
+ spin_lock_irqsave(&bus->gpio_lock, flags);
+ res = bcma_chipco_gpio_control(&bus->drv_cc, mask, value);
+ spin_unlock_irqrestore(&bus->gpio_lock, flags);
+
+ return res;
+}
+EXPORT_SYMBOL(bcma_gpio_control);
+
+u32 bcma_gpio_intmask(struct bcma_bus *bus, u32 mask, u32 value)
+{
+ unsigned long flags;
+ u32 res = 0;
+
+ spin_lock_irqsave(&bus->gpio_lock, flags);
+ res = bcma_chipco_gpio_intmask(&bus->drv_cc, mask, value);
+ spin_unlock_irqrestore(&bus->gpio_lock, flags);
+
+ return res;
+}
+EXPORT_SYMBOL(bcma_gpio_intmask);
+
+u32 bcma_gpio_polarity(struct bcma_bus *bus, u32 mask, u32 value)
+{
+ unsigned long flags;
+ u32 res = 0;
+
+ spin_lock_irqsave(&bus->gpio_lock, flags);
+ res = bcma_chipco_gpio_polarity(&bus->drv_cc, mask, value);
+ spin_unlock_irqrestore(&bus->gpio_lock, flags);
+
+ return res;
+}
+EXPORT_SYMBOL(bcma_gpio_polarity);
--- a/drivers/bcma/scan.c
+++ b/drivers/bcma/scan.c
@@ -422,6 +422,10 @@ void bcma_init_bus(struct bcma_bus *bus)
if (bus->init_done)
return;
+#ifdef CONFIG_BCMA_DRIVER_GPIO @@ -79,34 +81,81 @@ u32 bcma_chipco_irq_status(struct bcma_d
+ spin_lock_init(&bus->gpio_lock);
+#endif u32 bcma_chipco_gpio_in(struct bcma_drv_cc *cc, u32 mask)
{
- return bcma_cc_read32(cc, BCMA_CC_GPIOIN) & mask;
+ unsigned long flags;
+ u32 res;
+ +
INIT_LIST_HEAD(&bus->cores); + spin_lock_irqsave(&cc->gpio_lock, flags);
bus->nr_cores = 0; + res = bcma_cc_read32(cc, BCMA_CC_GPIOIN) & mask;
+ spin_unlock_irqrestore(&cc->gpio_lock, flags);
+
+ return res;
}
+EXPORT_SYMBOL_GPL(bcma_chipco_gpio_in);
--- a/include/linux/bcma/bcma.h u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value)
+++ b/include/linux/bcma/bcma.h {
@@ -255,6 +255,11 @@ struct bcma_bus { - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
struct bcma_drv_mips drv_mips; + unsigned long flags;
struct bcma_drv_gmac_cmn drv_gmac_cmn; + u32 res;
+
+ spin_lock_irqsave(&cc->gpio_lock, flags);
+ res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
+ spin_unlock_irqrestore(&cc->gpio_lock, flags);
+
+ return res;
}
+EXPORT_SYMBOL_GPL(bcma_chipco_gpio_out);
+#ifdef CONFIG_BCMA_DRIVER_GPIO u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value)
{
- return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
+ unsigned long flags;
+ u32 res;
+
+ spin_lock_irqsave(&cc->gpio_lock, flags);
+ res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
+ spin_unlock_irqrestore(&cc->gpio_lock, flags);
+
+ return res;
}
+EXPORT_SYMBOL_GPL(bcma_chipco_gpio_outen);
u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value)
{
- return bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
+ unsigned long flags;
+ u32 res;
+
+ spin_lock_irqsave(&cc->gpio_lock, flags);
+ res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
+ spin_unlock_irqrestore(&cc->gpio_lock, flags);
+
+ return res;
}
EXPORT_SYMBOL_GPL(bcma_chipco_gpio_control);
u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value)
{
- return bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
+ unsigned long flags;
+ u32 res;
+
+ spin_lock_irqsave(&cc->gpio_lock, flags);
+ res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
+ spin_unlock_irqrestore(&cc->gpio_lock, flags);
+
+ return res;
}
+EXPORT_SYMBOL_GPL(bcma_chipco_gpio_intmask);
u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value)
{
- return bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
+ unsigned long flags;
+ u32 res;
+
+ spin_lock_irqsave(&cc->gpio_lock, flags);
+ res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
+ spin_unlock_irqrestore(&cc->gpio_lock, flags);
+
+ return res;
}
+EXPORT_SYMBOL_GPL(bcma_chipco_gpio_polarity);
#ifdef CONFIG_BCMA_DRIVER_MIPS
void bcma_chipco_serial_init(struct bcma_drv_cc *cc)
--- a/include/linux/bcma/bcma_driver_chipcommon.h
+++ b/include/linux/bcma/bcma_driver_chipcommon.h
@@ -494,6 +494,9 @@ struct bcma_drv_cc {
int nr_serial_ports;
struct bcma_serial_port serial_ports[4];
#endif /* CONFIG_BCMA_DRIVER_MIPS */
+
+ /* Lock for GPIO register access. */ + /* Lock for GPIO register access. */
+ spinlock_t gpio_lock; + spinlock_t gpio_lock;
+#endif /* CONFIG_BCMA_DRIVER_GPIO */ };
/* Register access */
@@ -523,13 +526,22 @@ void bcma_chipco_irq_mask(struct bcma_dr
u32 bcma_chipco_irq_status(struct bcma_drv_cc *cc, u32 mask);
+#define BCMA_CC_GPIO_LINES 16
+ +
/* We decided to share SPROM struct with SSB as long as we do not need /* Chipcommon GPIO pin access. */
* any hacks for BCMA. This simplifies drivers code. */ -u32 bcma_chipco_gpio_in(struct bcma_drv_cc *cc, u32 mask);
struct ssb_sprom sprom; -u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value);
--- /dev/null -u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value);
+++ b/include/linux/bcma/bcma_driver_gpio.h -u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value);
@@ -0,0 +1,21 @@ -u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value);
+#ifndef LINUX_BCMA_DRIVER_GPIO_H_ -u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value);
+#define LINUX_BCMA_DRIVER_GPIO_H_ +extern u32 bcma_chipco_gpio_in(struct bcma_drv_cc *cc, u32 mask);
+ +extern u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value);
+#include <linux/types.h> +extern u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value);
+#include <linux/bcma/bcma.h> +extern u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask,
+ + u32 value);
+#define BCMA_GPIO_CC_LINES 16 +extern u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask,
+ + u32 value);
+u32 bcma_gpio_in(struct bcma_bus *bus, u32 mask); +extern u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask,
+u32 bcma_gpio_out(struct bcma_bus *bus, u32 mask, u32 value); + u32 value);
+u32 bcma_gpio_outen(struct bcma_bus *bus, u32 mask, u32 value); +static inline int bcma_chipco_gpio_count(void)
+u32 bcma_gpio_control(struct bcma_bus *bus, u32 mask, u32 value);
+u32 bcma_gpio_intmask(struct bcma_bus *bus, u32 mask, u32 value);
+u32 bcma_gpio_polarity(struct bcma_bus *bus, u32 mask, u32 value);
+
+static inline int bcma_gpio_count(struct bcma_bus *bus)
+{ +{
+ return BCMA_GPIO_CC_LINES; + return BCMA_CC_GPIO_LINES;
+} +}
+
+#endif /* LINUX_BCMA_DRIVER_GPIO_H_ */ /* PMU support */
extern void bcma_pmu_init(struct bcma_drv_cc *cc);

View File

@ -8,8 +8,8 @@
select BOOT_RAW select BOOT_RAW
select CEVT_R4K select CEVT_R4K
select CSRC_R4K select CSRC_R4K
@@ -100,7 +101,6 @@ config BCM47XX @@ -101,7 +102,6 @@ config BCM47XX
select IRQ_CPU select NO_EXCEPT_FILL
select SYS_SUPPORTS_32BIT_KERNEL select SYS_SUPPORTS_32BIT_KERNEL
select SYS_SUPPORTS_LITTLE_ENDIAN select SYS_SUPPORTS_LITTLE_ENDIAN
- select GENERIC_GPIO - select GENERIC_GPIO
@ -18,7 +18,7 @@
Support for BCM47XX based boards Support for BCM47XX based boards
--- a/arch/mips/bcm47xx/gpio.c --- a/arch/mips/bcm47xx/gpio.c
+++ b/arch/mips/bcm47xx/gpio.c +++ b/arch/mips/bcm47xx/gpio.c
@@ -4,83 +4,150 @@ @@ -4,83 +4,154 @@
* for more details. * for more details.
* *
* Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net> * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
@ -36,7 +36,6 @@
-#include <asm/mach-bcm47xx/gpio.h> -#include <asm/mach-bcm47xx/gpio.h>
+#include <linux/ssb/ssb_embedded.h> +#include <linux/ssb/ssb_embedded.h>
+#include <linux/bcma/bcma.h> +#include <linux/bcma/bcma.h>
+#include <linux/bcma/bcma_driver_gpio.h>
+ +
+#include <bcm47xx.h> +#include <bcm47xx.h>
@ -76,7 +75,7 @@
- -
- if (test_and_set_bit(gpio, gpio_in_use)) - if (test_and_set_bit(gpio, gpio_in_use))
- return -EBUSY; - return -EBUSY;
+ return bcma_gpio_in(&bcm47xx_bus.bcma.bus, mask); + return bcma_chipco_gpio_in(&bcm47xx_bus.bcma.bus.drv_cc, mask);
+#endif +#endif
+ } + }
+ return -EINVAL; + return -EINVAL;
@ -93,7 +92,8 @@
+#endif +#endif
+#ifdef CONFIG_BCM47XX_BCMA +#ifdef CONFIG_BCM47XX_BCMA
+ case BCM47XX_BUS_TYPE_BCMA: + case BCM47XX_BUS_TYPE_BCMA:
+ return bcma_gpio_out(&bcm47xx_bus.bcma.bus, mask, value); + return bcma_chipco_gpio_out(&bcm47xx_bus.bcma.bus.drv_cc, mask,
+ value);
#endif #endif
} }
return -EINVAL; return -EINVAL;
@ -114,7 +114,8 @@
+#endif +#endif
+#ifdef CONFIG_BCM47XX_BCMA +#ifdef CONFIG_BCM47XX_BCMA
+ case BCM47XX_BUS_TYPE_BCMA: + case BCM47XX_BUS_TYPE_BCMA:
+ return bcma_gpio_outen(&bcm47xx_bus.bcma.bus, mask, value); + return bcma_chipco_gpio_outen(&bcm47xx_bus.bcma.bus.drv_cc,
+ mask, value);
+#endif +#endif
+ } + }
+ return -EINVAL; + return -EINVAL;
@ -133,7 +134,8 @@
+#endif +#endif
+#ifdef CONFIG_BCM47XX_BCMA +#ifdef CONFIG_BCM47XX_BCMA
+ case BCM47XX_BUS_TYPE_BCMA: + case BCM47XX_BUS_TYPE_BCMA:
+ return bcma_gpio_control(&bcm47xx_bus.bcma.bus, mask, value); + return bcma_chipco_gpio_control(&bcm47xx_bus.bcma.bus.drv_cc,
+ mask, value);
+#endif +#endif
+ } + }
+ return -EINVAL; + return -EINVAL;
@ -153,7 +155,8 @@
case BCM47XX_BUS_TYPE_BCMA: case BCM47XX_BUS_TYPE_BCMA:
- if (gpio >= BCM47XX_CHIPCO_GPIO_LINES) - if (gpio >= BCM47XX_CHIPCO_GPIO_LINES)
- return; - return;
+ return bcma_gpio_intmask(&bcm47xx_bus.bcma.bus, mask, value); + return bcma_chipco_gpio_intmask(&bcm47xx_bus.bcma.bus.drv_cc,
+ mask, value);
+#endif +#endif
+ } + }
+ return -EINVAL; + return -EINVAL;
@ -171,7 +174,8 @@
+#endif +#endif
+#ifdef CONFIG_BCM47XX_BCMA +#ifdef CONFIG_BCM47XX_BCMA
+ case BCM47XX_BUS_TYPE_BCMA: + case BCM47XX_BUS_TYPE_BCMA:
+ return bcma_gpio_polarity(&bcm47xx_bus.bcma.bus, mask, value); + return bcma_chipco_gpio_polarity(&bcm47xx_bus.bcma.bus.drv_cc,
+ mask, value);
#endif #endif
} }
+ return -EINVAL; + return -EINVAL;
@ -213,7 +217,7 @@
{ {
switch (bcm47xx_bus_type) { switch (bcm47xx_bus_type) {
#ifdef CONFIG_BCM47XX_SSB #ifdef CONFIG_BCM47XX_SSB
@@ -99,4 +166,55 @@ int gpio_to_irq(unsigned gpio) @@ -99,4 +170,55 @@ int gpio_to_irq(unsigned gpio)
} }
return -EINVAL; return -EINVAL;
} }
@ -241,7 +245,7 @@
+#endif +#endif
+#ifdef CONFIG_BCM47XX_BCMA +#ifdef CONFIG_BCM47XX_BCMA
+ case BCM47XX_BUS_TYPE_BCMA: + case BCM47XX_BUS_TYPE_BCMA:
+ bcm47xx_gpio_count = bcma_gpio_count(&bcm47xx_bus.bcma.bus); + bcm47xx_gpio_count = bcma_chipco_gpio_count();
+ break; + break;
+#endif +#endif
+ } + }