diff options
Diffstat (limited to 'target/linux')
-rw-r--r-- | target/linux/adm5120-2.6/files/arch/mips/adm5120/gpio.c | 43 | ||||
-rw-r--r-- | target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/gpio.h | 17 |
2 files changed, 38 insertions, 22 deletions
diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/gpio.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/gpio.c index 1fac84bb5..41299a9a5 100644 --- a/target/linux/adm5120-2.6/files/arch/mips/adm5120/gpio.c +++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/gpio.c @@ -204,10 +204,27 @@ static inline int leds_direction_output(unsigned led, int value) t = GPIO_READ(reg); t &= ~(LED_MODE_MASK << s); - if (value) - t |= (LED_MODE_OUT_HIGH << s); - else + + switch (value) { + case ADM5120_GPIO_LOW: t |= (LED_MODE_OUT_LOW << s); + break; + case ADM5120_GPIO_FLASH: + case ADM5120_GPIO_LINK: + case ADM5120_GPIO_SPEED: + case ADM5120_GPIO_DUPLEX: + case ADM5120_GPIO_ACT: + case ADM5120_GPIO_COLL: + case ADM5120_GPIO_LINK_ACT: + case ADM5120_GPIO_DUPLEX_COLL: + case ADM5120_GPIO_10M_ACT: + case ADM5120_GPIO_100M_ACT: + t |= ((value & LED_MODE_MASK) << s); + break; + default: + t |= (LED_MODE_OUT_HIGH << s); + break; + } GPIO_WRITE(t,reg); @@ -232,24 +249,6 @@ static inline int leds_get_value(unsigned led) return 1; } -static inline void leds_set_value(unsigned led, int value) -{ - gpio_reg_t *reg; - u32 s,t; - - reg = led_table[led].reg; - s = led_table[led].mode_shift; - - t = GPIO_READ(reg); - t &= ~(LED_MODE_MASK << s); - if (value) - t |= (LED_MODE_OUT_HIGH << s); - else - t |= (LED_MODE_OUT_LOW << s); - - GPIO_WRITE(t,reg); -} - /* * Main GPIO support routines */ @@ -294,7 +293,7 @@ void adm5120_gpio_set_value(unsigned gpio, int value) } gpio -= ADM5120_GPIO_P0L0; - leds_set_value(gpio, value); + leds_direction_output(gpio, value); } int adm5120_gpio_request(unsigned gpio, const char *label) diff --git a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/gpio.h b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/gpio.h index 97e187ea0..58147d393 100644 --- a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/gpio.h +++ b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/gpio.h @@ -26,6 +26,8 @@ #ifndef _ADM5120_GPIO_H_ #define _ADM5120_GPIO_H_ +#include <asm/mach-adm5120/adm5120_switch.h> + #define ADM5120_GPIO_PIN0 0 #define ADM5120_GPIO_PIN1 1 #define ADM5120_GPIO_PIN2 2 @@ -52,6 +54,21 @@ #define ADM5120_GPIO_MAX 22 #define ADM5120_GPIO_COUNT ADM5120_GPIO_MAX+1 +#define ADM5120_GPIO_LOW 0 +#define ADM5120_GPIO_HIGH 1 + +#define ADM5120_GPIO_SWITCH 0x10 +#define ADM5120_GPIO_FLASH (ADM5120_GPIO_SWITCH | LED_MODE_FLASH) +#define ADM5120_GPIO_LINK (ADM5120_GPIO_SWITCH | LED_MODE_LINK) +#define ADM5120_GPIO_SPEED (ADM5120_GPIO_SWITCH | LED_MODE_SPEED) +#define ADM5120_GPIO_DUPLEX (ADM5120_GPIO_SWITCH | LED_MODE_DUPLEX) +#define ADM5120_GPIO_ACT (ADM5120_GPIO_SWITCH | LED_MODE_ACT) +#define ADM5120_GPIO_COLL (ADM5120_GPIO_SWITCH | LED_MODE_COLL) +#define ADM5120_GPIO_LINK_ACT (ADM5120_GPIO_SWITCH | LED_MODE_LINK_ACT) +#define ADM5120_GPIO_DUPLEX_COLL (ADM5120_GPIO_SWITCH | LED_MODE_DUPLEX_COLL) +#define ADM5120_GPIO_10M_ACT (ADM5120_GPIO_SWITCH | LED_MODE_10M_ACT) +#define ADM5120_GPIO_100M_ACT (ADM5120_GPIO_SWITCH | LED_MODE_100M_ACT) + extern int adm5120_gpio_direction_input(unsigned gpio); extern int adm5120_gpio_direction_output(unsigned gpio, int value); extern int adm5120_gpio_get_value(unsigned gpio); |