summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
Diffstat (limited to 'package')
-rw-r--r--package/broadcom-diag/src/diag.c108
-rw-r--r--package/broadcom-diag/src/gpio.h153
-rw-r--r--package/switch/src/gpio-bcm947xx.h55
-rw-r--r--package/switch/src/gpio.h14
-rw-r--r--package/switch/src/switch-adm.c34
5 files changed, 98 insertions, 266 deletions
diff --git a/package/broadcom-diag/src/diag.c b/package/broadcom-diag/src/diag.c
index 090fc5e3d5..cf6d789c29 100644
--- a/package/broadcom-diag/src/diag.c
+++ b/package/broadcom-diag/src/diag.c
@@ -156,9 +156,9 @@ static void __init bcm4780_init(void) {
/* Enables GPIO 3 that controls HDD and led power on ASUS WL-700gE */
printk(MODULE_NAME ": Spinning up HDD and enabling leds\n");
- gpio_outen(pin, pin);
- gpio_control(pin, 0);
- gpio_out(pin, pin);
+ bcm47xx_gpio_outen(pin, pin);
+ bcm47xx_gpio_control(pin, 0);
+ bcm47xx_gpio_out(pin, pin);
/* Wait 5s, so the HDD can spin up */
set_current_state(TASK_INTERRUPTIBLE);
@@ -168,14 +168,14 @@ static void __init bcm4780_init(void) {
static void __init NetCenter_init(void) {
/* unset pin 6 (+12V) */
int pin = 1 << 6;
- gpio_outen(pin, pin);
- gpio_control(pin, 0);
- gpio_out(pin, pin);
+ bcm47xx_gpio_outen(pin, pin);
+ bcm47xx_gpio_control(pin, 0);
+ bcm47xx_gpio_out(pin, pin);
/* unset pin 1 (turn off red led, blue will light alone if +5V comes up) */
pin = 1 << 1;
- gpio_outen(pin, pin);
- gpio_control(pin, 0);
- gpio_out(pin, pin);
+ bcm47xx_gpio_outen(pin, pin);
+ bcm47xx_gpio_control(pin, 0);
+ bcm47xx_gpio_out(pin, pin);
/* unset pin 3 (+5V) and wait 5 seconds (harddisk spin up) */
bcm4780_init();
}
@@ -184,9 +184,9 @@ static void __init bcm57xx_init(void) {
int pin = 1 << 2;
/* FIXME: switch comes up, but port mappings/vlans not right */
- gpio_outen(pin, pin);
- gpio_control(pin, 0);
- gpio_out(pin, pin);
+ bcm47xx_gpio_outen(pin, pin);
+ bcm47xx_gpio_control(pin, 0);
+ bcm47xx_gpio_out(pin, pin);
}
static struct platform_t __initdata platforms[] = {
@@ -1283,6 +1283,42 @@ static struct platform_t __init *platform_detect(void)
return NULL;
}
+static inline void ssb_maskset32(struct ssb_device *dev,
+ u16 offset, u32 mask, u32 set)
+{
+ ssb_write32(dev, offset, (ssb_read32(dev, offset) & mask) | set);
+}
+
+static void gpio_set_irqenable(int enabled, irqreturn_t (*handler)(int, void *))
+{
+ int irq;
+
+ irq = gpio_to_irq(0);
+ if (irq == -EINVAL) return;
+
+ if (enabled) {
+ if (request_irq(irq, handler, IRQF_SHARED | IRQF_SAMPLE_RANDOM, "gpio", handler))
+ return;
+ } else {
+ free_irq(irq, handler);
+ }
+
+ switch (bcm47xx_bus_type) {
+#ifdef CONFIG_BCM47XX_SSB
+ case BCM47XX_BUS_TYPE_SSB:
+ if (bcm47xx_bus.ssb.chipco.dev)
+ ssb_maskset32(bcm47xx_bus.ssb.chipco.dev, SSB_CHIPCO_IRQMASK, ~SSB_CHIPCO_IRQ_GPIO, (enabled ? SSB_CHIPCO_IRQ_GPIO : 0));
+ break;
+#endif
+#ifdef CONFIG_BCM47XX_BCMA
+ case BCM47XX_BUS_TYPE_BCMA:
+ if (bcm47xx_bus.bcma.bus.drv_cc.core)
+ bcma_maskset32(bcm47xx_bus.bcma.bus.drv_cc.core, BCMA_CC_IRQMASK, ~BCMA_CC_IRQ_GPIO, (enabled ? BCMA_CC_IRQ_GPIO : 0));
+ break;
+#endif
+ }
+}
+
static void register_buttons(struct button_t *b)
{
for (; b->name; b++)
@@ -1290,18 +1326,18 @@ static void register_buttons(struct button_t *b)
platform.button_mask &= ~gpiomask;
- gpio_outen(platform.button_mask, 0);
- gpio_control(platform.button_mask, 0);
- platform.button_polarity = gpio_in() & platform.button_mask;
- gpio_intpolarity(platform.button_mask, platform.button_polarity);
- gpio_setintmask(platform.button_mask, platform.button_mask);
+ bcm47xx_gpio_outen(platform.button_mask, 0);
+ bcm47xx_gpio_control(platform.button_mask, 0);
+ platform.button_polarity = bcm47xx_gpio_in(~0) & platform.button_mask;
+ bcm47xx_gpio_polarity(platform.button_mask, platform.button_polarity);
+ bcm47xx_gpio_intmask(platform.button_mask, platform.button_mask);
gpio_set_irqenable(1, button_handler);
}
static void unregister_buttons(struct button_t *b)
{
- gpio_setintmask(platform.button_mask, 0);
+ bcm47xx_gpio_intmask(platform.button_mask, 0);
gpio_set_irqenable(0, button_handler);
}
@@ -1361,12 +1397,12 @@ static irqreturn_t button_handler(int irq, void *dev_id)
struct button_t *b;
u32 in, changed;
- in = gpio_in() & platform.button_mask;
- gpio_intpolarity(platform.button_mask, in);
+ in = bcm47xx_gpio_in(~0) & platform.button_mask;
+ bcm47xx_gpio_polarity(platform.button_mask, in);
changed = platform.button_polarity ^ in;
platform.button_polarity = in;
- changed &= ~gpio_outen(0, 0);
+ changed &= ~bcm47xx_gpio_outen(0, 0);
for (b = platform.buttons; b->name; b++) {
struct event_t *event;
@@ -1422,10 +1458,10 @@ static void register_leds(struct led_t *l)
}
}
- gpio_outen(mask, oe_mask);
- gpio_control(mask, 0);
- gpio_out(mask, val);
- gpio_setintmask(mask, 0);
+ bcm47xx_gpio_outen(mask, oe_mask);
+ bcm47xx_gpio_control(mask, 0);
+ bcm47xx_gpio_out(mask, val);
+ bcm47xx_gpio_intmask(mask, 0);
}
static void unregister_leds(struct led_t *l)
@@ -1438,7 +1474,11 @@ static void unregister_leds(struct led_t *l)
static void set_led_extif(struct led_t *led)
{
- gpio_set_extif(led->gpio, led->state);
+ volatile u8 *addr = (volatile u8 *) KSEG1ADDR(EXTIF_UART) + (led->gpio & ~GPIO_TYPE_MASK);
+ if (led->state)
+ *addr = 0xFF;
+ else
+ *addr;
}
static void led_flash(unsigned long dummy) {
@@ -1460,11 +1500,11 @@ static void led_flash(unsigned long dummy) {
mask &= ~gpiomask;
if (mask) {
- u32 val = ~gpio_in();
+ u32 val = ~bcm47xx_gpio_in(~0);
- gpio_outen(mask, mask);
- gpio_control(mask, 0);
- gpio_out(mask, val);
+ bcm47xx_gpio_outen(mask, mask);
+ bcm47xx_gpio_control(mask, 0);
+ bcm47xx_gpio_out(mask, val);
}
if (mask || extif_blink) {
mod_timer(&led_timer, jiffies + FLASH_TIME);
@@ -1491,7 +1531,7 @@ static ssize_t diag_proc_read(struct file *file, char *buf, size_t count, loff_t
if (led->gpio & GPIO_TYPE_EXTIF) {
len = sprintf(page, "%d\n", led->state);
} else {
- u32 in = (gpio_in() & led->gpio ? 1 : 0);
+ u32 in = (bcm47xx_gpio_in(~0) & led->gpio ? 1 : 0);
u8 p = (led->polarity == NORMAL ? 0 : 1);
len = sprintf(page, "%d\n", ((in ^ p) ? 1 : 0));
}
@@ -1555,9 +1595,9 @@ static ssize_t diag_proc_write(struct file *file, const char *buf, size_t count,
led->state = p ^ ((page[0] == '1') ? 1 : 0);
set_led_extif(led);
} else {
- gpio_outen(led->gpio, led->gpio);
- gpio_control(led->gpio, 0);
- gpio_out(led->gpio, ((p ^ (page[0] == '1')) ? led->gpio : 0));
+ bcm47xx_gpio_outen(led->gpio, led->gpio);
+ bcm47xx_gpio_control(led->gpio, 0);
+ bcm47xx_gpio_out(led->gpio, ((p ^ (page[0] == '1')) ? led->gpio : 0));
}
}
break;
diff --git a/package/broadcom-diag/src/gpio.h b/package/broadcom-diag/src/gpio.h
index 4e382edeeb..d0e3e06c8a 100644
--- a/package/broadcom-diag/src/gpio.h
+++ b/package/broadcom-diag/src/gpio.h
@@ -6,150 +6,6 @@
#include <linux/gpio.h>
#include <bcm47xx.h>
-static inline u32 gpio_in(void)
-{
- switch (bcm47xx_bus_type) {
-#ifdef CONFIG_BCM47XX_SSB
- case BCM47XX_BUS_TYPE_SSB:
- return ssb_gpio_in(&bcm47xx_bus.ssb, ~0);
-#endif
-#ifdef CONFIG_BCM47XX_BCMA
- case BCM47XX_BUS_TYPE_BCMA:
- return bcma_chipco_gpio_in(&bcm47xx_bus.bcma.bus.drv_cc, ~0);
-#endif
- }
- return -EINVAL;
-}
-
-static inline u32 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:
- return bcma_chipco_gpio_out(&bcm47xx_bus.bcma.bus.drv_cc, mask, value);
-#endif
- }
- return -EINVAL;
-}
-
-static inline u32 gpio_outen(u32 mask, u32 value)
-{
- switch (bcm47xx_bus_type) {
-#ifdef CONFIG_BCM47XX_SSB
- case BCM47XX_BUS_TYPE_SSB:
- ssb_gpio_outen(&bcm47xx_bus.ssb, mask, value);
- return 0;
-#endif
-#ifdef CONFIG_BCM47XX_BCMA
- case BCM47XX_BUS_TYPE_BCMA:
- bcma_chipco_gpio_outen(&bcm47xx_bus.bcma.bus.drv_cc, mask, value);
- return 0;
-#endif
- }
- return -EINVAL;
-}
-
-static inline u32 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:
- return bcma_chipco_gpio_control(&bcm47xx_bus.bcma.bus.drv_cc, mask, value);
-#endif
- }
- return -EINVAL;
-}
-
-static inline u32 gpio_setintmask(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
-#ifdef CONFIG_BCM47XX_BCMA
- case BCM47XX_BUS_TYPE_BCMA:
- return bcma_chipco_gpio_intmask(&bcm47xx_bus.bcma.bus.drv_cc, mask, value);
-#endif
- }
- return -EINVAL;
-}
-
-static inline u32 gpio_intpolarity(u32 mask, u32 value)
-{
- switch (bcm47xx_bus_type) {
-#ifdef CONFIG_BCM47XX_SSB
- case BCM47XX_BUS_TYPE_SSB:
- return ssb_gpio_polarity(&bcm47xx_bus.ssb, mask, value);
-#endif
-#ifdef CONFIG_BCM47XX_BCMA
- case BCM47XX_BUS_TYPE_BCMA:
- return bcma_chipco_gpio_polarity(&bcm47xx_bus.bcma.bus.drv_cc, mask, value);
-#endif
- }
- return -EINVAL;
-}
-
-#ifdef CONFIG_BCM47XX_SSB
-static inline u32 __ssb_write32_masked(struct ssb_device *dev, u16 offset,
- u32 mask, u32 value)
-{
- value &= mask;
- value |= ssb_read32(dev, offset) & ~mask;
- ssb_write32(dev, offset, value);
- return value;
-}
-#endif
-
-#ifdef CONFIG_BCM47XX_BCMA
-static inline u32 __bcma_write32_masked(struct bcma_device *dev, u16 offset,
- u32 mask, u32 value)
-{
- value &= mask;
- value |= bcma_read32(dev, offset) & ~mask;
- bcma_write32(dev, offset, value);
- return value;
-}
-#endif
-
-static void gpio_set_irqenable(int enabled, irqreturn_t (*handler)(int, void *))
-{
- int irq;
-
- irq = gpio_to_irq(0);
- if (irq == -EINVAL) return;
-
- if (enabled) {
- if (request_irq(irq, handler, IRQF_SHARED | IRQF_SAMPLE_RANDOM, "gpio", handler))
- return;
- } else {
- free_irq(irq, handler);
- }
-
- switch (bcm47xx_bus_type) {
-#ifdef CONFIG_BCM47XX_SSB
- case BCM47XX_BUS_TYPE_SSB:
- if (bcm47xx_bus.ssb.chipco.dev)
- __ssb_write32_masked(bcm47xx_bus.ssb.chipco.dev, SSB_CHIPCO_IRQMASK, SSB_CHIPCO_IRQ_GPIO, (enabled ? SSB_CHIPCO_IRQ_GPIO : 0));
- break;
-#endif
-#ifdef CONFIG_BCM47XX_BCMA
- case BCM47XX_BUS_TYPE_BCMA:
- if (bcm47xx_bus.bcma.bus.drv_cc.core)
- __bcma_write32_masked(bcm47xx_bus.bcma.bus.drv_cc.core, BCMA_CC_IRQMASK, BCMA_CC_IRQ_GPIO, (enabled ? BCMA_CC_IRQ_GPIO : 0));
- break;
-#endif
- }
-}
-
#define EXTIF_ADDR 0x1f000000
#define EXTIF_UART (EXTIF_ADDR + 0x00800000)
@@ -157,13 +13,4 @@ static void gpio_set_irqenable(int enabled, irqreturn_t (*handler)(int, void *))
#define GPIO_TYPE_EXTIF (0x1 << 24)
#define GPIO_TYPE_MASK (0xf << 24)
-static inline void gpio_set_extif(int gpio, int value)
-{
- volatile u8 *addr = (volatile u8 *) KSEG1ADDR(EXTIF_UART) + (gpio & ~GPIO_TYPE_MASK);
- if (value)
- *addr = 0xFF;
- else
- *addr;
-}
-
#endif /* __DIAG_GPIO_H */
diff --git a/package/switch/src/gpio-bcm947xx.h b/package/switch/src/gpio-bcm947xx.h
deleted file mode 100644
index 23c221da87..0000000000
--- a/package/switch/src/gpio-bcm947xx.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef __SWITCH_GPIO_H
-#define __SWITCH_GPIO_H
-
-#include <linux/ssb/ssb_embedded.h>
-#include <linux/bcma/bcma_driver_chipcommon.h>
-#include <bcm47xx.h>
-
-static inline u32 gpio_in(void)
-{
- switch (bcm47xx_bus_type) {
-#ifdef CONFIG_BCM47XX_SSB
- case BCM47XX_BUS_TYPE_SSB:
- return ssb_gpio_in(&bcm47xx_bus.ssb, ~0);
-#endif
-#ifdef CONFIG_BCM47XX_BCMA
- case BCM47XX_BUS_TYPE_BCMA:
- return bcma_chipco_gpio_in(&bcm47xx_bus.bcma.bus.drv_cc, ~0);
-#endif
- }
- return -EINVAL;
-}
-
-static inline u32 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:
- return bcma_chipco_gpio_out(&bcm47xx_bus.bcma.bus.drv_cc, mask, value);
-#endif
- }
- return -EINVAL;
-}
-
-static inline u32 gpio_outen(u32 mask, u32 value)
-{
- switch (bcm47xx_bus_type) {
-#ifdef CONFIG_BCM47XX_SSB
- case BCM47XX_BUS_TYPE_SSB:
- ssb_gpio_outen(&bcm47xx_bus.ssb, mask, value);
- return 0;
-#endif
-#ifdef CONFIG_BCM47XX_BCMA
- case BCM47XX_BUS_TYPE_BCMA:
- bcma_chipco_gpio_outen(&bcm47xx_bus.bcma.bus.drv_cc, mask, value);
- return 0;
-#endif
- }
- return -EINVAL;
-}
-
-#endif /* __SWITCH_GPIO_H */
diff --git a/package/switch/src/gpio.h b/package/switch/src/gpio.h
index 90bafd39ed..cb734f7b1b 100644
--- a/package/switch/src/gpio.h
+++ b/package/switch/src/gpio.h
@@ -9,16 +9,16 @@
#define __GPIO_H
#ifdef CONFIG_BCM47XX
-#include "gpio-bcm947xx.h"
+#include <linux/gpio.h>
#else
#warning "Unsupported configuration."
-#define gpio_in() (-1U)
-#define gpio_out(mask, value) (-1U)
-#define gpio_outen(mask, value) (-1U)
-#define gpio_control(mask, value) (-1U)
-#define gpio_intmask(mask, value) (-1U)
-#define gpio_intpolarity(mask, value) (-1U)
+#define bcm47xx_gpio_in(mask) (-1U)
+#define bcm47xx_gpio_out(mask, value) (-1U)
+#define bcm47xx_gpio_outen(mask, value) (-1U)
+#define bcm47xx_gpio_control(mask, value) (-1U)
+#define bcm47xx_gpio_intmask(mask, value) (-1U)
+#define bcm47xx_gpio_polarity(mask, value) (-1U)
#endif
diff --git a/package/switch/src/switch-adm.c b/package/switch/src/switch-adm.c
index 3826ca57f8..9a6d32b1ef 100644
--- a/package/switch/src/switch-adm.c
+++ b/package/switch/src/switch-adm.c
@@ -104,7 +104,7 @@ static void adm_write(int cs, char *buf, unsigned int bits)
int i, len = (bits + 7) / 8;
__u8 mask;
- gpio_out(eecs, (cs ? eecs : 0));
+ bcm47xx_gpio_out(eecs, (cs ? eecs : 0));
udelay(EECK_EDGE_TIME);
/* Byte assemble from MSB to LSB */
@@ -112,25 +112,25 @@ static void adm_write(int cs, char *buf, unsigned int bits)
/* Bit bang from MSB to LSB */
for (mask = 0x80; mask && bits > 0; mask >>= 1, bits --) {
/* Clock low */
- gpio_out(eesk, 0);
+ bcm47xx_gpio_out(eesk, 0);
udelay(EECK_EDGE_TIME);
/* Output on rising edge */
- gpio_out(eedi, ((mask & buf[i]) ? eedi : 0));
+ bcm47xx_gpio_out(eedi, ((mask & buf[i]) ? eedi : 0));
udelay(EEDI_SETUP_TIME);
/* Clock high */
- gpio_out(eesk, eesk);
+ bcm47xx_gpio_out(eesk, eesk);
udelay(EECK_EDGE_TIME);
}
}
/* Clock low */
- gpio_out(eesk, 0);
+ bcm47xx_gpio_out(eesk, 0);
udelay(EECK_EDGE_TIME);
if (cs)
- gpio_out(eecs, 0);
+ bcm47xx_gpio_out(eecs, 0);
}
@@ -139,7 +139,7 @@ static void adm_read(int cs, char *buf, unsigned int bits)
int i, len = (bits + 7) / 8;
__u8 mask;
- gpio_out(eecs, (cs ? eecs : 0));
+ bcm47xx_gpio_out(eecs, (cs ? eecs : 0));
udelay(EECK_EDGE_TIME);
/* Byte assemble from MSB to LSB */
@@ -151,16 +151,16 @@ static void adm_read(int cs, char *buf, unsigned int bits)
__u8 gp;
/* Clock low */
- gpio_out(eesk, 0);
+ bcm47xx_gpio_out(eesk, 0);
udelay(EECK_EDGE_TIME);
/* Input on rising edge */
- gp = gpio_in();
+ gp = bcm47xx_gpio_in(~0);
if (gp & eedi)
byte |= mask;
/* Clock high */
- gpio_out(eesk, eesk);
+ bcm47xx_gpio_out(eesk, eesk);
udelay(EECK_EDGE_TIME);
}
@@ -168,11 +168,11 @@ static void adm_read(int cs, char *buf, unsigned int bits)
}
/* Clock low */
- gpio_out(eesk, 0);
+ bcm47xx_gpio_out(eesk, 0);
udelay(EECK_EDGE_TIME);
if (cs)
- gpio_out(eecs, 0);
+ bcm47xx_gpio_out(eecs, 0);
}
@@ -180,10 +180,10 @@ static void adm_read(int cs, char *buf, unsigned int bits)
static void adm_enout(__u8 pins, __u8 val)
{
/* Prepare GPIO output value */
- gpio_out(pins, val);
+ bcm47xx_gpio_out(pins, val);
/* Enable GPIO outputs */
- gpio_outen(pins, pins);
+ bcm47xx_gpio_outen(pins, pins);
udelay(EECK_EDGE_TIME);
}
@@ -192,7 +192,7 @@ static void adm_enout(__u8 pins, __u8 val)
static void adm_disout(__u8 pins)
{
/* Disable GPIO outputs */
- gpio_outen(pins, 0);
+ bcm47xx_gpio_outen(pins, 0);
udelay(EECK_EDGE_TIME);
}
@@ -203,11 +203,11 @@ static void adm_adclk(int clocks)
int i;
for (i = 0; i < clocks; i++) {
/* Clock high */
- gpio_out(eesk, eesk);
+ bcm47xx_gpio_out(eesk, eesk);
udelay(EECK_EDGE_TIME);
/* Clock low */
- gpio_out(eesk, 0);
+ bcm47xx_gpio_out(eesk, 0);
udelay(EECK_EDGE_TIME);
}
}