diff options
Diffstat (limited to 'include/asm-arm/arch-omap')
-rw-r--r-- | include/asm-arm/arch-omap/gpio.h | 66 |
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 f486b72070ea..3762a6ae6a7f 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); | |||
76 | extern void omap_set_gpio_dataout(int gpio, int enable); | 76 | extern void omap_set_gpio_dataout(int gpio, int enable); |
77 | extern int omap_get_gpio_datain(int gpio); | 77 | extern 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 | |||
88 | static inline int gpio_request(unsigned gpio, const char *label) | ||
89 | { | ||
90 | return omap_request_gpio(gpio); | ||
91 | } | ||
92 | |||
93 | static inline void gpio_free(unsigned gpio) | ||
94 | { | ||
95 | omap_free_gpio(gpio); | ||
96 | } | ||
97 | |||
98 | static 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 | |||
111 | static inline int gpio_direction_input(unsigned gpio) | ||
112 | { | ||
113 | return __gpio_set_direction(gpio, 1); | ||
114 | } | ||
115 | |||
116 | static inline int gpio_direction_output(unsigned gpio) | ||
117 | { | ||
118 | return __gpio_set_direction(gpio, 0); | ||
119 | } | ||
120 | |||
121 | static inline int gpio_get_value(unsigned gpio) | ||
122 | { | ||
123 | return omap_get_gpio_datain(gpio); | ||
124 | } | ||
125 | |||
126 | static 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 | |||
133 | static inline int gpio_to_irq(unsigned gpio) | ||
134 | { | ||
135 | return OMAP_GPIO_IRQ(gpio); | ||
136 | } | ||
137 | |||
138 | static 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 |