aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-arm
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-arm')
-rw-r--r--include/asm-arm/arch-omap/gpio.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/include/asm-arm/arch-omap/gpio.h b/include/asm-arm/arch-omap/gpio.h
index f486b72070e..3762a6ae6a7 100644
--- a/include/asm-arm/arch-omap/gpio.h
+++ b/include/asm-arm/arch-omap/gpio.h
@@ -76,4 +76,70 @@ extern void omap_set_gpio_direction(int gpio, int is_input);
76extern void omap_set_gpio_dataout(int gpio, int enable); 76extern void omap_set_gpio_dataout(int gpio, int enable);
77extern int omap_get_gpio_datain(int gpio); 77extern int omap_get_gpio_datain(int gpio);
78 78
79/*-------------------------------------------------------------------------*/
80
81/* wrappers for "new style" GPIO calls. the old OMAP-specfic ones should
82 * eventually be removed (along with this errno.h inclusion), and maybe
83 * gpios should put MPUIOs last too.
84 */
85
86#include <asm/errno.h>
87
88static inline int gpio_request(unsigned gpio, const char *label)
89{
90 return omap_request_gpio(gpio);
91}
92
93static inline void gpio_free(unsigned gpio)
94{
95 omap_free_gpio(gpio);
96}
97
98static inline int __gpio_set_direction(unsigned gpio, int is_input)
99{
100 if (cpu_class_is_omap2()) {
101 if (gpio > OMAP_MAX_GPIO_LINES)
102 return -EINVAL;
103 } else {
104 if (gpio > (OMAP_MAX_GPIO_LINES + 16 /* MPUIO */))
105 return -EINVAL;
106 }
107 omap_set_gpio_direction(gpio, is_input);
108 return 0;
109}
110
111static inline int gpio_direction_input(unsigned gpio)
112{
113 return __gpio_set_direction(gpio, 1);
114}
115
116static inline int gpio_direction_output(unsigned gpio)
117{
118 return __gpio_set_direction(gpio, 0);
119}
120
121static inline int gpio_get_value(unsigned gpio)
122{
123 return omap_get_gpio_datain(gpio);
124}
125
126static inline void gpio_set_value(unsigned gpio, int value)
127{
128 omap_set_gpio_dataout(gpio, value);
129}
130
131#include <asm-generic/gpio.h> /* cansleep wrappers */
132
133static inline int gpio_to_irq(unsigned gpio)
134{
135 return OMAP_GPIO_IRQ(gpio);
136}
137
138static inline int irq_to_gpio(unsigned irq)
139{
140 if (cpu_class_is_omap1() && (irq < (IH_MPUIO_BASE + 16)))
141 return (irq - IH_MPUIO_BASE) + OMAP_MAX_GPIO_LINES;
142 return irq - IH_GPIO_BASE;
143}
144
79#endif 145#endif