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/rt2500pci.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/rt2500pci.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2500pci.c | 88 |
1 files changed, 48 insertions, 40 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c index 36c64f751b1..bb359a14b4a 100644 --- a/drivers/net/wireless/rt2x00/rt2500pci.c +++ b/drivers/net/wireless/rt2x00/rt2500pci.c | |||
@@ -243,6 +243,30 @@ static int rt2500pci_rfkill_poll(struct rt2x00_dev *rt2x00dev) | |||
243 | #define rt2500pci_rfkill_poll NULL | 243 | #define rt2500pci_rfkill_poll NULL |
244 | #endif /* CONFIG_RT2500PCI_RFKILL */ | 244 | #endif /* CONFIG_RT2500PCI_RFKILL */ |
245 | 245 | ||
246 | #ifdef CONFIG_RT2500PCI_LEDS | ||
247 | static void rt2500pci_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 rt2500pci_led_brightness NULL | ||
268 | #endif /* CONFIG_RT2500PCI_LEDS */ | ||
269 | |||
246 | /* | 270 | /* |
247 | * Configuration handlers. | 271 | * Configuration handlers. |
248 | */ | 272 | */ |
@@ -549,34 +573,6 @@ static void rt2500pci_config(struct rt2x00_dev *rt2x00dev, | |||
549 | } | 573 | } |
550 | 574 | ||
551 | /* | 575 | /* |
552 | * LED functions. | ||
553 | */ | ||
554 | static void rt2500pci_enable_led(struct rt2x00_dev *rt2x00dev) | ||
555 | { | ||
556 | u32 reg; | ||
557 | |||
558 | rt2x00pci_register_read(rt2x00dev, LEDCSR, ®); | ||
559 | |||
560 | rt2x00_set_field32(®, LEDCSR_ON_PERIOD, 70); | ||
561 | rt2x00_set_field32(®, LEDCSR_OFF_PERIOD, 30); | ||
562 | rt2x00_set_field32(®, LEDCSR_LINK, | ||
563 | (rt2x00dev->led_mode != LED_MODE_ASUS)); | ||
564 | rt2x00_set_field32(®, LEDCSR_ACTIVITY, | ||
565 | (rt2x00dev->led_mode != LED_MODE_TXRX_ACTIVITY)); | ||
566 | rt2x00pci_register_write(rt2x00dev, LEDCSR, reg); | ||
567 | } | ||
568 | |||
569 | static void rt2500pci_disable_led(struct rt2x00_dev *rt2x00dev) | ||
570 | { | ||
571 | u32 reg; | ||
572 | |||
573 | rt2x00pci_register_read(rt2x00dev, LEDCSR, ®); | ||
574 | rt2x00_set_field32(®, LEDCSR_LINK, 0); | ||
575 | rt2x00_set_field32(®, LEDCSR_ACTIVITY, 0); | ||
576 | rt2x00pci_register_write(rt2x00dev, LEDCSR, reg); | ||
577 | } | ||
578 | |||
579 | /* | ||
580 | * Link tuning | 576 | * Link tuning |
581 | */ | 577 | */ |
582 | static void rt2500pci_link_stats(struct rt2x00_dev *rt2x00dev, | 578 | static void rt2500pci_link_stats(struct rt2x00_dev *rt2x00dev, |
@@ -795,6 +791,11 @@ static int rt2500pci_init_registers(struct rt2x00_dev *rt2x00dev) | |||
795 | rt2x00_set_field32(®, CSR11_CW_SELECT, 0); | 791 | rt2x00_set_field32(®, CSR11_CW_SELECT, 0); |
796 | rt2x00pci_register_write(rt2x00dev, CSR11, reg); | 792 | rt2x00pci_register_write(rt2x00dev, CSR11, reg); |
797 | 793 | ||
794 | rt2x00pci_register_read(rt2x00dev, LEDCSR, ®); | ||
795 | rt2x00_set_field32(®, LEDCSR_ON_PERIOD, 70); | ||
796 | rt2x00_set_field32(®, LEDCSR_OFF_PERIOD, 30); | ||
797 | rt2x00pci_register_write(rt2x00dev, LEDCSR, reg); | ||
798 | |||
798 | rt2x00pci_register_write(rt2x00dev, CNT3, 0); | 799 | rt2x00pci_register_write(rt2x00dev, CNT3, 0); |
799 | 800 | ||
800 | rt2x00pci_register_read(rt2x00dev, TXCSR8, ®); | 801 | rt2x00pci_register_read(rt2x00dev, TXCSR8, ®); |
@@ -1026,11 +1027,6 @@ static int rt2500pci_enable_radio(struct rt2x00_dev *rt2x00dev) | |||
1026 | */ | 1027 | */ |
1027 | rt2500pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_ON); | 1028 | rt2500pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_ON); |
1028 | 1029 | ||
1029 | /* | ||
1030 | * Enable LED | ||
1031 | */ | ||
1032 | rt2500pci_enable_led(rt2x00dev); | ||
1033 | |||
1034 | return 0; | 1030 | return 0; |
1035 | } | 1031 | } |
1036 | 1032 | ||
@@ -1038,11 +1034,6 @@ static void rt2500pci_disable_radio(struct rt2x00_dev *rt2x00dev) | |||
1038 | { | 1034 | { |
1039 | u32 reg; | 1035 | u32 reg; |
1040 | 1036 | ||
1041 | /* | ||
1042 | * Disable LED | ||
1043 | */ | ||
1044 | rt2500pci_disable_led(rt2x00dev); | ||
1045 | |||
1046 | rt2x00pci_register_write(rt2x00dev, PWRCSR0, 0); | 1037 | rt2x00pci_register_write(rt2x00dev, PWRCSR0, 0); |
1047 | 1038 | ||
1048 | /* | 1039 | /* |
@@ -1445,8 +1436,24 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
1445 | /* | 1436 | /* |
1446 | * Store led mode, for correct led behaviour. | 1437 | * Store led mode, for correct led behaviour. |
1447 | */ | 1438 | */ |
1448 | rt2x00dev->led_mode = | 1439 | #ifdef CONFIG_RT2500PCI_LEDS |
1449 | rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); | 1440 | value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); |
1441 | |||
1442 | switch (value) { | ||
1443 | case LED_MODE_ASUS: | ||
1444 | case LED_MODE_ALPHA: | ||
1445 | case LED_MODE_DEFAULT: | ||
1446 | rt2x00dev->led_flags = LED_SUPPORT_RADIO; | ||
1447 | break; | ||
1448 | case LED_MODE_TXRX_ACTIVITY: | ||
1449 | rt2x00dev->led_flags = | ||
1450 | LED_SUPPORT_RADIO | LED_SUPPORT_ACTIVITY; | ||
1451 | break; | ||
1452 | case LED_MODE_SIGNAL_STRENGTH: | ||
1453 | rt2x00dev->led_flags = LED_SUPPORT_RADIO; | ||
1454 | break; | ||
1455 | } | ||
1456 | #endif /* CONFIG_RT2500PCI_LEDS */ | ||
1450 | 1457 | ||
1451 | /* | 1458 | /* |
1452 | * Detect if this device has an hardware controlled radio. | 1459 | * Detect if this device has an hardware controlled radio. |
@@ -1906,6 +1913,7 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = { | |||
1906 | .link_stats = rt2500pci_link_stats, | 1913 | .link_stats = rt2500pci_link_stats, |
1907 | .reset_tuner = rt2500pci_reset_tuner, | 1914 | .reset_tuner = rt2500pci_reset_tuner, |
1908 | .link_tuner = rt2500pci_link_tuner, | 1915 | .link_tuner = rt2500pci_link_tuner, |
1916 | .led_brightness = rt2500pci_led_brightness, | ||
1909 | .write_tx_desc = rt2500pci_write_tx_desc, | 1917 | .write_tx_desc = rt2500pci_write_tx_desc, |
1910 | .write_tx_data = rt2x00pci_write_tx_data, | 1918 | .write_tx_data = rt2x00pci_write_tx_data, |
1911 | .kick_tx_queue = rt2500pci_kick_tx_queue, | 1919 | .kick_tx_queue = rt2500pci_kick_tx_queue, |