diff options
author | Ivo van Doorn <ivdoorn@gmail.com> | 2008-02-03 09:53:40 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-02-29 15:37:00 -0500 |
commit | a9450b70a755abf093600035ef5361c53343fe9a (patch) | |
tree | 94b509ea1e73454d327f805273a1fce994d95b1b /drivers/net/wireless/rt2x00/rt2400pci.c | |
parent | f2a3c7f5c8e3c1356dbbce1e9ac2e7f4d5365ba9 (diff) |
rt2x00: Make use of MAC80211_LED_TRIGGERS
Make use of the led triggers provided by mac80211 to control
the led status. This can be enabled through a per-driver
configuration option which will automatically enable the
generic handler in rt2x00lib.
This has been enabled for rt2500usb and rt73usb for the moment
since the led class will call set_brightness in irq context which
will not work correctly with the usb drivers who need to sleep.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2400pci.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2400pci.c | 88 |
1 files changed, 48 insertions, 40 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c index feb8c09a33ad..69b4852d4c7f 100644 --- a/drivers/net/wireless/rt2x00/rt2400pci.c +++ b/drivers/net/wireless/rt2x00/rt2400pci.c | |||
@@ -243,6 +243,30 @@ static int rt2400pci_rfkill_poll(struct rt2x00_dev *rt2x00dev) | |||
243 | #define rt2400pci_rfkill_poll NULL | 243 | #define rt2400pci_rfkill_poll NULL |
244 | #endif /* CONFIG_RT2400PCI_RFKILL */ | 244 | #endif /* CONFIG_RT2400PCI_RFKILL */ |
245 | 245 | ||
246 | #ifdef CONFIG_RT2400PCI_LEDS | ||
247 | static void rt2400pci_led_brightness(struct led_classdev *led_cdev, | ||
248 | enum led_brightness brightness) | ||
249 | { | ||
250 | struct rt2x00_led *led = | ||
251 | container_of(led_cdev, struct rt2x00_led, led_dev); | ||
252 | unsigned int enabled = brightness != LED_OFF; | ||
253 | unsigned int activity = | ||
254 | led->rt2x00dev->led_flags & LED_SUPPORT_ACTIVITY; | ||
255 | u32 reg; | ||
256 | |||
257 | rt2x00pci_register_read(led->rt2x00dev, LEDCSR, ®); | ||
258 | |||
259 | if (led->type == LED_TYPE_RADIO || led->type == LED_TYPE_ASSOC) { | ||
260 | rt2x00_set_field32(®, LEDCSR_LINK, enabled); | ||
261 | rt2x00_set_field32(®, LEDCSR_ACTIVITY, enabled && activity); | ||
262 | } | ||
263 | |||
264 | rt2x00pci_register_write(led->rt2x00dev, LEDCSR, reg); | ||
265 | } | ||
266 | #else | ||
267 | #define rt2400pci_led_brightness NULL | ||
268 | #endif /* CONFIG_RT2400PCI_LEDS */ | ||
269 | |||
246 | /* | 270 | /* |
247 | * Configuration handlers. | 271 | * Configuration handlers. |
248 | */ | 272 | */ |
@@ -511,34 +535,6 @@ static void rt2400pci_config_cw(struct rt2x00_dev *rt2x00dev, | |||
511 | } | 535 | } |
512 | 536 | ||
513 | /* | 537 | /* |
514 | * LED functions. | ||
515 | */ | ||
516 | static void rt2400pci_enable_led(struct rt2x00_dev *rt2x00dev) | ||
517 | { | ||
518 | u32 reg; | ||
519 | |||
520 | rt2x00pci_register_read(rt2x00dev, LEDCSR, ®); | ||
521 | |||
522 | rt2x00_set_field32(®, LEDCSR_ON_PERIOD, 70); | ||
523 | rt2x00_set_field32(®, LEDCSR_OFF_PERIOD, 30); | ||
524 | rt2x00_set_field32(®, LEDCSR_LINK, | ||
525 | (rt2x00dev->led_mode != LED_MODE_ASUS)); | ||
526 | rt2x00_set_field32(®, LEDCSR_ACTIVITY, | ||
527 | (rt2x00dev->led_mode != LED_MODE_TXRX_ACTIVITY)); | ||
528 | rt2x00pci_register_write(rt2x00dev, LEDCSR, reg); | ||
529 | } | ||
530 | |||
531 | static void rt2400pci_disable_led(struct rt2x00_dev *rt2x00dev) | ||
532 | { | ||
533 | u32 reg; | ||
534 | |||
535 | rt2x00pci_register_read(rt2x00dev, LEDCSR, ®); | ||
536 | rt2x00_set_field32(®, LEDCSR_LINK, 0); | ||
537 | rt2x00_set_field32(®, LEDCSR_ACTIVITY, 0); | ||
538 | rt2x00pci_register_write(rt2x00dev, LEDCSR, reg); | ||
539 | } | ||
540 | |||
541 | /* | ||
542 | * Link tuning | 538 | * Link tuning |
543 | */ | 539 | */ |
544 | static void rt2400pci_link_stats(struct rt2x00_dev *rt2x00dev, | 540 | static void rt2400pci_link_stats(struct rt2x00_dev *rt2x00dev, |
@@ -703,6 +699,11 @@ static int rt2400pci_init_registers(struct rt2x00_dev *rt2x00dev) | |||
703 | (rt2x00dev->rx->data_size / 128)); | 699 | (rt2x00dev->rx->data_size / 128)); |
704 | rt2x00pci_register_write(rt2x00dev, CSR9, reg); | 700 | rt2x00pci_register_write(rt2x00dev, CSR9, reg); |
705 | 701 | ||
702 | rt2x00pci_register_read(rt2x00dev, LEDCSR, ®); | ||
703 | rt2x00_set_field32(®, LEDCSR_ON_PERIOD, 70); | ||
704 | rt2x00_set_field32(®, LEDCSR_OFF_PERIOD, 30); | ||
705 | rt2x00pci_register_write(rt2x00dev, LEDCSR, reg); | ||
706 | |||
706 | rt2x00pci_register_write(rt2x00dev, CNT3, 0x3f080000); | 707 | rt2x00pci_register_write(rt2x00dev, CNT3, 0x3f080000); |
707 | 708 | ||
708 | rt2x00pci_register_read(rt2x00dev, ARCSR0, ®); | 709 | rt2x00pci_register_read(rt2x00dev, ARCSR0, ®); |
@@ -872,11 +873,6 @@ static int rt2400pci_enable_radio(struct rt2x00_dev *rt2x00dev) | |||
872 | */ | 873 | */ |
873 | rt2400pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_ON); | 874 | rt2400pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_ON); |
874 | 875 | ||
875 | /* | ||
876 | * Enable LED | ||
877 | */ | ||
878 | rt2400pci_enable_led(rt2x00dev); | ||
879 | |||
880 | return 0; | 876 | return 0; |
881 | } | 877 | } |
882 | 878 | ||
@@ -884,11 +880,6 @@ static void rt2400pci_disable_radio(struct rt2x00_dev *rt2x00dev) | |||
884 | { | 880 | { |
885 | u32 reg; | 881 | u32 reg; |
886 | 882 | ||
887 | /* | ||
888 | * Disable LED | ||
889 | */ | ||
890 | rt2400pci_disable_led(rt2x00dev); | ||
891 | |||
892 | rt2x00pci_register_write(rt2x00dev, PWRCSR0, 0); | 883 | rt2x00pci_register_write(rt2x00dev, PWRCSR0, 0); |
893 | 884 | ||
894 | /* | 885 | /* |
@@ -1273,8 +1264,24 @@ static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
1273 | /* | 1264 | /* |
1274 | * Store led mode, for correct led behaviour. | 1265 | * Store led mode, for correct led behaviour. |
1275 | */ | 1266 | */ |
1276 | rt2x00dev->led_mode = | 1267 | #ifdef CONFIG_RT2400PCI_LEDS |
1277 | rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); | 1268 | value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); |
1269 | |||
1270 | switch (value) { | ||
1271 | case LED_MODE_ASUS: | ||
1272 | case LED_MODE_ALPHA: | ||
1273 | case LED_MODE_DEFAULT: | ||
1274 | rt2x00dev->led_flags = LED_SUPPORT_RADIO; | ||
1275 | break; | ||
1276 | case LED_MODE_TXRX_ACTIVITY: | ||
1277 | rt2x00dev->led_flags = | ||
1278 | LED_SUPPORT_RADIO | LED_SUPPORT_ACTIVITY; | ||
1279 | break; | ||
1280 | case LED_MODE_SIGNAL_STRENGTH: | ||
1281 | rt2x00dev->led_flags = LED_SUPPORT_RADIO; | ||
1282 | break; | ||
1283 | } | ||
1284 | #endif /* CONFIG_RT2400PCI_LEDS */ | ||
1278 | 1285 | ||
1279 | /* | 1286 | /* |
1280 | * Detect if this device has an hardware controlled radio. | 1287 | * Detect if this device has an hardware controlled radio. |
@@ -1594,6 +1601,7 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = { | |||
1594 | .link_stats = rt2400pci_link_stats, | 1601 | .link_stats = rt2400pci_link_stats, |
1595 | .reset_tuner = rt2400pci_reset_tuner, | 1602 | .reset_tuner = rt2400pci_reset_tuner, |
1596 | .link_tuner = rt2400pci_link_tuner, | 1603 | .link_tuner = rt2400pci_link_tuner, |
1604 | .led_brightness = rt2400pci_led_brightness, | ||
1597 | .write_tx_desc = rt2400pci_write_tx_desc, | 1605 | .write_tx_desc = rt2400pci_write_tx_desc, |
1598 | .write_tx_data = rt2x00pci_write_tx_data, | 1606 | .write_tx_data = rt2x00pci_write_tx_data, |
1599 | .kick_tx_queue = rt2400pci_kick_tx_queue, | 1607 | .kick_tx_queue = rt2400pci_kick_tx_queue, |