aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/ath79
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2013-01-29 03:19:12 -0500
committerJohn Crispin <blogic@openwrt.org>2013-02-16 19:25:27 -0500
commit8838becdf5f7261d7f5dfbbe957fe9b9ed188aec (patch)
tree9a2bfbe783c71cba97fff61978f96a815876cc98 /arch/mips/ath79
parent778eeb1b199b85bec79b49ac483b013e270636ea (diff)
MIPS: ath79: fix GPIO function selection for AR934x SoCs
GPIO function selection is not working on the AR934x SoCs because the offset of the function selection register is different on those. Add a helper routine which returns the correct register address based on the SoC type, and use that in the 'ath79_gpio_function_*' routines. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Patchwork: http://patchwork.linux-mips.org/patch/4870/ Signed-off-by: John Crispin <blogic@openwrt.org>
Diffstat (limited to 'arch/mips/ath79')
-rw-r--r--arch/mips/ath79/gpio.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/arch/mips/ath79/gpio.c b/arch/mips/ath79/gpio.c
index 48fe762d2526..662a10ecd8e7 100644
--- a/arch/mips/ath79/gpio.c
+++ b/arch/mips/ath79/gpio.c
@@ -137,47 +137,61 @@ static struct gpio_chip ath79_gpio_chip = {
137 .base = 0, 137 .base = 0,
138}; 138};
139 139
140static void __iomem *ath79_gpio_get_function_reg(void)
141{
142 u32 reg = 0;
143
144 if (soc_is_ar71xx() ||
145 soc_is_ar724x() ||
146 soc_is_ar913x() ||
147 soc_is_ar933x())
148 reg = AR71XX_GPIO_REG_FUNC;
149 else if (soc_is_ar934x())
150 reg = AR934X_GPIO_REG_FUNC;
151 else
152 BUG();
153
154 return ath79_gpio_base + reg;
155}
156
140void ath79_gpio_function_enable(u32 mask) 157void ath79_gpio_function_enable(u32 mask)
141{ 158{
142 void __iomem *base = ath79_gpio_base; 159 void __iomem *reg = ath79_gpio_get_function_reg();
143 unsigned long flags; 160 unsigned long flags;
144 161
145 spin_lock_irqsave(&ath79_gpio_lock, flags); 162 spin_lock_irqsave(&ath79_gpio_lock, flags);
146 163
147 __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_FUNC) | mask, 164 __raw_writel(__raw_readl(reg) | mask, reg);
148 base + AR71XX_GPIO_REG_FUNC);
149 /* flush write */ 165 /* flush write */
150 __raw_readl(base + AR71XX_GPIO_REG_FUNC); 166 __raw_readl(reg);
151 167
152 spin_unlock_irqrestore(&ath79_gpio_lock, flags); 168 spin_unlock_irqrestore(&ath79_gpio_lock, flags);
153} 169}
154 170
155void ath79_gpio_function_disable(u32 mask) 171void ath79_gpio_function_disable(u32 mask)
156{ 172{
157 void __iomem *base = ath79_gpio_base; 173 void __iomem *reg = ath79_gpio_get_function_reg();
158 unsigned long flags; 174 unsigned long flags;
159 175
160 spin_lock_irqsave(&ath79_gpio_lock, flags); 176 spin_lock_irqsave(&ath79_gpio_lock, flags);
161 177
162 __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_FUNC) & ~mask, 178 __raw_writel(__raw_readl(reg) & ~mask, reg);
163 base + AR71XX_GPIO_REG_FUNC);
164 /* flush write */ 179 /* flush write */
165 __raw_readl(base + AR71XX_GPIO_REG_FUNC); 180 __raw_readl(reg);
166 181
167 spin_unlock_irqrestore(&ath79_gpio_lock, flags); 182 spin_unlock_irqrestore(&ath79_gpio_lock, flags);
168} 183}
169 184
170void ath79_gpio_function_setup(u32 set, u32 clear) 185void ath79_gpio_function_setup(u32 set, u32 clear)
171{ 186{
172 void __iomem *base = ath79_gpio_base; 187 void __iomem *reg = ath79_gpio_get_function_reg();
173 unsigned long flags; 188 unsigned long flags;
174 189
175 spin_lock_irqsave(&ath79_gpio_lock, flags); 190 spin_lock_irqsave(&ath79_gpio_lock, flags);
176 191
177 __raw_writel((__raw_readl(base + AR71XX_GPIO_REG_FUNC) & ~clear) | set, 192 __raw_writel((__raw_readl(reg) & ~clear) | set, reg);
178 base + AR71XX_GPIO_REG_FUNC);
179 /* flush write */ 193 /* flush write */
180 __raw_readl(base + AR71XX_GPIO_REG_FUNC); 194 __raw_readl(reg);
181 195
182 spin_unlock_irqrestore(&ath79_gpio_lock, flags); 196 spin_unlock_irqrestore(&ath79_gpio_lock, flags);
183} 197}