2012-08-04 22:46:25 +03:00
|
|
|
--- a/arch/mips/Kconfig
|
|
|
|
+++ b/arch/mips/Kconfig
|
|
|
|
@@ -92,6 +92,7 @@ config ATH79
|
|
|
|
|
|
|
|
config BCM47XX
|
|
|
|
bool "Broadcom BCM47XX based boards"
|
|
|
|
+ select ARCH_REQUIRE_GPIOLIB
|
|
|
|
select BOOT_RAW
|
|
|
|
select CEVT_R4K
|
|
|
|
select CSRC_R4K
|
2012-09-19 13:17:51 +03:00
|
|
|
@@ -101,7 +102,6 @@ config BCM47XX
|
|
|
|
select NO_EXCEPT_FILL
|
2012-08-04 22:46:25 +03:00
|
|
|
select SYS_SUPPORTS_32BIT_KERNEL
|
|
|
|
select SYS_SUPPORTS_LITTLE_ENDIAN
|
|
|
|
- select GENERIC_GPIO
|
|
|
|
select CFE
|
|
|
|
help
|
|
|
|
Support for BCM47XX based boards
|
|
|
|
--- a/arch/mips/bcm47xx/gpio.c
|
|
|
|
+++ b/arch/mips/bcm47xx/gpio.c
|
2012-09-19 13:17:51 +03:00
|
|
|
@@ -4,83 +4,154 @@
|
2012-08-04 22:46:25 +03:00
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
|
|
|
|
+ * Copyright (C) 2012 Hauke Mehrtens <hauke@hauke-m.de>
|
|
|
|
+ *
|
|
|
|
+ * Parts of this file are based on Atheros AR71XX/AR724X/AR913X GPIO
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/export.h>
|
|
|
|
+#include <linux/gpio.h>
|
|
|
|
#include <linux/ssb/ssb.h>
|
|
|
|
-#include <linux/ssb/ssb_driver_chipcommon.h>
|
|
|
|
-#include <linux/ssb/ssb_driver_extif.h>
|
|
|
|
-#include <asm/mach-bcm47xx/bcm47xx.h>
|
|
|
|
-#include <asm/mach-bcm47xx/gpio.h>
|
|
|
|
+#include <linux/ssb/ssb_embedded.h>
|
|
|
|
+#include <linux/bcma/bcma.h>
|
|
|
|
+
|
|
|
|
+#include <bcm47xx.h>
|
|
|
|
|
|
|
|
-#if (BCM47XX_CHIPCO_GPIO_LINES > BCM47XX_EXTIF_GPIO_LINES)
|
|
|
|
-static DECLARE_BITMAP(gpio_in_use, BCM47XX_CHIPCO_GPIO_LINES);
|
|
|
|
-#else
|
|
|
|
-static DECLARE_BITMAP(gpio_in_use, BCM47XX_EXTIF_GPIO_LINES);
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
-int gpio_request(unsigned gpio, const char *tag)
|
|
|
|
+static unsigned long bcm47xx_gpio_count;
|
|
|
|
+
|
|
|
|
+/* low level BCM47xx gpio api */
|
|
|
|
+u32 bcm47xx_gpio_in(u32 mask)
|
|
|
|
{
|
|
|
|
switch (bcm47xx_bus_type) {
|
|
|
|
#ifdef CONFIG_BCM47XX_SSB
|
|
|
|
case BCM47XX_BUS_TYPE_SSB:
|
|
|
|
- if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco) &&
|
|
|
|
- ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES))
|
|
|
|
- return -EINVAL;
|
|
|
|
-
|
|
|
|
- if (ssb_extif_available(&bcm47xx_bus.ssb.extif) &&
|
|
|
|
- ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES))
|
|
|
|
- return -EINVAL;
|
2012-08-18 14:51:35 +03:00
|
|
|
-
|
|
|
|
- if (test_and_set_bit(gpio, gpio_in_use))
|
|
|
|
- return -EBUSY;
|
|
|
|
-
|
|
|
|
- return 0;
|
2012-08-04 22:46:25 +03:00
|
|
|
+ return ssb_gpio_in(&bcm47xx_bus.ssb, mask);
|
2012-08-18 14:51:35 +03:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_BCM47XX_BCMA
|
|
|
|
case BCM47XX_BUS_TYPE_BCMA:
|
|
|
|
- if (gpio >= BCM47XX_CHIPCO_GPIO_LINES)
|
|
|
|
- return -EINVAL;
|
|
|
|
-
|
|
|
|
- if (test_and_set_bit(gpio, gpio_in_use))
|
|
|
|
- return -EBUSY;
|
2012-09-19 13:17:51 +03:00
|
|
|
+ return bcma_chipco_gpio_in(&bcm47xx_bus.bcma.bus.drv_cc, mask);
|
2012-08-04 22:46:25 +03:00
|
|
|
+#endif
|
|
|
|
+ }
|
|
|
|
+ return -EINVAL;
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(bcm47xx_gpio_in);
|
|
|
|
|
2012-08-18 14:51:35 +03:00
|
|
|
- return 0;
|
2012-08-04 22:46:25 +03:00
|
|
|
+u32 bcm47xx_gpio_out(u32 mask, u32 value)
|
|
|
|
+{
|
|
|
|
+ switch (bcm47xx_bus_type) {
|
|
|
|
+#ifdef CONFIG_BCM47XX_SSB
|
|
|
|
+ case BCM47XX_BUS_TYPE_SSB:
|
|
|
|
+ return ssb_gpio_out(&bcm47xx_bus.ssb, mask, value);
|
|
|
|
+#endif
|
|
|
|
+#ifdef CONFIG_BCM47XX_BCMA
|
|
|
|
+ case BCM47XX_BUS_TYPE_BCMA:
|
2012-09-19 13:17:51 +03:00
|
|
|
+ return bcma_chipco_gpio_out(&bcm47xx_bus.bcma.bus.drv_cc, mask,
|
|
|
|
+ value);
|
2012-08-18 14:51:35 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
-EXPORT_SYMBOL(gpio_request);
|
2012-08-04 22:46:25 +03:00
|
|
|
+EXPORT_SYMBOL(bcm47xx_gpio_out);
|
|
|
|
|
2012-08-18 14:51:35 +03:00
|
|
|
-void gpio_free(unsigned gpio)
|
2012-08-04 22:46:25 +03:00
|
|
|
+u32 bcm47xx_gpio_outen(u32 mask, u32 value)
|
2012-08-18 14:51:35 +03:00
|
|
|
{
|
|
|
|
switch (bcm47xx_bus_type) {
|
|
|
|
#ifdef CONFIG_BCM47XX_SSB
|
|
|
|
case BCM47XX_BUS_TYPE_SSB:
|
|
|
|
- if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco) &&
|
|
|
|
- ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES))
|
|
|
|
- return;
|
2012-08-04 22:46:25 +03:00
|
|
|
+ return ssb_gpio_outen(&bcm47xx_bus.ssb, mask, value);
|
2012-08-18 14:51:35 +03:00
|
|
|
+#endif
|
|
|
|
+#ifdef CONFIG_BCM47XX_BCMA
|
|
|
|
+ case BCM47XX_BUS_TYPE_BCMA:
|
2012-09-19 13:17:51 +03:00
|
|
|
+ return bcma_chipco_gpio_outen(&bcm47xx_bus.bcma.bus.drv_cc,
|
|
|
|
+ mask, value);
|
2012-08-04 22:46:25 +03:00
|
|
|
+#endif
|
|
|
|
+ }
|
|
|
|
+ return -EINVAL;
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(bcm47xx_gpio_outen);
|
|
|
|
|
2012-08-18 14:51:35 +03:00
|
|
|
- if (ssb_extif_available(&bcm47xx_bus.ssb.extif) &&
|
|
|
|
- ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES))
|
|
|
|
- return;
|
2012-08-04 22:46:25 +03:00
|
|
|
+u32 bcm47xx_gpio_control(u32 mask, u32 value)
|
|
|
|
+{
|
|
|
|
+ switch (bcm47xx_bus_type) {
|
|
|
|
+#ifdef CONFIG_BCM47XX_SSB
|
|
|
|
+ case BCM47XX_BUS_TYPE_SSB:
|
|
|
|
+ return ssb_gpio_control(&bcm47xx_bus.ssb, mask, value);
|
|
|
|
+#endif
|
|
|
|
+#ifdef CONFIG_BCM47XX_BCMA
|
|
|
|
+ case BCM47XX_BUS_TYPE_BCMA:
|
2012-09-19 13:17:51 +03:00
|
|
|
+ return bcma_chipco_gpio_control(&bcm47xx_bus.bcma.bus.drv_cc,
|
|
|
|
+ mask, value);
|
2012-08-04 22:46:25 +03:00
|
|
|
+#endif
|
|
|
|
+ }
|
|
|
|
+ return -EINVAL;
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(bcm47xx_gpio_control);
|
|
|
|
|
2012-08-18 14:51:35 +03:00
|
|
|
- clear_bit(gpio, gpio_in_use);
|
|
|
|
- return;
|
2012-08-04 22:46:25 +03:00
|
|
|
+u32 bcm47xx_gpio_intmask(u32 mask, u32 value)
|
|
|
|
+{
|
|
|
|
+ switch (bcm47xx_bus_type) {
|
|
|
|
+#ifdef CONFIG_BCM47XX_SSB
|
|
|
|
+ case BCM47XX_BUS_TYPE_SSB:
|
|
|
|
+ return ssb_gpio_intmask(&bcm47xx_bus.ssb, mask, value);
|
|
|
|
#endif
|
2012-08-18 14:51:35 +03:00
|
|
|
#ifdef CONFIG_BCM47XX_BCMA
|
|
|
|
case BCM47XX_BUS_TYPE_BCMA:
|
|
|
|
- if (gpio >= BCM47XX_CHIPCO_GPIO_LINES)
|
|
|
|
- return;
|
2012-09-19 13:17:51 +03:00
|
|
|
+ return bcma_chipco_gpio_intmask(&bcm47xx_bus.bcma.bus.drv_cc,
|
|
|
|
+ mask, value);
|
2012-08-18 14:51:35 +03:00
|
|
|
+#endif
|
|
|
|
+ }
|
|
|
|
+ return -EINVAL;
|
|
|
|
+}
|
2012-08-04 22:46:25 +03:00
|
|
|
+EXPORT_SYMBOL(bcm47xx_gpio_intmask);
|
|
|
|
|
2012-08-18 14:51:35 +03:00
|
|
|
- clear_bit(gpio, gpio_in_use);
|
|
|
|
- return;
|
2012-08-04 22:46:25 +03:00
|
|
|
+u32 bcm47xx_gpio_polarity(u32 mask, u32 value)
|
2012-08-18 14:51:35 +03:00
|
|
|
+{
|
|
|
|
+ switch (bcm47xx_bus_type) {
|
|
|
|
+#ifdef CONFIG_BCM47XX_SSB
|
|
|
|
+ case BCM47XX_BUS_TYPE_SSB:
|
2012-08-04 22:46:25 +03:00
|
|
|
+ return ssb_gpio_polarity(&bcm47xx_bus.ssb, mask, value);
|
|
|
|
+#endif
|
|
|
|
+#ifdef CONFIG_BCM47XX_BCMA
|
|
|
|
+ case BCM47XX_BUS_TYPE_BCMA:
|
2012-09-19 13:17:51 +03:00
|
|
|
+ return bcma_chipco_gpio_polarity(&bcm47xx_bus.bcma.bus.drv_cc,
|
|
|
|
+ mask, value);
|
2012-08-18 14:51:35 +03:00
|
|
|
#endif
|
|
|
|
}
|
2012-08-04 22:46:25 +03:00
|
|
|
+ return -EINVAL;
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(bcm47xx_gpio_polarity);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+static int bcm47xx_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
|
|
|
|
+{
|
|
|
|
+ return bcm47xx_gpio_in(1 << gpio);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void bcm47xx_gpio_set_value(struct gpio_chip *chip,
|
|
|
|
+ unsigned gpio, int value)
|
|
|
|
+{
|
|
|
|
+ bcm47xx_gpio_out(1 << gpio, value ? 1 << gpio : 0);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int bcm47xx_gpio_direction_input(struct gpio_chip *chip,
|
|
|
|
+ unsigned gpio)
|
|
|
|
+{
|
|
|
|
+ bcm47xx_gpio_outen(1 << gpio, 0);
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int bcm47xx_gpio_direction_output(struct gpio_chip *chip,
|
|
|
|
+ unsigned gpio, int value)
|
|
|
|
+{
|
|
|
|
+ /* first set the gpio out value */
|
|
|
|
+ bcm47xx_gpio_out(1 << gpio, value ? 1 << gpio : 0);
|
|
|
|
+ /* then set the gpio mode */
|
|
|
|
+ bcm47xx_gpio_outen(1 << gpio, 1 << gpio);
|
|
|
|
+ return 0;
|
2012-08-18 14:51:35 +03:00
|
|
|
}
|
|
|
|
-EXPORT_SYMBOL(gpio_free);
|
|
|
|
|
|
|
|
-int gpio_to_irq(unsigned gpio)
|
|
|
|
+static int bcm47xx_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
|
|
|
|
{
|
|
|
|
switch (bcm47xx_bus_type) {
|
|
|
|
#ifdef CONFIG_BCM47XX_SSB
|
2012-09-19 13:17:51 +03:00
|
|
|
@@ -99,4 +170,55 @@ int gpio_to_irq(unsigned gpio)
|
2012-08-18 14:51:35 +03:00
|
|
|
}
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
-EXPORT_SYMBOL_GPL(gpio_to_irq);
|
2012-08-04 22:46:25 +03:00
|
|
|
+
|
|
|
|
+static struct gpio_chip bcm47xx_gpio_chip = {
|
|
|
|
+ .label = "bcm47xx",
|
|
|
|
+ .get = bcm47xx_gpio_get_value,
|
|
|
|
+ .set = bcm47xx_gpio_set_value,
|
|
|
|
+ .direction_input = bcm47xx_gpio_direction_input,
|
|
|
|
+ .direction_output = bcm47xx_gpio_direction_output,
|
2012-08-18 14:51:35 +03:00
|
|
|
+ .to_irq = bcm47xx_gpio_to_irq,
|
2012-08-04 22:46:25 +03:00
|
|
|
+ .base = 0,
|
|
|
|
+};
|
2012-08-18 14:51:35 +03:00
|
|
|
+
|
2012-08-04 22:46:25 +03:00
|
|
|
+void __init bcm47xx_gpio_init(void)
|
|
|
|
+{
|
|
|
|
+ int err;
|
2012-08-18 14:51:35 +03:00
|
|
|
+
|
2012-08-04 22:46:25 +03:00
|
|
|
+ switch (bcm47xx_bus_type) {
|
|
|
|
+#ifdef CONFIG_BCM47XX_SSB
|
|
|
|
+ case BCM47XX_BUS_TYPE_SSB:
|
|
|
|
+ bcm47xx_gpio_count = ssb_gpio_count(&bcm47xx_bus.ssb);
|
2012-08-18 14:51:35 +03:00
|
|
|
+ break;
|
|
|
|
+#endif
|
|
|
|
+#ifdef CONFIG_BCM47XX_BCMA
|
|
|
|
+ case BCM47XX_BUS_TYPE_BCMA:
|
2012-09-19 13:17:51 +03:00
|
|
|
+ bcm47xx_gpio_count = bcma_chipco_gpio_count();
|
2012-08-18 14:51:35 +03:00
|
|
|
+ break;
|
|
|
|
+#endif
|
|
|
|
+ }
|
2012-08-04 22:46:25 +03:00
|
|
|
+
|
|
|
|
+ bcm47xx_gpio_chip.ngpio = bcm47xx_gpio_count;
|
|
|
|
+
|
|
|
|
+ err = gpiochip_add(&bcm47xx_gpio_chip);
|
|
|
|
+ if (err)
|
|
|
|
+ panic("cannot add BCM47xx GPIO chip, error=%d", err);
|
2012-08-18 14:51:35 +03:00
|
|
|
+}
|
2012-08-04 22:46:25 +03:00
|
|
|
+
|
|
|
|
+int gpio_get_value(unsigned gpio)
|
|
|
|
+{
|
|
|
|
+ if (gpio < bcm47xx_gpio_count)
|
|
|
|
+ return bcm47xx_gpio_in(1 << gpio);
|
|
|
|
+
|
|
|
|
+ return __gpio_get_value(gpio);
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(gpio_get_value);
|
|
|
|
+
|
|
|
|
+void gpio_set_value(unsigned gpio, int value)
|
|
|
|
+{
|
|
|
|
+ if (gpio < bcm47xx_gpio_count)
|
|
|
|
+ bcm47xx_gpio_out(1 << gpio, value ? 1 << gpio : 0);
|
|
|
|
+ else
|
|
|
|
+ __gpio_set_value(gpio, value);
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(gpio_set_value);
|
|
|
|
--- a/arch/mips/bcm47xx/setup.c
|
|
|
|
+++ b/arch/mips/bcm47xx/setup.c
|
2012-08-18 17:08:35 +03:00
|
|
|
@@ -345,6 +345,8 @@ void __init plat_mem_setup(void)
|
2012-08-04 22:46:25 +03:00
|
|
|
_machine_restart = bcm47xx_machine_restart;
|
|
|
|
_machine_halt = bcm47xx_machine_halt;
|
|
|
|
pm_power_off = bcm47xx_machine_halt;
|
|
|
|
+
|
|
|
|
+ bcm47xx_gpio_init();
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init bcm47xx_register_bus_complete(void)
|
|
|
|
--- a/arch/mips/bcm47xx/wgt634u.c
|
|
|
|
+++ b/arch/mips/bcm47xx/wgt634u.c
|
|
|
|
@@ -133,6 +133,7 @@ static int __init wgt634u_init(void)
|
|
|
|
* been allocated ranges 00:09:5b:xx:xx:xx and 00:0f:b5:xx:xx:xx.
|
|
|
|
*/
|
|
|
|
u8 *et0mac;
|
|
|
|
+ int err;
|
|
|
|
|
|
|
|
if (bcm47xx_bus_type != BCM47XX_BUS_TYPE_SSB)
|
|
|
|
return -ENODEV;
|
|
|
|
@@ -146,6 +147,12 @@ static int __init wgt634u_init(void)
|
|
|
|
|
|
|
|
printk(KERN_INFO "WGT634U machine detected.\n");
|
|
|
|
|
|
|
|
+ err = gpio_request(WGT634U_GPIO_RESET, "reset-buton");
|
|
|
|
+ if (err) {
|
2012-08-18 14:51:35 +03:00
|
|
|
+ printk(KERN_INFO "Can not register gpio for reset button\n");
|
2012-08-04 22:46:25 +03:00
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (!request_irq(gpio_to_irq(WGT634U_GPIO_RESET),
|
|
|
|
gpio_interrupt, IRQF_SHARED,
|
2012-08-05 15:40:05 +03:00
|
|
|
"WGT634U GPIO", ccore)) {
|
2012-08-04 22:46:25 +03:00
|
|
|
--- a/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
|
|
|
|
+++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
|
|
|
|
@@ -56,4 +56,6 @@ void bcm47xx_fill_bcma_boardinfo(struct
|
|
|
|
const char *prefix);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+void bcm47xx_gpio_init(void);
|
|
|
|
+
|
|
|
|
#endif /* __ASM_BCM47XX_H */
|
|
|
|
--- a/arch/mips/include/asm/mach-bcm47xx/gpio.h
|
|
|
|
+++ b/arch/mips/include/asm/mach-bcm47xx/gpio.h
|
2012-08-18 14:51:35 +03:00
|
|
|
@@ -4,152 +4,42 @@
|
2012-08-04 22:46:25 +03:00
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
|
|
|
|
+ * Copyright (C) 2012 Hauke Mehrtens <hauke@hauke-m.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __BCM47XX_GPIO_H
|
|
|
|
#define __BCM47XX_GPIO_H
|
|
|
|
|
|
|
|
-#include <linux/ssb/ssb_embedded.h>
|
|
|
|
-#include <linux/bcma/bcma.h>
|
|
|
|
-#include <asm/mach-bcm47xx/bcm47xx.h>
|
|
|
|
-
|
|
|
|
-#define BCM47XX_EXTIF_GPIO_LINES 5
|
|
|
|
-#define BCM47XX_CHIPCO_GPIO_LINES 16
|
|
|
|
-
|
|
|
|
-extern int gpio_request(unsigned gpio, const char *label);
|
|
|
|
-extern void gpio_free(unsigned gpio);
|
|
|
|
-extern int gpio_to_irq(unsigned gpio);
|
2012-08-18 14:51:35 +03:00
|
|
|
-
|
2012-08-04 22:46:25 +03:00
|
|
|
-static inline int gpio_get_value(unsigned gpio)
|
|
|
|
-{
|
|
|
|
- switch (bcm47xx_bus_type) {
|
|
|
|
-#ifdef CONFIG_BCM47XX_SSB
|
|
|
|
- case BCM47XX_BUS_TYPE_SSB:
|
|
|
|
- return ssb_gpio_in(&bcm47xx_bus.ssb, 1 << gpio);
|
|
|
|
-#endif
|
|
|
|
-#ifdef CONFIG_BCM47XX_BCMA
|
|
|
|
- case BCM47XX_BUS_TYPE_BCMA:
|
|
|
|
- return bcma_chipco_gpio_in(&bcm47xx_bus.bcma.bus.drv_cc,
|
|
|
|
- 1 << gpio);
|
|
|
|
-#endif
|
|
|
|
- }
|
|
|
|
- return -EINVAL;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-#define gpio_get_value_cansleep gpio_get_value
|
|
|
|
-
|
|
|
|
-static inline void gpio_set_value(unsigned gpio, int value)
|
|
|
|
-{
|
|
|
|
- switch (bcm47xx_bus_type) {
|
|
|
|
-#ifdef CONFIG_BCM47XX_SSB
|
|
|
|
- case BCM47XX_BUS_TYPE_SSB:
|
|
|
|
- ssb_gpio_out(&bcm47xx_bus.ssb, 1 << gpio,
|
|
|
|
- value ? 1 << gpio : 0);
|
|
|
|
- return;
|
|
|
|
-#endif
|
|
|
|
-#ifdef CONFIG_BCM47XX_BCMA
|
|
|
|
- case BCM47XX_BUS_TYPE_BCMA:
|
|
|
|
- bcma_chipco_gpio_out(&bcm47xx_bus.bcma.bus.drv_cc, 1 << gpio,
|
|
|
|
- value ? 1 << gpio : 0);
|
|
|
|
- return;
|
|
|
|
-#endif
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-#define gpio_set_value_cansleep gpio_set_value
|
|
|
|
-
|
|
|
|
-static inline int gpio_cansleep(unsigned gpio)
|
|
|
|
-{
|
|
|
|
- return 0;
|
|
|
|
-}
|
2012-08-18 14:51:35 +03:00
|
|
|
-
|
|
|
|
-static inline int gpio_is_valid(unsigned gpio)
|
|
|
|
-{
|
|
|
|
- return gpio < (BCM47XX_EXTIF_GPIO_LINES + BCM47XX_CHIPCO_GPIO_LINES);
|
|
|
|
-}
|
|
|
|
+#define ARCH_NR_GPIOS 64
|
|
|
|
+#include <asm-generic/gpio.h>
|
|
|
|
|
2012-08-04 22:46:25 +03:00
|
|
|
+/* low level BCM47xx gpio api */
|
|
|
|
+u32 bcm47xx_gpio_in(u32 mask);
|
|
|
|
+u32 bcm47xx_gpio_out(u32 mask, u32 value);
|
|
|
|
+u32 bcm47xx_gpio_outen(u32 mask, u32 value);
|
|
|
|
+u32 bcm47xx_gpio_control(u32 mask, u32 value);
|
|
|
|
+u32 bcm47xx_gpio_intmask(u32 mask, u32 value);
|
|
|
|
+u32 bcm47xx_gpio_polarity(u32 mask, u32 value);
|
|
|
|
|
|
|
|
-static inline int gpio_direction_input(unsigned gpio)
|
2012-08-18 14:51:35 +03:00
|
|
|
-{
|
2012-08-04 22:46:25 +03:00
|
|
|
- switch (bcm47xx_bus_type) {
|
|
|
|
-#ifdef CONFIG_BCM47XX_SSB
|
|
|
|
- case BCM47XX_BUS_TYPE_SSB:
|
|
|
|
- ssb_gpio_outen(&bcm47xx_bus.ssb, 1 << gpio, 0);
|
|
|
|
- return 0;
|
|
|
|
-#endif
|
|
|
|
-#ifdef CONFIG_BCM47XX_BCMA
|
|
|
|
- case BCM47XX_BUS_TYPE_BCMA:
|
|
|
|
- bcma_chipco_gpio_outen(&bcm47xx_bus.bcma.bus.drv_cc, 1 << gpio,
|
|
|
|
- 0);
|
|
|
|
- return 0;
|
|
|
|
-#endif
|
|
|
|
- }
|
|
|
|
- return -EINVAL;
|
2012-08-18 14:51:35 +03:00
|
|
|
-}
|
|
|
|
+int gpio_get_value(unsigned gpio);
|
|
|
|
+void gpio_set_value(unsigned gpio, int value);
|
2012-08-04 22:46:25 +03:00
|
|
|
|
|
|
|
-static inline int gpio_direction_output(unsigned gpio, int value)
|
2012-08-18 14:51:35 +03:00
|
|
|
+static inline void gpio_intmask(unsigned gpio, int value)
|
2012-08-04 22:46:25 +03:00
|
|
|
{
|
|
|
|
- switch (bcm47xx_bus_type) {
|
|
|
|
-#ifdef CONFIG_BCM47XX_SSB
|
|
|
|
- case BCM47XX_BUS_TYPE_SSB:
|
|
|
|
- /* first set the gpio out value */
|
|
|
|
- ssb_gpio_out(&bcm47xx_bus.ssb, 1 << gpio,
|
|
|
|
- value ? 1 << gpio : 0);
|
|
|
|
- /* then set the gpio mode */
|
|
|
|
- ssb_gpio_outen(&bcm47xx_bus.ssb, 1 << gpio, 1 << gpio);
|
|
|
|
- return 0;
|
|
|
|
-#endif
|
|
|
|
-#ifdef CONFIG_BCM47XX_BCMA
|
|
|
|
- case BCM47XX_BUS_TYPE_BCMA:
|
|
|
|
- /* first set the gpio out value */
|
|
|
|
- bcma_chipco_gpio_out(&bcm47xx_bus.bcma.bus.drv_cc, 1 << gpio,
|
|
|
|
- value ? 1 << gpio : 0);
|
|
|
|
- /* then set the gpio mode */
|
|
|
|
- bcma_chipco_gpio_outen(&bcm47xx_bus.bcma.bus.drv_cc, 1 << gpio,
|
|
|
|
- 1 << gpio);
|
|
|
|
- return 0;
|
|
|
|
-#endif
|
|
|
|
- }
|
|
|
|
- return -EINVAL;
|
2012-08-18 14:51:35 +03:00
|
|
|
+ bcm47xx_gpio_intmask(1 << gpio, value ? 1 << gpio : 0);
|
2012-08-04 22:46:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
-static inline int gpio_intmask(unsigned gpio, int value)
|
2012-08-18 14:51:35 +03:00
|
|
|
+static inline void gpio_polarity(unsigned gpio, int value)
|
|
|
|
{
|
2012-08-04 22:46:25 +03:00
|
|
|
- switch (bcm47xx_bus_type) {
|
|
|
|
-#ifdef CONFIG_BCM47XX_SSB
|
|
|
|
- case BCM47XX_BUS_TYPE_SSB:
|
|
|
|
- ssb_gpio_intmask(&bcm47xx_bus.ssb, 1 << gpio,
|
|
|
|
- value ? 1 << gpio : 0);
|
|
|
|
- return 0;
|
|
|
|
-#endif
|
|
|
|
-#ifdef CONFIG_BCM47XX_BCMA
|
|
|
|
- case BCM47XX_BUS_TYPE_BCMA:
|
|
|
|
- bcma_chipco_gpio_intmask(&bcm47xx_bus.bcma.bus.drv_cc,
|
|
|
|
- 1 << gpio, value ? 1 << gpio : 0);
|
|
|
|
- return 0;
|
|
|
|
-#endif
|
|
|
|
- }
|
|
|
|
- return -EINVAL;
|
2012-08-18 14:51:35 +03:00
|
|
|
+ bcm47xx_gpio_polarity(1 << gpio, value ? 1 << gpio : 0);
|
|
|
|
}
|
|
|
|
|
2012-08-04 22:46:25 +03:00
|
|
|
-static inline int gpio_polarity(unsigned gpio, int value)
|
2012-08-18 14:51:35 +03:00
|
|
|
+static inline int irq_to_gpio(int gpio)
|
|
|
|
{
|
2012-08-04 22:46:25 +03:00
|
|
|
- switch (bcm47xx_bus_type) {
|
|
|
|
-#ifdef CONFIG_BCM47XX_SSB
|
|
|
|
- case BCM47XX_BUS_TYPE_SSB:
|
|
|
|
- ssb_gpio_polarity(&bcm47xx_bus.ssb, 1 << gpio,
|
|
|
|
- value ? 1 << gpio : 0);
|
|
|
|
- return 0;
|
|
|
|
-#endif
|
|
|
|
-#ifdef CONFIG_BCM47XX_BCMA
|
|
|
|
- case BCM47XX_BUS_TYPE_BCMA:
|
|
|
|
- bcma_chipco_gpio_polarity(&bcm47xx_bus.bcma.bus.drv_cc,
|
|
|
|
- 1 << gpio, value ? 1 << gpio : 0);
|
|
|
|
- return 0;
|
|
|
|
-#endif
|
|
|
|
- }
|
2012-08-18 14:51:35 +03:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2012-08-04 22:46:25 +03:00
|
|
|
|
|
|
|
+#define gpio_cansleep __gpio_cansleep
|
2012-08-18 14:51:35 +03:00
|
|
|
+#define gpio_to_irq __gpio_to_irq
|
2012-08-04 22:46:25 +03:00
|
|
|
|
|
|
|
#endif /* __BCM47XX_GPIO_H */
|