diff options
Diffstat (limited to 'drivers/net/wireless/ath/ath5k/gpio.c')
-rw-r--r-- | drivers/net/wireless/ath/ath5k/gpio.c | 81 |
1 files changed, 63 insertions, 18 deletions
diff --git a/drivers/net/wireless/ath/ath5k/gpio.c b/drivers/net/wireless/ath/ath5k/gpio.c index 859297811914..73d3dd8a306a 100644 --- a/drivers/net/wireless/ath/ath5k/gpio.c +++ b/drivers/net/wireless/ath/ath5k/gpio.c | |||
@@ -24,10 +24,33 @@ | |||
24 | #include "reg.h" | 24 | #include "reg.h" |
25 | #include "debug.h" | 25 | #include "debug.h" |
26 | 26 | ||
27 | /* | 27 | |
28 | * Set led state | 28 | /** |
29 | * DOC: GPIO/LED functions | ||
30 | * | ||
31 | * Here we control the 6 bidirectional GPIO pins provided by the hw. | ||
32 | * We can set a GPIO pin to be an input or an output pin on GPIO control | ||
33 | * register and then read or set its status from GPIO data input/output | ||
34 | * registers. | ||
35 | * | ||
36 | * We also control the two LED pins provided by the hw, LED_0 is our | ||
37 | * "power" LED and LED_1 is our "network activity" LED but many scenarios | ||
38 | * are available from hw. Vendors might also provide LEDs connected to the | ||
39 | * GPIO pins, we handle them through the LED subsystem on led.c | ||
40 | */ | ||
41 | |||
42 | |||
43 | /** | ||
44 | * ath5k_hw_set_ledstate() - Set led state | ||
45 | * @ah: The &struct ath5k_hw | ||
46 | * @state: One of AR5K_LED_* | ||
47 | * | ||
48 | * Used to set the LED blinking state. This only | ||
49 | * works for the LED connected to the LED_0, LED_1 pins, | ||
50 | * not the GPIO based. | ||
29 | */ | 51 | */ |
30 | void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state) | 52 | void |
53 | ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state) | ||
31 | { | 54 | { |
32 | u32 led; | 55 | u32 led; |
33 | /*5210 has different led mode handling*/ | 56 | /*5210 has different led mode handling*/ |
@@ -74,10 +97,13 @@ void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state) | |||
74 | AR5K_REG_ENABLE_BITS(ah, AR5K_PCICFG, led_5210); | 97 | AR5K_REG_ENABLE_BITS(ah, AR5K_PCICFG, led_5210); |
75 | } | 98 | } |
76 | 99 | ||
77 | /* | 100 | /** |
78 | * Set GPIO inputs | 101 | * ath5k_hw_set_gpio_input() - Set GPIO inputs |
102 | * @ah: The &struct ath5k_hw | ||
103 | * @gpio: GPIO pin to set as input | ||
79 | */ | 104 | */ |
80 | int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio) | 105 | int |
106 | ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio) | ||
81 | { | 107 | { |
82 | if (gpio >= AR5K_NUM_GPIO) | 108 | if (gpio >= AR5K_NUM_GPIO) |
83 | return -EINVAL; | 109 | return -EINVAL; |
@@ -89,10 +115,13 @@ int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio) | |||
89 | return 0; | 115 | return 0; |
90 | } | 116 | } |
91 | 117 | ||
92 | /* | 118 | /** |
93 | * Set GPIO outputs | 119 | * ath5k_hw_set_gpio_output() - Set GPIO outputs |
120 | * @ah: The &struct ath5k_hw | ||
121 | * @gpio: The GPIO pin to set as output | ||
94 | */ | 122 | */ |
95 | int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio) | 123 | int |
124 | ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio) | ||
96 | { | 125 | { |
97 | if (gpio >= AR5K_NUM_GPIO) | 126 | if (gpio >= AR5K_NUM_GPIO) |
98 | return -EINVAL; | 127 | return -EINVAL; |
@@ -104,10 +133,13 @@ int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio) | |||
104 | return 0; | 133 | return 0; |
105 | } | 134 | } |
106 | 135 | ||
107 | /* | 136 | /** |
108 | * Get GPIO state | 137 | * ath5k_hw_get_gpio() - Get GPIO state |
138 | * @ah: The &struct ath5k_hw | ||
139 | * @gpio: The GPIO pin to read | ||
109 | */ | 140 | */ |
110 | u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio) | 141 | u32 |
142 | ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio) | ||
111 | { | 143 | { |
112 | if (gpio >= AR5K_NUM_GPIO) | 144 | if (gpio >= AR5K_NUM_GPIO) |
113 | return 0xffffffff; | 145 | return 0xffffffff; |
@@ -117,10 +149,14 @@ u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio) | |||
117 | 0x1; | 149 | 0x1; |
118 | } | 150 | } |
119 | 151 | ||
120 | /* | 152 | /** |
121 | * Set GPIO state | 153 | * ath5k_hw_set_gpio() - Set GPIO state |
154 | * @ah: The &struct ath5k_hw | ||
155 | * @gpio: The GPIO pin to set | ||
156 | * @val: Value to set (boolean) | ||
122 | */ | 157 | */ |
123 | int ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val) | 158 | int |
159 | ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val) | ||
124 | { | 160 | { |
125 | u32 data; | 161 | u32 data; |
126 | 162 | ||
@@ -138,10 +174,19 @@ int ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val) | |||
138 | return 0; | 174 | return 0; |
139 | } | 175 | } |
140 | 176 | ||
141 | /* | 177 | /** |
142 | * Initialize the GPIO interrupt (RFKill switch) | 178 | * ath5k_hw_set_gpio_intr() - Initialize the GPIO interrupt (RFKill switch) |
179 | * @ah: The &struct ath5k_hw | ||
180 | * @gpio: The GPIO pin to use | ||
181 | * @interrupt_level: True to generate interrupt on active pin (high) | ||
182 | * | ||
183 | * This function is used to set up the GPIO interrupt for the hw RFKill switch. | ||
184 | * That switch is connected to a GPIO pin and it's number is stored on EEPROM. | ||
185 | * It can either open or close the circuit to indicate that we should disable | ||
186 | * RF/Wireless to save power (we also get that from EEPROM). | ||
143 | */ | 187 | */ |
144 | void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio, | 188 | void |
189 | ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio, | ||
145 | u32 interrupt_level) | 190 | u32 interrupt_level) |
146 | { | 191 | { |
147 | u32 data; | 192 | u32 data; |