All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/2] rt2800: Add documentation on MCU requests
@ 2012-02-22 20:58 Jakub Kicinski
  2012-02-22 20:58 ` [PATCH v3 2/2] rt2800pci: Fix 'Error - MCU request failed' during initialization Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2012-02-22 20:58 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, users, Jakub Kicinski

Add documentation on MCU communication, some of known commands and
their arguments. Supplement command ids.

Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>  
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
---
 drivers/net/wireless/rt2x00/rt2800.h    |   15 ++++++++++++++-
 drivers/net/wireless/rt2x00/rt2800pci.c |    8 +++++---
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index 06acabd..3ab1f7f 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -1627,6 +1627,7 @@ struct mac_iveiv_entry {
 
 /*
  * H2M_MAILBOX_CSR: Host-to-MCU Mailbox.
+ * CMD_TOKEN: Command id, 0xff disable status reporting.
  */
 #define H2M_MAILBOX_CSR			0x7010
 #define H2M_MAILBOX_CSR_ARG0		FIELD32(0x000000ff)
@@ -1636,6 +1637,8 @@ struct mac_iveiv_entry {
 
 /*
  * H2M_MAILBOX_CID:
+ * Free slots contain 0xff. MCU will store command's token to lowest free slot.
+ * If all slots are occupied status will be dropped.
  */
 #define H2M_MAILBOX_CID			0x7014
 #define H2M_MAILBOX_CID_CMD0		FIELD32(0x000000ff)
@@ -1645,6 +1648,7 @@ struct mac_iveiv_entry {
 
 /*
  * H2M_MAILBOX_STATUS:
+ * Command status will be saved to same slot as command id.
  */
 #define H2M_MAILBOX_STATUS		0x701c
 
@@ -2288,6 +2292,12 @@ struct mac_iveiv_entry {
 
 /*
  * MCU mailbox commands.
+ * MCU_SLEEP - go to power-save mode.
+ *             arg1: 1: save as much power as possible, 0: save less power.
+ *             status: 1: success, 2: already asleep,
+ *                     3: maybe MAC is busy so can't finish this task.
+ * MCU_RADIO_OFF
+ *             arg0: 0: do power-saving, NOT turn off radio.
  */
 #define MCU_SLEEP			0x30
 #define MCU_WAKEUP			0x31
@@ -2308,7 +2318,10 @@ 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 6ad6929..891547c 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -521,14 +521,16 @@ 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);
+		rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, TOKEN_WAKEUP,
+				   0, 0x02);
+		rt2800pci_mcu_status(rt2x00dev, TOKEN_WAKEUP);
 	} 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);
+		rt2800_mcu_request(rt2x00dev, MCU_SLEEP, TOKEN_SLEEP,
+				   0xff, 0x01);
 	}
 
 	return 0;
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 2/2] rt2800pci: Fix 'Error - MCU request failed' during initialization
  2012-02-22 20:58 [PATCH v3 1/2] rt2800: Add documentation on MCU requests Jakub Kicinski
@ 2012-02-22 20:58 ` Jakub Kicinski
  2012-02-23  7:28   ` Gertjan van Wingerde
  2012-02-25  8:46   ` Ivo Van Doorn
  0 siblings, 2 replies; 4+ messages in thread
From: Jakub Kicinski @ 2012-02-22 20:58 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, users, Jakub Kicinski

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@wp.pl>
---
v3: move code from switch statement to appropriate function.
---
 drivers/net/wireless/rt2x00/rt2800pci.c |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index 891547c..ac874db 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -501,11 +501,27 @@ static int rt2800pci_init_registers(struct rt2x00_dev *rt2x00dev)
 
 static int rt2800pci_enable_radio(struct rt2x00_dev *rt2x00dev)
 {
+	int retval;
+
 	if (unlikely(rt2800_wait_wpdma_ready(rt2x00dev) ||
 		     rt2800pci_init_queues(rt2x00dev)))
 		return -EIO;
 
-	return rt2800_enable_radio(rt2x00dev);
+	retval = rt2800_enable_radio(rt2x00dev);
+	if (retval)
+		return retval;
+
+	/* After resume MCU_BOOT_SIGNAL will trash these. */
+	rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0);
+	rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
+
+	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);
+
+	return retval;
 }
 
 static void rt2800pci_disable_radio(struct rt2x00_dev *rt2x00dev)
@@ -543,13 +559,6 @@ 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);
 		retval = rt2800pci_enable_radio(rt2x00dev);
 		break;
 	case STATE_RADIO_OFF:
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 2/2] rt2800pci: Fix 'Error - MCU request failed' during initialization
  2012-02-22 20:58 ` [PATCH v3 2/2] rt2800pci: Fix 'Error - MCU request failed' during initialization Jakub Kicinski
@ 2012-02-23  7:28   ` Gertjan van Wingerde
  2012-02-25  8:46   ` Ivo Van Doorn
  1 sibling, 0 replies; 4+ messages in thread
From: Gertjan van Wingerde @ 2012-02-23  7:28 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: linville, linux-wireless, users

On 02/22/12 21:58, Jakub Kicinski wrote:
> 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@wp.pl>

Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>

> ---
> v3: move code from switch statement to appropriate function.
> ---
>  drivers/net/wireless/rt2x00/rt2800pci.c |   25 +++++++++++++++++--------
>  1 files changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
> index 891547c..ac874db 100644
> --- a/drivers/net/wireless/rt2x00/rt2800pci.c
> +++ b/drivers/net/wireless/rt2x00/rt2800pci.c
> @@ -501,11 +501,27 @@ static int rt2800pci_init_registers(struct rt2x00_dev *rt2x00dev)
>  
>  static int rt2800pci_enable_radio(struct rt2x00_dev *rt2x00dev)
>  {
> +	int retval;
> +
>  	if (unlikely(rt2800_wait_wpdma_ready(rt2x00dev) ||
>  		     rt2800pci_init_queues(rt2x00dev)))
>  		return -EIO;
>  
> -	return rt2800_enable_radio(rt2x00dev);
> +	retval = rt2800_enable_radio(rt2x00dev);
> +	if (retval)
> +		return retval;
> +
> +	/* After resume MCU_BOOT_SIGNAL will trash these. */
> +	rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0);
> +	rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
> +
> +	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);
> +
> +	return retval;
>  }
>  
>  static void rt2800pci_disable_radio(struct rt2x00_dev *rt2x00dev)
> @@ -543,13 +559,6 @@ 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);
>  		retval = rt2800pci_enable_radio(rt2x00dev);
>  		break;
>  	case STATE_RADIO_OFF:


-- 
---
Gertjan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 2/2] rt2800pci: Fix 'Error - MCU request failed' during initialization
  2012-02-22 20:58 ` [PATCH v3 2/2] rt2800pci: Fix 'Error - MCU request failed' during initialization Jakub Kicinski
  2012-02-23  7:28   ` Gertjan van Wingerde
@ 2012-02-25  8:46   ` Ivo Van Doorn
  1 sibling, 0 replies; 4+ messages in thread
From: Ivo Van Doorn @ 2012-02-25  8:46 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: linville, linux-wireless, users

On Wed, Feb 22, 2012 at 9:58 PM, Jakub Kicinski <kubakici@wp.pl> wrote:
> 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@wp.pl>

Acked-by: Ivo van Doorn <IvDoorn@gmail.com>

> ---
> v3: move code from switch statement to appropriate function.
> ---
>  drivers/net/wireless/rt2x00/rt2800pci.c |   25 +++++++++++++++++--------
>  1 files changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
> index 891547c..ac874db 100644
> --- a/drivers/net/wireless/rt2x00/rt2800pci.c
> +++ b/drivers/net/wireless/rt2x00/rt2800pci.c
> @@ -501,11 +501,27 @@ static int rt2800pci_init_registers(struct rt2x00_dev *rt2x00dev)
>
>  static int rt2800pci_enable_radio(struct rt2x00_dev *rt2x00dev)
>  {
> +       int retval;
> +
>        if (unlikely(rt2800_wait_wpdma_ready(rt2x00dev) ||
>                     rt2800pci_init_queues(rt2x00dev)))
>                return -EIO;
>
> -       return rt2800_enable_radio(rt2x00dev);
> +       retval = rt2800_enable_radio(rt2x00dev);
> +       if (retval)
> +               return retval;
> +
> +       /* After resume MCU_BOOT_SIGNAL will trash these. */
> +       rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0);
> +       rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
> +
> +       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);
> +
> +       return retval;
>  }
>
>  static void rt2800pci_disable_radio(struct rt2x00_dev *rt2x00dev)
> @@ -543,13 +559,6 @@ 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);
>                retval = rt2800pci_enable_radio(rt2x00dev);
>                break;
>        case STATE_RADIO_OFF:
> --
> 1.7.7.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-25  8:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-22 20:58 [PATCH v3 1/2] rt2800: Add documentation on MCU requests Jakub Kicinski
2012-02-22 20:58 ` [PATCH v3 2/2] rt2800pci: Fix 'Error - MCU request failed' during initialization Jakub Kicinski
2012-02-23  7:28   ` Gertjan van Wingerde
2012-02-25  8:46   ` Ivo Van Doorn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.