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>
19 #define PERIPHERAL_USAGE 1
24 #include <linux/compiler.h>
26 /***********************************************************
28 * FUNCTIONS: Blackfin General Purpose Ports Access Functions
31 * gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS
34 * DESCRIPTION: These functions abstract direct register access
35 * to Blackfin processor General Purpose
38 * CAUTION: These functions do not belong to the GPIO Driver API
39 *************************************************************
40 * MODIFICATION HISTORY :
41 **************************************************************/
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);
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
;
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
;
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
;
104 unsigned short dummy13
;
105 unsigned short polar
;
106 unsigned short dummy14
;
108 unsigned short dummy15
;
110 unsigned short dummy16
;
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
);
121 int bfin_pm_standby_ctrl(unsigned ctrl
);
123 static inline int bfin_pm_standby_setup(void)
125 return bfin_pm_standby_ctrl(1);
128 static inline void bfin_pm_standby_restore(void)
130 bfin_pm_standby_ctrl(0);
133 void bfin_gpio_pm_hibernate_restore(void);
134 void bfin_gpio_pm_hibernate_suspend(void);
137 int gpio_pm_wakeup_ctrl(unsigned gpio
, unsigned ctrl
);
141 unsigned short maska
;
142 unsigned short maskb
;
144 unsigned short polar
;
150 unsigned short reserved
;
153 #endif /*CONFIG_BF54x*/
155 /***********************************************************
157 * FUNCTIONS: Blackfin GPIO Driver
160 * gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS
163 * DESCRIPTION: Blackfin GPIO Driver API
166 *************************************************************
167 * MODIFICATION HISTORY :
168 **************************************************************/
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
);
180 #include <asm/errno.h>
182 #ifdef CONFIG_GPIOLIB
183 #include <asm-generic/gpio.h> /* cansleep wrappers */
185 static inline int gpio_get_value(unsigned int gpio
)
187 if (gpio
< MAX_BLACKFIN_GPIOS
)
188 return bfin_gpio_get_value(gpio
);
190 return __gpio_get_value(gpio
);
193 static inline void gpio_set_value(unsigned int gpio
, int value
)
195 if (gpio
< MAX_BLACKFIN_GPIOS
)
196 bfin_gpio_set_value(gpio
, value
);
198 __gpio_set_value(gpio
, value
);
201 static inline int gpio_cansleep(unsigned int gpio
)
203 return __gpio_cansleep(gpio
);
206 static inline int gpio_to_irq(unsigned gpio
)
208 return __gpio_to_irq(gpio
);
211 #else /* !CONFIG_GPIOLIB */
213 static inline int gpio_request(unsigned gpio
, const char *label
)
215 return bfin_gpio_request(gpio
, label
);
218 static inline void gpio_free(unsigned gpio
)
220 return bfin_gpio_free(gpio
);
223 static inline int gpio_direction_input(unsigned gpio
)
225 return bfin_gpio_direction_input(gpio
);
228 static inline int gpio_direction_output(unsigned gpio
, int value
)
230 return bfin_gpio_direction_output(gpio
, value
);
233 static inline int gpio_set_debounce(unsigned gpio
, unsigned debounce
)
238 static inline int gpio_get_value(unsigned gpio
)
240 return bfin_gpio_get_value(gpio
);
243 static inline void gpio_set_value(unsigned gpio
, int value
)
245 return bfin_gpio_set_value(gpio
, value
);
248 static inline int gpio_to_irq(unsigned gpio
)
250 if (likely(gpio
< MAX_BLACKFIN_GPIOS
))
251 return gpio
+ GPIO_IRQ_BASE
;
256 #include <asm-generic/gpio.h> /* cansleep wrappers */
257 #endif /* !CONFIG_GPIOLIB */
259 static inline int irq_to_gpio(unsigned irq
)
261 return (irq
- GPIO_IRQ_BASE
);
264 #endif /* __ASSEMBLY__ */
266 #endif /* __ARCH_BLACKFIN_GPIO_H__ */
This page took 0.203247 seconds and 5 git commands to generate.