.. | .. |
---|
120 | 120 | return (v >> gpio) & 1; |
---|
121 | 121 | } |
---|
122 | 122 | |
---|
123 | | -/**********************************************************************/ |
---|
124 | | - |
---|
125 | | -/* Linux gpio framework integration. |
---|
126 | | -* |
---|
127 | | -* 4 use cases of Alchemy GPIOS: |
---|
128 | | -*(1) GPIOLIB=y, ALCHEMY_GPIO_INDIRECT=y: |
---|
129 | | -* Board must register gpiochips. |
---|
130 | | -*(2) GPIOLIB=y, ALCHEMY_GPIO_INDIRECT=n: |
---|
131 | | -* A gpiochip for the 75 GPIOs is registered. |
---|
132 | | -* |
---|
133 | | -*(3) GPIOLIB=n, ALCHEMY_GPIO_INDIRECT=y: |
---|
134 | | -* the boards' gpio.h must provide the linux gpio wrapper functions, |
---|
135 | | -* |
---|
136 | | -*(4) GPIOLIB=n, ALCHEMY_GPIO_INDIRECT=n: |
---|
137 | | -* inlinable gpio functions are provided which enable access to the |
---|
138 | | -* Au1300 gpios only by using the numbers straight out of the data- |
---|
139 | | -* sheets. |
---|
140 | | - |
---|
141 | | -* Cases 1 and 3 are intended for boards which want to provide their own |
---|
142 | | -* GPIO namespace and -operations (i.e. for example you have 8 GPIOs |
---|
143 | | -* which are in part provided by spare Au1300 GPIO pins and in part by |
---|
144 | | -* an external FPGA but you still want them to be accessible in linux |
---|
145 | | -* as gpio0-7. The board can of course use the alchemy_gpioX_* functions |
---|
146 | | -* as required). |
---|
147 | | -*/ |
---|
148 | | - |
---|
149 | | -#ifndef CONFIG_GPIOLIB |
---|
150 | | - |
---|
151 | | -#ifdef CONFIG_ALCHEMY_GPIOINT_AU1300 |
---|
152 | | - |
---|
153 | | -#ifndef CONFIG_ALCHEMY_GPIO_INDIRECT /* case (4) */ |
---|
154 | | - |
---|
155 | | -static inline int gpio_direction_input(unsigned int gpio) |
---|
156 | | -{ |
---|
157 | | - return au1300_gpio_direction_input(gpio); |
---|
158 | | -} |
---|
159 | | - |
---|
160 | | -static inline int gpio_direction_output(unsigned int gpio, int v) |
---|
161 | | -{ |
---|
162 | | - return au1300_gpio_direction_output(gpio, v); |
---|
163 | | -} |
---|
164 | | - |
---|
165 | | -static inline int gpio_get_value(unsigned int gpio) |
---|
166 | | -{ |
---|
167 | | - return au1300_gpio_get_value(gpio); |
---|
168 | | -} |
---|
169 | | - |
---|
170 | | -static inline void gpio_set_value(unsigned int gpio, int v) |
---|
171 | | -{ |
---|
172 | | - au1300_gpio_set_value(gpio, v); |
---|
173 | | -} |
---|
174 | | - |
---|
175 | | -static inline int gpio_get_value_cansleep(unsigned gpio) |
---|
176 | | -{ |
---|
177 | | - return gpio_get_value(gpio); |
---|
178 | | -} |
---|
179 | | - |
---|
180 | | -static inline void gpio_set_value_cansleep(unsigned gpio, int value) |
---|
181 | | -{ |
---|
182 | | - gpio_set_value(gpio, value); |
---|
183 | | -} |
---|
184 | | - |
---|
185 | | -static inline int gpio_is_valid(unsigned int gpio) |
---|
186 | | -{ |
---|
187 | | - return au1300_gpio_is_valid(gpio); |
---|
188 | | -} |
---|
189 | | - |
---|
190 | | -static inline int gpio_cansleep(unsigned int gpio) |
---|
191 | | -{ |
---|
192 | | - return au1300_gpio_cansleep(gpio); |
---|
193 | | -} |
---|
194 | | - |
---|
195 | | -static inline int gpio_to_irq(unsigned int gpio) |
---|
196 | | -{ |
---|
197 | | - return au1300_gpio_to_irq(gpio); |
---|
198 | | -} |
---|
199 | | - |
---|
200 | | -static inline int irq_to_gpio(unsigned int irq) |
---|
201 | | -{ |
---|
202 | | - return au1300_irq_to_gpio(irq); |
---|
203 | | -} |
---|
204 | | - |
---|
205 | | -static inline int gpio_request(unsigned int gpio, const char *label) |
---|
206 | | -{ |
---|
207 | | - return 0; |
---|
208 | | -} |
---|
209 | | - |
---|
210 | | -static inline int gpio_request_one(unsigned gpio, |
---|
211 | | - unsigned long flags, const char *label) |
---|
212 | | -{ |
---|
213 | | - return 0; |
---|
214 | | -} |
---|
215 | | - |
---|
216 | | -static inline int gpio_request_array(struct gpio *array, size_t num) |
---|
217 | | -{ |
---|
218 | | - return 0; |
---|
219 | | -} |
---|
220 | | - |
---|
221 | | -static inline void gpio_free(unsigned gpio) |
---|
222 | | -{ |
---|
223 | | -} |
---|
224 | | - |
---|
225 | | -static inline void gpio_free_array(struct gpio *array, size_t num) |
---|
226 | | -{ |
---|
227 | | -} |
---|
228 | | - |
---|
229 | | -static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) |
---|
230 | | -{ |
---|
231 | | - return -ENOSYS; |
---|
232 | | -} |
---|
233 | | - |
---|
234 | | -static inline void gpio_unexport(unsigned gpio) |
---|
235 | | -{ |
---|
236 | | -} |
---|
237 | | - |
---|
238 | | -static inline int gpio_export(unsigned gpio, bool direction_may_change) |
---|
239 | | -{ |
---|
240 | | - return -ENOSYS; |
---|
241 | | -} |
---|
242 | | - |
---|
243 | | -static inline int gpio_sysfs_set_active_low(unsigned gpio, int value) |
---|
244 | | -{ |
---|
245 | | - return -ENOSYS; |
---|
246 | | -} |
---|
247 | | - |
---|
248 | | -static inline int gpio_export_link(struct device *dev, const char *name, |
---|
249 | | - unsigned gpio) |
---|
250 | | -{ |
---|
251 | | - return -ENOSYS; |
---|
252 | | -} |
---|
253 | | - |
---|
254 | | -#endif /* !CONFIG_ALCHEMY_GPIO_INDIRECT */ |
---|
255 | | - |
---|
256 | | -#endif /* CONFIG_ALCHEMY_GPIOINT_AU1300 */ |
---|
257 | | - |
---|
258 | | -#endif /* CONFIG GPIOLIB */ |
---|
259 | | - |
---|
260 | 123 | #endif /* _GPIO_AU1300_H_ */ |
---|