diff options
author | hauke <hauke@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2012-08-04 19:46:25 +0000 |
---|---|---|
committer | hauke <hauke@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2012-08-04 19:46:25 +0000 |
commit | 1d6c42df96154e859a0c02ec578780cb2948bb43 (patch) | |
tree | c9205034126c854e2e3791e91fec1fd6d6925bc3 /package/switch/src | |
parent | 039f1795516bfb35e637ab26168d5ae42c547bf0 (diff) |
brcm47xx: use libgpio instaed of implementing the gpio interface ourself.
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32992 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/switch/src')
-rw-r--r-- | package/switch/src/gpio-bcm947xx.h | 55 | ||||
-rw-r--r-- | package/switch/src/gpio.h | 14 | ||||
-rw-r--r-- | package/switch/src/switch-adm.c | 34 |
3 files changed, 24 insertions, 79 deletions
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); } } |