aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-davinci
diff options
context:
space:
mode:
authorCyril Chemparathy <cyril@ti.com>2010-05-01 18:37:52 -0400
committerKevin Hilman <khilman@deeprootsystems.com>2010-05-06 18:02:08 -0400
commit99e9e52de635728d7c89a0fdf79b307f3082cf3a (patch)
tree554517b1dc2552819954174c8ddafd3927f34970 /arch/arm/mach-davinci
parentba4a984e838dfb1c46135ff8cadeea5f8ca5fd0a (diff)
Davinci: gpio - structs and functions renamed
Renamed gpio types to something more sensible: struct gpio_controller --> struct davinci_gpio_regs struct davinci_gpio --> struct davinci_gpio_controller gpio2controller() --> gpio2regs() irq2controller() --> irq2regs() This change also moves davinci_gpio_controller definition to gpio.h. Eventually, the gpio registers structure will be moved to gpio.c and no longer a common cross-soc definition. Signed-off-by: Cyril Chemparathy <cyril@ti.com> Tested-by: Sandeep Paulraj <s-paulraj@ti.com> Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Diffstat (limited to 'arch/arm/mach-davinci')
-rw-r--r--arch/arm/mach-davinci/gpio.c50
-rw-r--r--arch/arm/mach-davinci/include/mach/gpio.h14
2 files changed, 32 insertions, 32 deletions
diff --git a/arch/arm/mach-davinci/gpio.c b/arch/arm/mach-davinci/gpio.c
index 93f7c686153a..c77683c3c3d2 100644
--- a/arch/arm/mach-davinci/gpio.c
+++ b/arch/arm/mach-davinci/gpio.c
@@ -22,28 +22,22 @@
22 22
23static DEFINE_SPINLOCK(gpio_lock); 23static DEFINE_SPINLOCK(gpio_lock);
24 24
25struct davinci_gpio {
26 struct gpio_chip chip;
27 struct gpio_controller __iomem *regs;
28 int irq_base;
29};
30
31#define chip2controller(chip) \ 25#define chip2controller(chip) \
32 container_of(chip, struct davinci_gpio, chip) 26 container_of(chip, struct davinci_gpio_controller, chip)
33 27
34static struct davinci_gpio chips[DIV_ROUND_UP(DAVINCI_N_GPIO, 32)]; 28static struct davinci_gpio_controller chips[DIV_ROUND_UP(DAVINCI_N_GPIO, 32)];
35 29
36/* create a non-inlined version */ 30/* create a non-inlined version */
37static struct gpio_controller __iomem __init *gpio2controller(unsigned gpio) 31static struct davinci_gpio_regs __iomem __init *gpio2regs(unsigned gpio)
38{ 32{
39 return __gpio_to_controller(gpio); 33 return __gpio_to_controller(gpio);
40} 34}
41 35
42static inline struct gpio_controller __iomem *irq2controller(int irq) 36static inline struct davinci_gpio_regs __iomem *irq2regs(int irq)
43{ 37{
44 struct gpio_controller __iomem *g; 38 struct davinci_gpio_regs __iomem *g;
45 39
46 g = (__force struct gpio_controller __iomem *)get_irq_chip_data(irq); 40 g = (__force struct davinci_gpio_regs __iomem *)get_irq_chip_data(irq);
47 41
48 return g; 42 return g;
49} 43}
@@ -60,8 +54,8 @@ static int __init davinci_gpio_irq_setup(void);
60static inline int __davinci_direction(struct gpio_chip *chip, 54static inline int __davinci_direction(struct gpio_chip *chip,
61 unsigned offset, bool out, int value) 55 unsigned offset, bool out, int value)
62{ 56{
63 struct davinci_gpio *d = chip2controller(chip); 57 struct davinci_gpio_controller *d = chip2controller(chip);
64 struct gpio_controller __iomem *g = d->regs; 58 struct davinci_gpio_regs __iomem *g = d->regs;
65 u32 temp; 59 u32 temp;
66 u32 mask = 1 << offset; 60 u32 mask = 1 << offset;
67 61
@@ -99,8 +93,8 @@ davinci_direction_out(struct gpio_chip *chip, unsigned offset, int value)
99 */ 93 */
100static int davinci_gpio_get(struct gpio_chip *chip, unsigned offset) 94static int davinci_gpio_get(struct gpio_chip *chip, unsigned offset)
101{ 95{
102 struct davinci_gpio *d = chip2controller(chip); 96 struct davinci_gpio_controller *d = chip2controller(chip);
103 struct gpio_controller __iomem *g = d->regs; 97 struct davinci_gpio_regs __iomem *g = d->regs;
104 98
105 return (1 << offset) & __raw_readl(&g->in_data); 99 return (1 << offset) & __raw_readl(&g->in_data);
106} 100}
@@ -111,8 +105,8 @@ static int davinci_gpio_get(struct gpio_chip *chip, unsigned offset)
111static void 105static void
112davinci_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 106davinci_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
113{ 107{
114 struct davinci_gpio *d = chip2controller(chip); 108 struct davinci_gpio_controller *d = chip2controller(chip);
115 struct gpio_controller __iomem *g = d->regs; 109 struct davinci_gpio_regs __iomem *g = d->regs;
116 110
117 __raw_writel((1 << offset), value ? &g->set_data : &g->clr_data); 111 __raw_writel((1 << offset), value ? &g->set_data : &g->clr_data);
118} 112}
@@ -150,7 +144,7 @@ static int __init davinci_gpio_setup(void)
150 if (chips[i].chip.ngpio > 32) 144 if (chips[i].chip.ngpio > 32)
151 chips[i].chip.ngpio = 32; 145 chips[i].chip.ngpio = 32;
152 146
153 chips[i].regs = gpio2controller(base); 147 chips[i].regs = gpio2regs(base);
154 148
155 gpiochip_add(&chips[i].chip); 149 gpiochip_add(&chips[i].chip);
156 } 150 }
@@ -174,7 +168,7 @@ pure_initcall(davinci_gpio_setup);
174 168
175static void gpio_irq_disable(unsigned irq) 169static void gpio_irq_disable(unsigned irq)
176{ 170{
177 struct gpio_controller __iomem *g = irq2controller(irq); 171 struct davinci_gpio_regs __iomem *g = irq2regs(irq);
178 u32 mask = (u32) get_irq_data(irq); 172 u32 mask = (u32) get_irq_data(irq);
179 173
180 __raw_writel(mask, &g->clr_falling); 174 __raw_writel(mask, &g->clr_falling);
@@ -183,7 +177,7 @@ static void gpio_irq_disable(unsigned irq)
183 177
184static void gpio_irq_enable(unsigned irq) 178static void gpio_irq_enable(unsigned irq)
185{ 179{
186 struct gpio_controller __iomem *g = irq2controller(irq); 180 struct davinci_gpio_regs __iomem *g = irq2regs(irq);
187 u32 mask = (u32) get_irq_data(irq); 181 u32 mask = (u32) get_irq_data(irq);
188 unsigned status = irq_desc[irq].status; 182 unsigned status = irq_desc[irq].status;
189 183
@@ -199,7 +193,7 @@ static void gpio_irq_enable(unsigned irq)
199 193
200static int gpio_irq_type(unsigned irq, unsigned trigger) 194static int gpio_irq_type(unsigned irq, unsigned trigger)
201{ 195{
202 struct gpio_controller __iomem *g = irq2controller(irq); 196 struct davinci_gpio_regs __iomem *g = irq2regs(irq);
203 u32 mask = (u32) get_irq_data(irq); 197 u32 mask = (u32) get_irq_data(irq);
204 198
205 if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) 199 if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
@@ -228,7 +222,7 @@ static struct irq_chip gpio_irqchip = {
228static void 222static void
229gpio_irq_handler(unsigned irq, struct irq_desc *desc) 223gpio_irq_handler(unsigned irq, struct irq_desc *desc)
230{ 224{
231 struct gpio_controller __iomem *g = irq2controller(irq); 225 struct davinci_gpio_regs __iomem *g = irq2regs(irq);
232 u32 mask = 0xffff; 226 u32 mask = 0xffff;
233 227
234 /* we only care about one bank */ 228 /* we only care about one bank */
@@ -266,7 +260,7 @@ gpio_irq_handler(unsigned irq, struct irq_desc *desc)
266 260
267static int gpio_to_irq_banked(struct gpio_chip *chip, unsigned offset) 261static int gpio_to_irq_banked(struct gpio_chip *chip, unsigned offset)
268{ 262{
269 struct davinci_gpio *d = chip2controller(chip); 263 struct davinci_gpio_controller *d = chip2controller(chip);
270 264
271 if (d->irq_base >= 0) 265 if (d->irq_base >= 0)
272 return d->irq_base + offset; 266 return d->irq_base + offset;
@@ -289,7 +283,7 @@ static int gpio_to_irq_unbanked(struct gpio_chip *chip, unsigned offset)
289 283
290static int gpio_irq_type_unbanked(unsigned irq, unsigned trigger) 284static int gpio_irq_type_unbanked(unsigned irq, unsigned trigger)
291{ 285{
292 struct gpio_controller __iomem *g = irq2controller(irq); 286 struct davinci_gpio_regs __iomem *g = irq2regs(irq);
293 u32 mask = (u32) get_irq_data(irq); 287 u32 mask = (u32) get_irq_data(irq);
294 288
295 if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) 289 if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
@@ -318,7 +312,7 @@ static int __init davinci_gpio_irq_setup(void)
318 u32 binten = 0; 312 u32 binten = 0;
319 unsigned ngpio, bank_irq; 313 unsigned ngpio, bank_irq;
320 struct davinci_soc_info *soc_info = &davinci_soc_info; 314 struct davinci_soc_info *soc_info = &davinci_soc_info;
321 struct gpio_controller __iomem *g; 315 struct davinci_gpio_regs __iomem *g;
322 316
323 ngpio = soc_info->gpio_num; 317 ngpio = soc_info->gpio_num;
324 318
@@ -367,7 +361,7 @@ static int __init davinci_gpio_irq_setup(void)
367 gpio_irqchip_unbanked.set_type = gpio_irq_type_unbanked; 361 gpio_irqchip_unbanked.set_type = gpio_irq_type_unbanked;
368 362
369 /* default trigger: both edges */ 363 /* default trigger: both edges */
370 g = gpio2controller(0); 364 g = gpio2regs(0);
371 __raw_writel(~0, &g->set_falling); 365 __raw_writel(~0, &g->set_falling);
372 __raw_writel(~0, &g->set_rising); 366 __raw_writel(~0, &g->set_rising);
373 367
@@ -392,7 +386,7 @@ static int __init davinci_gpio_irq_setup(void)
392 unsigned i; 386 unsigned i;
393 387
394 /* disabled by default, enabled only as needed */ 388 /* disabled by default, enabled only as needed */
395 g = gpio2controller(gpio); 389 g = gpio2regs(gpio);
396 __raw_writel(~0, &g->clr_falling); 390 __raw_writel(~0, &g->clr_falling);
397 __raw_writel(~0, &g->clr_rising); 391 __raw_writel(~0, &g->clr_rising);
398 392
diff --git a/arch/arm/mach-davinci/include/mach/gpio.h b/arch/arm/mach-davinci/include/mach/gpio.h
index 0099e6e5aff8..bdab001950ba 100644
--- a/arch/arm/mach-davinci/include/mach/gpio.h
+++ b/arch/arm/mach-davinci/include/mach/gpio.h
@@ -45,7 +45,7 @@
45/* Convert GPIO signal to GPIO pin number */ 45/* Convert GPIO signal to GPIO pin number */
46#define GPIO_TO_PIN(bank, gpio) (16 * (bank) + (gpio)) 46#define GPIO_TO_PIN(bank, gpio) (16 * (bank) + (gpio))
47 47
48struct gpio_controller { 48struct davinci_gpio_regs {
49 u32 dir; 49 u32 dir;
50 u32 out_data; 50 u32 out_data;
51 u32 set_data; 51 u32 set_data;
@@ -58,6 +58,12 @@ struct gpio_controller {
58 u32 intstat; 58 u32 intstat;
59}; 59};
60 60
61struct davinci_gpio_controller {
62 struct davinci_gpio_regs __iomem *regs;
63 struct gpio_chip chip;
64 int irq_base;
65};
66
61/* The __gpio_to_controller() and __gpio_mask() functions inline to constants 67/* The __gpio_to_controller() and __gpio_mask() functions inline to constants
62 * with constant parameters; or in outlined code they execute at runtime. 68 * with constant parameters; or in outlined code they execute at runtime.
63 * 69 *
@@ -67,7 +73,7 @@ struct gpio_controller {
67 * 73 *
68 * These are NOT part of the cross-platform GPIO interface 74 * These are NOT part of the cross-platform GPIO interface
69 */ 75 */
70static inline struct gpio_controller __iomem * 76static inline struct davinci_gpio_regs __iomem *
71__gpio_to_controller(unsigned gpio) 77__gpio_to_controller(unsigned gpio)
72{ 78{
73 void __iomem *ptr; 79 void __iomem *ptr;
@@ -102,7 +108,7 @@ static inline u32 __gpio_mask(unsigned gpio)
102static inline void gpio_set_value(unsigned gpio, int value) 108static inline void gpio_set_value(unsigned gpio, int value)
103{ 109{
104 if (__builtin_constant_p(value) && gpio < DAVINCI_N_GPIO) { 110 if (__builtin_constant_p(value) && gpio < DAVINCI_N_GPIO) {
105 struct gpio_controller __iomem *g; 111 struct davinci_gpio_regs __iomem *g;
106 u32 mask; 112 u32 mask;
107 113
108 g = __gpio_to_controller(gpio); 114 g = __gpio_to_controller(gpio);
@@ -128,7 +134,7 @@ static inline void gpio_set_value(unsigned gpio, int value)
128 */ 134 */
129static inline int gpio_get_value(unsigned gpio) 135static inline int gpio_get_value(unsigned gpio)
130{ 136{
131 struct gpio_controller __iomem *g; 137 struct davinci_gpio_regs __iomem *g;
132 138
133 if (!__builtin_constant_p(gpio) || gpio >= DAVINCI_N_GPIO) 139 if (!__builtin_constant_p(gpio) || gpio >= DAVINCI_N_GPIO)
134 return __gpio_get_value(gpio); 140 return __gpio_get_value(gpio);