aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath10k/pci.c
diff options
context:
space:
mode:
authorMichal Kazior <michal.kazior@tieto.com>2014-02-10 11:14:22 -0500
committerKalle Valo <kvalo@qca.qualcomm.com>2014-02-13 09:55:01 -0500
commitfc36e3ffcdd0ef214008d459bf8d8bff159ce16f (patch)
treedd2155c2e84bcef8e2313cce0e320482dcb0215d /drivers/net/wireless/ath/ath10k/pci.c
parent36786024df993f0fb5e7d1b56058c4f48f24d5e8 (diff)
ath10k: fix device initialization routine
Hardware CUS232 version 2 has some issues with cold reset that lead to Data Bus Errors or system hangs in some cases. It's safer to use warm reset when possible as it shouldn't trigger the aforementioned issues. Prefer warm reset over cold reset. However since warm reset doesn't work after FW crash make sure to fallback to cold reset when booting up the HW. Signed-off-by: Michal Kazior <michal.kazior@tieto.com> Signed-off-by: Marek Puzyniak <marek.puzyniak@tieto.com> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath10k/pci.c')
-rw-r--r--drivers/net/wireless/ath/ath10k/pci.c134
1 files changed, 127 insertions, 7 deletions
diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index 9179c88007d1..486412b9fec2 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -64,7 +64,8 @@ static int ath10k_pci_post_rx_pipe(struct ath10k_pci_pipe *pipe_info,
64 int num); 64 int num);
65static void ath10k_pci_rx_pipe_cleanup(struct ath10k_pci_pipe *pipe_info); 65static void ath10k_pci_rx_pipe_cleanup(struct ath10k_pci_pipe *pipe_info);
66static void ath10k_pci_stop_ce(struct ath10k *ar); 66static void ath10k_pci_stop_ce(struct ath10k *ar);
67static int ath10k_pci_device_reset(struct ath10k *ar); 67static int ath10k_pci_cold_reset(struct ath10k *ar);
68static int ath10k_pci_warm_reset(struct ath10k *ar);
68static int ath10k_pci_wait_for_target_init(struct ath10k *ar); 69static int ath10k_pci_wait_for_target_init(struct ath10k *ar);
69static int ath10k_pci_init_irq(struct ath10k *ar); 70static int ath10k_pci_init_irq(struct ath10k *ar);
70static int ath10k_pci_deinit_irq(struct ath10k *ar); 71static int ath10k_pci_deinit_irq(struct ath10k *ar);
@@ -1500,7 +1501,7 @@ static void ath10k_pci_hif_stop(struct ath10k *ar)
1500 * configuration during init. If ringbuffers are freed and the device 1501 * configuration during init. If ringbuffers are freed and the device
1501 * were to access them this could lead to memory corruption on the 1502 * were to access them this could lead to memory corruption on the
1502 * host. */ 1503 * host. */
1503 ath10k_pci_device_reset(ar); 1504 ath10k_pci_warm_reset(ar);
1504 1505
1505 ar_pci->started = 0; 1506 ar_pci->started = 0;
1506} 1507}
@@ -1991,7 +1992,94 @@ static void ath10k_pci_fw_interrupt_handler(struct ath10k *ar)
1991 ath10k_pci_sleep(ar); 1992 ath10k_pci_sleep(ar);
1992} 1993}
1993 1994
1994static int ath10k_pci_hif_power_up(struct ath10k *ar) 1995static int ath10k_pci_warm_reset(struct ath10k *ar)
1996{
1997 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1998 int ret = 0;
1999 u32 val;
2000
2001 ath10k_dbg(ATH10K_DBG_BOOT, "boot performing warm chip reset\n");
2002
2003 ret = ath10k_do_pci_wake(ar);
2004 if (ret) {
2005 ath10k_err("failed to wake up target: %d\n", ret);
2006 return ret;
2007 }
2008
2009 /* debug */
2010 val = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS +
2011 PCIE_INTR_CAUSE_ADDRESS);
2012 ath10k_dbg(ATH10K_DBG_BOOT, "boot host cpu intr cause: 0x%08x\n", val);
2013
2014 val = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS +
2015 CPU_INTR_ADDRESS);
2016 ath10k_dbg(ATH10K_DBG_BOOT, "boot target cpu intr cause: 0x%08x\n",
2017 val);
2018
2019 /* disable pending irqs */
2020 ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS +
2021 PCIE_INTR_ENABLE_ADDRESS, 0);
2022
2023 ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS +
2024 PCIE_INTR_CLR_ADDRESS, ~0);
2025
2026 msleep(100);
2027
2028 /* clear fw indicator */
2029 ath10k_pci_write32(ar, ar_pci->fw_indicator_address, 0);
2030
2031 /* clear target LF timer interrupts */
2032 val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS +
2033 SOC_LF_TIMER_CONTROL0_ADDRESS);
2034 ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS +
2035 SOC_LF_TIMER_CONTROL0_ADDRESS,
2036 val & ~SOC_LF_TIMER_CONTROL0_ENABLE_MASK);
2037
2038 /* reset CE */
2039 val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS +
2040 SOC_RESET_CONTROL_ADDRESS);
2041 ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS + SOC_RESET_CONTROL_ADDRESS,
2042 val | SOC_RESET_CONTROL_CE_RST_MASK);
2043 val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS +
2044 SOC_RESET_CONTROL_ADDRESS);
2045 msleep(10);
2046
2047 /* unreset CE */
2048 ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS + SOC_RESET_CONTROL_ADDRESS,
2049 val & ~SOC_RESET_CONTROL_CE_RST_MASK);
2050 val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS +
2051 SOC_RESET_CONTROL_ADDRESS);
2052 msleep(10);
2053
2054 /* debug */
2055 val = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS +
2056 PCIE_INTR_CAUSE_ADDRESS);
2057 ath10k_dbg(ATH10K_DBG_BOOT, "boot host cpu intr cause: 0x%08x\n", val);
2058
2059 val = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS +
2060 CPU_INTR_ADDRESS);
2061 ath10k_dbg(ATH10K_DBG_BOOT, "boot target cpu intr cause: 0x%08x\n",
2062 val);
2063
2064 /* CPU warm reset */
2065 val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS +
2066 SOC_RESET_CONTROL_ADDRESS);
2067 ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS + SOC_RESET_CONTROL_ADDRESS,
2068 val | SOC_RESET_CONTROL_CPU_WARM_RST_MASK);
2069
2070 val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS +
2071 SOC_RESET_CONTROL_ADDRESS);
2072 ath10k_dbg(ATH10K_DBG_BOOT, "boot target reset state: 0x%08x\n", val);
2073
2074 msleep(100);
2075
2076 ath10k_dbg(ATH10K_DBG_BOOT, "boot warm reset complete\n");
2077
2078 ath10k_do_pci_sleep(ar);
2079 return ret;
2080}
2081
2082static int __ath10k_pci_hif_power_up(struct ath10k *ar, bool cold_reset)
1995{ 2083{
1996 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 2084 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1997 const char *irq_mode; 2085 const char *irq_mode;
@@ -2007,7 +2095,11 @@ static int ath10k_pci_hif_power_up(struct ath10k *ar)
2007 * is in an unexpected state. We try to catch that here in order to 2095 * is in an unexpected state. We try to catch that here in order to
2008 * reset the Target and retry the probe. 2096 * reset the Target and retry the probe.
2009 */ 2097 */
2010 ret = ath10k_pci_device_reset(ar); 2098 if (cold_reset)
2099 ret = ath10k_pci_cold_reset(ar);
2100 else
2101 ret = ath10k_pci_warm_reset(ar);
2102
2011 if (ret) { 2103 if (ret) {
2012 ath10k_err("failed to reset target: %d\n", ret); 2104 ath10k_err("failed to reset target: %d\n", ret);
2013 goto err; 2105 goto err;
@@ -2077,7 +2169,7 @@ err_deinit_irq:
2077 ath10k_pci_deinit_irq(ar); 2169 ath10k_pci_deinit_irq(ar);
2078err_ce: 2170err_ce:
2079 ath10k_pci_ce_deinit(ar); 2171 ath10k_pci_ce_deinit(ar);
2080 ath10k_pci_device_reset(ar); 2172 ath10k_pci_warm_reset(ar);
2081err_ps: 2173err_ps:
2082 if (!test_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features)) 2174 if (!test_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features))
2083 ath10k_do_pci_sleep(ar); 2175 ath10k_do_pci_sleep(ar);
@@ -2085,6 +2177,34 @@ err:
2085 return ret; 2177 return ret;
2086} 2178}
2087 2179
2180static int ath10k_pci_hif_power_up(struct ath10k *ar)
2181{
2182 int ret;
2183
2184 /*
2185 * Hardware CUS232 version 2 has some issues with cold reset and the
2186 * preferred (and safer) way to perform a device reset is through a
2187 * warm reset.
2188 *
2189 * Warm reset doesn't always work though (notably after a firmware
2190 * crash) so fall back to cold reset if necessary.
2191 */
2192 ret = __ath10k_pci_hif_power_up(ar, false);
2193 if (ret) {
2194 ath10k_warn("failed to power up target using warm reset (%d), trying cold reset\n",
2195 ret);
2196
2197 ret = __ath10k_pci_hif_power_up(ar, true);
2198 if (ret) {
2199 ath10k_err("failed to power up target using cold reset too (%d)\n",
2200 ret);
2201 return ret;
2202 }
2203 }
2204
2205 return 0;
2206}
2207
2088static void ath10k_pci_hif_power_down(struct ath10k *ar) 2208static void ath10k_pci_hif_power_down(struct ath10k *ar)
2089{ 2209{
2090 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 2210 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
@@ -2092,7 +2212,7 @@ static void ath10k_pci_hif_power_down(struct ath10k *ar)
2092 ath10k_pci_free_early_irq(ar); 2212 ath10k_pci_free_early_irq(ar);
2093 ath10k_pci_kill_tasklet(ar); 2213 ath10k_pci_kill_tasklet(ar);
2094 ath10k_pci_deinit_irq(ar); 2214 ath10k_pci_deinit_irq(ar);
2095 ath10k_pci_device_reset(ar); 2215 ath10k_pci_warm_reset(ar);
2096 2216
2097 ath10k_pci_ce_deinit(ar); 2217 ath10k_pci_ce_deinit(ar);
2098 if (!test_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features)) 2218 if (!test_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features))
@@ -2521,7 +2641,7 @@ out:
2521 return ret; 2641 return ret;
2522} 2642}
2523 2643
2524static int ath10k_pci_device_reset(struct ath10k *ar) 2644static int ath10k_pci_cold_reset(struct ath10k *ar)
2525{ 2645{
2526 int i, ret; 2646 int i, ret;
2527 u32 val; 2647 u32 val;