aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvinash Patil <patila@marvell.com>2014-03-19 01:19:17 -0400
committerJohn W. Linville <linville@tuxdriver.com>2014-03-19 15:15:47 -0400
commitc4bc980f1b34a8c172b3812e8c946368c730bddd (patch)
tree8b2f9f13675f262ecf5168e19cfc475fdec5199b
parentcc5c1afb1ed6318cdb3f92b7aa936564c4427f28 (diff)
mwifiex: add support for sleep cookie in PCIe
This patch adds support to read sleep cookie for command response before accessing buffer. Signed-off-by: Avinash Patil <patila@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/mwifiex/pcie.c26
-rw-r--r--drivers/net/wireless/mwifiex/pcie.h2
2 files changed, 28 insertions, 0 deletions
diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
index 9f1683b5f28f..57c353a94b29 100644
--- a/drivers/net/wireless/mwifiex/pcie.c
+++ b/drivers/net/wireless/mwifiex/pcie.c
@@ -327,6 +327,30 @@ static void mwifiex_pcie_dev_wakeup_delay(struct mwifiex_adapter *adapter)
327 return; 327 return;
328} 328}
329 329
330static void mwifiex_delay_for_sleep_cookie(struct mwifiex_adapter *adapter,
331 u32 max_delay_loop_cnt)
332{
333 struct pcie_service_card *card = adapter->card;
334 u8 *buffer;
335 u32 sleep_cookie, count;
336
337 for (count = 0; count < max_delay_loop_cnt; count++) {
338 buffer = card->cmdrsp_buf->data - INTF_HEADER_LEN;
339 sleep_cookie = *(u32 *)buffer;
340
341 if (sleep_cookie == MWIFIEX_DEF_SLEEP_COOKIE) {
342 dev_dbg(adapter->dev,
343 "sleep cookie found at count %d\n", count);
344 break;
345 }
346 usleep_range(20, 30);
347 }
348
349 if (count >= max_delay_loop_cnt)
350 dev_dbg(adapter->dev,
351 "max count reached while accessing sleep cookie\n");
352}
353
330/* This function wakes up the card by reading fw_status register. */ 354/* This function wakes up the card by reading fw_status register. */
331static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter) 355static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter)
332{ 356{
@@ -1539,6 +1563,8 @@ static int mwifiex_pcie_process_cmd_complete(struct mwifiex_adapter *adapter)
1539 "Write register failed\n"); 1563 "Write register failed\n");
1540 return -1; 1564 return -1;
1541 } 1565 }
1566 mwifiex_delay_for_sleep_cookie(adapter,
1567 MWIFIEX_MAX_DELAY_COUNT);
1542 while (reg->sleep_cookie && (count++ < 10) && 1568 while (reg->sleep_cookie && (count++ < 10) &&
1543 mwifiex_pcie_ok_to_access_hw(adapter)) 1569 mwifiex_pcie_ok_to_access_hw(adapter))
1544 usleep_range(50, 60); 1570 usleep_range(50, 60);
diff --git a/drivers/net/wireless/mwifiex/pcie.h b/drivers/net/wireless/mwifiex/pcie.h
index 193af75bf582..e8ec561f8a64 100644
--- a/drivers/net/wireless/mwifiex/pcie.h
+++ b/drivers/net/wireless/mwifiex/pcie.h
@@ -97,6 +97,8 @@
97#define MWIFIEX_PCIE_BLOCK_SIZE_FW_DNLD 256 97#define MWIFIEX_PCIE_BLOCK_SIZE_FW_DNLD 256
98/* FW awake cookie after FW ready */ 98/* FW awake cookie after FW ready */
99#define FW_AWAKE_COOKIE (0xAA55AA55) 99#define FW_AWAKE_COOKIE (0xAA55AA55)
100#define MWIFIEX_DEF_SLEEP_COOKIE 0xBEEFBEEF
101#define MWIFIEX_MAX_DELAY_COUNT 5
100 102
101struct mwifiex_pcie_card_reg { 103struct mwifiex_pcie_card_reg {
102 u16 cmd_addr_lo; 104 u16 cmd_addr_lo;