aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/include/asm/mach-au1x00/gpio-au1000.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/include/asm/mach-au1x00/gpio-au1000.h')
-rw-r--r--arch/mips/include/asm/mach-au1x00/gpio-au1000.h164
1 files changed, 80 insertions, 84 deletions
diff --git a/arch/mips/include/asm/mach-au1x00/gpio-au1000.h b/arch/mips/include/asm/mach-au1x00/gpio-au1000.h
index 91595fa8903..62d2f136d94 100644
--- a/arch/mips/include/asm/mach-au1x00/gpio-au1000.h
+++ b/arch/mips/include/asm/mach-au1x00/gpio-au1000.h
@@ -35,15 +35,13 @@ static inline int au1000_gpio2_to_irq(int gpio)
35 return -ENXIO; 35 return -ENXIO;
36} 36}
37 37
38#ifdef CONFIG_SOC_AU1000
39static inline int au1000_irq_to_gpio(int irq) 38static inline int au1000_irq_to_gpio(int irq)
40{ 39{
41 if ((irq >= AU1000_GPIO_0) && (irq <= AU1000_GPIO_31)) 40 if ((irq >= AU1000_GPIO0_INT) && (irq <= AU1000_GPIO31_INT))
42 return ALCHEMY_GPIO1_BASE + (irq - AU1000_GPIO_0) + 0; 41 return ALCHEMY_GPIO1_BASE + (irq - AU1000_GPIO0_INT) + 0;
43 42
44 return -ENXIO; 43 return -ENXIO;
45} 44}
46#endif
47 45
48static inline int au1500_gpio1_to_irq(int gpio) 46static inline int au1500_gpio1_to_irq(int gpio)
49{ 47{
@@ -71,27 +69,25 @@ static inline int au1500_gpio2_to_irq(int gpio)
71 return -ENXIO; 69 return -ENXIO;
72} 70}
73 71
74#ifdef CONFIG_SOC_AU1500
75static inline int au1500_irq_to_gpio(int irq) 72static inline int au1500_irq_to_gpio(int irq)
76{ 73{
77 switch (irq) { 74 switch (irq) {
78 case AU1000_GPIO_0 ... AU1000_GPIO_15: 75 case AU1500_GPIO0_INT ... AU1500_GPIO15_INT:
79 case AU1500_GPIO_20: 76 case AU1500_GPIO20_INT:
80 case AU1500_GPIO_23 ... AU1500_GPIO_28: 77 case AU1500_GPIO23_INT ... AU1500_GPIO28_INT:
81 return ALCHEMY_GPIO1_BASE + (irq - AU1000_GPIO_0) + 0; 78 return ALCHEMY_GPIO1_BASE + (irq - AU1500_GPIO0_INT) + 0;
82 case AU1500_GPIO_200 ... AU1500_GPIO_203: 79 case AU1500_GPIO200_INT ... AU1500_GPIO203_INT:
83 return ALCHEMY_GPIO2_BASE + (irq - AU1500_GPIO_200) + 0; 80 return ALCHEMY_GPIO2_BASE + (irq - AU1500_GPIO200_INT) + 0;
84 case AU1500_GPIO_204 ... AU1500_GPIO_205: 81 case AU1500_GPIO204_INT ... AU1500_GPIO205_INT:
85 return ALCHEMY_GPIO2_BASE + (irq - AU1500_GPIO_204) + 4; 82 return ALCHEMY_GPIO2_BASE + (irq - AU1500_GPIO204_INT) + 4;
86 case AU1500_GPIO_206 ... AU1500_GPIO_207: 83 case AU1500_GPIO206_INT ... AU1500_GPIO207_INT:
87 return ALCHEMY_GPIO2_BASE + (irq - AU1500_GPIO_206) + 6; 84 return ALCHEMY_GPIO2_BASE + (irq - AU1500_GPIO206_INT) + 6;
88 case AU1500_GPIO_208_215: 85 case AU1500_GPIO208_215_INT:
89 return ALCHEMY_GPIO2_BASE + 8; 86 return ALCHEMY_GPIO2_BASE + 8;
90 } 87 }
91 88
92 return -ENXIO; 89 return -ENXIO;
93} 90}
94#endif
95 91
96static inline int au1100_gpio1_to_irq(int gpio) 92static inline int au1100_gpio1_to_irq(int gpio)
97{ 93{
@@ -108,19 +104,17 @@ static inline int au1100_gpio2_to_irq(int gpio)
108 return -ENXIO; 104 return -ENXIO;
109} 105}
110 106
111#ifdef CONFIG_SOC_AU1100
112static inline int au1100_irq_to_gpio(int irq) 107static inline int au1100_irq_to_gpio(int irq)
113{ 108{
114 switch (irq) { 109 switch (irq) {
115 case AU1000_GPIO_0 ... AU1000_GPIO_31: 110 case AU1100_GPIO0_INT ... AU1100_GPIO31_INT:
116 return ALCHEMY_GPIO1_BASE + (irq - AU1000_GPIO_0) + 0; 111 return ALCHEMY_GPIO1_BASE + (irq - AU1100_GPIO0_INT) + 0;
117 case AU1100_GPIO_208_215: 112 case AU1100_GPIO208_215_INT:
118 return ALCHEMY_GPIO2_BASE + 8; 113 return ALCHEMY_GPIO2_BASE + 8;
119 } 114 }
120 115
121 return -ENXIO; 116 return -ENXIO;
122} 117}
123#endif
124 118
125static inline int au1550_gpio1_to_irq(int gpio) 119static inline int au1550_gpio1_to_irq(int gpio)
126{ 120{
@@ -149,24 +143,22 @@ static inline int au1550_gpio2_to_irq(int gpio)
149 return -ENXIO; 143 return -ENXIO;
150} 144}
151 145
152#ifdef CONFIG_SOC_AU1550
153static inline int au1550_irq_to_gpio(int irq) 146static inline int au1550_irq_to_gpio(int irq)
154{ 147{
155 switch (irq) { 148 switch (irq) {
156 case AU1000_GPIO_0 ... AU1000_GPIO_15: 149 case AU1550_GPIO0_INT ... AU1550_GPIO15_INT:
157 return ALCHEMY_GPIO1_BASE + (irq - AU1000_GPIO_0) + 0; 150 return ALCHEMY_GPIO1_BASE + (irq - AU1550_GPIO0_INT) + 0;
158 case AU1550_GPIO_200: 151 case AU1550_GPIO200_INT:
159 case AU1500_GPIO_201_205: 152 case AU1550_GPIO201_205_INT:
160 return ALCHEMY_GPIO2_BASE + (irq - AU1550_GPIO_200) + 0; 153 return ALCHEMY_GPIO2_BASE + (irq - AU1550_GPIO200_INT) + 0;
161 case AU1500_GPIO_16 ... AU1500_GPIO_28: 154 case AU1550_GPIO16_INT ... AU1550_GPIO28_INT:
162 return ALCHEMY_GPIO1_BASE + (irq - AU1500_GPIO_16) + 16; 155 return ALCHEMY_GPIO1_BASE + (irq - AU1550_GPIO16_INT) + 16;
163 case AU1500_GPIO_206 ... AU1500_GPIO_208_218: 156 case AU1550_GPIO206_INT ... AU1550_GPIO208_215_INT:
164 return ALCHEMY_GPIO2_BASE + (irq - AU1500_GPIO_206) + 6; 157 return ALCHEMY_GPIO2_BASE + (irq - AU1550_GPIO206_INT) + 6;
165 } 158 }
166 159
167 return -ENXIO; 160 return -ENXIO;
168} 161}
169#endif
170 162
171static inline int au1200_gpio1_to_irq(int gpio) 163static inline int au1200_gpio1_to_irq(int gpio)
172{ 164{
@@ -187,23 +179,21 @@ static inline int au1200_gpio2_to_irq(int gpio)
187 return -ENXIO; 179 return -ENXIO;
188} 180}
189 181
190#ifdef CONFIG_SOC_AU1200
191static inline int au1200_irq_to_gpio(int irq) 182static inline int au1200_irq_to_gpio(int irq)
192{ 183{
193 switch (irq) { 184 switch (irq) {
194 case AU1000_GPIO_0 ... AU1000_GPIO_31: 185 case AU1200_GPIO0_INT ... AU1200_GPIO31_INT:
195 return ALCHEMY_GPIO1_BASE + (irq - AU1000_GPIO_0) + 0; 186 return ALCHEMY_GPIO1_BASE + (irq - AU1200_GPIO0_INT) + 0;
196 case AU1200_GPIO_200 ... AU1200_GPIO_202: 187 case AU1200_GPIO200_INT ... AU1200_GPIO202_INT:
197 return ALCHEMY_GPIO2_BASE + (irq - AU1200_GPIO_200) + 0; 188 return ALCHEMY_GPIO2_BASE + (irq - AU1200_GPIO200_INT) + 0;
198 case AU1200_GPIO_203: 189 case AU1200_GPIO203_INT:
199 return ALCHEMY_GPIO2_BASE + 3; 190 return ALCHEMY_GPIO2_BASE + 3;
200 case AU1200_GPIO_204 ... AU1200_GPIO_208_215: 191 case AU1200_GPIO204_INT ... AU1200_GPIO208_215_INT:
201 return ALCHEMY_GPIO2_BASE + (irq - AU1200_GPIO_204) + 4; 192 return ALCHEMY_GPIO2_BASE + (irq - AU1200_GPIO204_INT) + 4;
202 } 193 }
203 194
204 return -ENXIO; 195 return -ENXIO;
205} 196}
206#endif
207 197
208/* 198/*
209 * GPIO1 block macros for common linux gpio functions. 199 * GPIO1 block macros for common linux gpio functions.
@@ -246,19 +236,19 @@ static inline int alchemy_gpio1_is_valid(int gpio)
246 236
247static inline int alchemy_gpio1_to_irq(int gpio) 237static inline int alchemy_gpio1_to_irq(int gpio)
248{ 238{
249#if defined(CONFIG_SOC_AU1000) 239 switch (alchemy_get_cputype()) {
250 return au1000_gpio1_to_irq(gpio); 240 case ALCHEMY_CPU_AU1000:
251#elif defined(CONFIG_SOC_AU1100) 241 return au1000_gpio1_to_irq(gpio);
252 return au1100_gpio1_to_irq(gpio); 242 case ALCHEMY_CPU_AU1100:
253#elif defined(CONFIG_SOC_AU1500) 243 return au1100_gpio1_to_irq(gpio);
254 return au1500_gpio1_to_irq(gpio); 244 case ALCHEMY_CPU_AU1500:
255#elif defined(CONFIG_SOC_AU1550) 245 return au1500_gpio1_to_irq(gpio);
256 return au1550_gpio1_to_irq(gpio); 246 case ALCHEMY_CPU_AU1550:
257#elif defined(CONFIG_SOC_AU1200) 247 return au1550_gpio1_to_irq(gpio);
258 return au1200_gpio1_to_irq(gpio); 248 case ALCHEMY_CPU_AU1200:
259#else 249 return au1200_gpio1_to_irq(gpio);
250 }
260 return -ENXIO; 251 return -ENXIO;
261#endif
262} 252}
263 253
264/* 254/*
@@ -316,19 +306,19 @@ static inline int alchemy_gpio2_is_valid(int gpio)
316 306
317static inline int alchemy_gpio2_to_irq(int gpio) 307static inline int alchemy_gpio2_to_irq(int gpio)
318{ 308{
319#if defined(CONFIG_SOC_AU1000) 309 switch (alchemy_get_cputype()) {
320 return au1000_gpio2_to_irq(gpio); 310 case ALCHEMY_CPU_AU1000:
321#elif defined(CONFIG_SOC_AU1100) 311 return au1000_gpio2_to_irq(gpio);
322 return au1100_gpio2_to_irq(gpio); 312 case ALCHEMY_CPU_AU1100:
323#elif defined(CONFIG_SOC_AU1500) 313 return au1100_gpio2_to_irq(gpio);
324 return au1500_gpio2_to_irq(gpio); 314 case ALCHEMY_CPU_AU1500:
325#elif defined(CONFIG_SOC_AU1550) 315 return au1500_gpio2_to_irq(gpio);
326 return au1550_gpio2_to_irq(gpio); 316 case ALCHEMY_CPU_AU1550:
327#elif defined(CONFIG_SOC_AU1200) 317 return au1550_gpio2_to_irq(gpio);
328 return au1200_gpio2_to_irq(gpio); 318 case ALCHEMY_CPU_AU1200:
329#else 319 return au1200_gpio2_to_irq(gpio);
320 }
330 return -ENXIO; 321 return -ENXIO;
331#endif
332} 322}
333 323
334/**********************************************************************/ 324/**********************************************************************/
@@ -384,10 +374,13 @@ static inline void alchemy_gpio2_enable_int(int gpio2)
384 374
385 gpio2 -= ALCHEMY_GPIO2_BASE; 375 gpio2 -= ALCHEMY_GPIO2_BASE;
386 376
387#if defined(CONFIG_SOC_AU1100) || defined(CONFIG_SOC_AU1500)
388 /* Au1100/Au1500 have GPIO208-215 enable bits at 0..7 */ 377 /* Au1100/Au1500 have GPIO208-215 enable bits at 0..7 */
389 gpio2 -= 8; 378 switch (alchemy_get_cputype()) {
390#endif 379 case ALCHEMY_CPU_AU1100:
380 case ALCHEMY_CPU_AU1500:
381 gpio2 -= 8;
382 }
383
391 local_irq_save(flags); 384 local_irq_save(flags);
392 __alchemy_gpio2_mod_int(gpio2, 1); 385 __alchemy_gpio2_mod_int(gpio2, 1);
393 local_irq_restore(flags); 386 local_irq_restore(flags);
@@ -405,10 +398,13 @@ static inline void alchemy_gpio2_disable_int(int gpio2)
405 398
406 gpio2 -= ALCHEMY_GPIO2_BASE; 399 gpio2 -= ALCHEMY_GPIO2_BASE;
407 400
408#if defined(CONFIG_SOC_AU1100) || defined(CONFIG_SOC_AU1500)
409 /* Au1100/Au1500 have GPIO208-215 enable bits at 0..7 */ 401 /* Au1100/Au1500 have GPIO208-215 enable bits at 0..7 */
410 gpio2 -= 8; 402 switch (alchemy_get_cputype()) {
411#endif 403 case ALCHEMY_CPU_AU1100:
404 case ALCHEMY_CPU_AU1500:
405 gpio2 -= 8;
406 }
407
412 local_irq_save(flags); 408 local_irq_save(flags);
413 __alchemy_gpio2_mod_int(gpio2, 0); 409 __alchemy_gpio2_mod_int(gpio2, 0);
414 local_irq_restore(flags); 410 local_irq_restore(flags);
@@ -494,19 +490,19 @@ static inline int alchemy_gpio_to_irq(int gpio)
494 490
495static inline int alchemy_irq_to_gpio(int irq) 491static inline int alchemy_irq_to_gpio(int irq)
496{ 492{
497#if defined(CONFIG_SOC_AU1000) 493 switch (alchemy_get_cputype()) {
498 return au1000_irq_to_gpio(irq); 494 case ALCHEMY_CPU_AU1000:
499#elif defined(CONFIG_SOC_AU1100) 495 return au1000_irq_to_gpio(irq);
500 return au1100_irq_to_gpio(irq); 496 case ALCHEMY_CPU_AU1100:
501#elif defined(CONFIG_SOC_AU1500) 497 return au1100_irq_to_gpio(irq);
502 return au1500_irq_to_gpio(irq); 498 case ALCHEMY_CPU_AU1500:
503#elif defined(CONFIG_SOC_AU1550) 499 return au1500_irq_to_gpio(irq);
504 return au1550_irq_to_gpio(irq); 500 case ALCHEMY_CPU_AU1550:
505#elif defined(CONFIG_SOC_AU1200) 501 return au1550_irq_to_gpio(irq);
506 return au1200_irq_to_gpio(irq); 502 case ALCHEMY_CPU_AU1200:
507#else 503 return au1200_irq_to_gpio(irq);
504 }
508 return -ENXIO; 505 return -ENXIO;
509#endif
510} 506}
511 507
512/**********************************************************************/ 508/**********************************************************************/