]>
git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - arch/blackfin/include/asm/gpio.h
2 * File: arch/blackfin/kernel/bfin_gpio.h
4 * Author: Michael Hennerich (hennerich@blackfin.uclinux.org)
10 * Copyright 2004-2008 Analog Devices Inc.
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 * Number BF537/6/4 BF561 BF533/2/1
44 * GPIO_10 PF10 PF10 PF10
45 * GPIO_11 PF11 PF11 PF11
46 * GPIO_12 PF12 PF12 PF12
47 * GPIO_13 PF13 PF13 PF13
48 * GPIO_14 PF14 PF14 PF14
49 * GPIO_15 PF15 PF15 PF15
84 #ifndef __ARCH_BLACKFIN_GPIO_H__
85 #define __ARCH_BLACKFIN_GPIO_H__
87 #define gpio_bank(x) ((x) >> 4)
88 #define gpio_bit(x) (1<<((x) & 0xF))
89 #define gpio_sub_n(x) ((x) & 0xF)
91 #define GPIO_BANKSIZE 16
92 #define GPIO_BANK_NUM DIV_ROUND_UP(MAX_BLACKFIN_GPIOS, GPIO_BANKSIZE)
94 #include <mach/gpio.h>
145 #define PERIPHERAL_USAGE 1
150 /***********************************************************
152 * FUNCTIONS: Blackfin General Purpose Ports Access Functions
155 * gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS
158 * DESCRIPTION: These functions abstract direct register access
159 * to Blackfin processor General Purpose
162 * CAUTION: These functions do not belong to the GPIO Driver API
163 *************************************************************
164 * MODIFICATION HISTORY :
165 **************************************************************/
168 void set_gpio_dir(unsigned, unsigned short);
169 void set_gpio_inen(unsigned, unsigned short);
170 void set_gpio_polar(unsigned, unsigned short);
171 void set_gpio_edge(unsigned, unsigned short);
172 void set_gpio_both(unsigned, unsigned short);
173 void set_gpio_data(unsigned, unsigned short);
174 void set_gpio_maska(unsigned, unsigned short);
175 void set_gpio_maskb(unsigned, unsigned short);
176 void set_gpio_toggle(unsigned);
177 void set_gpiop_dir(unsigned, unsigned short);
178 void set_gpiop_inen(unsigned, unsigned short);
179 void set_gpiop_polar(unsigned, unsigned short);
180 void set_gpiop_edge(unsigned, unsigned short);
181 void set_gpiop_both(unsigned, unsigned short);
182 void set_gpiop_data(unsigned, unsigned short);
183 void set_gpiop_maska(unsigned, unsigned short);
184 void set_gpiop_maskb(unsigned, unsigned short);
185 unsigned short get_gpio_dir(unsigned);
186 unsigned short get_gpio_inen(unsigned);
187 unsigned short get_gpio_polar(unsigned);
188 unsigned short get_gpio_edge(unsigned);
189 unsigned short get_gpio_both(unsigned);
190 unsigned short get_gpio_maska(unsigned);
191 unsigned short get_gpio_maskb(unsigned);
192 unsigned short get_gpio_data(unsigned);
193 unsigned short get_gpiop_dir(unsigned);
194 unsigned short get_gpiop_inen(unsigned);
195 unsigned short get_gpiop_polar(unsigned);
196 unsigned short get_gpiop_edge(unsigned);
197 unsigned short get_gpiop_both(unsigned);
198 unsigned short get_gpiop_maska(unsigned);
199 unsigned short get_gpiop_maskb(unsigned);
200 unsigned short get_gpiop_data(unsigned);
204 unsigned short dummy1
;
205 unsigned short data_clear
;
206 unsigned short dummy2
;
207 unsigned short data_set
;
208 unsigned short dummy3
;
209 unsigned short toggle
;
210 unsigned short dummy4
;
211 unsigned short maska
;
212 unsigned short dummy5
;
213 unsigned short maska_clear
;
214 unsigned short dummy6
;
215 unsigned short maska_set
;
216 unsigned short dummy7
;
217 unsigned short maska_toggle
;
218 unsigned short dummy8
;
219 unsigned short maskb
;
220 unsigned short dummy9
;
221 unsigned short maskb_clear
;
222 unsigned short dummy10
;
223 unsigned short maskb_set
;
224 unsigned short dummy11
;
225 unsigned short maskb_toggle
;
226 unsigned short dummy12
;
228 unsigned short dummy13
;
229 unsigned short polar
;
230 unsigned short dummy14
;
232 unsigned short dummy15
;
234 unsigned short dummy16
;
241 unsigned int bfin_pm_standby_setup(void);
242 void bfin_pm_standby_restore(void);
244 void bfin_gpio_pm_hibernate_restore(void);
245 void bfin_gpio_pm_hibernate_suspend(void);
248 #define PM_WAKE_RISING 0x1
249 #define PM_WAKE_FALLING 0x2
250 #define PM_WAKE_HIGH 0x4
251 #define PM_WAKE_LOW 0x8
252 #define PM_WAKE_BOTH_EDGES (PM_WAKE_RISING | PM_WAKE_FALLING)
253 #define PM_WAKE_IGNORE 0xF0
255 int gpio_pm_wakeup_request(unsigned gpio
, unsigned char type
);
256 void gpio_pm_wakeup_free(unsigned gpio
);
260 unsigned short maska
;
261 unsigned short maskb
;
263 unsigned short polar
;
269 unsigned short reserved
;
272 #endif /*CONFIG_BF54x*/
274 /***********************************************************
276 * FUNCTIONS: Blackfin GPIO Driver
279 * gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS
282 * DESCRIPTION: Blackfin GPIO Driver API
285 *************************************************************
286 * MODIFICATION HISTORY :
287 **************************************************************/
289 int bfin_gpio_request(unsigned gpio
, const char *label
);
290 void bfin_gpio_free(unsigned gpio
);
291 int bfin_gpio_irq_request(unsigned gpio
, const char *label
);
292 void bfin_gpio_irq_free(unsigned gpio
);
293 int bfin_gpio_direction_input(unsigned gpio
);
294 int bfin_gpio_direction_output(unsigned gpio
, int value
);
295 int bfin_gpio_get_value(unsigned gpio
);
296 void bfin_gpio_set_value(unsigned gpio
, int value
);
299 #define bfin_gpio_set_value(gpio, value) set_gpio_data(gpio, value)
302 #ifdef CONFIG_GPIOLIB
303 #include <asm-generic/gpio.h> /* cansleep wrappers */
305 static inline int gpio_get_value(unsigned int gpio
)
307 if (gpio
< MAX_BLACKFIN_GPIOS
)
308 return bfin_gpio_get_value(gpio
);
310 return __gpio_get_value(gpio
);
313 static inline void gpio_set_value(unsigned int gpio
, int value
)
315 if (gpio
< MAX_BLACKFIN_GPIOS
)
316 bfin_gpio_set_value(gpio
, value
);
318 __gpio_set_value(gpio
, value
);
321 static inline int gpio_cansleep(unsigned int gpio
)
323 return __gpio_cansleep(gpio
);
326 #else /* !CONFIG_GPIOLIB */
328 static inline int gpio_request(unsigned gpio
, const char *label
)
330 return bfin_gpio_request(gpio
, label
);
333 static inline void gpio_free(unsigned gpio
)
335 return bfin_gpio_free(gpio
);
338 static inline int gpio_direction_input(unsigned gpio
)
340 return bfin_gpio_direction_input(gpio
);
343 static inline int gpio_direction_output(unsigned gpio
, int value
)
345 return bfin_gpio_direction_output(gpio
, value
);
348 static inline int gpio_get_value(unsigned gpio
)
350 return bfin_gpio_get_value(gpio
);
353 static inline void gpio_set_value(unsigned gpio
, int value
)
355 return bfin_gpio_set_value(gpio
, value
);
358 #include <asm-generic/gpio.h> /* cansleep wrappers */
359 #endif /* !CONFIG_GPIOLIB */
362 static inline int gpio_to_irq(unsigned gpio
)
364 return (gpio
+ GPIO_IRQ_BASE
);
367 static inline int irq_to_gpio(unsigned irq
)
369 return (irq
- GPIO_IRQ_BASE
);
372 #endif /* __ASSEMBLY__ */
374 #endif /* __ARCH_BLACKFIN_GPIO_H__ */