41 ctl &= ~(1 << led_index);
43 ctl |= (1 << led_index);
47 static void b43_led_turn_off(
struct b43_wldev *dev,
u8 led_index,
54 ctl |= (1 << led_index);
56 ctl &= ~(1 << led_index);
60 static void b43_led_update(
struct b43_wldev *dev,
78 if (turn_on == led->hw_state)
80 led->hw_state = turn_on;
83 b43_led_turn_on(dev, led->index, led->activelow);
85 b43_led_turn_off(dev, led->index, led->activelow);
99 b43_led_update(dev, &wl->
leds.led_tx);
100 b43_led_update(dev, &wl->
leds.led_rx);
101 b43_led_update(dev, &wl->
leds.led_radio);
102 b43_led_update(dev, &wl->
leds.led_assoc);
109 static void b43_led_brightness_set(
struct led_classdev *led_dev,
112 struct b43_led *led =
container_of(led_dev,
struct b43_led, led_dev);
113 struct b43_wl *wl = led->wl;
121 static int b43_register_led(
struct b43_wldev *dev,
struct b43_led *led,
122 const char *
name,
const char *default_trigger,
123 u8 led_index,
bool activelow)
129 if (!default_trigger)
132 led->index = led_index;
133 led->activelow = activelow;
134 strncpy(led->name, name,
sizeof(led->name));
137 led->led_dev.name = led->name;
138 led->led_dev.default_trigger = default_trigger;
139 led->led_dev.brightness_set = b43_led_brightness_set;
143 b43warn(dev->
wl,
"LEDs: Failed to register %s\n", name);
151 static void b43_unregister_led(
struct b43_led *led)
159 static void b43_map_led(
struct b43_wldev *dev,
161 enum b43_led_behaviour behaviour,
165 char name[B43_LED_MAX_NAME_LEN + 1];
170 case B43_LED_INACTIVE:
174 case B43_LED_ACTIVITY:
175 case B43_LED_TRANSFER:
176 case B43_LED_APTRANSFER:
178 "b43-%s::tx", wiphy_name(hw->
wiphy));
179 b43_register_led(dev, &dev->
wl->leds.led_tx, name,
180 ieee80211_get_tx_led_name(hw),
181 led_index, activelow);
183 "b43-%s::rx", wiphy_name(hw->
wiphy));
184 b43_register_led(dev, &dev->
wl->leds.led_rx, name,
185 ieee80211_get_rx_led_name(hw),
186 led_index, activelow);
188 case B43_LED_RADIO_ALL:
189 case B43_LED_RADIO_A:
190 case B43_LED_RADIO_B:
191 case B43_LED_MODE_BG:
193 "b43-%s::radio", wiphy_name(hw->
wiphy));
194 b43_register_led(dev, &dev->
wl->leds.led_radio, name,
195 ieee80211_get_radio_led_name(hw),
196 led_index, activelow);
201 "b43-%s::assoc", wiphy_name(hw->
wiphy));
202 b43_register_led(dev, &dev->
wl->leds.led_assoc, name,
203 ieee80211_get_assoc_led_name(hw),
204 led_index, activelow);
207 b43warn(dev->
wl,
"LEDs: Unknown behaviour 0x%02X\n",
213 static void b43_led_get_sprominfo(
struct b43_wldev *dev,
214 unsigned int led_index,
215 enum b43_led_behaviour *behaviour,
220 sprom[0] = dev->
dev->bus_sprom->gpio0;
221 sprom[1] = dev->
dev->bus_sprom->gpio1;
222 sprom[2] = dev->
dev->bus_sprom->gpio2;
223 sprom[3] = dev->
dev->bus_sprom->gpio3;
225 if (sprom[led_index] == 0xFF) {
231 *behaviour = B43_LED_ACTIVITY;
234 *behaviour = B43_LED_RADIO_ALL;
237 *behaviour = B43_LED_RADIO_B;
239 *behaviour = B43_LED_ASSOC;
242 *behaviour = B43_LED_RADIO_A;
245 *behaviour = B43_LED_OFF;
248 *behaviour = B43_LED_OFF;
253 *behaviour = sprom[led_index] & B43_LED_BEHAVIOUR;
254 *activelow = !!(sprom[led_index] & B43_LED_ACTIVELOW);
262 enum b43_led_behaviour behaviour;
266 led = &dev->
wl->leds.led_radio;
269 b43_led_turn_on(dev, led->index, led->activelow);
270 led->hw_state =
true;
273 b43_led_turn_off(dev, led->index, led->activelow);
274 led->hw_state =
false;
280 led = &dev->
wl->leds.led_tx;
282 b43_led_turn_off(dev, led->index, led->activelow);
283 led->hw_state =
false;
286 led = &dev->
wl->leds.led_rx;
288 b43_led_turn_off(dev, led->index, led->activelow);
289 led->hw_state =
false;
292 led = &dev->
wl->leds.led_assoc;
294 b43_led_turn_off(dev, led->index, led->activelow);
295 led->hw_state =
false;
300 for (i = 0; i < B43_MAX_NR_LEDS; i++) {
301 b43_led_get_sprominfo(dev, i, &behaviour, &activelow);
304 b43_led_turn_off(dev, i, activelow);
307 b43_led_turn_on(dev, i, activelow);
315 dev->
wl->leds.stop = 0;
322 b43_led_turn_off(dev, leds->led_tx.index, leds->led_tx.activelow);
323 b43_led_turn_off(dev, leds->led_rx.index, leds->led_rx.activelow);
324 b43_led_turn_off(dev, leds->led_assoc.index, leds->led_assoc.activelow);
325 b43_led_turn_off(dev, leds->led_radio.index, leds->led_radio.activelow);
339 enum b43_led_behaviour behaviour;
345 for (i = 0; i < B43_MAX_NR_LEDS; i++) {
346 b43_led_get_sprominfo(dev, i, &behaviour, &activelow);
347 b43_map_led(dev, i, behaviour, activelow);
355 b43_unregister_led(&leds->led_tx);
356 b43_unregister_led(&leds->led_rx);
357 b43_unregister_led(&leds->led_assoc);
358 b43_unregister_led(&leds->led_radio);