added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / arch / blackfin / include / asm / gpio.h
blobd4a082ef75b472456f3f206b7d087ead9e2da39d
1 /*
2 * File: arch/blackfin/kernel/bfin_gpio.h
3 * Based on:
4 * Author: Michael Hennerich (hennerich@blackfin.uclinux.org)
6 * Created:
7 * Description:
9 * Modified:
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
30 #ifndef __ARCH_BLACKFIN_GPIO_H__
31 #define __ARCH_BLACKFIN_GPIO_H__
33 #define gpio_bank(x) ((x) >> 4)
34 #define gpio_bit(x) (1<<((x) & 0xF))
35 #define gpio_sub_n(x) ((x) & 0xF)
37 #define GPIO_BANKSIZE 16
38 #define GPIO_BANK_NUM DIV_ROUND_UP(MAX_BLACKFIN_GPIOS, GPIO_BANKSIZE)
40 #include <mach/gpio.h>
42 #define GPIO_0 0
43 #define GPIO_1 1
44 #define GPIO_2 2
45 #define GPIO_3 3
46 #define GPIO_4 4
47 #define GPIO_5 5
48 #define GPIO_6 6
49 #define GPIO_7 7
50 #define GPIO_8 8
51 #define GPIO_9 9
52 #define GPIO_10 10
53 #define GPIO_11 11
54 #define GPIO_12 12
55 #define GPIO_13 13
56 #define GPIO_14 14
57 #define GPIO_15 15
58 #define GPIO_16 16
59 #define GPIO_17 17
60 #define GPIO_18 18
61 #define GPIO_19 19
62 #define GPIO_20 20
63 #define GPIO_21 21
64 #define GPIO_22 22
65 #define GPIO_23 23
66 #define GPIO_24 24
67 #define GPIO_25 25
68 #define GPIO_26 26
69 #define GPIO_27 27
70 #define GPIO_28 28
71 #define GPIO_29 29
72 #define GPIO_30 30
73 #define GPIO_31 31
74 #define GPIO_32 32
75 #define GPIO_33 33
76 #define GPIO_34 34
77 #define GPIO_35 35
78 #define GPIO_36 36
79 #define GPIO_37 37
80 #define GPIO_38 38
81 #define GPIO_39 39
82 #define GPIO_40 40
83 #define GPIO_41 41
84 #define GPIO_42 42
85 #define GPIO_43 43
86 #define GPIO_44 44
87 #define GPIO_45 45
88 #define GPIO_46 46
89 #define GPIO_47 47
91 #define PERIPHERAL_USAGE 1
92 #define GPIO_USAGE 0
94 #ifndef __ASSEMBLY__
96 /***********************************************************
98 * FUNCTIONS: Blackfin General Purpose Ports Access Functions
100 * INPUTS/OUTPUTS:
101 * gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS
104 * DESCRIPTION: These functions abstract direct register access
105 * to Blackfin processor General Purpose
106 * Ports Regsiters
108 * CAUTION: These functions do not belong to the GPIO Driver API
109 *************************************************************
110 * MODIFICATION HISTORY :
111 **************************************************************/
113 #ifndef BF548_FAMILY
114 void set_gpio_dir(unsigned, unsigned short);
115 void set_gpio_inen(unsigned, unsigned short);
116 void set_gpio_polar(unsigned, unsigned short);
117 void set_gpio_edge(unsigned, unsigned short);
118 void set_gpio_both(unsigned, unsigned short);
119 void set_gpio_data(unsigned, unsigned short);
120 void set_gpio_maska(unsigned, unsigned short);
121 void set_gpio_maskb(unsigned, unsigned short);
122 void set_gpio_toggle(unsigned);
123 void set_gpiop_dir(unsigned, unsigned short);
124 void set_gpiop_inen(unsigned, unsigned short);
125 void set_gpiop_polar(unsigned, unsigned short);
126 void set_gpiop_edge(unsigned, unsigned short);
127 void set_gpiop_both(unsigned, unsigned short);
128 void set_gpiop_data(unsigned, unsigned short);
129 void set_gpiop_maska(unsigned, unsigned short);
130 void set_gpiop_maskb(unsigned, unsigned short);
131 unsigned short get_gpio_dir(unsigned);
132 unsigned short get_gpio_inen(unsigned);
133 unsigned short get_gpio_polar(unsigned);
134 unsigned short get_gpio_edge(unsigned);
135 unsigned short get_gpio_both(unsigned);
136 unsigned short get_gpio_maska(unsigned);
137 unsigned short get_gpio_maskb(unsigned);
138 unsigned short get_gpio_data(unsigned);
139 unsigned short get_gpiop_dir(unsigned);
140 unsigned short get_gpiop_inen(unsigned);
141 unsigned short get_gpiop_polar(unsigned);
142 unsigned short get_gpiop_edge(unsigned);
143 unsigned short get_gpiop_both(unsigned);
144 unsigned short get_gpiop_maska(unsigned);
145 unsigned short get_gpiop_maskb(unsigned);
146 unsigned short get_gpiop_data(unsigned);
148 struct gpio_port_t {
149 unsigned short data;
150 unsigned short dummy1;
151 unsigned short data_clear;
152 unsigned short dummy2;
153 unsigned short data_set;
154 unsigned short dummy3;
155 unsigned short toggle;
156 unsigned short dummy4;
157 unsigned short maska;
158 unsigned short dummy5;
159 unsigned short maska_clear;
160 unsigned short dummy6;
161 unsigned short maska_set;
162 unsigned short dummy7;
163 unsigned short maska_toggle;
164 unsigned short dummy8;
165 unsigned short maskb;
166 unsigned short dummy9;
167 unsigned short maskb_clear;
168 unsigned short dummy10;
169 unsigned short maskb_set;
170 unsigned short dummy11;
171 unsigned short maskb_toggle;
172 unsigned short dummy12;
173 unsigned short dir;
174 unsigned short dummy13;
175 unsigned short polar;
176 unsigned short dummy14;
177 unsigned short edge;
178 unsigned short dummy15;
179 unsigned short both;
180 unsigned short dummy16;
181 unsigned short inen;
183 #endif
185 #ifdef CONFIG_PM
187 unsigned int bfin_pm_standby_setup(void);
188 void bfin_pm_standby_restore(void);
190 void bfin_gpio_pm_hibernate_restore(void);
191 void bfin_gpio_pm_hibernate_suspend(void);
193 #ifndef CONFIG_BF54x
194 #define PM_WAKE_RISING 0x1
195 #define PM_WAKE_FALLING 0x2
196 #define PM_WAKE_HIGH 0x4
197 #define PM_WAKE_LOW 0x8
198 #define PM_WAKE_BOTH_EDGES (PM_WAKE_RISING | PM_WAKE_FALLING)
199 #define PM_WAKE_IGNORE 0xF0
201 int gpio_pm_wakeup_request(unsigned gpio, unsigned char type);
202 void gpio_pm_wakeup_free(unsigned gpio);
204 struct gpio_port_s {
205 unsigned short data;
206 unsigned short maska;
207 unsigned short maskb;
208 unsigned short dir;
209 unsigned short polar;
210 unsigned short edge;
211 unsigned short both;
212 unsigned short inen;
214 unsigned short fer;
215 unsigned short reserved;
216 unsigned short mux;
218 #endif /*CONFIG_BF54x*/
219 #endif /*CONFIG_PM*/
220 /***********************************************************
222 * FUNCTIONS: Blackfin GPIO Driver
224 * INPUTS/OUTPUTS:
225 * gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS
228 * DESCRIPTION: Blackfin GPIO Driver API
230 * CAUTION:
231 *************************************************************
232 * MODIFICATION HISTORY :
233 **************************************************************/
235 int bfin_gpio_request(unsigned gpio, const char *label);
236 void bfin_gpio_free(unsigned gpio);
237 int bfin_gpio_irq_request(unsigned gpio, const char *label);
238 void bfin_gpio_irq_free(unsigned gpio);
239 int bfin_gpio_direction_input(unsigned gpio);
240 int bfin_gpio_direction_output(unsigned gpio, int value);
241 int bfin_gpio_get_value(unsigned gpio);
242 void bfin_gpio_set_value(unsigned gpio, int value);
244 #ifdef CONFIG_GPIOLIB
245 #include <asm-generic/gpio.h> /* cansleep wrappers */
247 static inline int gpio_get_value(unsigned int gpio)
249 if (gpio < MAX_BLACKFIN_GPIOS)
250 return bfin_gpio_get_value(gpio);
251 else
252 return __gpio_get_value(gpio);
255 static inline void gpio_set_value(unsigned int gpio, int value)
257 if (gpio < MAX_BLACKFIN_GPIOS)
258 bfin_gpio_set_value(gpio, value);
259 else
260 __gpio_set_value(gpio, value);
263 static inline int gpio_cansleep(unsigned int gpio)
265 return __gpio_cansleep(gpio);
268 #else /* !CONFIG_GPIOLIB */
270 static inline int gpio_request(unsigned gpio, const char *label)
272 return bfin_gpio_request(gpio, label);
275 static inline void gpio_free(unsigned gpio)
277 return bfin_gpio_free(gpio);
280 static inline int gpio_direction_input(unsigned gpio)
282 return bfin_gpio_direction_input(gpio);
285 static inline int gpio_direction_output(unsigned gpio, int value)
287 return bfin_gpio_direction_output(gpio, value);
290 static inline int gpio_get_value(unsigned gpio)
292 return bfin_gpio_get_value(gpio);
295 static inline void gpio_set_value(unsigned gpio, int value)
297 return bfin_gpio_set_value(gpio, value);
300 #include <asm-generic/gpio.h> /* cansleep wrappers */
301 #endif /* !CONFIG_GPIOLIB */
302 #include <asm/irq.h>
304 static inline int gpio_to_irq(unsigned gpio)
306 return (gpio + GPIO_IRQ_BASE);
309 static inline int irq_to_gpio(unsigned irq)
311 return (irq - GPIO_IRQ_BASE);
314 #endif /* __ASSEMBLY__ */
316 #endif /* __ARCH_BLACKFIN_GPIO_H__ */