[rt2x00-users] [PATCH] Fix 'Error - MCU request failed' during initialization
Jakub Kicinski
kubakici at wp.pl
Tue Jan 17 05:38:04 EST 2012
Hello!
I post my humble attempt to get rid of notorious Error - MCU request
failed ;)
I tried to fully mimic legacy driver, which should explain some obscure
moves like putting device to sleep and waking it up immediately.
Also during the work I earned some understanding of MCU requests and
found some info on arguments. Would you like me to share it or perhaps
add some documentation to header files?
The rt2800pci_set_state function got somehow lost during development
and I decided not to recreate it since it feels a little confusing to
me. Although note that behaviour for STATE_DEEP_SLEEP and STATE_STANDBY
will change. Previously transitions to those states were forwarded to
rt2800pci_set_state and ignored there. Now they will be treated the
same as STATE_SLEEP. In practice though, it shouldn't change behaviour
since mentioned states are not used in rt2800.
I have tested this on my only PCI device (rt: 2860, rf: 0001, rev:
0102). Please post your comments and possibly give it more testing on
your devices.
---
Bring MCU operations during device initialization to sync with legacy
driver.
This should fix following error:
phy0 -> rt2800pci_mcu_status: Error - MCU request failed, no response
from hardware
Signed-off-by: Jakub Kicinski <kubakici at wp.pl>
---
drivers/net/wireless/rt2x00/rt2800.h | 4 ++-
drivers/net/wireless/rt2x00/rt2800pci.c | 50 +++++++++++++++----------------
2 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index 2571a2f..2a37373 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -2279,7 +2279,9 @@ struct mac_iveiv_entry {
/*
* MCU mailbox tokens
*/
-#define TOKEN_WAKUP 3
+#define TOKEN_SLEEP 1
+#define TOKEN_RADIO_OFF 2
+#define TOKEN_WAKEUP 3
/*
* DMA descriptor defines.
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index 4941a1a..8ceda61 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -529,23 +529,6 @@ static void rt2800pci_disable_radio(struct rt2x00_dev *rt2x00dev)
}
}
-static int rt2800pci_set_state(struct rt2x00_dev *rt2x00dev,
- enum dev_state state)
-{
- if (state == STATE_AWAKE) {
- rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, TOKEN_WAKUP, 0, 0x02);
- rt2800pci_mcu_status(rt2x00dev, TOKEN_WAKUP);
- } else if (state == STATE_SLEEP) {
- rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_STATUS,
- 0xffffffff);
- rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_CID,
- 0xffffffff);
- rt2800_mcu_request(rt2x00dev, MCU_SLEEP, 0x01, 0xff, 0x01);
- }
-
- return 0;
-}
-
static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev,
enum dev_state state)
{
@@ -553,14 +536,20 @@ static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev,
switch (state) {
case STATE_RADIO_ON:
- /*
- * Before the radio can be enabled, the device first has
- * to be woken up. After that it needs a bit of time
- * to be fully awake and then the radio can be enabled.
- */
- rt2800pci_set_state(rt2x00dev, STATE_AWAKE);
- msleep(1);
+ /* Initialise all registers and send MCU_BOOT_SIGNAL. */
retval = rt2800pci_enable_radio(rt2x00dev);
+
+ /* After resume MCU_BOOT_SIGNAL will trash those. */
+ rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0);
+ rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
+
+ /* Finish initialization procedure. */
+ rt2800_mcu_request(rt2x00dev, MCU_SLEEP, TOKEN_RADIO_OFF,
+ 0xff, 0x02);
+ rt2800pci_mcu_status(rt2x00dev, TOKEN_RADIO_OFF);
+
+ rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, TOKEN_WAKEUP, 0, 0);
+ rt2800pci_mcu_status(rt2x00dev, TOKEN_WAKEUP);
break;
case STATE_RADIO_OFF:
/*
@@ -568,7 +557,7 @@ static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev,
* be put to sleep for powersaving.
*/
rt2800pci_disable_radio(rt2x00dev);
- rt2800pci_set_state(rt2x00dev, STATE_SLEEP);
+ rt2800pci_set_device_state(rt2x00dev, STATE_SLEEP);
break;
case STATE_RADIO_IRQ_ON:
case STATE_RADIO_IRQ_OFF:
@@ -577,8 +566,17 @@ static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev,
case STATE_DEEP_SLEEP:
case STATE_SLEEP:
case STATE_STANDBY:
+ /* PCIe devices won't report status after SLEEP request. */
+ rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0);
+ rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
+ rt2800_mcu_request(rt2x00dev, MCU_SLEEP, TOKEN_SLEEP,
+ 0xff, 0x01);
+ break;
case STATE_AWAKE:
- retval = rt2800pci_set_state(rt2x00dev, state);
+ /* Autowakeup configuration should be cleared by the caller. */
+ rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, TOKEN_WAKEUP,
+ 0, 0x02);
+ rt2800pci_mcu_status(rt2x00dev, TOKEN_WAKEUP);
break;
default:
retval = -ENOTSUPP;
More information about the users
mailing list