rt2x00: Support TXRX led handling
Subsystems (3)
PATCH 28/32 rt2x00: Support TXRX led handling
From: Ivo van Doorn <[email protected]>
Create more advanced led handling, enable txrx activity by switching on and off the led at interrupt time.
Signed-off-by Ivo van Doorn <[email protected]>
drivers/net/wireless/d80211/rt2x00/rt2400pci.c +67 -12
@@ -669,6 +669,57 @@ rt2400pci_link_tuner(struct rt2x00_pci * }/* +* LED functions. +*/ +static void +rt2400pci_enable_led (struct rt2x00_pci *rt2x00pci) +{ +u32 reg; + +rt2x00_register_read (rt2x00pci,LEDCSR , ®); + +rt2x00_set_field32 (®,LEDCSR_ON_PERIOD ,30 ); +rt2x00_set_field32 (®,LEDCSR_OFF_PERIOD ,70 ); + +if (rt2x00pci->led_mode ==LED_MODE_TXRX_ACTIVITY ) { +rt2x00_set_field32 (®,LEDCSR_LINK ,1 ); +rt2x00_set_field32 (®,LEDCSR_ACTIVITY ,0 ); + }else if (rt2x00pci->led_mode ==LED_MODE_ASUS ) { +rt2x00_set_field32 (®,LEDCSR_LINK ,0 ); +rt2x00_set_field32 (®,LEDCSR_ACTIVITY ,1 ); + }else { +rt2x00_set_field32 (®,LEDCSR_LINK ,1 ); +rt2x00_set_field32 (®,LEDCSR_ACTIVITY ,1 ); + } + +rt2x00_register_write (rt2x00pci,LEDCSR , reg); +} + +static void +rt2400pci_disable_led (struct rt2x00_pci *rt2x00pci) +{ +u32 reg; + +rt2x00_register_read (rt2x00pci,LEDCSR , ®); +rt2x00_set_field32 (®,LEDCSR_LINK ,0 ); +rt2x00_set_field32 (®,LEDCSR_ACTIVITY ,0 ); +rt2x00_register_write (rt2x00pci,LEDCSR , reg); +} + +static void +rt2400pci_activity_led (struct rt2x00_pci *rt2x00pci,char activity) +{ +u32 reg; + +if (rt2x00pci->led_mode !=LED_MODE_TXRX_ACTIVITY ) +return ; + +rt2x00_register_read (rt2x00pci,LEDCSR , ®); +rt2x00_set_field32 (®,LEDCSR_ACTIVITY , activity); +rt2x00_register_write (rt2x00pci,LEDCSR , reg); +} + +/* * Device state switch. * This will put the device to sleep, or awake it. */
@@ -882,6 +933,11 @@ rt2400pci_rxdone(void *data)* Tune link for optimal performance. */ rt2400pci_link_tuner (rt2x00pci); + +/* +* Update LED. +*/ +rt2400pci_activity_led (rt2x00pci,0 ); } static void
@@ -987,10 +1043,13 @@ rt2400pci_interrupt(int irq, void *dev_i/* * 2 - Rx ring done interrupt. +* Enable the TXRX activity led. */ -if (rt2x00_get_field32 (reg,CSR7_RXDONE )) +if (rt2x00_get_field32 (reg,CSR7_RXDONE )) {queue_work (rt2x00pci->workqueue, &rt2x00pci->ring[RING_RX ].irq_work); +rt2400pci_activity_led (rt2x00pci,1 ); + }/* * 3 - Atim ring transmit done interrupt.
@@ -1333,13 +1392,6 @@ rt2400pci_init_registers(struct rt2x00_prt2x00_set_field32 (®,RALINKCSR_AR_BBP_ID1 ,154 );rt2x00_register_write (rt2x00pci,RALINKCSR , reg); -rt2x00_register_read (rt2x00pci,LEDCSR , ®); -rt2x00_set_field32 (®,LEDCSR_ON_PERIOD ,30 ); -rt2x00_set_field32 (®,LEDCSR_OFF_PERIOD ,70 ); -rt2x00_set_field32 (®,LEDCSR_LINK ,0 ); -rt2x00_set_field32 (®,LEDCSR_ACTIVITY ,0 ); -rt2x00_register_write (rt2x00pci,LEDCSR , reg); -rt2x00_register_read (rt2x00pci,CSR1 , ®);rt2x00_set_field32 (®,CSR1_SOFT_RESET ,1 );rt2x00_set_field32 (®,CSR1_BBP_RESET ,0 );
@@ -1555,6 +1607,11 @@ rt2400pci_open(struct net_device *net_de }/* +* Enable LED +*/ +rt2400pci_enable_led (rt2x00pci); + +/* * Enable interrupts. */ rt2x00_register_read (rt2x00pci,CSR8 , ®);
@@ -1597,11 +1654,9 @@ rt2400pci_stop(struct net_device *net_dert2x00_register_write (rt2x00pci,RXCSR0 , reg);/* -* Switch off LED. +* Disable LED */ -rt2x00_register_read (rt2x00pci,LEDCSR , ®); -rt2x00_set_field32 (®,LEDCSR_LINK ,0 ); -rt2x00_register_write (rt2x00pci,LEDCSR , reg); +rt2400pci_disable_led (rt2x00pci);/* * Disable interrupts.
drivers/net/wireless/d80211/rt2x00/rt2500pci.c +67 -12
119 lines not on this page · raw message
drivers/net/wireless/d80211/rt2x00/rt2500usb.c +73 -6
123 lines not on this page · raw message