Blackfin: gpio: punt unused GPIO_# defines
[deliverable/linux.git] / arch / blackfin / include / asm / gpio.h
1 /*
2 * Copyright 2006-2009 Analog Devices Inc.
3 *
4 * Licensed under the GPL-2 or later.
5 */
6
7 #ifndef __ARCH_BLACKFIN_GPIO_H__
8 #define __ARCH_BLACKFIN_GPIO_H__
9
10 #define gpio_bank(x) ((x) >> 4)
11 #define gpio_bit(x) (1<<((x) & 0xF))
12 #define gpio_sub_n(x) ((x) & 0xF)
13
14 #define GPIO_BANKSIZE 16
15 #define GPIO_BANK_NUM DIV_ROUND_UP(MAX_BLACKFIN_GPIOS, GPIO_BANKSIZE)
16
17 #include <mach/gpio.h>
18
19 #define PERIPHERAL_USAGE 1
20 #define GPIO_USAGE 0
21
22 #ifndef __ASSEMBLY__
23
24 #include <linux/compiler.h>
25
26 /***********************************************************
27 *
28 * FUNCTIONS: Blackfin General Purpose Ports Access Functions
29 *
30 * INPUTS/OUTPUTS:
31 * gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS
32 *
33 *
34 * DESCRIPTION: These functions abstract direct register access
35 * to Blackfin processor General Purpose
36 * Ports Regsiters
37 *
38 * CAUTION: These functions do not belong to the GPIO Driver API
39 *************************************************************
40 * MODIFICATION HISTORY :
41 **************************************************************/
42
43 #ifndef CONFIG_BF54x
44 void set_gpio_dir(unsigned, unsigned short);
45 void set_gpio_inen(unsigned, unsigned short);
46 void set_gpio_polar(unsigned, unsigned short);
47 void set_gpio_edge(unsigned, unsigned short);
48 void set_gpio_both(unsigned, unsigned short);
49 void set_gpio_data(unsigned, unsigned short);
50 void set_gpio_maska(unsigned, unsigned short);
51 void set_gpio_maskb(unsigned, unsigned short);
52 void set_gpio_toggle(unsigned);
53 void set_gpiop_dir(unsigned, unsigned short);
54 void set_gpiop_inen(unsigned, unsigned short);
55 void set_gpiop_polar(unsigned, unsigned short);
56 void set_gpiop_edge(unsigned, unsigned short);
57 void set_gpiop_both(unsigned, unsigned short);
58 void set_gpiop_data(unsigned, unsigned short);
59 void set_gpiop_maska(unsigned, unsigned short);
60 void set_gpiop_maskb(unsigned, unsigned short);
61 unsigned short get_gpio_dir(unsigned);
62 unsigned short get_gpio_inen(unsigned);
63 unsigned short get_gpio_polar(unsigned);
64 unsigned short get_gpio_edge(unsigned);
65 unsigned short get_gpio_both(unsigned);
66 unsigned short get_gpio_maska(unsigned);
67 unsigned short get_gpio_maskb(unsigned);
68 unsigned short get_gpio_data(unsigned);
69 unsigned short get_gpiop_dir(unsigned);
70 unsigned short get_gpiop_inen(unsigned);
71 unsigned short get_gpiop_polar(unsigned);
72 unsigned short get_gpiop_edge(unsigned);
73 unsigned short get_gpiop_both(unsigned);
74 unsigned short get_gpiop_maska(unsigned);
75 unsigned short get_gpiop_maskb(unsigned);
76 unsigned short get_gpiop_data(unsigned);
77
78 struct gpio_port_t {
79 unsigned short data;
80 unsigned short dummy1;
81 unsigned short data_clear;
82 unsigned short dummy2;
83 unsigned short data_set;
84 unsigned short dummy3;
85 unsigned short toggle;
86 unsigned short dummy4;
87 unsigned short maska;
88 unsigned short dummy5;
89 unsigned short maska_clear;
90 unsigned short dummy6;
91 unsigned short maska_set;
92 unsigned short dummy7;
93 unsigned short maska_toggle;
94 unsigned short dummy8;
95 unsigned short maskb;
96 unsigned short dummy9;
97 unsigned short maskb_clear;
98 unsigned short dummy10;
99 unsigned short maskb_set;
100 unsigned short dummy11;
101 unsigned short maskb_toggle;
102 unsigned short dummy12;
103 unsigned short dir;
104 unsigned short dummy13;
105 unsigned short polar;
106 unsigned short dummy14;
107 unsigned short edge;
108 unsigned short dummy15;
109 unsigned short both;
110 unsigned short dummy16;
111 unsigned short inen;
112 };
113 #endif
114
115 #ifdef BFIN_SPECIAL_GPIO_BANKS
116 void bfin_special_gpio_free(unsigned gpio);
117 int bfin_special_gpio_request(unsigned gpio, const char *label);
118 #endif
119
120 #ifdef CONFIG_PM
121 int bfin_pm_standby_ctrl(unsigned ctrl);
122
123 static inline int bfin_pm_standby_setup(void)
124 {
125 return bfin_pm_standby_ctrl(1);
126 }
127
128 static inline void bfin_pm_standby_restore(void)
129 {
130 bfin_pm_standby_ctrl(0);
131 }
132
133 void bfin_gpio_pm_hibernate_restore(void);
134 void bfin_gpio_pm_hibernate_suspend(void);
135
136 #ifndef CONFIG_BF54x
137 int gpio_pm_wakeup_ctrl(unsigned gpio, unsigned ctrl);
138
139 struct gpio_port_s {
140 unsigned short data;
141 unsigned short maska;
142 unsigned short maskb;
143 unsigned short dir;
144 unsigned short polar;
145 unsigned short edge;
146 unsigned short both;
147 unsigned short inen;
148
149 unsigned short fer;
150 unsigned short reserved;
151 unsigned short mux;
152 };
153 #endif /*CONFIG_BF54x*/
154 #endif /*CONFIG_PM*/
155 /***********************************************************
156 *
157 * FUNCTIONS: Blackfin GPIO Driver
158 *
159 * INPUTS/OUTPUTS:
160 * gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS
161 *
162 *
163 * DESCRIPTION: Blackfin GPIO Driver API
164 *
165 * CAUTION:
166 *************************************************************
167 * MODIFICATION HISTORY :
168 **************************************************************/
169
170 int bfin_gpio_request(unsigned gpio, const char *label);
171 void bfin_gpio_free(unsigned gpio);
172 int bfin_gpio_irq_request(unsigned gpio, const char *label);
173 void bfin_gpio_irq_free(unsigned gpio);
174 int bfin_gpio_direction_input(unsigned gpio);
175 int bfin_gpio_direction_output(unsigned gpio, int value);
176 int bfin_gpio_get_value(unsigned gpio);
177 void bfin_gpio_set_value(unsigned gpio, int value);
178
179 #include <asm/irq.h>
180 #include <asm/errno.h>
181
182 #ifdef CONFIG_GPIOLIB
183 #include <asm-generic/gpio.h> /* cansleep wrappers */
184
185 static inline int gpio_get_value(unsigned int gpio)
186 {
187 if (gpio < MAX_BLACKFIN_GPIOS)
188 return bfin_gpio_get_value(gpio);
189 else
190 return __gpio_get_value(gpio);
191 }
192
193 static inline void gpio_set_value(unsigned int gpio, int value)
194 {
195 if (gpio < MAX_BLACKFIN_GPIOS)
196 bfin_gpio_set_value(gpio, value);
197 else
198 __gpio_set_value(gpio, value);
199 }
200
201 static inline int gpio_cansleep(unsigned int gpio)
202 {
203 return __gpio_cansleep(gpio);
204 }
205
206 static inline int gpio_to_irq(unsigned gpio)
207 {
208 return __gpio_to_irq(gpio);
209 }
210
211 #else /* !CONFIG_GPIOLIB */
212
213 static inline int gpio_request(unsigned gpio, const char *label)
214 {
215 return bfin_gpio_request(gpio, label);
216 }
217
218 static inline void gpio_free(unsigned gpio)
219 {
220 return bfin_gpio_free(gpio);
221 }
222
223 static inline int gpio_direction_input(unsigned gpio)
224 {
225 return bfin_gpio_direction_input(gpio);
226 }
227
228 static inline int gpio_direction_output(unsigned gpio, int value)
229 {
230 return bfin_gpio_direction_output(gpio, value);
231 }
232
233 static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
234 {
235 return -EINVAL;
236 }
237
238 static inline int gpio_get_value(unsigned gpio)
239 {
240 return bfin_gpio_get_value(gpio);
241 }
242
243 static inline void gpio_set_value(unsigned gpio, int value)
244 {
245 return bfin_gpio_set_value(gpio, value);
246 }
247
248 static inline int gpio_to_irq(unsigned gpio)
249 {
250 if (likely(gpio < MAX_BLACKFIN_GPIOS))
251 return gpio + GPIO_IRQ_BASE;
252
253 return -EINVAL;
254 }
255
256 #include <asm-generic/gpio.h> /* cansleep wrappers */
257 #endif /* !CONFIG_GPIOLIB */
258
259 static inline int irq_to_gpio(unsigned irq)
260 {
261 return (irq - GPIO_IRQ_BASE);
262 }
263
264 #endif /* __ASSEMBLY__ */
265
266 #endif /* __ARCH_BLACKFIN_GPIO_H__ */
This page took 0.203247 seconds and 5 git commands to generate.