Commit c0880a29 authored by Avinash Patil's avatar Avinash Patil Committed by John W. Linville

mwifiex: use fw_status register to wake up PCIe card

FW can be woken up even by accessing device registers; we need
not explicitily enable interrupts for doing this. Future PCIe
devices will not be woken up by writing to host registers.
This patch enables driver to wake up device by reading FW status
register.

Also devices with sleep cookie enabled need some more time before
proceeding with processing. Handle this by adding a delay loop.
Signed-off-by: default avatarAvinash Patil <patila@marvell.com>
Signed-off-by: default avatarBing Zhao <bzhao@marvell.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent c24d992a
...@@ -287,18 +287,13 @@ static int mwifiex_read_reg(struct mwifiex_adapter *adapter, int reg, u32 *data) ...@@ -287,18 +287,13 @@ static int mwifiex_read_reg(struct mwifiex_adapter *adapter, int reg, u32 *data)
} }
/* /*
* This function wakes up the card. * This function adds delay loop to ensure FW is awake before proceeding.
*
* A host power up command is written to the card configuration
* register to wake up the card.
*/ */
static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter) static void mwifiex_pcie_dev_wakeup_delay(struct mwifiex_adapter *adapter)
{ {
int i = 0; int i = 0;
struct pcie_service_card *card = adapter->card;
const struct mwifiex_pcie_card_reg *reg = card->pcie.reg;
while (reg->sleep_cookie && mwifiex_pcie_ok_to_access_hw(adapter)) { while (mwifiex_pcie_ok_to_access_hw(adapter)) {
i++; i++;
usleep_range(10, 20); usleep_range(10, 20);
/* 50ms max wait */ /* 50ms max wait */
...@@ -306,16 +301,32 @@ static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter) ...@@ -306,16 +301,32 @@ static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter)
break; break;
} }
return;
}
/* This function wakes up the card by reading fw_status register. */
static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter)
{
u32 fw_status;
struct pcie_service_card *card = adapter->card;
const struct mwifiex_pcie_card_reg *reg = card->pcie.reg;
dev_dbg(adapter->dev, "event: Wakeup device...\n"); dev_dbg(adapter->dev, "event: Wakeup device...\n");
/* Enable interrupts or any chip access will wakeup device */ if (reg->sleep_cookie)
if (mwifiex_write_reg(adapter, PCIE_HOST_INT_MASK, HOST_INTR_MASK)) { mwifiex_pcie_dev_wakeup_delay(adapter);
dev_warn(adapter->dev, "Enable host interrupt failed\n");
/* Reading fw_status register will wakeup device */
if (mwifiex_read_reg(adapter, reg->fw_status, &fw_status)) {
dev_warn(adapter->dev, "Reading fw_status register failed\n");
return -1; return -1;
} }
dev_dbg(adapter->dev, "PCIE wakeup: Setting PS_STATE_AWAKE\n"); if (reg->sleep_cookie) {
adapter->ps_state = PS_STATE_AWAKE; mwifiex_pcie_dev_wakeup_delay(adapter);
dev_dbg(adapter->dev, "PCIE wakeup: Setting PS_STATE_AWAKE\n");
adapter->ps_state = PS_STATE_AWAKE;
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment