diff options
Diffstat (limited to 'arch/mips/bcm63xx/gpio.c')
-rw-r--r-- | arch/mips/bcm63xx/gpio.c | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/arch/mips/bcm63xx/gpio.c b/arch/mips/bcm63xx/gpio.c index f560fe7d38dd..a6c2135dbf38 100644 --- a/arch/mips/bcm63xx/gpio.c +++ b/arch/mips/bcm63xx/gpio.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * for more details. | 4 | * for more details. |
5 | * | 5 | * |
6 | * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> | 6 | * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> |
7 | * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org> | 7 | * Copyright (C) 2008-2011 Florian Fainelli <florian@openwrt.org> |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
@@ -18,6 +18,34 @@ | |||
18 | #include <bcm63xx_io.h> | 18 | #include <bcm63xx_io.h> |
19 | #include <bcm63xx_regs.h> | 19 | #include <bcm63xx_regs.h> |
20 | 20 | ||
21 | #ifndef BCMCPU_RUNTIME_DETECT | ||
22 | #define gpio_out_low_reg GPIO_DATA_LO_REG | ||
23 | #ifdef CONFIG_BCM63XX_CPU_6345 | ||
24 | #ifdef gpio_out_low_reg | ||
25 | #undef gpio_out_low_reg | ||
26 | #define gpio_out_low_reg GPIO_DATA_LO_REG_6345 | ||
27 | #endif /* gpio_out_low_reg */ | ||
28 | #endif /* CONFIG_BCM63XX_CPU_6345 */ | ||
29 | |||
30 | static inline void bcm63xx_gpio_out_low_reg_init(void) | ||
31 | { | ||
32 | } | ||
33 | #else /* ! BCMCPU_RUNTIME_DETECT */ | ||
34 | static u32 gpio_out_low_reg; | ||
35 | |||
36 | static void bcm63xx_gpio_out_low_reg_init(void) | ||
37 | { | ||
38 | switch (bcm63xx_get_cpu_id()) { | ||
39 | case BCM6345_CPU_ID: | ||
40 | gpio_out_low_reg = GPIO_DATA_LO_REG_6345; | ||
41 | break; | ||
42 | default: | ||
43 | gpio_out_low_reg = GPIO_DATA_LO_REG; | ||
44 | break; | ||
45 | } | ||
46 | } | ||
47 | #endif /* ! BCMCPU_RUNTIME_DETECT */ | ||
48 | |||
21 | static DEFINE_SPINLOCK(bcm63xx_gpio_lock); | 49 | static DEFINE_SPINLOCK(bcm63xx_gpio_lock); |
22 | static u32 gpio_out_low, gpio_out_high; | 50 | static u32 gpio_out_low, gpio_out_high; |
23 | 51 | ||
@@ -33,7 +61,7 @@ static void bcm63xx_gpio_set(struct gpio_chip *chip, | |||
33 | BUG(); | 61 | BUG(); |
34 | 62 | ||
35 | if (gpio < 32) { | 63 | if (gpio < 32) { |
36 | reg = GPIO_DATA_LO_REG; | 64 | reg = gpio_out_low_reg; |
37 | mask = 1 << gpio; | 65 | mask = 1 << gpio; |
38 | v = &gpio_out_low; | 66 | v = &gpio_out_low; |
39 | } else { | 67 | } else { |
@@ -60,7 +88,7 @@ static int bcm63xx_gpio_get(struct gpio_chip *chip, unsigned gpio) | |||
60 | BUG(); | 88 | BUG(); |
61 | 89 | ||
62 | if (gpio < 32) { | 90 | if (gpio < 32) { |
63 | reg = GPIO_DATA_LO_REG; | 91 | reg = gpio_out_low_reg; |
64 | mask = 1 << gpio; | 92 | mask = 1 << gpio; |
65 | } else { | 93 | } else { |
66 | reg = GPIO_DATA_HI_REG; | 94 | reg = GPIO_DATA_HI_REG; |
@@ -125,8 +153,11 @@ static struct gpio_chip bcm63xx_gpio_chip = { | |||
125 | 153 | ||
126 | int __init bcm63xx_gpio_init(void) | 154 | int __init bcm63xx_gpio_init(void) |
127 | { | 155 | { |
128 | gpio_out_low = bcm_gpio_readl(GPIO_DATA_LO_REG); | 156 | bcm63xx_gpio_out_low_reg_init(); |
129 | gpio_out_high = bcm_gpio_readl(GPIO_DATA_HI_REG); | 157 | |
158 | gpio_out_low = bcm_gpio_readl(gpio_out_low_reg); | ||
159 | if (!BCMCPU_IS_6345()) | ||
160 | gpio_out_high = bcm_gpio_readl(GPIO_DATA_HI_REG); | ||
130 | bcm63xx_gpio_chip.ngpio = bcm63xx_gpio_count(); | 161 | bcm63xx_gpio_chip.ngpio = bcm63xx_gpio_count(); |
131 | pr_info("registering %d GPIOs\n", bcm63xx_gpio_chip.ngpio); | 162 | pr_info("registering %d GPIOs\n", bcm63xx_gpio_chip.ngpio); |
132 | 163 | ||