diff options
Diffstat (limited to 'drivers/net/wireless/ath/ath10k/pci.c')
-rw-r--r-- | drivers/net/wireless/ath/ath10k/pci.c | 170 |
1 files changed, 152 insertions, 18 deletions
diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index 7abb8367119a..e6972b09333e 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c | |||
@@ -58,12 +58,27 @@ MODULE_PARM_DESC(reset_mode, "0: auto, 1: warm only (default: 0)"); | |||
58 | #define ATH10K_PCI_NUM_WARM_RESET_ATTEMPTS 3 | 58 | #define ATH10K_PCI_NUM_WARM_RESET_ATTEMPTS 3 |
59 | 59 | ||
60 | #define QCA988X_2_0_DEVICE_ID (0x003c) | 60 | #define QCA988X_2_0_DEVICE_ID (0x003c) |
61 | #define QCA6174_2_1_DEVICE_ID (0x003e) | ||
61 | 62 | ||
62 | static const struct pci_device_id ath10k_pci_id_table[] = { | 63 | static const struct pci_device_id ath10k_pci_id_table[] = { |
63 | { PCI_VDEVICE(ATHEROS, QCA988X_2_0_DEVICE_ID) }, /* PCI-E QCA988X V2 */ | 64 | { PCI_VDEVICE(ATHEROS, QCA988X_2_0_DEVICE_ID) }, /* PCI-E QCA988X V2 */ |
65 | { PCI_VDEVICE(ATHEROS, QCA6174_2_1_DEVICE_ID) }, /* PCI-E QCA6174 V2.1 */ | ||
64 | {0} | 66 | {0} |
65 | }; | 67 | }; |
66 | 68 | ||
69 | static const struct ath10k_pci_supp_chip ath10k_pci_supp_chips[] = { | ||
70 | /* QCA988X pre 2.0 chips are not supported because they need some nasty | ||
71 | * hacks. ath10k doesn't have them and these devices crash horribly | ||
72 | * because of that. | ||
73 | */ | ||
74 | { QCA988X_2_0_DEVICE_ID, QCA988X_HW_2_0_CHIP_ID_REV }, | ||
75 | { QCA6174_2_1_DEVICE_ID, QCA6174_HW_2_1_CHIP_ID_REV }, | ||
76 | { QCA6174_2_1_DEVICE_ID, QCA6174_HW_2_2_CHIP_ID_REV }, | ||
77 | { QCA6174_2_1_DEVICE_ID, QCA6174_HW_3_0_CHIP_ID_REV }, | ||
78 | { QCA6174_2_1_DEVICE_ID, QCA6174_HW_3_1_CHIP_ID_REV }, | ||
79 | { QCA6174_2_1_DEVICE_ID, QCA6174_HW_3_2_CHIP_ID_REV }, | ||
80 | }; | ||
81 | |||
67 | static void ath10k_pci_buffer_cleanup(struct ath10k *ar); | 82 | static void ath10k_pci_buffer_cleanup(struct ath10k *ar); |
68 | static int ath10k_pci_cold_reset(struct ath10k *ar); | 83 | static int ath10k_pci_cold_reset(struct ath10k *ar); |
69 | static int ath10k_pci_warm_reset(struct ath10k *ar); | 84 | static int ath10k_pci_warm_reset(struct ath10k *ar); |
@@ -395,7 +410,7 @@ static int __ath10k_pci_rx_post_buf(struct ath10k_pci_pipe *pipe) | |||
395 | return -EIO; | 410 | return -EIO; |
396 | } | 411 | } |
397 | 412 | ||
398 | ATH10K_SKB_CB(skb)->paddr = paddr; | 413 | ATH10K_SKB_RXCB(skb)->paddr = paddr; |
399 | 414 | ||
400 | ret = __ath10k_ce_rx_post_buf(ce_pipe, skb, paddr); | 415 | ret = __ath10k_ce_rx_post_buf(ce_pipe, skb, paddr); |
401 | if (ret) { | 416 | if (ret) { |
@@ -864,7 +879,7 @@ static void ath10k_pci_ce_recv_data(struct ath10k_ce_pipe *ce_state) | |||
864 | &flags) == 0) { | 879 | &flags) == 0) { |
865 | skb = transfer_context; | 880 | skb = transfer_context; |
866 | max_nbytes = skb->len + skb_tailroom(skb); | 881 | max_nbytes = skb->len + skb_tailroom(skb); |
867 | dma_unmap_single(ar->dev, ATH10K_SKB_CB(skb)->paddr, | 882 | dma_unmap_single(ar->dev, ATH10K_SKB_RXCB(skb)->paddr, |
868 | max_nbytes, DMA_FROM_DEVICE); | 883 | max_nbytes, DMA_FROM_DEVICE); |
869 | 884 | ||
870 | if (unlikely(max_nbytes < nbytes)) { | 885 | if (unlikely(max_nbytes < nbytes)) { |
@@ -1230,7 +1245,7 @@ static void ath10k_pci_rx_pipe_cleanup(struct ath10k_pci_pipe *pci_pipe) | |||
1230 | 1245 | ||
1231 | ce_ring->per_transfer_context[i] = NULL; | 1246 | ce_ring->per_transfer_context[i] = NULL; |
1232 | 1247 | ||
1233 | dma_unmap_single(ar->dev, ATH10K_SKB_CB(skb)->paddr, | 1248 | dma_unmap_single(ar->dev, ATH10K_SKB_RXCB(skb)->paddr, |
1234 | skb->len + skb_tailroom(skb), | 1249 | skb->len + skb_tailroom(skb), |
1235 | DMA_FROM_DEVICE); | 1250 | DMA_FROM_DEVICE); |
1236 | dev_kfree_skb_any(skb); | 1251 | dev_kfree_skb_any(skb); |
@@ -1498,6 +1513,35 @@ static int ath10k_pci_wake_target_cpu(struct ath10k *ar) | |||
1498 | return 0; | 1513 | return 0; |
1499 | } | 1514 | } |
1500 | 1515 | ||
1516 | static int ath10k_pci_get_num_banks(struct ath10k *ar) | ||
1517 | { | ||
1518 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); | ||
1519 | |||
1520 | switch (ar_pci->pdev->device) { | ||
1521 | case QCA988X_2_0_DEVICE_ID: | ||
1522 | return 1; | ||
1523 | case QCA6174_2_1_DEVICE_ID: | ||
1524 | switch (MS(ar->chip_id, SOC_CHIP_ID_REV)) { | ||
1525 | case QCA6174_HW_1_0_CHIP_ID_REV: | ||
1526 | case QCA6174_HW_1_1_CHIP_ID_REV: | ||
1527 | return 3; | ||
1528 | case QCA6174_HW_1_3_CHIP_ID_REV: | ||
1529 | return 2; | ||
1530 | case QCA6174_HW_2_1_CHIP_ID_REV: | ||
1531 | case QCA6174_HW_2_2_CHIP_ID_REV: | ||
1532 | return 6; | ||
1533 | case QCA6174_HW_3_0_CHIP_ID_REV: | ||
1534 | case QCA6174_HW_3_1_CHIP_ID_REV: | ||
1535 | case QCA6174_HW_3_2_CHIP_ID_REV: | ||
1536 | return 9; | ||
1537 | } | ||
1538 | break; | ||
1539 | } | ||
1540 | |||
1541 | ath10k_warn(ar, "unknown number of banks, assuming 1\n"); | ||
1542 | return 1; | ||
1543 | } | ||
1544 | |||
1501 | static int ath10k_pci_init_config(struct ath10k *ar) | 1545 | static int ath10k_pci_init_config(struct ath10k *ar) |
1502 | { | 1546 | { |
1503 | u32 interconnect_targ_addr; | 1547 | u32 interconnect_targ_addr; |
@@ -1608,7 +1652,8 @@ static int ath10k_pci_init_config(struct ath10k *ar) | |||
1608 | /* first bank is switched to IRAM */ | 1652 | /* first bank is switched to IRAM */ |
1609 | ealloc_value |= ((HI_EARLY_ALLOC_MAGIC << HI_EARLY_ALLOC_MAGIC_SHIFT) & | 1653 | ealloc_value |= ((HI_EARLY_ALLOC_MAGIC << HI_EARLY_ALLOC_MAGIC_SHIFT) & |
1610 | HI_EARLY_ALLOC_MAGIC_MASK); | 1654 | HI_EARLY_ALLOC_MAGIC_MASK); |
1611 | ealloc_value |= ((1 << HI_EARLY_ALLOC_IRAM_BANKS_SHIFT) & | 1655 | ealloc_value |= ((ath10k_pci_get_num_banks(ar) << |
1656 | HI_EARLY_ALLOC_IRAM_BANKS_SHIFT) & | ||
1612 | HI_EARLY_ALLOC_IRAM_BANKS_MASK); | 1657 | HI_EARLY_ALLOC_IRAM_BANKS_MASK); |
1613 | 1658 | ||
1614 | ret = ath10k_pci_diag_write32(ar, ealloc_targ_addr, ealloc_value); | 1659 | ret = ath10k_pci_diag_write32(ar, ealloc_targ_addr, ealloc_value); |
@@ -1804,12 +1849,12 @@ static int ath10k_pci_warm_reset(struct ath10k *ar) | |||
1804 | return 0; | 1849 | return 0; |
1805 | } | 1850 | } |
1806 | 1851 | ||
1807 | static int ath10k_pci_chip_reset(struct ath10k *ar) | 1852 | static int ath10k_pci_qca988x_chip_reset(struct ath10k *ar) |
1808 | { | 1853 | { |
1809 | int i, ret; | 1854 | int i, ret; |
1810 | u32 val; | 1855 | u32 val; |
1811 | 1856 | ||
1812 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot chip reset\n"); | 1857 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot 988x chip reset\n"); |
1813 | 1858 | ||
1814 | /* Some hardware revisions (e.g. CUS223v2) has issues with cold reset. | 1859 | /* Some hardware revisions (e.g. CUS223v2) has issues with cold reset. |
1815 | * It is thus preferred to use warm reset which is safer but may not be | 1860 | * It is thus preferred to use warm reset which is safer but may not be |
@@ -1873,11 +1918,53 @@ static int ath10k_pci_chip_reset(struct ath10k *ar) | |||
1873 | return ret; | 1918 | return ret; |
1874 | } | 1919 | } |
1875 | 1920 | ||
1876 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot chip reset complete (cold)\n"); | 1921 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot qca988x chip reset complete (cold)\n"); |
1922 | |||
1923 | return 0; | ||
1924 | } | ||
1925 | |||
1926 | static int ath10k_pci_qca6174_chip_reset(struct ath10k *ar) | ||
1927 | { | ||
1928 | int ret; | ||
1929 | |||
1930 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot qca6174 chip reset\n"); | ||
1931 | |||
1932 | /* FIXME: QCA6174 requires cold + warm reset to work. */ | ||
1933 | |||
1934 | ret = ath10k_pci_cold_reset(ar); | ||
1935 | if (ret) { | ||
1936 | ath10k_warn(ar, "failed to cold reset: %d\n", ret); | ||
1937 | return ret; | ||
1938 | } | ||
1939 | |||
1940 | ret = ath10k_pci_wait_for_target_init(ar); | ||
1941 | if (ret) { | ||
1942 | ath10k_warn(ar, "failed to wait for target after cold reset: %d\n", | ||
1943 | ret); | ||
1944 | return ret; | ||
1945 | } | ||
1946 | |||
1947 | ret = ath10k_pci_warm_reset(ar); | ||
1948 | if (ret) { | ||
1949 | ath10k_warn(ar, "failed to warm reset: %d\n", ret); | ||
1950 | return ret; | ||
1951 | } | ||
1952 | |||
1953 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot qca6174 chip reset complete (cold)\n"); | ||
1877 | 1954 | ||
1878 | return 0; | 1955 | return 0; |
1879 | } | 1956 | } |
1880 | 1957 | ||
1958 | static int ath10k_pci_chip_reset(struct ath10k *ar) | ||
1959 | { | ||
1960 | if (QCA_REV_988X(ar)) | ||
1961 | return ath10k_pci_qca988x_chip_reset(ar); | ||
1962 | else if (QCA_REV_6174(ar)) | ||
1963 | return ath10k_pci_qca6174_chip_reset(ar); | ||
1964 | else | ||
1965 | return -ENOTSUPP; | ||
1966 | } | ||
1967 | |||
1881 | static int ath10k_pci_hif_power_up(struct ath10k *ar) | 1968 | static int ath10k_pci_hif_power_up(struct ath10k *ar) |
1882 | { | 1969 | { |
1883 | int ret; | 1970 | int ret; |
@@ -1902,6 +1989,12 @@ static int ath10k_pci_hif_power_up(struct ath10k *ar) | |||
1902 | */ | 1989 | */ |
1903 | ret = ath10k_pci_chip_reset(ar); | 1990 | ret = ath10k_pci_chip_reset(ar); |
1904 | if (ret) { | 1991 | if (ret) { |
1992 | if (ath10k_pci_has_fw_crashed(ar)) { | ||
1993 | ath10k_warn(ar, "firmware crashed during chip reset\n"); | ||
1994 | ath10k_pci_fw_crashed_clear(ar); | ||
1995 | ath10k_pci_fw_crashed_dump(ar); | ||
1996 | } | ||
1997 | |||
1905 | ath10k_err(ar, "failed to reset chip: %d\n", ret); | 1998 | ath10k_err(ar, "failed to reset chip: %d\n", ret); |
1906 | goto err_sleep; | 1999 | goto err_sleep; |
1907 | } | 2000 | } |
@@ -2033,6 +2126,7 @@ static void ath10k_msi_err_tasklet(unsigned long data) | |||
2033 | return; | 2126 | return; |
2034 | } | 2127 | } |
2035 | 2128 | ||
2129 | ath10k_pci_irq_disable(ar); | ||
2036 | ath10k_pci_fw_crashed_clear(ar); | 2130 | ath10k_pci_fw_crashed_clear(ar); |
2037 | ath10k_pci_fw_crashed_dump(ar); | 2131 | ath10k_pci_fw_crashed_dump(ar); |
2038 | } | 2132 | } |
@@ -2102,6 +2196,7 @@ static void ath10k_pci_tasklet(unsigned long data) | |||
2102 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); | 2196 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
2103 | 2197 | ||
2104 | if (ath10k_pci_has_fw_crashed(ar)) { | 2198 | if (ath10k_pci_has_fw_crashed(ar)) { |
2199 | ath10k_pci_irq_disable(ar); | ||
2105 | ath10k_pci_fw_crashed_clear(ar); | 2200 | ath10k_pci_fw_crashed_clear(ar); |
2106 | ath10k_pci_fw_crashed_dump(ar); | 2201 | ath10k_pci_fw_crashed_dump(ar); |
2107 | return; | 2202 | return; |
@@ -2344,8 +2439,6 @@ static int ath10k_pci_wait_for_target_init(struct ath10k *ar) | |||
2344 | 2439 | ||
2345 | if (val & FW_IND_EVENT_PENDING) { | 2440 | if (val & FW_IND_EVENT_PENDING) { |
2346 | ath10k_warn(ar, "device has crashed during init\n"); | 2441 | ath10k_warn(ar, "device has crashed during init\n"); |
2347 | ath10k_pci_fw_crashed_clear(ar); | ||
2348 | ath10k_pci_fw_crashed_dump(ar); | ||
2349 | return -ECOMM; | 2442 | return -ECOMM; |
2350 | } | 2443 | } |
2351 | 2444 | ||
@@ -2476,17 +2569,46 @@ static void ath10k_pci_release(struct ath10k *ar) | |||
2476 | pci_disable_device(pdev); | 2569 | pci_disable_device(pdev); |
2477 | } | 2570 | } |
2478 | 2571 | ||
2572 | static bool ath10k_pci_chip_is_supported(u32 dev_id, u32 chip_id) | ||
2573 | { | ||
2574 | const struct ath10k_pci_supp_chip *supp_chip; | ||
2575 | int i; | ||
2576 | u32 rev_id = MS(chip_id, SOC_CHIP_ID_REV); | ||
2577 | |||
2578 | for (i = 0; i < ARRAY_SIZE(ath10k_pci_supp_chips); i++) { | ||
2579 | supp_chip = &ath10k_pci_supp_chips[i]; | ||
2580 | |||
2581 | if (supp_chip->dev_id == dev_id && | ||
2582 | supp_chip->rev_id == rev_id) | ||
2583 | return true; | ||
2584 | } | ||
2585 | |||
2586 | return false; | ||
2587 | } | ||
2588 | |||
2479 | static int ath10k_pci_probe(struct pci_dev *pdev, | 2589 | static int ath10k_pci_probe(struct pci_dev *pdev, |
2480 | const struct pci_device_id *pci_dev) | 2590 | const struct pci_device_id *pci_dev) |
2481 | { | 2591 | { |
2482 | int ret = 0; | 2592 | int ret = 0; |
2483 | struct ath10k *ar; | 2593 | struct ath10k *ar; |
2484 | struct ath10k_pci *ar_pci; | 2594 | struct ath10k_pci *ar_pci; |
2595 | enum ath10k_hw_rev hw_rev; | ||
2485 | u32 chip_id; | 2596 | u32 chip_id; |
2486 | 2597 | ||
2487 | ar = ath10k_core_create(sizeof(*ar_pci), &pdev->dev, | 2598 | switch (pci_dev->device) { |
2488 | ATH10K_BUS_PCI, | 2599 | case QCA988X_2_0_DEVICE_ID: |
2489 | &ath10k_pci_hif_ops); | 2600 | hw_rev = ATH10K_HW_QCA988X; |
2601 | break; | ||
2602 | case QCA6174_2_1_DEVICE_ID: | ||
2603 | hw_rev = ATH10K_HW_QCA6174; | ||
2604 | break; | ||
2605 | default: | ||
2606 | WARN_ON(1); | ||
2607 | return -ENOTSUPP; | ||
2608 | } | ||
2609 | |||
2610 | ar = ath10k_core_create(sizeof(*ar_pci), &pdev->dev, ATH10K_BUS_PCI, | ||
2611 | hw_rev, &ath10k_pci_hif_ops); | ||
2490 | if (!ar) { | 2612 | if (!ar) { |
2491 | dev_err(&pdev->dev, "failed to allocate core\n"); | 2613 | dev_err(&pdev->dev, "failed to allocate core\n"); |
2492 | return -ENOMEM; | 2614 | return -ENOMEM; |
@@ -2515,12 +2637,6 @@ static int ath10k_pci_probe(struct pci_dev *pdev, | |||
2515 | goto err_release; | 2637 | goto err_release; |
2516 | } | 2638 | } |
2517 | 2639 | ||
2518 | chip_id = ath10k_pci_soc_read32(ar, SOC_CHIP_ID_ADDRESS); | ||
2519 | if (chip_id == 0xffffffff) { | ||
2520 | ath10k_err(ar, "failed to get chip id\n"); | ||
2521 | goto err_sleep; | ||
2522 | } | ||
2523 | |||
2524 | ret = ath10k_pci_alloc_pipes(ar); | 2640 | ret = ath10k_pci_alloc_pipes(ar); |
2525 | if (ret) { | 2641 | if (ret) { |
2526 | ath10k_err(ar, "failed to allocate copy engine pipes: %d\n", | 2642 | ath10k_err(ar, "failed to allocate copy engine pipes: %d\n", |
@@ -2547,6 +2663,24 @@ static int ath10k_pci_probe(struct pci_dev *pdev, | |||
2547 | goto err_deinit_irq; | 2663 | goto err_deinit_irq; |
2548 | } | 2664 | } |
2549 | 2665 | ||
2666 | ret = ath10k_pci_chip_reset(ar); | ||
2667 | if (ret) { | ||
2668 | ath10k_err(ar, "failed to reset chip: %d\n", ret); | ||
2669 | goto err_free_irq; | ||
2670 | } | ||
2671 | |||
2672 | chip_id = ath10k_pci_soc_read32(ar, SOC_CHIP_ID_ADDRESS); | ||
2673 | if (chip_id == 0xffffffff) { | ||
2674 | ath10k_err(ar, "failed to get chip id\n"); | ||
2675 | goto err_free_irq; | ||
2676 | } | ||
2677 | |||
2678 | if (!ath10k_pci_chip_is_supported(pdev->device, chip_id)) { | ||
2679 | ath10k_err(ar, "device %04x with chip_id %08x isn't supported\n", | ||
2680 | pdev->device, chip_id); | ||
2681 | goto err_sleep; | ||
2682 | } | ||
2683 | |||
2550 | ath10k_pci_sleep(ar); | 2684 | ath10k_pci_sleep(ar); |
2551 | 2685 | ||
2552 | ret = ath10k_core_register(ar, chip_id); | 2686 | ret = ath10k_core_register(ar, chip_id); |