diff options
author | Mark A. Greer <mgreer@mvista.com> | 2009-04-15 15:40:35 -0400 |
---|---|---|
committer | Kevin Hilman <khilman@deeprootsystems.com> | 2009-05-28 18:16:30 -0400 |
commit | a994955cc091a8a51b7d7412174d9cf6de04d26b (patch) | |
tree | 14c62610ee3ec0aa59fa5df49d4bf5ac88c8eb4c /arch/arm/mach-davinci/include/mach | |
parent | 951d6f6d703110790256abfce03ced117d2dcc6b (diff) |
davinci: Make GPIO code more generic
The current gpio code needs to know the number of
gpio irqs there are and what the bank irq number is.
To determine those values, it checks the SoC type.
It also assumes that the base address and the number
of irqs the interrupt controller uses is fixed.
To clean up the SoC checks and make it support
different base addresses and interrupt controllers,
have the SoC-specific code set those values in
the soc_info structure and have the gpio code
reference them there.
Signed-off-by: Mark A. Greer <mgreer@mvista.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Diffstat (limited to 'arch/arm/mach-davinci/include/mach')
-rw-r--r-- | arch/arm/mach-davinci/include/mach/common.h | 3 | ||||
-rw-r--r-- | arch/arm/mach-davinci/include/mach/gpio.h | 14 |
2 files changed, 11 insertions, 6 deletions
diff --git a/arch/arm/mach-davinci/include/mach/common.h b/arch/arm/mach-davinci/include/mach/common.h index d63703826a60..06ff6d6e3678 100644 --- a/arch/arm/mach-davinci/include/mach/common.h +++ b/arch/arm/mach-davinci/include/mach/common.h | |||
@@ -58,6 +58,9 @@ struct davinci_soc_info { | |||
58 | unsigned long intc_irq_num; | 58 | unsigned long intc_irq_num; |
59 | struct davinci_timer_info *timer_info; | 59 | struct davinci_timer_info *timer_info; |
60 | void __iomem *wdt_base; | 60 | void __iomem *wdt_base; |
61 | void __iomem *gpio_base; | ||
62 | unsigned gpio_num; | ||
63 | unsigned gpio_irq; | ||
61 | }; | 64 | }; |
62 | 65 | ||
63 | extern struct davinci_soc_info davinci_soc_info; | 66 | extern struct davinci_soc_info davinci_soc_info; |
diff --git a/arch/arm/mach-davinci/include/mach/gpio.h b/arch/arm/mach-davinci/include/mach/gpio.h index efe3281364e6..ae0745568316 100644 --- a/arch/arm/mach-davinci/include/mach/gpio.h +++ b/arch/arm/mach-davinci/include/mach/gpio.h | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <asm-generic/gpio.h> | 17 | #include <asm-generic/gpio.h> |
18 | 18 | ||
19 | #include <mach/irqs.h> | 19 | #include <mach/irqs.h> |
20 | #include <mach/common.h> | ||
20 | 21 | ||
21 | #define DAVINCI_GPIO_BASE 0x01C67000 | 22 | #define DAVINCI_GPIO_BASE 0x01C67000 |
22 | 23 | ||
@@ -67,15 +68,16 @@ static inline struct gpio_controller *__iomem | |||
67 | __gpio_to_controller(unsigned gpio) | 68 | __gpio_to_controller(unsigned gpio) |
68 | { | 69 | { |
69 | void *__iomem ptr; | 70 | void *__iomem ptr; |
71 | void __iomem *base = davinci_soc_info.gpio_base; | ||
70 | 72 | ||
71 | if (gpio < 32 * 1) | 73 | if (gpio < 32 * 1) |
72 | ptr = IO_ADDRESS(DAVINCI_GPIO_BASE + 0x10); | 74 | ptr = base + 0x10; |
73 | else if (gpio < 32 * 2) | 75 | else if (gpio < 32 * 2) |
74 | ptr = IO_ADDRESS(DAVINCI_GPIO_BASE + 0x38); | 76 | ptr = base + 0x38; |
75 | else if (gpio < 32 * 3) | 77 | else if (gpio < 32 * 3) |
76 | ptr = IO_ADDRESS(DAVINCI_GPIO_BASE + 0x60); | 78 | ptr = base + 0x60; |
77 | else if (gpio < 32 * 4) | 79 | else if (gpio < 32 * 4) |
78 | ptr = IO_ADDRESS(DAVINCI_GPIO_BASE + 0x88); | 80 | ptr = base + 0x88; |
79 | else | 81 | else |
80 | ptr = NULL; | 82 | ptr = NULL; |
81 | return ptr; | 83 | return ptr; |
@@ -142,13 +144,13 @@ static inline int gpio_to_irq(unsigned gpio) | |||
142 | { | 144 | { |
143 | if (gpio >= DAVINCI_N_GPIO) | 145 | if (gpio >= DAVINCI_N_GPIO) |
144 | return -EINVAL; | 146 | return -EINVAL; |
145 | return DAVINCI_N_AINTC_IRQ + gpio; | 147 | return davinci_soc_info.intc_irq_num + gpio; |
146 | } | 148 | } |
147 | 149 | ||
148 | static inline int irq_to_gpio(unsigned irq) | 150 | static inline int irq_to_gpio(unsigned irq) |
149 | { | 151 | { |
150 | /* caller guarantees gpio_to_irq() succeeded */ | 152 | /* caller guarantees gpio_to_irq() succeeded */ |
151 | return irq - DAVINCI_N_AINTC_IRQ; | 153 | return irq - davinci_soc_info.intc_irq_num; |
152 | } | 154 | } |
153 | 155 | ||
154 | #endif /* __DAVINCI_GPIO_H */ | 156 | #endif /* __DAVINCI_GPIO_H */ |