Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a396e100 authored by Gertjan van Wingerde's avatar Gertjan van Wingerde Committed by John W. Linville
Browse files

rt2x00: Fix rfkill polling prior to interface start.



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: default avatarAndreas Messer <andi@bastelmap.de>
Signed-off-by: default avatarGertjan van Wingerde <gwingerde@gmail.com>
Cc: <stable@vger.kernel.org>
Acked-by: default avatarIvo Van Doorn <ivdoorn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 6ced58a5
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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.
@@ -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.
	 */
+1 −0
Original line number Diff line number Diff line
@@ -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.
+9 −0
Original line number Diff line number Diff line
@@ -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.
@@ -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.
	 */
+9 −0
Original line number Diff line number Diff line
@@ -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.
@@ -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.
	 */
+1 −0
Original line number Diff line number Diff line
@@ -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.
Loading