aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2500usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2500usb.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c91
1 files changed, 49 insertions, 42 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index df176cd2ef42..6352ebe8cb43 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -282,6 +282,31 @@ static const struct rt2x00debug rt2500usb_rt2x00debug = {
282}; 282};
283#endif /* CONFIG_RT2X00_LIB_DEBUGFS */ 283#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
284 284
285#ifdef CONFIG_RT2500USB_LEDS
286static void rt2500usb_led_brightness(struct led_classdev *led_cdev,
287 enum led_brightness brightness)
288{
289 struct rt2x00_led *led =
290 container_of(led_cdev, struct rt2x00_led, led_dev);
291 unsigned int enabled = brightness != LED_OFF;
292 unsigned int activity =
293 led->rt2x00dev->led_flags & LED_SUPPORT_ACTIVITY;
294 u16 reg;
295
296 rt2500usb_register_read(led->rt2x00dev, MAC_CSR20, &reg);
297
298 if (led->type == LED_TYPE_RADIO || led->type == LED_TYPE_ASSOC) {
299 rt2x00_set_field16(&reg, MAC_CSR20_LINK, enabled);
300 rt2x00_set_field16(&reg, MAC_CSR20_ACTIVITY,
301 enabled && activity);
302 }
303
304 rt2500usb_register_write(led->rt2x00dev, MAC_CSR20, reg);
305}
306#else
307#define rt2500usb_led_brightness NULL
308#endif /* CONFIG_RT2500USB_LEDS */
309
285/* 310/*
286 * Configuration handlers. 311 * Configuration handlers.
287 */ 312 */
@@ -526,36 +551,6 @@ static void rt2500usb_config(struct rt2x00_dev *rt2x00dev,
526} 551}
527 552
528/* 553/*
529 * LED functions.
530 */
531static void rt2500usb_enable_led(struct rt2x00_dev *rt2x00dev)
532{
533 u16 reg;
534
535 rt2500usb_register_read(rt2x00dev, MAC_CSR21, &reg);
536 rt2x00_set_field16(&reg, MAC_CSR21_ON_PERIOD, 70);
537 rt2x00_set_field16(&reg, MAC_CSR21_OFF_PERIOD, 30);
538 rt2500usb_register_write(rt2x00dev, MAC_CSR21, reg);
539
540 rt2500usb_register_read(rt2x00dev, MAC_CSR20, &reg);
541 rt2x00_set_field16(&reg, MAC_CSR20_LINK,
542 (rt2x00dev->led_mode != LED_MODE_ASUS));
543 rt2x00_set_field16(&reg, MAC_CSR20_ACTIVITY,
544 (rt2x00dev->led_mode != LED_MODE_TXRX_ACTIVITY));
545 rt2500usb_register_write(rt2x00dev, MAC_CSR20, reg);
546}
547
548static void rt2500usb_disable_led(struct rt2x00_dev *rt2x00dev)
549{
550 u16 reg;
551
552 rt2500usb_register_read(rt2x00dev, MAC_CSR20, &reg);
553 rt2x00_set_field16(&reg, MAC_CSR20_LINK, 0);
554 rt2x00_set_field16(&reg, MAC_CSR20_ACTIVITY, 0);
555 rt2500usb_register_write(rt2x00dev, MAC_CSR20, reg);
556}
557
558/*
559 * Link tuning 554 * Link tuning
560 */ 555 */
561static void rt2500usb_link_stats(struct rt2x00_dev *rt2x00dev, 556static void rt2500usb_link_stats(struct rt2x00_dev *rt2x00dev,
@@ -751,6 +746,11 @@ static int rt2500usb_init_registers(struct rt2x00_dev *rt2x00dev)
751 rt2x00_set_field16(&reg, MAC_CSR1_HOST_READY, 0); 746 rt2x00_set_field16(&reg, MAC_CSR1_HOST_READY, 0);
752 rt2500usb_register_write(rt2x00dev, MAC_CSR1, reg); 747 rt2500usb_register_write(rt2x00dev, MAC_CSR1, reg);
753 748
749 rt2500usb_register_read(rt2x00dev, MAC_CSR21, &reg);
750 rt2x00_set_field16(&reg, MAC_CSR21_ON_PERIOD, 70);
751 rt2x00_set_field16(&reg, MAC_CSR21_OFF_PERIOD, 30);
752 rt2500usb_register_write(rt2x00dev, MAC_CSR21, reg);
753
754 rt2500usb_register_read(rt2x00dev, TXRX_CSR5, &reg); 754 rt2500usb_register_read(rt2x00dev, TXRX_CSR5, &reg);
755 rt2x00_set_field16(&reg, TXRX_CSR5_BBP_ID0, 13); 755 rt2x00_set_field16(&reg, TXRX_CSR5_BBP_ID0, 13);
756 rt2x00_set_field16(&reg, TXRX_CSR5_BBP_ID0_VALID, 1); 756 rt2x00_set_field16(&reg, TXRX_CSR5_BBP_ID0_VALID, 1);
@@ -924,21 +924,11 @@ static int rt2500usb_enable_radio(struct rt2x00_dev *rt2x00dev)
924 return -EIO; 924 return -EIO;
925 } 925 }
926 926
927 /*
928 * Enable LED
929 */
930 rt2500usb_enable_led(rt2x00dev);
931
932 return 0; 927 return 0;
933} 928}
934 929
935static void rt2500usb_disable_radio(struct rt2x00_dev *rt2x00dev) 930static void rt2500usb_disable_radio(struct rt2x00_dev *rt2x00dev)
936{ 931{
937 /*
938 * Disable LED
939 */
940 rt2500usb_disable_led(rt2x00dev);
941
942 rt2500usb_register_write(rt2x00dev, MAC_CSR13, 0x2121); 932 rt2500usb_register_write(rt2x00dev, MAC_CSR13, 0x2121);
943 rt2500usb_register_write(rt2x00dev, MAC_CSR14, 0x2121); 933 rt2500usb_register_write(rt2x00dev, MAC_CSR14, 0x2121);
944 934
@@ -1370,8 +1360,24 @@ static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
1370 /* 1360 /*
1371 * Store led mode, for correct led behaviour. 1361 * Store led mode, for correct led behaviour.
1372 */ 1362 */
1373 rt2x00dev->led_mode = 1363#ifdef CONFIG_RT2500USB_LEDS
1374 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); 1364 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE);
1365
1366 switch (value) {
1367 case LED_MODE_ASUS:
1368 case LED_MODE_ALPHA:
1369 case LED_MODE_DEFAULT:
1370 rt2x00dev->led_flags = LED_SUPPORT_RADIO;
1371 break;
1372 case LED_MODE_TXRX_ACTIVITY:
1373 rt2x00dev->led_flags =
1374 LED_SUPPORT_RADIO | LED_SUPPORT_ACTIVITY;
1375 break;
1376 case LED_MODE_SIGNAL_STRENGTH:
1377 rt2x00dev->led_flags = LED_SUPPORT_RADIO;
1378 break;
1379 }
1380#endif /* CONFIG_RT2500USB_LEDS */
1375 1381
1376 /* 1382 /*
1377 * Check if the BBP tuning should be disabled. 1383 * Check if the BBP tuning should be disabled.
@@ -1817,6 +1823,7 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
1817 .link_stats = rt2500usb_link_stats, 1823 .link_stats = rt2500usb_link_stats,
1818 .reset_tuner = rt2500usb_reset_tuner, 1824 .reset_tuner = rt2500usb_reset_tuner,
1819 .link_tuner = rt2500usb_link_tuner, 1825 .link_tuner = rt2500usb_link_tuner,
1826 .led_brightness = rt2500usb_led_brightness,
1820 .write_tx_desc = rt2500usb_write_tx_desc, 1827 .write_tx_desc = rt2500usb_write_tx_desc,
1821 .write_tx_data = rt2x00usb_write_tx_data, 1828 .write_tx_data = rt2x00usb_write_tx_data,
1822 .get_tx_data_len = rt2500usb_get_tx_data_len, 1829 .get_tx_data_len = rt2500usb_get_tx_data_len,