aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-msm/gpio.c
diff options
context:
space:
mode:
authorDavid Brown <davidb@codeaurora.org>2011-05-12 04:28:01 -0400
committerDavid Brown <davidb@codeaurora.org>2011-08-01 07:57:59 -0400
commit10eb5f6bcbdc5e460e5500e1dbc39b2e7713ebfd (patch)
tree9ff483903277f697441c75fa535f4733b82b7d1c /arch/arm/mach-msm/gpio.c
parent2e01d2c593d1cc5ed48cab6c07493185e4ac7a68 (diff)
msm: gpio: Remove ifdefs on gpio chip registers
Select the GPIO register configuration at runtime rather than through idefs. Change-Id: I02ea0a3d61bc81669f32097c32420f0688552231 Signed-off-by: David Brown <davidb@codeaurora.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Diffstat (limited to 'arch/arm/mach-msm/gpio.c')
-rw-r--r--arch/arm/mach-msm/gpio.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/arch/arm/mach-msm/gpio.c b/arch/arm/mach-msm/gpio.c
index 335afbd97c1d..e96199dd14d0 100644
--- a/arch/arm/mach-msm/gpio.c
+++ b/arch/arm/mach-msm/gpio.c
@@ -20,6 +20,7 @@
20#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/irq.h> 21#include <linux/irq.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <mach/cpu.h>
23#include "gpio_hw.h" 24#include "gpio_hw.h"
24#include "gpiomux.h" 25#include "gpiomux.h"
25 26
@@ -189,15 +190,19 @@ static void msm_gpio_free(struct gpio_chip *chip, unsigned offset)
189#define msm_gpio_free NULL 190#define msm_gpio_free NULL
190#endif 191#endif
191 192
192struct msm_gpio_chip msm_gpio_chips[] = { 193static struct msm_gpio_chip *msm_gpio_chips;
193#if defined(CONFIG_ARCH_MSM7X00A) 194static int msm_gpio_count;
195
196static struct msm_gpio_chip msm_gpio_chips_msm7x01[] = {
194 MSM_GPIO_BANK(MSM7X00, 0, 0, 15), 197 MSM_GPIO_BANK(MSM7X00, 0, 0, 15),
195 MSM_GPIO_BANK(MSM7X00, 1, 16, 42), 198 MSM_GPIO_BANK(MSM7X00, 1, 16, 42),
196 MSM_GPIO_BANK(MSM7X00, 2, 43, 67), 199 MSM_GPIO_BANK(MSM7X00, 2, 43, 67),
197 MSM_GPIO_BANK(MSM7X00, 3, 68, 94), 200 MSM_GPIO_BANK(MSM7X00, 3, 68, 94),
198 MSM_GPIO_BANK(MSM7X00, 4, 95, 106), 201 MSM_GPIO_BANK(MSM7X00, 4, 95, 106),
199 MSM_GPIO_BANK(MSM7X00, 5, 107, 121), 202 MSM_GPIO_BANK(MSM7X00, 5, 107, 121),
200#elif defined(CONFIG_ARCH_MSM7X30) 203};
204
205static struct msm_gpio_chip msm_gpio_chips_msm7x30[] = {
201 MSM_GPIO_BANK(MSM7X30, 0, 0, 15), 206 MSM_GPIO_BANK(MSM7X30, 0, 0, 15),
202 MSM_GPIO_BANK(MSM7X30, 1, 16, 43), 207 MSM_GPIO_BANK(MSM7X30, 1, 16, 43),
203 MSM_GPIO_BANK(MSM7X30, 2, 44, 67), 208 MSM_GPIO_BANK(MSM7X30, 2, 44, 67),
@@ -206,7 +211,9 @@ struct msm_gpio_chip msm_gpio_chips[] = {
206 MSM_GPIO_BANK(MSM7X30, 5, 107, 133), 211 MSM_GPIO_BANK(MSM7X30, 5, 107, 133),
207 MSM_GPIO_BANK(MSM7X30, 6, 134, 150), 212 MSM_GPIO_BANK(MSM7X30, 6, 134, 150),
208 MSM_GPIO_BANK(MSM7X30, 7, 151, 181), 213 MSM_GPIO_BANK(MSM7X30, 7, 151, 181),
209#elif defined(CONFIG_ARCH_QSD8X50) 214};
215
216static struct msm_gpio_chip msm_gpio_chips_qsd8x50[] = {
210 MSM_GPIO_BANK(QSD8X50, 0, 0, 15), 217 MSM_GPIO_BANK(QSD8X50, 0, 0, 15),
211 MSM_GPIO_BANK(QSD8X50, 1, 16, 42), 218 MSM_GPIO_BANK(QSD8X50, 1, 16, 42),
212 MSM_GPIO_BANK(QSD8X50, 2, 43, 67), 219 MSM_GPIO_BANK(QSD8X50, 2, 43, 67),
@@ -215,7 +222,6 @@ struct msm_gpio_chip msm_gpio_chips[] = {
215 MSM_GPIO_BANK(QSD8X50, 5, 104, 121), 222 MSM_GPIO_BANK(QSD8X50, 5, 104, 121),
216 MSM_GPIO_BANK(QSD8X50, 6, 122, 152), 223 MSM_GPIO_BANK(QSD8X50, 6, 122, 152),
217 MSM_GPIO_BANK(QSD8X50, 7, 153, 164), 224 MSM_GPIO_BANK(QSD8X50, 7, 153, 164),
218#endif
219}; 225};
220 226
221static void msm_gpio_irq_ack(struct irq_data *d) 227static void msm_gpio_irq_ack(struct irq_data *d)
@@ -311,7 +317,7 @@ static void msm_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
311 int i, j, mask; 317 int i, j, mask;
312 unsigned val; 318 unsigned val;
313 319
314 for (i = 0; i < ARRAY_SIZE(msm_gpio_chips); i++) { 320 for (i = 0; i < msm_gpio_count; i++) {
315 struct msm_gpio_chip *msm_chip = &msm_gpio_chips[i]; 321 struct msm_gpio_chip *msm_chip = &msm_gpio_chips[i];
316 val = readl(msm_chip->regs.int_status); 322 val = readl(msm_chip->regs.int_status);
317 val &= msm_chip->int_enable[0]; 323 val &= msm_chip->int_enable[0];
@@ -342,6 +348,19 @@ static int __init msm_init_gpio(void)
342{ 348{
343 int i, j = 0; 349 int i, j = 0;
344 350
351 if (cpu_is_msm7x01()) {
352 msm_gpio_chips = msm_gpio_chips_msm7x01;
353 msm_gpio_count = ARRAY_SIZE(msm_gpio_chips_msm7x01);
354 } else if (cpu_is_msm7x30()) {
355 msm_gpio_chips = msm_gpio_chips_msm7x30;
356 msm_gpio_count = ARRAY_SIZE(msm_gpio_chips_msm7x30);
357 } else if (cpu_is_qsd8x50()) {
358 msm_gpio_chips = msm_gpio_chips_qsd8x50;
359 msm_gpio_count = ARRAY_SIZE(msm_gpio_chips_qsd8x50);
360 } else {
361 return 0;
362 }
363
345 for (i = FIRST_GPIO_IRQ; i < FIRST_GPIO_IRQ + NR_GPIO_IRQS; i++) { 364 for (i = FIRST_GPIO_IRQ; i < FIRST_GPIO_IRQ + NR_GPIO_IRQS; i++) {
346 if (i - FIRST_GPIO_IRQ >= 365 if (i - FIRST_GPIO_IRQ >=
347 msm_gpio_chips[j].chip.base + 366 msm_gpio_chips[j].chip.base +
@@ -353,7 +372,7 @@ static int __init msm_init_gpio(void)
353 set_irq_flags(i, IRQF_VALID); 372 set_irq_flags(i, IRQF_VALID);
354 } 373 }
355 374
356 for (i = 0; i < ARRAY_SIZE(msm_gpio_chips); i++) { 375 for (i = 0; i < msm_gpio_count; i++) {
357 spin_lock_init(&msm_gpio_chips[i].lock); 376 spin_lock_init(&msm_gpio_chips[i].lock);
358 writel(0, msm_gpio_chips[i].regs.int_en); 377 writel(0, msm_gpio_chips[i].regs.int_en);
359 gpiochip_add(&msm_gpio_chips[i].chip); 378 gpiochip_add(&msm_gpio_chips[i].chip);