1 #ifndef _ATHEROS_GPIO_H_
2 #define _ATHEROS_GPIO_H_
6 /* Common AR531X global variables */
7 /* extern u32 ar531x_gpio_intr_Mask; */
9 /* AR5312 exported routines */
10 #ifdef CONFIG_ATHEROS_AR5312
11 asmlinkage
void ar5312_gpio_irq_dispatch(void);
14 /* AR5315 exported routines */
15 #ifdef CONFIG_ATHEROS_AR5315
16 asmlinkage
void ar5315_gpio_irq_dispatch(void);
20 * Wrappers for the generic GPIO layer
23 /* Sets a gpio to input, or returns ENXIO for non-existent gpio */
24 static inline int gpio_direction_input(unsigned gpio
) {
25 DO_AR5312( if (gpio
> AR531X_NUM_GPIO
) { \
28 sysRegWrite(AR531X_GPIO_CR
, \
29 sysRegRead(AR531X_GPIO_CR
) | \
30 AR531X_GPIO_CR_I(gpio
) ); \
34 DO_AR5315( if (gpio
> AR5315_NUM_GPIO
) { \
37 sysRegWrite(AR5315_GPIO_CR
, \
38 ( sysRegRead(AR5315_GPIO_CR
) & \
39 ~(AR5315_GPIO_CR_M(gpio
)) ) | \
40 AR5315_GPIO_CR_I(gpio
) ); \
47 /* Sets a gpio to output with value, or returns ENXIO for non-existent gpio */
48 static inline int gpio_direction_output(unsigned gpio
, int value
) {
49 DO_AR5312( if (gpio
> AR531X_NUM_GPIO
) { \
52 sysRegWrite(AR531X_GPIO_DO
, \
53 ( (sysRegRead(AR531X_GPIO_DO
) & \
55 ((value
!=0) << gpio
)) ); \
56 sysRegWrite(AR531X_GPIO_CR
, \
57 ( sysRegRead(AR531X_GPIO_CR
) & \
58 ~(AR531X_GPIO_CR_M(gpio
)) )); \
62 DO_AR5315( if (gpio
> AR5315_NUM_GPIO
) { \
65 sysRegWrite(AR5315_GPIO_DO
, \
66 ( (sysRegRead(AR5315_GPIO_DO
) & \
68 ((value
!=0) << gpio
)) ); \
69 sysRegWrite(AR5315_GPIO_CR
, \
70 sysRegRead(AR5315_GPIO_CR
) | \
71 AR5315_GPIO_CR_O(gpio
) ); \
78 /* Reads the gpio pin. Unchecked function */
79 static inline int gpio_get_value(unsigned gpio
) {
80 DO_AR5312(return (sysRegRead(AR531X_GPIO_DI
) & (1 << gpio
));)
81 DO_AR5315(return (sysRegRead(AR5315_GPIO_DI
) & (1 << gpio
));)
85 /* Writes to the gpio pin. Unchecked function */
86 static inline void gpio_set_value(unsigned gpio
, int value
) {
87 DO_AR5312( sysRegWrite(AR531X_GPIO_DO
, \
88 ( (sysRegRead(AR531X_GPIO_DO
) & \
90 ((value
!=0) << gpio
)) ); \
92 DO_AR5315( sysRegWrite(AR5315_GPIO_DO
, \
93 ( (sysRegRead(AR5315_GPIO_DO
) & \
95 ((value
!=0) << gpio
)) ); \
99 static inline int gpio_request(unsigned gpio
, const char *label
) {
103 static inline void gpio_free(unsigned gpio
) {
106 /* Returns IRQ to attach for gpio. Unchecked function */
107 static inline int gpio_to_irq(unsigned gpio
) {
108 return AR531X_GPIO_IRQ(gpio
);
111 /* Returns gpio for IRQ attached. Unchecked function */
112 static inline int irq_to_gpio(unsigned irq
) {
113 return (irq
- (AR531X_GPIO_IRQ(0)));
116 /* #include <asm-generic/gpio.h> */ /* cansleep wrappers */
117 /* platforms that don't directly support access to GPIOs through I2C, SPI,
118 * or other blocking infrastructure can use these wrappers.
121 static inline int gpio_cansleep(unsigned gpio
) {
125 static inline int gpio_get_value_cansleep(unsigned gpio
) {
127 return gpio_get_value(gpio
);
130 static inline void gpio_set_value_cansleep(unsigned gpio
, int value
) {
132 gpio_set_value(gpio
, value
);
This page took 0.048829 seconds and 5 git commands to generate.