Skip to content

Commit

Permalink
rt2x00: Fix rfkill polling prior to interface start.
Browse files Browse the repository at this point in the history
We need to program the rfkill switch GPIO pin direction to input at
device initialization time, not only when the interface is brought up.
Doing this only when the interface is brought up could lead to rfkill
detecting the switch is turned on erroneously and inability to create
the interface and bringing it up.

Reported-and-tested-by: Andreas Messer <[email protected]>
Signed-off-by: Gertjan van Wingerde <[email protected]>
Cc: <[email protected]>
Acked-by: Ivo Van Doorn <[email protected]>
Signed-off-by: John W. Linville <[email protected]>
  • Loading branch information
gwingerde authored and linvjw committed Sep 5, 2012
1 parent 6ced58a commit a396e10
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/net/wireless/rt2x00/rt2400pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -1623,6 +1624,14 @@ static int rt2400pci_probe_hw(struct rt2x00_dev *rt2x00dev)
if (retval)
return retval;

/*
* Enable rfkill polling by setting GPIO direction of the
* rfkill switch GPIO pin correctly.
*/
rt2x00pci_register_read(rt2x00dev, GPIOCSR, &reg);
rt2x00_set_field32(&reg, GPIOCSR_BIT8, 1);
rt2x00pci_register_write(rt2x00dev, GPIOCSR, reg);

/*
* Initialize hw specifications.
*/
Expand Down
1 change: 1 addition & 0 deletions drivers/net/wireless/rt2x00/rt2400pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@
#define GPIOCSR_BIT5 FIELD32(0x00000020)
#define GPIOCSR_BIT6 FIELD32(0x00000040)
#define GPIOCSR_BIT7 FIELD32(0x00000080)
#define GPIOCSR_BIT8 FIELD32(0x00000100)

/*
* BBPPCSR: BBP Pin control register.
Expand Down
9 changes: 9 additions & 0 deletions drivers/net/wireless/rt2x00/rt2500pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -1941,6 +1942,14 @@ static int rt2500pci_probe_hw(struct rt2x00_dev *rt2x00dev)
if (retval)
return retval;

/*
* Enable rfkill polling by setting GPIO direction of the
* rfkill switch GPIO pin correctly.
*/
rt2x00pci_register_read(rt2x00dev, GPIOCSR, &reg);
rt2x00_set_field32(&reg, GPIOCSR_DIR0, 1);
rt2x00pci_register_write(rt2x00dev, GPIOCSR, reg);

/*
* Initialize hw specifications.
*/
Expand Down
9 changes: 9 additions & 0 deletions drivers/net/wireless/rt2x00/rt2500usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -1780,6 +1781,14 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
if (retval)
return retval;

/*
* Enable rfkill polling by setting GPIO direction of the
* rfkill switch GPIO pin correctly.
*/
rt2500usb_register_read(rt2x00dev, MAC_CSR19, &reg);
rt2x00_set_field16(&reg, MAC_CSR19_BIT8, 0);
rt2500usb_register_write(rt2x00dev, MAC_CSR19, reg);

/*
* Initialize hw specifications.
*/
Expand Down
1 change: 1 addition & 0 deletions drivers/net/wireless/rt2x00/rt2500usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
#define MAC_CSR19_BIT5 FIELD16(0x0020)
#define MAC_CSR19_BIT6 FIELD16(0x0040)
#define MAC_CSR19_BIT7 FIELD16(0x0080)
#define MAC_CSR19_BIT8 FIELD16(0x0100)

/*
* MAC_CSR20: LED control register.
Expand Down
9 changes: 9 additions & 0 deletions drivers/net/wireless/rt2x00/rt2800pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -995,6 +996,14 @@ static int rt2800pci_probe_hw(struct rt2x00_dev *rt2x00dev)
if (retval)
return retval;

/*
* Enable rfkill polling by setting GPIO direction of the
* rfkill switch GPIO pin correctly.
*/
rt2x00pci_register_read(rt2x00dev, GPIO_CTRL_CFG, &reg);
rt2x00_set_field32(&reg, GPIO_CTRL_CFG_GPIOD_BIT2, 1);
rt2x00pci_register_write(rt2x00dev, GPIO_CTRL_CFG, reg);

/*
* Initialize hw specifications.
*/
Expand Down
9 changes: 9 additions & 0 deletions drivers/net/wireless/rt2x00/rt2800usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -748,6 +749,14 @@ static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev)
if (retval)
return retval;

/*
* Enable rfkill polling by setting GPIO direction of the
* rfkill switch GPIO pin correctly.
*/
rt2x00usb_register_read(rt2x00dev, GPIO_CTRL_CFG, &reg);
rt2x00_set_field32(&reg, GPIO_CTRL_CFG_GPIOD_BIT2, 1);
rt2x00usb_register_write(rt2x00dev, GPIO_CTRL_CFG, reg);

/*
* Initialize hw specifications.
*/
Expand Down
9 changes: 9 additions & 0 deletions drivers/net/wireless/rt2x00/rt61pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -2849,6 +2850,14 @@ static int rt61pci_probe_hw(struct rt2x00_dev *rt2x00dev)
if (retval)
return retval;

/*
* Enable rfkill polling by setting GPIO direction of the
* rfkill switch GPIO pin correctly.
*/
rt2x00pci_register_read(rt2x00dev, MAC_CSR13, &reg);
rt2x00_set_field32(&reg, MAC_CSR13_BIT13, 1);
rt2x00pci_register_write(rt2x00dev, MAC_CSR13, reg);

/*
* Initialize hw specifications.
*/
Expand Down
1 change: 1 addition & 0 deletions drivers/net/wireless/rt2x00/rt61pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ struct hw_pairwise_ta_entry {
#define MAC_CSR13_BIT10 FIELD32(0x00000400)
#define MAC_CSR13_BIT11 FIELD32(0x00000800)
#define MAC_CSR13_BIT12 FIELD32(0x00001000)
#define MAC_CSR13_BIT13 FIELD32(0x00002000)

/*
* MAC_CSR14: LED control register.
Expand Down
9 changes: 9 additions & 0 deletions drivers/net/wireless/rt2x00/rt73usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -2189,6 +2190,14 @@ static int rt73usb_probe_hw(struct rt2x00_dev *rt2x00dev)
if (retval)
return retval;

/*
* Enable rfkill polling by setting GPIO direction of the
* rfkill switch GPIO pin correctly.
*/
rt2x00usb_register_read(rt2x00dev, MAC_CSR13, &reg);
rt2x00_set_field32(&reg, MAC_CSR13_BIT15, 0);
rt2x00usb_register_write(rt2x00dev, MAC_CSR13, reg);

/*
* Initialize hw specifications.
*/
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/wireless/rt2x00/rt73usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ struct hw_pairwise_ta_entry {
#define MAC_CSR13_BIT10 FIELD32(0x00000400)
#define MAC_CSR13_BIT11 FIELD32(0x00000800)
#define MAC_CSR13_BIT12 FIELD32(0x00001000)
#define MAC_CSR13_BIT13 FIELD32(0x00002000)
#define MAC_CSR13_BIT14 FIELD32(0x00004000)
#define MAC_CSR13_BIT15 FIELD32(0x00008000)

/*
* MAC_CSR14: LED control register.
Expand Down

0 comments on commit a396e10

Please sign in to comment.