2 * Copyright 2006-2009 Analog Devices Inc.
4 * Licensed under the GPL-2 or later.
7 #ifndef __ARCH_BLACKFIN_GPIO_H__
8 #define __ARCH_BLACKFIN_GPIO_H__
10 #define gpio_bank(x) ((x) >> 4)
11 #define gpio_bit(x) (1<<((x) & 0xF))
12 #define gpio_sub_n(x) ((x) & 0xF)
14 #define GPIO_BANKSIZE 16
15 #define GPIO_BANK_NUM DIV_ROUND_UP(MAX_BLACKFIN_GPIOS, GPIO_BANKSIZE)
17 #include <mach/gpio.h>
68 #define PERIPHERAL_USAGE 1
73 /***********************************************************
75 * FUNCTIONS: Blackfin General Purpose Ports Access Functions
78 * gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS
81 * DESCRIPTION: These functions abstract direct register access
82 * to Blackfin processor General Purpose
85 * CAUTION: These functions do not belong to the GPIO Driver API
86 *************************************************************
87 * MODIFICATION HISTORY :
88 **************************************************************/
91 void set_gpio_dir(unsigned, unsigned short);
92 void set_gpio_inen(unsigned, unsigned short);
93 void set_gpio_polar(unsigned, unsigned short);
94 void set_gpio_edge(unsigned, unsigned short);
95 void set_gpio_both(unsigned, unsigned short);
96 void set_gpio_data(unsigned, unsigned short);
97 void set_gpio_maska(unsigned, unsigned short);
98 void set_gpio_maskb(unsigned, unsigned short);
99 void set_gpio_toggle(unsigned);
100 void set_gpiop_dir(unsigned, unsigned short);
101 void set_gpiop_inen(unsigned, unsigned short);
102 void set_gpiop_polar(unsigned, unsigned short);
103 void set_gpiop_edge(unsigned, unsigned short);
104 void set_gpiop_both(unsigned, unsigned short);
105 void set_gpiop_data(unsigned, unsigned short);
106 void set_gpiop_maska(unsigned, unsigned short);
107 void set_gpiop_maskb(unsigned, unsigned short);
108 unsigned short get_gpio_dir(unsigned);
109 unsigned short get_gpio_inen(unsigned);
110 unsigned short get_gpio_polar(unsigned);
111 unsigned short get_gpio_edge(unsigned);
112 unsigned short get_gpio_both(unsigned);
113 unsigned short get_gpio_maska(unsigned);
114 unsigned short get_gpio_maskb(unsigned);
115 unsigned short get_gpio_data(unsigned);
116 unsigned short get_gpiop_dir(unsigned);
117 unsigned short get_gpiop_inen(unsigned);
118 unsigned short get_gpiop_polar(unsigned);
119 unsigned short get_gpiop_edge(unsigned);
120 unsigned short get_gpiop_both(unsigned);
121 unsigned short get_gpiop_maska(unsigned);
122 unsigned short get_gpiop_maskb(unsigned);
123 unsigned short get_gpiop_data(unsigned);
127 unsigned short dummy1
;
128 unsigned short data_clear
;
129 unsigned short dummy2
;
130 unsigned short data_set
;
131 unsigned short dummy3
;
132 unsigned short toggle
;
133 unsigned short dummy4
;
134 unsigned short maska
;
135 unsigned short dummy5
;
136 unsigned short maska_clear
;
137 unsigned short dummy6
;
138 unsigned short maska_set
;
139 unsigned short dummy7
;
140 unsigned short maska_toggle
;
141 unsigned short dummy8
;
142 unsigned short maskb
;
143 unsigned short dummy9
;
144 unsigned short maskb_clear
;
145 unsigned short dummy10
;
146 unsigned short maskb_set
;
147 unsigned short dummy11
;
148 unsigned short maskb_toggle
;
149 unsigned short dummy12
;
151 unsigned short dummy13
;
152 unsigned short polar
;
153 unsigned short dummy14
;
155 unsigned short dummy15
;
157 unsigned short dummy16
;
164 unsigned int bfin_pm_standby_setup(void);
165 void bfin_pm_standby_restore(void);
167 void bfin_gpio_pm_hibernate_restore(void);
168 void bfin_gpio_pm_hibernate_suspend(void);
171 #define PM_WAKE_RISING 0x1
172 #define PM_WAKE_FALLING 0x2
173 #define PM_WAKE_HIGH 0x4
174 #define PM_WAKE_LOW 0x8
175 #define PM_WAKE_BOTH_EDGES (PM_WAKE_RISING | PM_WAKE_FALLING)
176 #define PM_WAKE_IGNORE 0xF0
178 int gpio_pm_wakeup_request(unsigned gpio
, unsigned char type
);
179 void gpio_pm_wakeup_free(unsigned gpio
);
183 unsigned short maska
;
184 unsigned short maskb
;
186 unsigned short polar
;
192 unsigned short reserved
;
195 #endif /*CONFIG_BF54x*/
197 /***********************************************************
199 * FUNCTIONS: Blackfin GPIO Driver
202 * gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS
205 * DESCRIPTION: Blackfin GPIO Driver API
208 *************************************************************
209 * MODIFICATION HISTORY :
210 **************************************************************/
212 int bfin_gpio_request(unsigned gpio
, const char *label
);
213 void bfin_gpio_free(unsigned gpio
);
214 int bfin_gpio_irq_request(unsigned gpio
, const char *label
);
215 void bfin_gpio_irq_free(unsigned gpio
);
216 int bfin_gpio_direction_input(unsigned gpio
);
217 int bfin_gpio_direction_output(unsigned gpio
, int value
);
218 int bfin_gpio_get_value(unsigned gpio
);
219 void bfin_gpio_set_value(unsigned gpio
, int value
);
221 #ifdef CONFIG_GPIOLIB
222 #include <asm-generic/gpio.h> /* cansleep wrappers */
224 static inline int gpio_get_value(unsigned int gpio
)
226 if (gpio
< MAX_BLACKFIN_GPIOS
)
227 return bfin_gpio_get_value(gpio
);
229 return __gpio_get_value(gpio
);
232 static inline void gpio_set_value(unsigned int gpio
, int value
)
234 if (gpio
< MAX_BLACKFIN_GPIOS
)
235 bfin_gpio_set_value(gpio
, value
);
237 __gpio_set_value(gpio
, value
);
240 static inline int gpio_cansleep(unsigned int gpio
)
242 return __gpio_cansleep(gpio
);
245 #else /* !CONFIG_GPIOLIB */
247 static inline int gpio_request(unsigned gpio
, const char *label
)
249 return bfin_gpio_request(gpio
, label
);
252 static inline void gpio_free(unsigned gpio
)
254 return bfin_gpio_free(gpio
);
257 static inline int gpio_direction_input(unsigned gpio
)
259 return bfin_gpio_direction_input(gpio
);
262 static inline int gpio_direction_output(unsigned gpio
, int value
)
264 return bfin_gpio_direction_output(gpio
, value
);
267 static inline int gpio_get_value(unsigned gpio
)
269 return bfin_gpio_get_value(gpio
);
272 static inline void gpio_set_value(unsigned gpio
, int value
)
274 return bfin_gpio_set_value(gpio
, value
);
277 #include <asm-generic/gpio.h> /* cansleep wrappers */
278 #endif /* !CONFIG_GPIOLIB */
281 static inline int gpio_to_irq(unsigned gpio
)
283 if (likely(gpio
< MAX_BLACKFIN_GPIOS
))
284 return gpio
+ GPIO_IRQ_BASE
;
289 static inline int irq_to_gpio(unsigned irq
)
291 return (irq
- GPIO_IRQ_BASE
);
294 #endif /* __ASSEMBLY__ */
296 #endif /* __ARCH_BLACKFIN_GPIO_H__ */