rt73usb not working since linux 3.4
Dear all,
updating my pc from linux kernel 3.3 to linux kernel 3.4 broke my wlan. I'm using rt2571 based wlan module from qcom: LR802UKG, which is wired to an internal usb port of my media center pc. The rfkill switch is hardwired to make wlan active all the time. This setup is (almost) properly working since about three years now. (If i ignore the occasional vendor_request_error things)
When I use kernel 3.4., i get a lot of additional devices reported by the kernel - three leds and a rfkill switch which have not been there before. (or at least I did not notice them) The wlan device now refuses to go online, saying that the kill switch is active, which of course can not be as it is working with linux kernel 3.3. Furthermore, the driver reports three leds, but my wlan device has only one, so probably a bad eeprom? i dont know... Anyway, I noticed, that when I set the radio led to brightness 255, which takes a lot of time and gives me some vendor_request_errors, the rfkill switch gets turned off (sys/class/rfkill/../hard = 0). Unfortunately, this doesn't help to bring the interface online: After doing that I get frequent vendor_request_failed messages, even the PC becomes stuck on shutdown. (Probably NetworkManager waiting for something...)
So, what can I do to track down the problem?
Cheers,
Andreas
Quoted 13 lines · Andreas Messer
Dear all,
updating my pc from linux kernel 3.3 to linux kernel 3.4 broke my wlan. I'm using rt2571 based wlan module from qcom: LR802UKG, which is wired to an internal usb port of my media center pc. The rfkill switch is hardwired to make wlan active all the time. This setup is (almost) properly working since about three years now. (If i ignore the occasional
vendor_request_errorthings)
When I use kernel 3.4., i get a lot of additional devices reported by the kernel - three leds and a rfkill switch which have not been there before. (or at least I did not notice them) The wlan device now refuses to go online, saying that the kill switch is active, which of course can not be as it is working with linux kernel 3.3. Furthermore, the driver reports three leds, but
Quoted 8 lines
my wlan device has only one, so probably a bad eeprom? i dont know... Anyway, I noticed, that when I set the radio led to brightness 255, which takes a lot of time and gives me some
vendor_request_errors, the rfkill switch gets turned off (sys/class/rfkill/../hard = 0). Unfortunately, this doesn't help to bring the interface online: After doing that I get frequentvendor_request_failedmessages, even the PC becomes stuck on shutdown. (Probably NetworkManager waiting for something...)
So, what can I do to track down the problem?
Andreas,
Hmmm...well, perhaps you can start by doing a git bisect to narrow-down the commit that started this problem for you? It may take serveral iterations, if you can only narrow it down to 3.3 working and 3.4 not working. But, at least that should point us in the right direction.
John
Signature · 2 lines
John W. Linville Someday the world will need a hero, and you [email protected] might be all we have. Be ready.
Quoted 23 lines · On Tue, 26 Jun 2012 18:03:56 +0200 Andreas Messer <[email protected]> wrote:
Dear all,
updating my pc from linux kernel 3.3 to linux kernel 3.4 broke my wlan. I'm using rt2571 based wlan module from qcom: LR802UKG, which is wired to an internal usb port of my media center pc. The rfkill switch is hardwired to make wlan active all the time. This setup is (almost) properly working since about three years now. (If i ignore the occasional
vendor_request_errorthings)
When I use kernel 3.4., i get a lot of additional devices reported by the kernel - three leds and a rfkill switch which have not been there before. (or at least I did not notice them) The wlan device now refuses to go online, saying that the kill switch is active, which of course can not be as it is working with linux kernel 3.3. Furthermore, the driver reports three leds, but my wlan device has only one, so probably a bad eeprom? i dont know... Anyway, I noticed, that when I set the radio led to brightness 255, which takes a lot of time and gives me somevendor_request_errors, the rfkill switch gets turned off (sys/class/rfkill/../hard = 0). Unfortunately, this doesn't help to bring the interface online: After doing that I get frequentvendor_request_failedmessages, even the PC becomes stuck on shutdown. (Probably NetworkManager waiting for something...) So, what can I do to track down the problem?
Quoted 2 lines
Cheers,
Andreas
I have the same problem with a rt73usb too and with the kernel 3.4.4-2-ARCH (Archlinux). The solution was to recompile the kernel with the option CONFIG_RFKILL unset (really unset not as a module). Then everything works properly (exept you cannot disable it with rfkill). I did not had this problem before the kernel 3.4 (but I do not know if rfkill actually works, or if the wlan was always enabled).
Olive
Quoted 8 lines
I have the same problem with a rt73usb too and with the kernel 3.4.4-2-ARCH (Archlinux). The solution was to recompile the kernel with the option
CONFIG_RFKILLunset (really unset not as a module). Then everything works properly (exept you cannot disable it with rfkill). I did not had this problem before the kernel 3.4 (but I do not know if rfkill actually works, or if the wlan was always enabled).
The strange thing is that after having disabled the CONFIG_RFKIL , the wireless works even if I physically put a physical switch in the off position. Anyway I prefer having a wireless card that works whgen it shouldn't than vice versa.
Olive
Hello Again,
Am Dienstag, 26. Juni 2012, 13:18:35 schrieb John W. Linville:
Quoted 16 lines · Andreas Messer
Quoted 14 lines
Dear all,
updating my pc from linux kernel 3.3 to linux kernel 3.4 broke my wlan. I'm
using rt2571 based wlan module from qcom: LR802UKG, which is wired to an internal usb port of my media center pc. The rfkill switch is hardwired to make wlan active all the time. This setup is (almost) properly working since about three years now. (If i ignore the occasionalvendor_request_errorthings)
The wlan device now refuses to go
online, saying that the kill switch is active, which of course can not be as it is working with linux kernel 3.3.
[...]
So, what can I do to track down the problem?
Quoted 8 lines
Andreas,
Hmmm...well, perhaps you can start by doing a git bisect to narrow-down the commit that started this problem for you? It may take serveral iterations, if you can only narrow it down to 3.3 working and 3.4 not working. But, at least that should point us in the right direction.
John
first of all, sorry for the long delay. After some hours of compiling and checking, I have found the following things: The problem is introduced somewhere between v3.3.8 and v3.4, actually the commit 7e29629 already shows the problem. So range is v3.3.8...7e29629. I thing there is something wrong with initialization of the chip because of the following behaviour: If I boot from power-off into 7e29629 the kill switch reports to be in state 1 (/sys/../hard = 1). If I first boot into 3.3.8 and afterwards re-boot into 7e29629, the kill switch reports to be in state 0 and the WLAN connection builds up properly.
Hope that helps somehow.
Cheers,
Andreas
Hey there,
Am Dienstag, 24. Juli 2012, 19:33:34 schrieb Andreas Messer:
Quoted 7 lines
Hello Again,
Am Dienstag, 26. Juni 2012, 13:18:35 schrieb John W. Linville:
Quoted 4 lines · Andreas Messer
Quoted 3 lines
Dear all,
updating my pc from linux kernel 3.3 to linux kernel 3.4 broke my wlan.
I have spent some more time on investigating the cause of the bug and found the problem. Actually I'm not sure which is the right solution. The problem is caused by the following points:
1) The rt73 hardware registers are not initialized before bringing the corresponding network interface up ('ifconfig wlan0 up')
2) Bringing the interface up is not possible because of the kill switch
3) The GPIO input pin for the kill switch is still in 'output mode' (the default power on value), therefore the register will always read 'killswitch on'
So something like a deadlock. While looking through the code, I have seen, that the whole rt2xx driver uses here the same concept, that the hardware register initialization and firmware-download does not happen before the interface is brought up. Im not sure if that is the right concept, shouldn't be the hardware initialized properly on loading the driver already? I mean, if values are read from the hardware in order to e.g. read the kill switch state shouldn't bethe hardware in a defined state before that? Anyway, it would be possible to solve this bug easily by only setting up the correct value of the CSR13 register right after reading the eeprom. For simple testing I have written the correct gpio mask to CSR13 using the debugfs interface and the wlan interface immediately was brought up and connected successfully with my Network.
So which is the right solution? I could make & test a patch for the simple solution easily.
Cheers
Andreas
Hi Andreas,
Quoted 37 lines · Andreas Messer
Hey there,
Am Dienstag, 24. Juli 2012, 19:33:34 schrieb Andreas Messer:
Quoted 7 lines
Hello Again,
Am Dienstag, 26. Juni 2012, 13:18:35 schrieb John W. Linville:
Quoted 4 lines · Andreas Messer
Quoted 3 lines
Dear all,
updating my pc from linux kernel 3.3 to linux kernel 3.4 broke my wlan.
I have spent some more time on investigating the cause of the bug and found the problem. Actually I'm not sure which is the right solution. The problem is caused by the following points:
1) The rt73 hardware registers are not initialized before bringing the corresponding network interface up ('ifconfig wlan0 up')
2) Bringing the interface up is not possible because of the kill switch
3) The GPIO input pin for the kill switch is still in 'output mode' (the default power on value), therefore the register will always read 'killswitch on'
So something like a deadlock. While looking through the code, I have seen, that the whole rt2xx driver uses here the same concept, that the hardware register initialization and firmware-download does not happen before the interface is brought up. Im not sure if that is the right concept, shouldn't be the hardware initialized properly on loading the driver already? I mean, if values are read from the hardware in order to e.g. read the kill switch state shouldn't bethe hardware in a defined state before that? Anyway, it would be possible to solve this bug easily by only setting up the correct value of the CSR13 register right after reading the eeprom. For simple testing I have written the correct gpio mask to CSR13 using the debugfs interface and the wlan interface immediately was brought up and connected successfully with my Network.
Quoted 3 lines
So which is the right solution? I could make & test a patch for the simple solution easily.
Thanks for you extensive analysis. You seem to be absolutely right that we need to properly setup the GPIO direction of the rfkill switch GPIO pin. And it seems that all rt2x00 drivers (not only rt73usb) are suffering from this.
The reason why we do most of the initialization at interface up is that that is the earliest possible time we can get the firmware image from userspace. A lot of the register programming we have to do for initialization depend on the firmware being uploaded and running, hence we initialize most at interface up time.
However, the correct fix IMHO here is to set the GPIO direction of the rfkill switch GPIO pin to input at driver load time.
Find attached a patch that does this for all the rt2x00 devices. I hope you are able to test whether this patch fixes the problem for you.
Once you have verified that the patch works, I will submit the changes as a proper patch series for inclusion upstream.
---
Gertjan
drivers/net/wireless/rt2x00/rt2400pci.c +10 -1
@@ -205,7 +205,7 @@ static int rt2400pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)u32 reg;rt2x00pci_register_read (rt2x00dev,GPIOCSR , ®); -return rt2x00_get_field32 (reg,GPIOCSR_BIT0 ); +return rt2x00_get_field32 (reg,GPIOCSR_VAL0 ); }#ifdef CONFIG_RT2X00_LIB_LEDS
@@ -1611,6 +1611,7 @@ static int rt2400pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)static int rt2400pci_probe_hw (struct rt2x00_dev *rt2x00dev) {int retval; +u32 reg;/* * Allocate eeprom data.
@@ -1624,6 +1625,14 @@ static int rt2400pci_probe_hw(struct rt2x00_dev *rt2x00dev)return retval;/* +* Enable rfkill polling by setting GPIO direction of the +* rfkill switch GPIO pin correctly. +*/ +rt2x00pci_register_read (rt2x00dev,GPIOCSR , ®); +rt2x00_set_field32 (®,GPIOCSR_DIR0 ,1 ); +rt2x00pci_register_write (rt2x00dev,GPIOCSR , reg); + +/* * Initialize hw specifications. */ retval =rt2400pci_probe_hw_mode (rt2x00dev);
drivers/net/wireless/rt2x00/rt2400pci.h +18 -8
@@ -660,16 +660,26 @@/* * GPIOCSR: GPIO control register. +* GPIOCSR_VALx: Actual GPIO pin x value +* GPIOCSR_DIRx: GPIO direction: 0 = output; 1 = input */ #define GPIOCSR 0x0120 -#define GPIOCSR_BIT0 FIELD32(0x00000001) -#define GPIOCSR_BIT1 FIELD32(0x00000002) -#define GPIOCSR_BIT2 FIELD32(0x00000004) -#define GPIOCSR_BIT3 FIELD32(0x00000008) -#define GPIOCSR_BIT4 FIELD32(0x00000010) -#define GPIOCSR_BIT5 FIELD32(0x00000020) -#define GPIOCSR_BIT6 FIELD32(0x00000040) -#define GPIOCSR_BIT7 FIELD32(0x00000080) +#define GPIOCSR_VAL0 FIELD32(0x00000001) +#define GPIOCSR_VAL1 FIELD32(0x00000002) +#define GPIOCSR_VAL2 FIELD32(0x00000004) +#define GPIOCSR_VAL3 FIELD32(0x00000008) +#define GPIOCSR_VAL4 FIELD32(0x00000010) +#define GPIOCSR_VAL5 FIELD32(0x00000020) +#define GPIOCSR_VAL6 FIELD32(0x00000040) +#define GPIOCSR_VAL7 FIELD32(0x00000080) +#define GPIOCSR_DIR0 FIELD32(0x00000100) +#define GPIOCSR_DIR1 FIELD32(0x00000200) +#define GPIOCSR_DIR2 FIELD32(0x00000400) +#define GPIOCSR_DIR3 FIELD32(0x00000800) +#define GPIOCSR_DIR4 FIELD32(0x00001000) +#define GPIOCSR_DIR5 FIELD32(0x00002000) +#define GPIOCSR_DIR6 FIELD32(0x00004000) +#define GPIOCSR_DIR7 FIELD32(0x00008000)/* * BBPPCSR: BBP Pin control register.
drivers/net/wireless/rt2x00/rt2500pci.c +10 -1
@@ -205,7 +205,7 @@ static int rt2500pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)u32 reg;rt2x00pci_register_read (rt2x00dev,GPIOCSR , ®); -return rt2x00_get_field32 (reg,GPIOCSR_BIT0 ); +return rt2x00_get_field32 (reg,GPIOCSR_VAL0 ); }#ifdef CONFIG_RT2X00_LIB_LEDS
@@ -1929,6 +1929,7 @@ static int rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)static int rt2500pci_probe_hw (struct rt2x00_dev *rt2x00dev) {int retval; +u32 reg;/* * Allocate eeprom data.
@@ -1942,6 +1943,14 @@ static int rt2500pci_probe_hw(struct rt2x00_dev *rt2x00dev)return retval;/* +* Enable rfkill polling by setting GPIO direction of the +* rfkill switch GPIO pin correctly. +*/ +rt2x00pci_register_read (rt2x00dev,GPIOCSR , ®); +rt2x00_set_field32 (®,GPIOCSR_DIR0 ,1 ); +rt2x00pci_register_write (rt2x00dev,GPIOCSR , reg); + +/* * Initialize hw specifications. */ retval =rt2500pci_probe_hw_mode (rt2x00dev);
drivers/net/wireless/rt2x00/rt2500pci.h +10 -8
@@ -789,16 +789,18 @@/* * GPIOCSR: GPIO control register. +* GPIOCSR_VALx: GPIO value +* GPIOCSR_DIRx: GPIO direction: 0 = output; 1 = input */ #define GPIOCSR 0x0120 -#define GPIOCSR_BIT0 FIELD32(0x00000001) -#define GPIOCSR_BIT1 FIELD32(0x00000002) -#define GPIOCSR_BIT2 FIELD32(0x00000004) -#define GPIOCSR_BIT3 FIELD32(0x00000008) -#define GPIOCSR_BIT4 FIELD32(0x00000010) -#define GPIOCSR_BIT5 FIELD32(0x00000020) -#define GPIOCSR_BIT6 FIELD32(0x00000040) -#define GPIOCSR_BIT7 FIELD32(0x00000080) +#define GPIOCSR_VAL0 FIELD32(0x00000001) +#define GPIOCSR_VAL1 FIELD32(0x00000002) +#define GPIOCSR_VAL2 FIELD32(0x00000004) +#define GPIOCSR_VAL3 FIELD32(0x00000008) +#define GPIOCSR_VAL4 FIELD32(0x00000010) +#define GPIOCSR_VAL5 FIELD32(0x00000020) +#define GPIOCSR_VAL6 FIELD32(0x00000040) +#define GPIOCSR_VAL7 FIELD32(0x00000080)#define GPIOCSR_DIR0 FIELD32(0x00000100)#define GPIOCSR_DIR1 FIELD32(0x00000200)#define GPIOCSR_DIR2 FIELD32(0x00000400)
drivers/net/wireless/rt2x00/rt2500usb.c +10 -1
@@ -283,7 +283,7 @@ static int rt2500usb_rfkill_poll(struct rt2x00_dev *rt2x00dev)u16 reg;rt2500usb_register_read (rt2x00dev,MAC_CSR19 , ®); -return rt2x00_get_field32 (reg,MAC_CSR19_BIT7 ); +return rt2x00_get_field16 (reg,MAC_CSR19_VAL7 ); }#ifdef CONFIG_RT2X00_LIB_LEDS
@@ -1768,6 +1768,7 @@ static int rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)static int rt2500usb_probe_hw (struct rt2x00_dev *rt2x00dev) {int retval; +u16 reg;/* * Allocate eeprom data.
@@ -1781,6 +1782,14 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)return retval;/* +* Enable rfkill polling by setting GPIO direction of the +* rfkill switch GPIO pin correctly. +*/ +rt2500usb_register_read (rt2x00dev,MAC_CSR19 , ®); +rt2x00_set_field16 (®,MAC_CSR19_DIR0 ,0 ); +rt2500usb_register_write (rt2x00dev,MAC_CSR19 , reg); + +/* * Initialize hw specifications. */ retval =rt2500usb_probe_hw_mode (rt2x00dev);
drivers/net/wireless/rt2x00/rt2500usb.h +18 -8
@@ -187,16 +187,26 @@/* * MAC_CSR19: GPIO control register. +* MAC_CSR19_VALx: GPIO value +* MAC_CSR19_DIRx: GPIO direction: 0 = input; 1 = output */ #define MAC_CSR19 0x0426 -#define MAC_CSR19_BIT0 FIELD32(0x0001) -#define MAC_CSR19_BIT1 FIELD32(0x0002) -#define MAC_CSR19_BIT2 FIELD32(0x0004) -#define MAC_CSR19_BIT3 FIELD32(0x0008) -#define MAC_CSR19_BIT4 FIELD32(0x0010) -#define MAC_CSR19_BIT5 FIELD32(0x0020) -#define MAC_CSR19_BIT6 FIELD32(0x0040) -#define MAC_CSR19_BIT7 FIELD32(0x0080) +#define MAC_CSR19_VAL0 FIELD16(0x0001) +#define MAC_CSR19_VAL1 FIELD16(0x0002) +#define MAC_CSR19_VAL2 FIELD16(0x0004) +#define MAC_CSR19_VAL3 FIELD16(0x0008) +#define MAC_CSR19_VAL4 FIELD16(0x0010) +#define MAC_CSR19_VAL5 FIELD16(0x0020) +#define MAC_CSR19_VAL6 FIELD16(0x0040) +#define MAC_CSR19_VAL7 FIELD16(0x0080) +#define MAC_CSR19_DIR0 FIELD16(0x0100) +#define MAC_CSR19_DIR1 FIELD16(0x0200) +#define MAC_CSR19_DIR2 FIELD16(0x0400) +#define MAC_CSR19_DIR3 FIELD16(0x0800) +#define MAC_CSR19_DIR4 FIELD32(0x1000) +#define MAC_CSR19_DIR5 FIELD16(0x2000) +#define MAC_CSR19_DIR6 FIELD16(0x4000) +#define MAC_CSR19_DIR7 FIELD16(0x8000)/* * MAC_CSR20: LED control register.
drivers/net/wireless/rt2x00/rt2800.h +27 -20
53 lines not on this page · raw message
drivers/net/wireless/rt2x00/rt2800lib.c +19 -19
@@ -923,8 +923,8 @@ int rt2800_rfkill_poll(struct rt2x00_dev *rt2x00dev)rt2800_register_read (rt2x00dev,WLAN_FUN_CTRL , ®);return rt2x00_get_field32 (reg,WLAN_GPIO_IN_BIT0 ); }else { -rt2800_register_read (rt2x00dev,GPIO_CTRL_CFG , ®); -return rt2x00_get_field32 (reg,GPIO_CTRL_CFG_BIT2 ); +rt2800_register_read (rt2x00dev,GPIO_CTRL , ®); +return rt2x00_get_field32 (reg,GPIO_CTRL_VAL2 ); } }EXPORT_SYMBOL_GPL (rt2800_rfkill_poll);
@@ -1570,10 +1570,10 @@ static void rt2800_set_ant_diversity(struct rt2x00_dev *rt2x00dev,rt2800_mcu_request (rt2x00dev,MCU_ANT_SELECT ,0xff , eesk_pin,0 ); -rt2800_register_read (rt2x00dev,GPIO_CTRL_CFG , ®); -rt2x00_set_field32 (®,GPIO_CTRL_CFG_GPIOD_BIT3 ,0 ); -rt2x00_set_field32 (®,GPIO_CTRL_CFG_BIT3 , gpio_bit3); -rt2800_register_write (rt2x00dev,GPIO_CTRL_CFG , reg); +rt2800_register_read (rt2x00dev,GPIO_CTRL , ®); +rt2x00_set_field32 (®,GPIO_CTRL_DIR3 ,0 ); +rt2x00_set_field32 (®,GPIO_CTRL_VAL3 , gpio_bit3); +rt2800_register_write (rt2x00dev,GPIO_CTRL , reg); }void rt2800_config_ant (struct rt2x00_dev *rt2x00dev,struct antenna_setup *ant)
@@ -1995,13 +1995,13 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev,rt2800_rfcsr_write (rt2x00dev,29 ,0x9f ); } -rt2800_register_read (rt2x00dev,GPIO_CTRL_CFG , ®); -rt2x00_set_field32 (®,GPIO_CTRL_CFG_GPIOD_BIT7 ,0 ); +rt2800_register_read (rt2x00dev,GPIO_CTRL , ®); +rt2x00_set_field32 (®,GPIO_CTRL_DIR7 ,0 );if (rf->channel <=14 ) -rt2x00_set_field32 (®,GPIO_CTRL_CFG_BIT7 ,1 ); +rt2x00_set_field32 (®,GPIO_CTRL_VAL7 ,1 );else -rt2x00_set_field32 (®,GPIO_CTRL_CFG_BIT7 ,0 ); -rt2800_register_write (rt2x00dev,GPIO_CTRL_CFG , reg); +rt2x00_set_field32 (®,GPIO_CTRL_VAL7 ,0 ); +rt2800_register_write (rt2x00dev,GPIO_CTRL , reg);rt2800_rfcsr_read (rt2x00dev,7 , &rfcsr);rt2x00_set_field8 (&rfcsr,RFCSR7_RF_TUNING ,1 );
@@ -3587,16 +3587,16 @@ static int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)if (test_bit (CAPABILITY_BT_COEXIST , &rt2x00dev->cap_flags)) {u32 reg; -rt2800_register_read (rt2x00dev,GPIO_CTRL_CFG , ®); -rt2x00_set_field32 (®,GPIO_CTRL_CFG_GPIOD_BIT3 ,0 ); -rt2x00_set_field32 (®,GPIO_CTRL_CFG_GPIOD_BIT6 ,0 ); -rt2x00_set_field32 (®,GPIO_CTRL_CFG_BIT3 ,0 ); -rt2x00_set_field32 (®,GPIO_CTRL_CFG_BIT6 ,0 ); +rt2800_register_read (rt2x00dev,GPIO_CTRL , ®); +rt2x00_set_field32 (®,GPIO_CTRL_DIR3 ,0 ); +rt2x00_set_field32 (®,GPIO_CTRL_DIR6 ,0 ); +rt2x00_set_field32 (®,GPIO_CTRL_VAL3 ,0 ); +rt2x00_set_field32 (®,GPIO_CTRL_VAL6 ,0 );if (ant ==0 ) -rt2x00_set_field32 (®,GPIO_CTRL_CFG_BIT3 ,1 ); +rt2x00_set_field32 (®,GPIO_CTRL_VAL3 ,1 );else if (ant ==1 ) -rt2x00_set_field32 (®,GPIO_CTRL_CFG_BIT6 ,1 ); -rt2800_register_write (rt2x00dev,GPIO_CTRL_CFG , reg); +rt2x00_set_field32 (®,GPIO_CTRL_VAL6 ,1 ); +rt2800_register_write (rt2x00dev,GPIO_CTRL , reg); }/* This chip has hardware antenna diversity*/
drivers/net/wireless/rt2x00/rt2800pci.c +9 -0
@@ -983,6 +983,7 @@ static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)static int rt2800pci_probe_hw (struct rt2x00_dev *rt2x00dev) {int retval; +u32 reg;/* * Allocate eeprom data.
@@ -996,6 +997,14 @@ static int rt2800pci_probe_hw(struct rt2x00_dev *rt2x00dev)return retval;/* +* Enable rfkill polling by setting GPIO direction of the +* rfkill switch GPIO pin correctly. +*/ +rt2x00pci_register_read (rt2x00dev,GPIO_CTRL , ®); +rt2x00_set_field32 (®,GPIO_CTRL_DIR2 ,1 ); +rt2x00pci_register_write (rt2x00dev,GPIO_CTRL , reg); + +/* * Initialize hw specifications. */ retval =rt2800_probe_hw_mode (rt2x00dev);
drivers/net/wireless/rt2x00/rt2800usb.c +9 -0
@@ -736,6 +736,7 @@ static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)static int rt2800usb_probe_hw (struct rt2x00_dev *rt2x00dev) {int retval; +u32 reg;/* * Allocate eeprom data.
@@ -749,6 +750,14 @@ static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev)return retval;/* +* Enable rfkill polling by setting GPIO direction of the +* rfkill switch GPIO pin correctly. +*/ +rt2x00usb_register_read (rt2x00dev,GPIO_CTRL , ®); +rt2x00_set_field32 (®,GPIO_CTRL_DIR2 ,1 ); +rt2x00usb_register_write (rt2x00dev,GPIO_CTRL , reg); + +/* * Initialize hw specifications. */ retval =rt2800_probe_hw_mode (rt2x00dev);
drivers/net/wireless/rt2x00/rt61pci.c +14 -5
@@ -243,7 +243,7 @@ static int rt61pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)u32 reg;rt2x00pci_register_read (rt2x00dev,MAC_CSR13 , ®); -return rt2x00_get_field32 (reg,MAC_CSR13_BIT5 ); +return rt2x00_get_field32 (reg,MAC_CSR13_VAL5 ); }#ifdef CONFIG_RT2X00_LIB_LEDS
@@ -715,11 +715,11 @@ static void rt61pci_config_antenna_2529_rx(struct rt2x00_dev *rt2x00dev,rt2x00pci_register_read (rt2x00dev,MAC_CSR13 , ®); -rt2x00_set_field32 (®,MAC_CSR13_BIT4 , p1); -rt2x00_set_field32 (®,MAC_CSR13_BIT12 ,0 ); +rt2x00_set_field32 (®,MAC_CSR13_DIR4 ,0 ); +rt2x00_set_field32 (®,MAC_CSR13_VAL4 , p1); -rt2x00_set_field32 (®,MAC_CSR13_BIT3 , !p2); -rt2x00_set_field32 (®,MAC_CSR13_BIT11 ,0 ); +rt2x00_set_field32 (®,MAC_CSR13_DIR3 ,0 ); +rt2x00_set_field32 (®,MAC_CSR13_VAL3 , !p2);rt2x00pci_register_write (rt2x00dev,MAC_CSR13 , reg); }
@@ -2832,6 +2832,7 @@ static int rt61pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)static int rt61pci_probe_hw (struct rt2x00_dev *rt2x00dev) {int retval; +u32 reg;/* * Disable power saving.
@@ -2850,6 +2851,14 @@ static int rt61pci_probe_hw(struct rt2x00_dev *rt2x00dev)return retval;/* +* Enable rfkill polling by setting GPIO direction of the +* rfkill switch GPIO pin correctly. +*/ +rt2x00pci_register_read (rt2x00dev,MAC_CSR13 , ®); +rt2x00_set_field32 (®,MAC_CSR13_DIR5 ,1 ); +rt2x00pci_register_write (rt2x00dev,MAC_CSR13 , reg); + +/* * Initialize hw specifications. */ retval =rt61pci_probe_hw_mode (rt2x00dev);
drivers/net/wireless/rt2x00/rt61pci.h +14 -13
@@ -357,21 +357,22 @@ struct hw_pairwise_ta_entry {/* * MAC_CSR13: GPIO. +* MAC_CSR13_VALx: GPIO value +* MAC_CSR13_DIRx: GPIO direction: 0 = output; 1 = input */ #define MAC_CSR13 0x3034 -#define MAC_CSR13_BIT0 FIELD32(0x00000001) -#define MAC_CSR13_BIT1 FIELD32(0x00000002) -#define MAC_CSR13_BIT2 FIELD32(0x00000004) -#define MAC_CSR13_BIT3 FIELD32(0x00000008) -#define MAC_CSR13_BIT4 FIELD32(0x00000010) -#define MAC_CSR13_BIT5 FIELD32(0x00000020) -#define MAC_CSR13_BIT6 FIELD32(0x00000040) -#define MAC_CSR13_BIT7 FIELD32(0x00000080) -#define MAC_CSR13_BIT8 FIELD32(0x00000100) -#define MAC_CSR13_BIT9 FIELD32(0x00000200) -#define MAC_CSR13_BIT10 FIELD32(0x00000400) -#define MAC_CSR13_BIT11 FIELD32(0x00000800) -#define MAC_CSR13_BIT12 FIELD32(0x00001000) +#define MAC_CSR13_VAL0 FIELD32(0x00000001) +#define MAC_CSR13_VAL1 FIELD32(0x00000002) +#define MAC_CSR13_VAL2 FIELD32(0x00000004) +#define MAC_CSR13_VAL3 FIELD32(0x00000008) +#define MAC_CSR13_VAL4 FIELD32(0x00000010) +#define MAC_CSR13_VAL5 FIELD32(0x00000020) +#define MAC_CSR13_DIR0 FIELD32(0x00000100) +#define MAC_CSR13_DIR1 FIELD32(0x00000200) +#define MAC_CSR13_DIR2 FIELD32(0x00000400) +#define MAC_CSR13_DIR3 FIELD32(0x00000800) +#define MAC_CSR13_DIR4 FIELD32(0x00001000) +#define MAC_CSR13_DIR5 FIELD32(0x00002000)/* * MAC_CSR14: LED control register.
drivers/net/wireless/rt2x00/rt73usb.c +10 -1
@@ -189,7 +189,7 @@ static int rt73usb_rfkill_poll(struct rt2x00_dev *rt2x00dev)u32 reg;rt2x00usb_register_read (rt2x00dev,MAC_CSR13 , ®); -return rt2x00_get_field32 (reg,MAC_CSR13_BIT7 ); +return rt2x00_get_field32 (reg,MAC_CSR13_VAL7 ); }#ifdef CONFIG_RT2X00_LIB_LEDS
@@ -2177,6 +2177,7 @@ static int rt73usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)static int rt73usb_probe_hw (struct rt2x00_dev *rt2x00dev) {int retval; +u32 reg;/* * Allocate eeprom data.
@@ -2190,6 +2191,14 @@ static int rt73usb_probe_hw(struct rt2x00_dev *rt2x00dev)return retval;/* +* Enable rfkill polling by setting GPIO direction of the +* rfkill switch GPIO pin correctly. +*/ +rt2x00usb_register_read (rt2x00dev,MAC_CSR13 , ®); +rt2x00_set_field32 (®,MAC_CSR13_DIR7 ,0 ); +rt2x00usb_register_write (rt2x00dev,MAC_CSR13 , reg); + +/* * Initialize hw specifications. */ retval =rt73usb_probe_hw_mode (rt2x00dev);
drivers/net/wireless/rt2x00/rt73usb.h +18 -13
@@ -267,21 +267,26 @@ struct hw_pairwise_ta_entry {/* * MAC_CSR13: GPIO. +* MAC_CSR13_VALx: GPIO value +* MAC_CSR13_DIRx: GPIO direction: 0 = input; 1 = output */ #define MAC_CSR13 0x3034 -#define MAC_CSR13_BIT0 FIELD32(0x00000001) -#define MAC_CSR13_BIT1 FIELD32(0x00000002) -#define MAC_CSR13_BIT2 FIELD32(0x00000004) -#define MAC_CSR13_BIT3 FIELD32(0x00000008) -#define MAC_CSR13_BIT4 FIELD32(0x00000010) -#define MAC_CSR13_BIT5 FIELD32(0x00000020) -#define MAC_CSR13_BIT6 FIELD32(0x00000040) -#define MAC_CSR13_BIT7 FIELD32(0x00000080) -#define MAC_CSR13_BIT8 FIELD32(0x00000100) -#define MAC_CSR13_BIT9 FIELD32(0x00000200) -#define MAC_CSR13_BIT10 FIELD32(0x00000400) -#define MAC_CSR13_BIT11 FIELD32(0x00000800) -#define MAC_CSR13_BIT12 FIELD32(0x00001000) +#define MAC_CSR13_VAL0 FIELD32(0x00000001) +#define MAC_CSR13_VAL1 FIELD32(0x00000002) +#define MAC_CSR13_VAL2 FIELD32(0x00000004) +#define MAC_CSR13_VAL3 FIELD32(0x00000008) +#define MAC_CSR13_VAL4 FIELD32(0x00000010) +#define MAC_CSR13_VAL5 FIELD32(0x00000020) +#define MAC_CSR13_VAL6 FIELD32(0x00000040) +#define MAC_CSR13_VAL7 FIELD32(0x00000080) +#define MAC_CSR13_DIR0 FIELD32(0x00000100) +#define MAC_CSR13_DIR1 FIELD32(0x00000200) +#define MAC_CSR13_DIR2 FIELD32(0x00000400) +#define MAC_CSR13_DIR3 FIELD32(0x00000800) +#define MAC_CSR13_DIR4 FIELD32(0x00001000) +#define MAC_CSR13_DIR5 FIELD32(0x00002000) +#define MAC_CSR13_DIR6 FIELD32(0x00004000) +#define MAC_CSR13_DIR7 FIELD32(0x00008000)/* * MAC_CSR14: LED control register.
Hey Gertjan,
Am Sonntag, 26. August 2012, 20:22:56 schrieb Gertjan van Wingerde:
Quoted 30 lines
Hi Andreas,
Quoted 27 lines · Andreas Messer
Hey there,
Am Dienstag, 24. Juli 2012, 19:33:34 schrieb Andreas Messer:
Quoted 7 lines
Hello Again,
Am Dienstag, 26. Juni 2012, 13:18:35 schrieb John W. Linville:
Quoted 4 lines · Andreas Messer
Quoted 3 lines
Dear all,
updating my pc from linux kernel 3.3 to linux kernel 3.4 broke my wlan.
I have spent some more time on investigating the cause of the bug and found
the problem. Actually I'm not sure which is the right solution. The problem is caused by the following points:1) The rt73 hardware registers are not initialized before bringing the
corresponding network interface up ('ifconfig wlan0 up')
2) Bringing the interface up is not possible because of the kill switch
3) The GPIO input pin for the kill switch is still in 'output mode' (the
default power on value), therefore the register will always read 'killswitch on'
Quoted 8 lines
Quoted 1 line
[...]
[...]
The reason why we do most of the initialization at interface up is that that is the earliest possible time we can get the firmware image from userspace. A lot of the register programming we have to do for initialization depend on the firmware being uploaded and running, hence we initialize most at interface up time.
[...]
Thanks for that explanation. Didn't know that about the firmware.
Quoted 2 lines
Find attached a patch that does this for all the rt2x00 devices. I hope you are able to test whether this patch fixes the problem for you.
Yep, the patch works fine for me. (Tested on latest git snapshot)
Cheers
Andreas
Hi Andreas,
Quoted 42 lines · Andreas Messer
Hey Gertjan,
Am Sonntag, 26. August 2012, 20:22:56 schrieb Gertjan van Wingerde:
Quoted 30 lines
Hi Andreas,
Quoted 27 lines · Andreas Messer
Hey there,
Am Dienstag, 24. Juli 2012, 19:33:34 schrieb Andreas Messer:
Quoted 7 lines
Hello Again,
Am Dienstag, 26. Juni 2012, 13:18:35 schrieb John W. Linville:
Quoted 4 lines · Andreas Messer
Quoted 3 lines
Dear all,
updating my pc from linux kernel 3.3 to linux kernel 3.4 broke my wlan.
I have spent some more time on investigating the cause of the bug and found
the problem. Actually I'm not sure which is the right solution. The problem is caused by the following points:1) The rt73 hardware registers are not initialized before bringing the
corresponding network interface up ('ifconfig wlan0 up')
2) Bringing the interface up is not possible because of the kill switch
3) The GPIO input pin for the kill switch is still in 'output mode' (the
default power on value), therefore the register will always read 'killswitch on'
Quoted 8 lines
Quoted 1 line
[...]
[...]
The reason why we do most of the initialization at interface up is that that is the earliest possible time we can get the firmware image from userspace. A lot of the register programming we have to do for initialization depend on the firmware being uploaded and running, hence we initialize most at interface up time.
[...]
Quoted 7 lines
Thanks for that explanation. Didn't know that about the firmware.
Quoted 2 lines
Find attached a patch that does this for all the rt2x00 devices. I hope you are able to test whether this patch fixes the problem for you.
Yep, the patch works fine for me. (Tested on latest git snapshot)
Thanks for testing. I'll submit the patch-set upstream later this week.
---
Gertjan