aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorKalle Valo <kvalo@qca.qualcomm.com>2014-03-28 03:32:21 -0400
committerKalle Valo <kvalo@qca.qualcomm.com>2014-03-28 08:21:41 -0400
commit0399eca8003945ab626c63ba5d796d57f81a8eb0 (patch)
tree22d1cd02032943049cf6d6a7aaaded46afa109c4 /drivers/net/wireless
parent36a8f413a3a53d0d77234e8ec7d29d50dfc2cf24 (diff)
ath10k: cleanup ath10k_pci_wait_for_target_init()
ath10k_pci_wait_for_target_init() did really follow the style used elsewhere in ath10k. Use ath10k_pci_read/write() wrappers, simplify the while loop and improve warning messages. Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/ath/ath10k/pci.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index 9d242d801d9d..43d63677b133 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -48,6 +48,9 @@ MODULE_PARM_DESC(ath10k_target_ps, "Enable ath10k Target (SoC) PS option");
48module_param_named(irq_mode, ath10k_pci_irq_mode, uint, 0644); 48module_param_named(irq_mode, ath10k_pci_irq_mode, uint, 0644);
49MODULE_PARM_DESC(irq_mode, "0: auto, 1: legacy, 2: msi (default: 0)"); 49MODULE_PARM_DESC(irq_mode, "0: auto, 1: legacy, 2: msi (default: 0)");
50 50
51/* how long wait to wait for target to initialise, in ms */
52#define ATH10K_PCI_TARGET_WAIT 3000
53
51#define QCA988X_2_0_DEVICE_ID (0x003c) 54#define QCA988X_2_0_DEVICE_ID (0x003c)
52 55
53static DEFINE_PCI_DEVICE_TABLE(ath10k_pci_id_table) = { 56static DEFINE_PCI_DEVICE_TABLE(ath10k_pci_id_table) = {
@@ -2385,30 +2388,41 @@ static int ath10k_pci_deinit_irq(struct ath10k *ar)
2385static int ath10k_pci_wait_for_target_init(struct ath10k *ar) 2388static int ath10k_pci_wait_for_target_init(struct ath10k *ar)
2386{ 2389{
2387 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 2390 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
2388 int wait_limit = 300; /* 3 sec */ 2391 unsigned long timeout;
2389 int ret; 2392 int ret;
2393 u32 val;
2390 2394
2391 ret = ath10k_pci_wake(ar); 2395 ret = ath10k_pci_wake(ar);
2392 if (ret) { 2396 if (ret) {
2393 ath10k_err("failed to wake up target: %d\n", ret); 2397 ath10k_err("failed to wake up target for init: %d\n", ret);
2394 return ret; 2398 return ret;
2395 } 2399 }
2396 2400
2397 while (wait_limit-- && 2401 timeout = jiffies + msecs_to_jiffies(ATH10K_PCI_TARGET_WAIT);
2398 !(ioread32(ar_pci->mem + FW_INDICATOR_ADDRESS) & 2402
2399 FW_IND_INITIALIZED)) { 2403 do {
2404 val = ath10k_pci_read32(ar, FW_INDICATOR_ADDRESS);
2405
2406 /* target should never return this */
2407 if (val == 0xffffffff)
2408 continue;
2409
2410 if (val & FW_IND_INITIALIZED)
2411 break;
2412
2400 if (ar_pci->num_msi_intrs == 0) 2413 if (ar_pci->num_msi_intrs == 0)
2401 /* Fix potential race by repeating CORE_BASE writes */ 2414 /* Fix potential race by repeating CORE_BASE writes */
2402 iowrite32(PCIE_INTR_FIRMWARE_MASK | 2415 ath10k_pci_soc_write32(ar, PCIE_INTR_ENABLE_ADDRESS,
2403 PCIE_INTR_CE_MASK_ALL, 2416 PCIE_INTR_FIRMWARE_MASK |
2404 ar_pci->mem + (SOC_CORE_BASE_ADDRESS | 2417 PCIE_INTR_CE_MASK_ALL);
2405 PCIE_INTR_ENABLE_ADDRESS)); 2418
2406 mdelay(10); 2419 mdelay(10);
2407 } 2420 } while (time_before(jiffies, timeout));
2408 2421
2409 if (wait_limit < 0) { 2422 if (val == 0xffffffff || !(val & FW_IND_INITIALIZED)) {
2410 ath10k_err("target stalled\n"); 2423 ath10k_err("failed to receive initialized event from target: %08x\n",
2411 ret = -EIO; 2424 val);
2425 ret = -ETIMEDOUT;
2412 goto out; 2426 goto out;
2413 } 2427 }
2414 2428