This source file includes following definitions.
- ath5k_rfkill_disable
- ath5k_rfkill_enable
- ath5k_rfkill_set_intr
- ath5k_is_rfkill_set
- ath5k_tasklet_rfkill_toggle
- ath5k_rfkill_hw_start
- ath5k_rfkill_hw_stop
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 #include "ath5k.h"
37
38
39 static inline void ath5k_rfkill_disable(struct ath5k_hw *ah)
40 {
41 ATH5K_DBG(ah, ATH5K_DEBUG_ANY, "rfkill disable (gpio:%d polarity:%d)\n",
42 ah->rf_kill.gpio, ah->rf_kill.polarity);
43 ath5k_hw_set_gpio_output(ah, ah->rf_kill.gpio);
44 ath5k_hw_set_gpio(ah, ah->rf_kill.gpio, !ah->rf_kill.polarity);
45 }
46
47
48 static inline void ath5k_rfkill_enable(struct ath5k_hw *ah)
49 {
50 ATH5K_DBG(ah, ATH5K_DEBUG_ANY, "rfkill enable (gpio:%d polarity:%d)\n",
51 ah->rf_kill.gpio, ah->rf_kill.polarity);
52 ath5k_hw_set_gpio_output(ah, ah->rf_kill.gpio);
53 ath5k_hw_set_gpio(ah, ah->rf_kill.gpio, ah->rf_kill.polarity);
54 }
55
56 static inline void ath5k_rfkill_set_intr(struct ath5k_hw *ah, bool enable)
57 {
58 u32 curval;
59
60 ath5k_hw_set_gpio_input(ah, ah->rf_kill.gpio);
61 curval = ath5k_hw_get_gpio(ah, ah->rf_kill.gpio);
62 ath5k_hw_set_gpio_intr(ah, ah->rf_kill.gpio, enable ?
63 !!curval : !curval);
64 }
65
66 static bool
67 ath5k_is_rfkill_set(struct ath5k_hw *ah)
68 {
69
70
71 return ath5k_hw_get_gpio(ah, ah->rf_kill.gpio) ==
72 ah->rf_kill.polarity;
73 }
74
75 static void
76 ath5k_tasklet_rfkill_toggle(unsigned long data)
77 {
78 struct ath5k_hw *ah = (void *)data;
79 bool blocked;
80
81 blocked = ath5k_is_rfkill_set(ah);
82 wiphy_rfkill_set_hw_state(ah->hw->wiphy, blocked);
83 }
84
85
86 void
87 ath5k_rfkill_hw_start(struct ath5k_hw *ah)
88 {
89
90 ah->rf_kill.gpio = ah->ah_capabilities.cap_eeprom.ee_rfkill_pin;
91 ah->rf_kill.polarity = ah->ah_capabilities.cap_eeprom.ee_rfkill_pol;
92
93 tasklet_init(&ah->rf_kill.toggleq, ath5k_tasklet_rfkill_toggle,
94 (unsigned long)ah);
95
96 ath5k_rfkill_disable(ah);
97
98
99 if (AR5K_EEPROM_HDR_RFKILL(ah->ah_capabilities.cap_eeprom.ee_header))
100 ath5k_rfkill_set_intr(ah, true);
101 }
102
103
104 void
105 ath5k_rfkill_hw_stop(struct ath5k_hw *ah)
106 {
107
108 if (AR5K_EEPROM_HDR_RFKILL(ah->ah_capabilities.cap_eeprom.ee_header))
109 ath5k_rfkill_set_intr(ah, false);
110
111 tasklet_kill(&ah->rf_kill.toggleq);
112
113
114 ath5k_rfkill_enable(ah);
115 }
116