Lines Matching +full:gpio +full:-

2  * GPIO functions for Au1000, Au1500, Au1100, Au1550, Au1200
12 #include <asm/mach-au1x00/au1000.h>
14 /* The default GPIO numberspace as documented in the Alchemy manuals.
15 * GPIO0-31 from GPIO1 block, GPIO200-215 from GPIO2 block.
22 #define ALCHEMY_GPIO1_MAX (ALCHEMY_GPIO1_BASE + ALCHEMY_GPIO1_NUM - 1)
23 #define ALCHEMY_GPIO2_MAX (ALCHEMY_GPIO2_BASE + ALCHEMY_GPIO2_NUM - 1)
43 struct gpio;
45 static inline int au1000_gpio1_to_irq(int gpio) in au1000_gpio1_to_irq() argument
47 return MAKE_IRQ(1, gpio - ALCHEMY_GPIO1_BASE); in au1000_gpio1_to_irq()
50 static inline int au1000_gpio2_to_irq(int gpio) in au1000_gpio2_to_irq() argument
52 return -ENXIO; in au1000_gpio2_to_irq()
58 return ALCHEMY_GPIO1_BASE + (irq - AU1000_GPIO0_INT) + 0; in au1000_irq_to_gpio()
60 return -ENXIO; in au1000_irq_to_gpio()
63 static inline int au1500_gpio1_to_irq(int gpio) in au1500_gpio1_to_irq() argument
65 gpio -= ALCHEMY_GPIO1_BASE; in au1500_gpio1_to_irq()
67 switch (gpio) { in au1500_gpio1_to_irq()
70 case 23 ... 28: return MAKE_IRQ(1, gpio); in au1500_gpio1_to_irq()
73 return -ENXIO; in au1500_gpio1_to_irq()
76 static inline int au1500_gpio2_to_irq(int gpio) in au1500_gpio2_to_irq() argument
78 gpio -= ALCHEMY_GPIO2_BASE; in au1500_gpio2_to_irq()
80 switch (gpio) { in au1500_gpio2_to_irq()
81 case 0 ... 3: return MAKE_IRQ(1, 16 + gpio - 0); in au1500_gpio2_to_irq()
82 case 4 ... 5: return MAKE_IRQ(1, 21 + gpio - 4); in au1500_gpio2_to_irq()
83 case 6 ... 7: return MAKE_IRQ(1, 29 + gpio - 6); in au1500_gpio2_to_irq()
86 return -ENXIO; in au1500_gpio2_to_irq()
95 return ALCHEMY_GPIO1_BASE + (irq - AU1500_GPIO0_INT) + 0; in au1500_irq_to_gpio()
97 return ALCHEMY_GPIO2_BASE + (irq - AU1500_GPIO200_INT) + 0; in au1500_irq_to_gpio()
99 return ALCHEMY_GPIO2_BASE + (irq - AU1500_GPIO204_INT) + 4; in au1500_irq_to_gpio()
101 return ALCHEMY_GPIO2_BASE + (irq - AU1500_GPIO206_INT) + 6; in au1500_irq_to_gpio()
106 return -ENXIO; in au1500_irq_to_gpio()
109 static inline int au1100_gpio1_to_irq(int gpio) in au1100_gpio1_to_irq() argument
111 return MAKE_IRQ(1, gpio - ALCHEMY_GPIO1_BASE); in au1100_gpio1_to_irq()
114 static inline int au1100_gpio2_to_irq(int gpio) in au1100_gpio2_to_irq() argument
116 gpio -= ALCHEMY_GPIO2_BASE; in au1100_gpio2_to_irq()
118 if ((gpio >= 8) && (gpio <= 15)) in au1100_gpio2_to_irq()
121 return -ENXIO; in au1100_gpio2_to_irq()
128 return ALCHEMY_GPIO1_BASE + (irq - AU1100_GPIO0_INT) + 0; in au1100_irq_to_gpio()
133 return -ENXIO; in au1100_irq_to_gpio()
136 static inline int au1550_gpio1_to_irq(int gpio) in au1550_gpio1_to_irq() argument
138 gpio -= ALCHEMY_GPIO1_BASE; in au1550_gpio1_to_irq()
140 switch (gpio) { in au1550_gpio1_to_irq()
142 case 20 ... 28: return MAKE_IRQ(1, gpio); in au1550_gpio1_to_irq()
143 case 16 ... 17: return MAKE_IRQ(1, 18 + gpio - 16); in au1550_gpio1_to_irq()
146 return -ENXIO; in au1550_gpio1_to_irq()
149 static inline int au1550_gpio2_to_irq(int gpio) in au1550_gpio2_to_irq() argument
151 gpio -= ALCHEMY_GPIO2_BASE; in au1550_gpio2_to_irq()
153 switch (gpio) { in au1550_gpio2_to_irq()
156 case 6 ... 7: return MAKE_IRQ(1, 29 + gpio - 6); in au1550_gpio2_to_irq()
160 return -ENXIO; in au1550_gpio2_to_irq()
167 return ALCHEMY_GPIO1_BASE + (irq - AU1550_GPIO0_INT) + 0; in au1550_irq_to_gpio()
170 return ALCHEMY_GPIO2_BASE + (irq - AU1550_GPIO200_INT) + 0; in au1550_irq_to_gpio()
172 return ALCHEMY_GPIO1_BASE + (irq - AU1550_GPIO16_INT) + 16; in au1550_irq_to_gpio()
174 return ALCHEMY_GPIO2_BASE + (irq - AU1550_GPIO206_INT) + 6; in au1550_irq_to_gpio()
177 return -ENXIO; in au1550_irq_to_gpio()
180 static inline int au1200_gpio1_to_irq(int gpio) in au1200_gpio1_to_irq() argument
182 return MAKE_IRQ(1, gpio - ALCHEMY_GPIO1_BASE); in au1200_gpio1_to_irq()
185 static inline int au1200_gpio2_to_irq(int gpio) in au1200_gpio2_to_irq() argument
187 gpio -= ALCHEMY_GPIO2_BASE; in au1200_gpio2_to_irq()
189 switch (gpio) { in au1200_gpio2_to_irq()
190 case 0 ... 2: return MAKE_IRQ(0, 5 + gpio - 0); in au1200_gpio2_to_irq()
192 case 4 ... 7: return MAKE_IRQ(0, 24 + gpio - 4); in au1200_gpio2_to_irq()
196 return -ENXIO; in au1200_gpio2_to_irq()
203 return ALCHEMY_GPIO1_BASE + (irq - AU1200_GPIO0_INT) + 0; in au1200_irq_to_gpio()
205 return ALCHEMY_GPIO2_BASE + (irq - AU1200_GPIO200_INT) + 0; in au1200_irq_to_gpio()
209 return ALCHEMY_GPIO2_BASE + (irq - AU1200_GPIO204_INT) + 4; in au1200_irq_to_gpio()
212 return -ENXIO; in au1200_irq_to_gpio()
216 * GPIO1 block macros for common linux gpio functions.
218 static inline void alchemy_gpio1_set_value(int gpio, int v) in alchemy_gpio1_set_value() argument
220 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); in alchemy_gpio1_set_value()
225 static inline int alchemy_gpio1_get_value(int gpio) in alchemy_gpio1_get_value() argument
227 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); in alchemy_gpio1_get_value()
231 static inline int alchemy_gpio1_direction_input(int gpio) in alchemy_gpio1_direction_input() argument
233 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); in alchemy_gpio1_direction_input()
238 static inline int alchemy_gpio1_direction_output(int gpio, int v) in alchemy_gpio1_direction_output() argument
243 alchemy_gpio1_set_value(gpio, v); in alchemy_gpio1_direction_output()
247 static inline int alchemy_gpio1_is_valid(int gpio) in alchemy_gpio1_is_valid() argument
249 return ((gpio >= ALCHEMY_GPIO1_BASE) && (gpio <= ALCHEMY_GPIO1_MAX)); in alchemy_gpio1_is_valid()
252 static inline int alchemy_gpio1_to_irq(int gpio) in alchemy_gpio1_to_irq() argument
256 return au1000_gpio1_to_irq(gpio); in alchemy_gpio1_to_irq()
258 return au1100_gpio1_to_irq(gpio); in alchemy_gpio1_to_irq()
260 return au1500_gpio1_to_irq(gpio); in alchemy_gpio1_to_irq()
262 return au1550_gpio1_to_irq(gpio); in alchemy_gpio1_to_irq()
264 return au1200_gpio1_to_irq(gpio); in alchemy_gpio1_to_irq()
266 return -ENXIO; in alchemy_gpio1_to_irq()
281 * GPIO2 block macros for common linux GPIO functions. The 'gpio'
284 static inline void __alchemy_gpio2_mod_dir(int gpio, int to_out) in __alchemy_gpio2_mod_dir() argument
287 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO2_BASE); in __alchemy_gpio2_mod_dir()
298 static inline void alchemy_gpio2_set_value(int gpio, int v) in alchemy_gpio2_set_value() argument
302 mask = ((v) ? 0x00010001 : 0x00010000) << (gpio - ALCHEMY_GPIO2_BASE); in alchemy_gpio2_set_value()
307 static inline int alchemy_gpio2_get_value(int gpio) in alchemy_gpio2_get_value() argument
311 (1 << (gpio - ALCHEMY_GPIO2_BASE)); in alchemy_gpio2_get_value()
314 static inline int alchemy_gpio2_direction_input(int gpio) in alchemy_gpio2_direction_input() argument
318 __alchemy_gpio2_mod_dir(gpio, 0); in alchemy_gpio2_direction_input()
323 static inline int alchemy_gpio2_direction_output(int gpio, int v) in alchemy_gpio2_direction_output() argument
326 alchemy_gpio2_set_value(gpio, v); in alchemy_gpio2_direction_output()
328 __alchemy_gpio2_mod_dir(gpio, 1); in alchemy_gpio2_direction_output()
333 static inline int alchemy_gpio2_is_valid(int gpio) in alchemy_gpio2_is_valid() argument
335 return ((gpio >= ALCHEMY_GPIO2_BASE) && (gpio <= ALCHEMY_GPIO2_MAX)); in alchemy_gpio2_is_valid()
338 static inline int alchemy_gpio2_to_irq(int gpio) in alchemy_gpio2_to_irq() argument
342 return au1000_gpio2_to_irq(gpio); in alchemy_gpio2_to_irq()
344 return au1100_gpio2_to_irq(gpio); in alchemy_gpio2_to_irq()
346 return au1500_gpio2_to_irq(gpio); in alchemy_gpio2_to_irq()
348 return au1550_gpio2_to_irq(gpio); in alchemy_gpio2_to_irq()
350 return au1200_gpio2_to_irq(gpio); in alchemy_gpio2_to_irq()
352 return -ENXIO; in alchemy_gpio2_to_irq()
372 * alchemy_gpio2_enable_int - Enable a GPIO2 pins' shared irq contribution.
375 * GPIO208-215 have one shared interrupt line to the INTC. They are
376 * and'ed with a per-pin enable bit and finally or'ed together to form
377 * a single irq request (useful for active-high sources).
379 * can be enabled. As with all other GPIO-based interrupts, the INTC
382 * NOTE: Calling this macro is only necessary for GPIO208-215; all other
383 * GPIO2-based interrupts have their own request to the INTC. Please
386 * NOTE: On the Au1550, GPIOs 201-205 also have a shared interrupt request
391 * (200-215 by default). No sanity checks are made,
397 gpio2 -= ALCHEMY_GPIO2_BASE; in alchemy_gpio2_enable_int()
399 /* Au1100/Au1500 have GPIO208-215 enable bits at 0..7 */ in alchemy_gpio2_enable_int()
403 gpio2 -= 8; in alchemy_gpio2_enable_int()
412 * alchemy_gpio2_disable_int - Disable a GPIO2 pins' shared irq contribution.
421 gpio2 -= ALCHEMY_GPIO2_BASE; in alchemy_gpio2_disable_int()
423 /* Au1100/Au1500 have GPIO208-215 enable bits at 0..7 */ in alchemy_gpio2_disable_int()
427 gpio2 -= 8; in alchemy_gpio2_disable_int()
436 * alchemy_gpio2_enable - Activate GPIO2 block.
451 * alchemy_gpio2_disable - disable GPIO2 block.
453 * Disable and put GPIO2 block in low-power mode.
464 /* wrappers for on-chip gpios; can be used before gpio chips have been
467 static inline int alchemy_gpio_direction_input(int gpio) in alchemy_gpio_direction_input() argument
469 return (gpio >= ALCHEMY_GPIO2_BASE) ? in alchemy_gpio_direction_input()
470 alchemy_gpio2_direction_input(gpio) : in alchemy_gpio_direction_input()
471 alchemy_gpio1_direction_input(gpio); in alchemy_gpio_direction_input()
474 static inline int alchemy_gpio_direction_output(int gpio, int v) in alchemy_gpio_direction_output() argument
476 return (gpio >= ALCHEMY_GPIO2_BASE) ? in alchemy_gpio_direction_output()
477 alchemy_gpio2_direction_output(gpio, v) : in alchemy_gpio_direction_output()
478 alchemy_gpio1_direction_output(gpio, v); in alchemy_gpio_direction_output()
481 static inline int alchemy_gpio_get_value(int gpio) in alchemy_gpio_get_value() argument
483 return (gpio >= ALCHEMY_GPIO2_BASE) ? in alchemy_gpio_get_value()
484 alchemy_gpio2_get_value(gpio) : in alchemy_gpio_get_value()
485 alchemy_gpio1_get_value(gpio); in alchemy_gpio_get_value()
488 static inline void alchemy_gpio_set_value(int gpio, int v) in alchemy_gpio_set_value() argument
490 if (gpio >= ALCHEMY_GPIO2_BASE) in alchemy_gpio_set_value()
491 alchemy_gpio2_set_value(gpio, v); in alchemy_gpio_set_value()
493 alchemy_gpio1_set_value(gpio, v); in alchemy_gpio_set_value()
496 static inline int alchemy_gpio_is_valid(int gpio) in alchemy_gpio_is_valid() argument
498 return (gpio >= ALCHEMY_GPIO2_BASE) ? in alchemy_gpio_is_valid()
499 alchemy_gpio2_is_valid(gpio) : in alchemy_gpio_is_valid()
500 alchemy_gpio1_is_valid(gpio); in alchemy_gpio_is_valid()
503 static inline int alchemy_gpio_to_irq(int gpio) in alchemy_gpio_to_irq() argument
505 return (gpio >= ALCHEMY_GPIO2_BASE) ? in alchemy_gpio_to_irq()
506 alchemy_gpio2_to_irq(gpio) : in alchemy_gpio_to_irq()
507 alchemy_gpio1_to_irq(gpio); in alchemy_gpio_to_irq()
524 return -ENXIO; in alchemy_irq_to_gpio()