diff options
Diffstat (limited to 'arch/arm/mach-davinci/gpio.c')
-rw-r--r-- | arch/arm/mach-davinci/gpio.c | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/arch/arm/mach-davinci/gpio.c b/arch/arm/mach-davinci/gpio.c index 40327b557d79..1b6532159c58 100644 --- a/arch/arm/mach-davinci/gpio.c +++ b/arch/arm/mach-davinci/gpio.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <mach/cputype.h> | 23 | #include <mach/cputype.h> |
24 | #include <mach/irqs.h> | 24 | #include <mach/irqs.h> |
25 | #include <mach/hardware.h> | 25 | #include <mach/hardware.h> |
26 | #include <mach/common.h> | ||
26 | #include <mach/gpio.h> | 27 | #include <mach/gpio.h> |
27 | 28 | ||
28 | #include <asm/mach/irq.h> | 29 | #include <asm/mach/irq.h> |
@@ -37,8 +38,6 @@ struct davinci_gpio { | |||
37 | 38 | ||
38 | static struct davinci_gpio chips[DIV_ROUND_UP(DAVINCI_N_GPIO, 32)]; | 39 | static struct davinci_gpio chips[DIV_ROUND_UP(DAVINCI_N_GPIO, 32)]; |
39 | 40 | ||
40 | static unsigned __initdata ngpio; | ||
41 | |||
42 | /* create a non-inlined version */ | 41 | /* create a non-inlined version */ |
43 | static struct gpio_controller __iomem * __init gpio2controller(unsigned gpio) | 42 | static struct gpio_controller __iomem * __init gpio2controller(unsigned gpio) |
44 | { | 43 | { |
@@ -116,23 +115,16 @@ davinci_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | |||
116 | static int __init davinci_gpio_setup(void) | 115 | static int __init davinci_gpio_setup(void) |
117 | { | 116 | { |
118 | int i, base; | 117 | int i, base; |
118 | unsigned ngpio; | ||
119 | struct davinci_soc_info *soc_info = &davinci_soc_info; | ||
119 | 120 | ||
120 | /* The gpio banks conceptually expose a segmented bitmap, | 121 | /* |
122 | * The gpio banks conceptually expose a segmented bitmap, | ||
121 | * and "ngpio" is one more than the largest zero-based | 123 | * and "ngpio" is one more than the largest zero-based |
122 | * bit index that's valid. | 124 | * bit index that's valid. |
123 | */ | 125 | */ |
124 | if (cpu_is_davinci_dm355()) { /* or dm335() */ | 126 | ngpio = soc_info->gpio_num; |
125 | ngpio = 104; | 127 | if (ngpio == 0) { |
126 | } else if (cpu_is_davinci_dm644x()) { /* or dm337() */ | ||
127 | ngpio = 71; | ||
128 | } else if (cpu_is_davinci_dm646x()) { | ||
129 | /* NOTE: each bank has several "reserved" bits, | ||
130 | * unusable as GPIOs. Only 33 of the GPIO numbers | ||
131 | * are usable, and we're not rejecting the others. | ||
132 | */ | ||
133 | ngpio = 43; | ||
134 | } else { | ||
135 | /* if cpu_is_davinci_dm643x() ngpio = 111 */ | ||
136 | pr_err("GPIO setup: how many GPIOs?\n"); | 128 | pr_err("GPIO setup: how many GPIOs?\n"); |
137 | return -EINVAL; | 129 | return -EINVAL; |
138 | } | 130 | } |
@@ -279,17 +271,15 @@ gpio_irq_handler(unsigned irq, struct irq_desc *desc) | |||
279 | static int __init davinci_gpio_irq_setup(void) | 271 | static int __init davinci_gpio_irq_setup(void) |
280 | { | 272 | { |
281 | unsigned gpio, irq, bank; | 273 | unsigned gpio, irq, bank; |
282 | unsigned bank_irq; | ||
283 | struct clk *clk; | 274 | struct clk *clk; |
284 | u32 binten = 0; | 275 | u32 binten = 0; |
276 | unsigned ngpio, bank_irq; | ||
277 | struct davinci_soc_info *soc_info = &davinci_soc_info; | ||
278 | |||
279 | ngpio = soc_info->gpio_num; | ||
285 | 280 | ||
286 | if (cpu_is_davinci_dm355()) { /* or dm335() */ | 281 | bank_irq = soc_info->gpio_irq; |
287 | bank_irq = IRQ_DM355_GPIOBNK0; | 282 | if (bank_irq == 0) { |
288 | } else if (cpu_is_davinci_dm644x()) { | ||
289 | bank_irq = IRQ_GPIOBNK0; | ||
290 | } else if (cpu_is_davinci_dm646x()) { | ||
291 | bank_irq = IRQ_DM646X_GPIOBNK0; | ||
292 | } else { | ||
293 | printk(KERN_ERR "Don't know first GPIO bank IRQ.\n"); | 283 | printk(KERN_ERR "Don't know first GPIO bank IRQ.\n"); |
294 | return -EINVAL; | 284 | return -EINVAL; |
295 | } | 285 | } |
@@ -329,8 +319,7 @@ static int __init davinci_gpio_irq_setup(void) | |||
329 | /* BINTEN -- per-bank interrupt enable. genirq would also let these | 319 | /* BINTEN -- per-bank interrupt enable. genirq would also let these |
330 | * bits be set/cleared dynamically. | 320 | * bits be set/cleared dynamically. |
331 | */ | 321 | */ |
332 | __raw_writel(binten, (void *__iomem) | 322 | __raw_writel(binten, soc_info->gpio_base + 0x08); |
333 | IO_ADDRESS(DAVINCI_GPIO_BASE + 0x08)); | ||
334 | 323 | ||
335 | printk(KERN_INFO "DaVinci: %d gpio irqs\n", irq - gpio_to_irq(0)); | 324 | printk(KERN_INFO "DaVinci: %d gpio irqs\n", irq - gpio_to_irq(0)); |
336 | 325 | ||