wil6210: use HW capabilities mask in reset
authorVladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>
Tue, 23 Dec 2014 07:47:18 +0000 (09:47 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 15 Jan 2015 12:31:35 +0000 (14:31 +0200)
Use the proper reset follow based on HW capabilities
detection instead of chip ID.
Remove old hw ID mechanism which was used only for reset flow.
Remove support for Marlon A0.

Signed-off-by: Vladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/wil6210/interrupt.c
drivers/net/wireless/ath/wil6210/main.c
drivers/net/wireless/ath/wil6210/pcie_bus.c
drivers/net/wireless/ath/wil6210/wil6210.h

index 5a0ea72d371095741b68dec5f7b4c9ae5a1c131c..384bb3171c452bd46f4c6701c8b027843553fe67 100644 (file)
@@ -194,18 +194,19 @@ static irqreturn_t wil6210_irq_rx(int irq, void *cookie)
                wil_dbg_irq(wil, "RX done\n");
 
                if (isr & BIT_DMA_EP_RX_ICR_RX_HTRSH)
-                       wil_err_ratelimited(wil, "Received \"Rx buffer is in risk "
-                               "of overflow\" interrupt\n");
+                       wil_err_ratelimited(wil,
+                                           "Received \"Rx buffer is in risk of overflow\" interrupt\n");
 
-               isr &= ~(BIT_DMA_EP_RX_ICR_RX_DONE | BIT_DMA_EP_RX_ICR_RX_HTRSH);
+               isr &= ~(BIT_DMA_EP_RX_ICR_RX_DONE |
+                        BIT_DMA_EP_RX_ICR_RX_HTRSH);
                if (test_bit(wil_status_reset_done, wil->status)) {
                        if (test_bit(wil_status_napi_en, wil->status)) {
                                wil_dbg_txrx(wil, "NAPI(Rx) schedule\n");
                                need_unmask = false;
                                napi_schedule(&wil->napi_rx);
                        } else {
-                               wil_err(wil, "Got Rx interrupt while "
-                                       "stopping interface\n");
+                               wil_err(wil,
+                                       "Got Rx interrupt while stopping interface\n");
                        }
                } else {
                        wil_err(wil, "Got Rx interrupt while in reset\n");
index a17278f4090ac22970a1ba64b6b43de60181ff8e..fb73ac5fa00eaa983e20e0d37ffe561a8dcc3deb 100644 (file)
@@ -502,13 +502,10 @@ static int wil_target_reset(struct wil6210_priv *wil)
 {
        int delay = 0;
        u32 x;
-       u32 rev_id;
-       bool is_sparrow = (wil->board->board == WIL_BOARD_SPARROW);
+       bool is_reset_v2 = test_bit(hw_capability_reset_v2,
+                                   wil->hw_capabilities);
 
-       wil_dbg_misc(wil, "Resetting \"%s\"...\n", wil->board->name);
-
-       wil->hw_version = R(RGF_USER_FW_REV_ID);
-       rev_id = wil->hw_version & 0xff;
+       wil_dbg_misc(wil, "Resetting \"%s\"...\n", wil->hw_name);
 
        /* Clear MAC link up */
        S(RGF_HP_CTRL, BIT(15));
@@ -520,7 +517,7 @@ static int wil_target_reset(struct wil6210_priv *wil)
        /* Clear Fw Download notification */
        C(RGF_USER_USAGE_6, BIT(0));
 
-       if (is_sparrow) {
+       if (is_reset_v2) {
                S(RGF_CAF_OSC_CONTROL, BIT_CAF_OSC_XTAL_EN);
                /* XTAL stabilization should take about 3ms */
                usleep_range(5000, 7000);
@@ -541,10 +538,11 @@ static int wil_target_reset(struct wil6210_priv *wil)
 
        W(RGF_USER_CLKS_CTL_SW_RST_VEC_2, 0xFE000000);
        W(RGF_USER_CLKS_CTL_SW_RST_VEC_1, 0x0000003F);
-       W(RGF_USER_CLKS_CTL_SW_RST_VEC_3, is_sparrow ? 0x000000f0 : 0x00000170);
+       W(RGF_USER_CLKS_CTL_SW_RST_VEC_3,
+         is_reset_v2 ? 0x000000f0 : 0x00000170);
        W(RGF_USER_CLKS_CTL_SW_RST_VEC_0, 0xFFE7FE00);
 
-       if (is_sparrow) {
+       if (is_reset_v2) {
                W(RGF_USER_CLKS_CTL_EXT_SW_RST_VEC_0, 0x0);
                W(RGF_USER_CLKS_CTL_EXT_SW_RST_VEC_1, 0x0);
        }
@@ -554,19 +552,14 @@ static int wil_target_reset(struct wil6210_priv *wil)
        W(RGF_USER_CLKS_CTL_SW_RST_VEC_1, 0);
        W(RGF_USER_CLKS_CTL_SW_RST_VEC_0, 0);
 
-       if (is_sparrow) {
+       if (is_reset_v2) {
                W(RGF_USER_CLKS_CTL_SW_RST_VEC_3, 0x00000003);
                /* reset A2 PCIE AHB */
                W(RGF_USER_CLKS_CTL_SW_RST_VEC_2, 0x00008000);
        } else {
                W(RGF_USER_CLKS_CTL_SW_RST_VEC_3, 0x00000001);
-               if (rev_id == 1) {
-                       /* reset A1 BOTH PCIE AHB & PCIE RGF */
-                       W(RGF_USER_CLKS_CTL_SW_RST_VEC_2, 0x00000080);
-               } else {
-                       W(RGF_PCIE_LOS_COUNTER_CTL, BIT(6) | BIT(8));
-                       W(RGF_USER_CLKS_CTL_SW_RST_VEC_2, 0x00008000);
-               }
+               W(RGF_PCIE_LOS_COUNTER_CTL, BIT(6) | BIT(8));
+               W(RGF_USER_CLKS_CTL_SW_RST_VEC_2, 0x00008000);
        }
 
        /* TODO: check order here!!! Erez code is different */
@@ -583,8 +576,7 @@ static int wil_target_reset(struct wil6210_priv *wil)
                }
        } while (x != HW_MACHINE_BOOT_DONE);
 
-       /* TODO: Erez check rev_id != 1 */
-       if (!is_sparrow && (rev_id != 1))
+       if (!is_reset_v2)
                W(RGF_PCIE_LOS_COUNTER_CTL, BIT(8));
 
        C(RGF_USER_CLKS_CTL_0, BIT_USER_CLKS_RST_PWGD);
@@ -653,6 +645,9 @@ int wil_reset(struct wil6210_priv *wil)
 
        wil_dbg_misc(wil, "%s()\n", __func__);
 
+       if (wil->hw_version == HW_VER_UNKNOWN)
+               return -ENODEV;
+
        WARN_ON(!mutex_is_locked(&wil->mutex));
        WARN_ON(test_bit(wil_status_napi_en, wil->status));
 
index 371809dfca73aa0e48ba84bef63beb9d9ea5863c..9b1a589cefbd133b12639d139b0e9c891b8b0d5e 100644 (file)
@@ -40,25 +40,31 @@ void wil_set_capabilities(struct wil6210_priv *wil)
 
        switch (rev_id) {
        case JTAG_DEV_ID_MARLON_B0:
-               wil_info(wil, "Board hardware is Marlon B0\n");
+               wil->hw_name = "Marlon B0";
                wil->hw_version = HW_VER_MARLON_B0;
                break;
        case JTAG_DEV_ID_SPARROW_A0:
-               wil_info(wil, "Board hardware is Sparrow A0\n");
+               wil->hw_name = "Sparrow A0";
                wil->hw_version = HW_VER_SPARROW_A0;
                break;
        case JTAG_DEV_ID_SPARROW_A1:
-               wil_info(wil, "Board hardware is Sparrow A1\n");
+               wil->hw_name = "Sparrow A1";
                wil->hw_version = HW_VER_SPARROW_A1;
                break;
        case JTAG_DEV_ID_SPARROW_B0:
-               wil_info(wil, "Board hardware is Sparrow B0\n");
+               wil->hw_name = "Sparrow B0";
                wil->hw_version = HW_VER_SPARROW_B0;
                break;
        default:
                wil_err(wil, "Unknown board hardware 0x%08x\n", rev_id);
+               wil->hw_name = "Unknown";
                wil->hw_version = HW_VER_UNKNOWN;
        }
+
+       wil_info(wil, "Board hardware is %s\n", wil->hw_name);
+
+       if (wil->hw_version >= HW_VER_SPARROW_A0)
+               set_bit(hw_capability_reset_v2, wil->hw_capabilities);
 }
 
 void wil_disable_irq(struct wil6210_priv *wil)
@@ -179,12 +185,11 @@ static int wil_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        struct wil6210_priv *wil;
        struct device *dev = &pdev->dev;
        void __iomem *csr;
-       struct wil_board *board = (struct wil_board *)id->driver_data;
        int rc;
 
        /* check HW */
        dev_info(&pdev->dev, WIL_NAME
-                " \"%s\" device found [%04x:%04x] (rev %x)\n", board->name,
+                " device found [%04x:%04x] (rev %x)\n",
                 (int)pdev->vendor, (int)pdev->device, (int)pdev->revision);
 
        if (pci_resource_len(pdev, 0) != WIL6210_MEM_SIZE) {
@@ -234,7 +239,6 @@ static int wil_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
        pci_set_drvdata(pdev, wil);
        wil->pdev = pdev;
-       wil->board = board;
        wil_set_capabilities(wil);
        wil6210_clear_irq(wil);
 
@@ -296,23 +300,10 @@ static void wil_pcie_remove(struct pci_dev *pdev)
        pci_disable_device(pdev);
 }
 
-static const struct wil_board wil_board_marlon = {
-       .board = WIL_BOARD_MARLON,
-       .name = "marlon",
-};
-
-static const struct wil_board wil_board_sparrow = {
-       .board = WIL_BOARD_SPARROW,
-       .name = "sparrow",
-};
-
 static const struct pci_device_id wil6210_pcie_ids[] = {
-       { PCI_DEVICE(0x1ae9, 0x0301),
-         .driver_data = (kernel_ulong_t)&wil_board_marlon },
-       { PCI_DEVICE(0x1ae9, 0x0310),
-         .driver_data = (kernel_ulong_t)&wil_board_sparrow },
-       { PCI_DEVICE(0x1ae9, 0x0302), /* same as above, firmware broken */
-         .driver_data = (kernel_ulong_t)&wil_board_sparrow },
+       { PCI_DEVICE(0x1ae9, 0x0301) },
+       { PCI_DEVICE(0x1ae9, 0x0310) },
+       { PCI_DEVICE(0x1ae9, 0x0302) }, /* same as above, firmware broken */
        { /* end: all zeroes */ },
 };
 MODULE_DEVICE_TABLE(pci, wil6210_pcie_ids);
index d296f2e17e56043cd3339ece2a483f6572994bd0..8a52a5ffd6b185b1c935b7086e5d2439a21fd125 100644 (file)
@@ -32,13 +32,6 @@ extern int agg_wsize;
 
 #define WIL_MAX_BUS_REQUEST_KBPS 800000 /* ~6.1Gbps */
 
-struct wil_board {
-       int board;
-#define WIL_BOARD_MARLON       (1)
-#define WIL_BOARD_SPARROW      (2)
-       const char * const name;
-};
-
 /**
  * extract bits [@b0:@b1] (inclusive) from the value @x
  * it should be @b0 <= @b1, or result is incorrect
@@ -441,7 +434,7 @@ enum {
 };
 
 enum {
-       hw_capability_dummy, /* to avoid zero array */
+       hw_capability_reset_v2 = 0,
        hw_capability_last
 };
 
@@ -471,8 +464,8 @@ struct wil6210_priv {
        DECLARE_BITMAP(status, wil_status_last);
        u32 fw_version;
        u32 hw_version;
+       const char *hw_name;
        DECLARE_BITMAP(hw_capabilities, hw_capability_last);
-       struct wil_board *board;
        u8 n_mids; /* number of additional MIDs as reported by FW */
        u32 recovery_count; /* num of FW recovery attempts in a short time */
        u32 recovery_state; /* FW recovery state machine */