Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2005-2011 Atheros Communications Inc. |
| 3 | * Copyright (c) 2011-2013 Qualcomm Atheros, Inc. |
| 4 | * |
| 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 6 | * purpose with or without fee is hereby granted, provided that the above |
| 7 | * copyright notice and this permission notice appear in all copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 | */ |
| 17 | |
| 18 | #include <linux/pci.h> |
| 19 | #include <linux/module.h> |
| 20 | #include <linux/interrupt.h> |
| 21 | #include <linux/spinlock.h> |
Kalle Valo | 650b91f | 2013-11-20 10:00:49 +0200 | [diff] [blame] | 22 | #include <linux/bitops.h> |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 23 | |
| 24 | #include "core.h" |
| 25 | #include "debug.h" |
| 26 | |
| 27 | #include "targaddrs.h" |
| 28 | #include "bmi.h" |
| 29 | |
| 30 | #include "hif.h" |
| 31 | #include "htc.h" |
| 32 | |
| 33 | #include "ce.h" |
| 34 | #include "pci.h" |
| 35 | |
Michal Kazior | cfe9c45 | 2013-11-25 14:06:27 +0100 | [diff] [blame] | 36 | enum ath10k_pci_irq_mode { |
| 37 | ATH10K_PCI_IRQ_AUTO = 0, |
| 38 | ATH10K_PCI_IRQ_LEGACY = 1, |
| 39 | ATH10K_PCI_IRQ_MSI = 2, |
| 40 | }; |
| 41 | |
Kalle Valo | 3509846 | 2014-03-28 09:32:27 +0200 | [diff] [blame] | 42 | enum ath10k_pci_reset_mode { |
| 43 | ATH10K_PCI_RESET_AUTO = 0, |
| 44 | ATH10K_PCI_RESET_WARM_ONLY = 1, |
| 45 | }; |
| 46 | |
Michal Kazior | cfe9c45 | 2013-11-25 14:06:27 +0100 | [diff] [blame] | 47 | static unsigned int ath10k_pci_irq_mode = ATH10K_PCI_IRQ_AUTO; |
Kalle Valo | 3509846 | 2014-03-28 09:32:27 +0200 | [diff] [blame] | 48 | static unsigned int ath10k_pci_reset_mode = ATH10K_PCI_RESET_AUTO; |
Michal Kazior | cfe9c45 | 2013-11-25 14:06:27 +0100 | [diff] [blame] | 49 | |
Michal Kazior | cfe9c45 | 2013-11-25 14:06:27 +0100 | [diff] [blame] | 50 | module_param_named(irq_mode, ath10k_pci_irq_mode, uint, 0644); |
| 51 | MODULE_PARM_DESC(irq_mode, "0: auto, 1: legacy, 2: msi (default: 0)"); |
| 52 | |
Kalle Valo | 3509846 | 2014-03-28 09:32:27 +0200 | [diff] [blame] | 53 | module_param_named(reset_mode, ath10k_pci_reset_mode, uint, 0644); |
| 54 | MODULE_PARM_DESC(reset_mode, "0: auto, 1: warm only (default: 0)"); |
| 55 | |
Kalle Valo | 0399eca | 2014-03-28 09:32:21 +0200 | [diff] [blame] | 56 | /* how long wait to wait for target to initialise, in ms */ |
| 57 | #define ATH10K_PCI_TARGET_WAIT 3000 |
Michal Kazior | 61c95ce | 2014-05-14 16:56:16 +0300 | [diff] [blame] | 58 | #define ATH10K_PCI_NUM_WARM_RESET_ATTEMPTS 3 |
Kalle Valo | 0399eca | 2014-03-28 09:32:21 +0200 | [diff] [blame] | 59 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 60 | #define QCA988X_2_0_DEVICE_ID (0x003c) |
Michal Kazior | d63955b | 2015-01-24 12:14:49 +0200 | [diff] [blame] | 61 | #define QCA6174_2_1_DEVICE_ID (0x003e) |
Vasanthakumar Thiagarajan | 8bd4702 | 2015-06-18 12:31:03 +0530 | [diff] [blame] | 62 | #define QCA99X0_2_0_DEVICE_ID (0x0040) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 63 | |
Benoit Taine | 9baa3c3 | 2014-08-08 15:56:03 +0200 | [diff] [blame] | 64 | static const struct pci_device_id ath10k_pci_id_table[] = { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 65 | { PCI_VDEVICE(ATHEROS, QCA988X_2_0_DEVICE_ID) }, /* PCI-E QCA988X V2 */ |
Michal Kazior | d63955b | 2015-01-24 12:14:49 +0200 | [diff] [blame] | 66 | { PCI_VDEVICE(ATHEROS, QCA6174_2_1_DEVICE_ID) }, /* PCI-E QCA6174 V2.1 */ |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 67 | {0} |
| 68 | }; |
| 69 | |
Michal Kazior | 7505f7c | 2014-12-02 10:55:54 +0200 | [diff] [blame] | 70 | static const struct ath10k_pci_supp_chip ath10k_pci_supp_chips[] = { |
| 71 | /* QCA988X pre 2.0 chips are not supported because they need some nasty |
| 72 | * hacks. ath10k doesn't have them and these devices crash horribly |
| 73 | * because of that. |
| 74 | */ |
| 75 | { QCA988X_2_0_DEVICE_ID, QCA988X_HW_2_0_CHIP_ID_REV }, |
Michal Kazior | d63955b | 2015-01-24 12:14:49 +0200 | [diff] [blame] | 76 | { QCA6174_2_1_DEVICE_ID, QCA6174_HW_2_1_CHIP_ID_REV }, |
| 77 | { QCA6174_2_1_DEVICE_ID, QCA6174_HW_2_2_CHIP_ID_REV }, |
| 78 | { QCA6174_2_1_DEVICE_ID, QCA6174_HW_3_0_CHIP_ID_REV }, |
| 79 | { QCA6174_2_1_DEVICE_ID, QCA6174_HW_3_1_CHIP_ID_REV }, |
| 80 | { QCA6174_2_1_DEVICE_ID, QCA6174_HW_3_2_CHIP_ID_REV }, |
Michal Kazior | 7505f7c | 2014-12-02 10:55:54 +0200 | [diff] [blame] | 81 | }; |
| 82 | |
Michal Kazior | 728f95e | 2014-08-22 14:33:14 +0200 | [diff] [blame] | 83 | static void ath10k_pci_buffer_cleanup(struct ath10k *ar); |
Michal Kazior | fc36e3f | 2014-02-10 17:14:22 +0100 | [diff] [blame] | 84 | static int ath10k_pci_cold_reset(struct ath10k *ar); |
| 85 | static int ath10k_pci_warm_reset(struct ath10k *ar); |
Michal Kazior | d7fb47f | 2013-11-08 08:01:26 +0100 | [diff] [blame] | 86 | static int ath10k_pci_wait_for_target_init(struct ath10k *ar); |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 87 | static int ath10k_pci_init_irq(struct ath10k *ar); |
| 88 | static int ath10k_pci_deinit_irq(struct ath10k *ar); |
| 89 | static int ath10k_pci_request_irq(struct ath10k *ar); |
| 90 | static void ath10k_pci_free_irq(struct ath10k *ar); |
Michal Kazior | 85622cd | 2013-11-25 14:06:22 +0100 | [diff] [blame] | 91 | static int ath10k_pci_bmi_wait(struct ath10k_ce_pipe *tx_pipe, |
| 92 | struct ath10k_ce_pipe *rx_pipe, |
| 93 | struct bmi_xfer *xfer); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 94 | |
| 95 | static const struct ce_attr host_ce_config_wlan[] = { |
Kalle Valo | 48e9c22 | 2013-09-01 10:01:32 +0300 | [diff] [blame] | 96 | /* CE0: host->target HTC control and raw streams */ |
| 97 | { |
| 98 | .flags = CE_ATTR_FLAGS, |
| 99 | .src_nentries = 16, |
| 100 | .src_sz_max = 256, |
| 101 | .dest_nentries = 0, |
| 102 | }, |
| 103 | |
| 104 | /* CE1: target->host HTT + HTC control */ |
| 105 | { |
| 106 | .flags = CE_ATTR_FLAGS, |
| 107 | .src_nentries = 0, |
Michal Kazior | 6383864 | 2015-02-09 15:04:55 +0100 | [diff] [blame] | 108 | .src_sz_max = 2048, |
Kalle Valo | 48e9c22 | 2013-09-01 10:01:32 +0300 | [diff] [blame] | 109 | .dest_nentries = 512, |
| 110 | }, |
| 111 | |
| 112 | /* CE2: target->host WMI */ |
| 113 | { |
| 114 | .flags = CE_ATTR_FLAGS, |
| 115 | .src_nentries = 0, |
| 116 | .src_sz_max = 2048, |
Rajkumar Manoharan | 30abb33 | 2015-03-04 15:43:44 +0200 | [diff] [blame] | 117 | .dest_nentries = 128, |
Kalle Valo | 48e9c22 | 2013-09-01 10:01:32 +0300 | [diff] [blame] | 118 | }, |
| 119 | |
| 120 | /* CE3: host->target WMI */ |
| 121 | { |
| 122 | .flags = CE_ATTR_FLAGS, |
| 123 | .src_nentries = 32, |
| 124 | .src_sz_max = 2048, |
| 125 | .dest_nentries = 0, |
| 126 | }, |
| 127 | |
| 128 | /* CE4: host->target HTT */ |
| 129 | { |
| 130 | .flags = CE_ATTR_FLAGS | CE_ATTR_DIS_INTR, |
| 131 | .src_nentries = CE_HTT_H2T_MSG_SRC_NENTRIES, |
| 132 | .src_sz_max = 256, |
| 133 | .dest_nentries = 0, |
| 134 | }, |
| 135 | |
| 136 | /* CE5: unused */ |
| 137 | { |
| 138 | .flags = CE_ATTR_FLAGS, |
| 139 | .src_nentries = 0, |
| 140 | .src_sz_max = 0, |
| 141 | .dest_nentries = 0, |
| 142 | }, |
| 143 | |
| 144 | /* CE6: target autonomous hif_memcpy */ |
| 145 | { |
| 146 | .flags = CE_ATTR_FLAGS, |
| 147 | .src_nentries = 0, |
| 148 | .src_sz_max = 0, |
| 149 | .dest_nentries = 0, |
| 150 | }, |
| 151 | |
| 152 | /* CE7: ce_diag, the Diagnostic Window */ |
| 153 | { |
| 154 | .flags = CE_ATTR_FLAGS, |
| 155 | .src_nentries = 2, |
| 156 | .src_sz_max = DIAG_TRANSFER_LIMIT, |
| 157 | .dest_nentries = 2, |
| 158 | }, |
Vasanthakumar Thiagarajan | 050af06 | 2015-06-18 12:31:04 +0530 | [diff] [blame] | 159 | |
| 160 | /* CE8: target->host pktlog */ |
| 161 | { |
| 162 | .flags = CE_ATTR_FLAGS, |
| 163 | .src_nentries = 0, |
| 164 | .src_sz_max = 2048, |
| 165 | .dest_nentries = 128, |
| 166 | }, |
| 167 | |
| 168 | /* CE9 target autonomous qcache memcpy */ |
| 169 | { |
| 170 | .flags = CE_ATTR_FLAGS, |
| 171 | .src_nentries = 0, |
| 172 | .src_sz_max = 0, |
| 173 | .dest_nentries = 0, |
| 174 | }, |
| 175 | |
| 176 | /* CE10: target autonomous hif memcpy */ |
| 177 | { |
| 178 | .flags = CE_ATTR_FLAGS, |
| 179 | .src_nentries = 0, |
| 180 | .src_sz_max = 0, |
| 181 | .dest_nentries = 0, |
| 182 | }, |
| 183 | |
| 184 | /* CE11: target autonomous hif memcpy */ |
| 185 | { |
| 186 | .flags = CE_ATTR_FLAGS, |
| 187 | .src_nentries = 0, |
| 188 | .src_sz_max = 0, |
| 189 | .dest_nentries = 0, |
| 190 | }, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 191 | }; |
| 192 | |
| 193 | /* Target firmware's Copy Engine configuration. */ |
| 194 | static const struct ce_pipe_config target_ce_config_wlan[] = { |
Kalle Valo | d88effb | 2013-09-01 10:01:39 +0300 | [diff] [blame] | 195 | /* CE0: host->target HTC control and raw streams */ |
| 196 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 197 | .pipenum = __cpu_to_le32(0), |
| 198 | .pipedir = __cpu_to_le32(PIPEDIR_OUT), |
| 199 | .nentries = __cpu_to_le32(32), |
| 200 | .nbytes_max = __cpu_to_le32(256), |
| 201 | .flags = __cpu_to_le32(CE_ATTR_FLAGS), |
| 202 | .reserved = __cpu_to_le32(0), |
Kalle Valo | d88effb | 2013-09-01 10:01:39 +0300 | [diff] [blame] | 203 | }, |
| 204 | |
| 205 | /* CE1: target->host HTT + HTC control */ |
| 206 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 207 | .pipenum = __cpu_to_le32(1), |
| 208 | .pipedir = __cpu_to_le32(PIPEDIR_IN), |
| 209 | .nentries = __cpu_to_le32(32), |
Michal Kazior | 6383864 | 2015-02-09 15:04:55 +0100 | [diff] [blame] | 210 | .nbytes_max = __cpu_to_le32(2048), |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 211 | .flags = __cpu_to_le32(CE_ATTR_FLAGS), |
| 212 | .reserved = __cpu_to_le32(0), |
Kalle Valo | d88effb | 2013-09-01 10:01:39 +0300 | [diff] [blame] | 213 | }, |
| 214 | |
| 215 | /* CE2: target->host WMI */ |
| 216 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 217 | .pipenum = __cpu_to_le32(2), |
| 218 | .pipedir = __cpu_to_le32(PIPEDIR_IN), |
Rajkumar Manoharan | 30abb33 | 2015-03-04 15:43:44 +0200 | [diff] [blame] | 219 | .nentries = __cpu_to_le32(64), |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 220 | .nbytes_max = __cpu_to_le32(2048), |
| 221 | .flags = __cpu_to_le32(CE_ATTR_FLAGS), |
| 222 | .reserved = __cpu_to_le32(0), |
Kalle Valo | d88effb | 2013-09-01 10:01:39 +0300 | [diff] [blame] | 223 | }, |
| 224 | |
| 225 | /* CE3: host->target WMI */ |
| 226 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 227 | .pipenum = __cpu_to_le32(3), |
| 228 | .pipedir = __cpu_to_le32(PIPEDIR_OUT), |
| 229 | .nentries = __cpu_to_le32(32), |
| 230 | .nbytes_max = __cpu_to_le32(2048), |
| 231 | .flags = __cpu_to_le32(CE_ATTR_FLAGS), |
| 232 | .reserved = __cpu_to_le32(0), |
Kalle Valo | d88effb | 2013-09-01 10:01:39 +0300 | [diff] [blame] | 233 | }, |
| 234 | |
| 235 | /* CE4: host->target HTT */ |
| 236 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 237 | .pipenum = __cpu_to_le32(4), |
| 238 | .pipedir = __cpu_to_le32(PIPEDIR_OUT), |
| 239 | .nentries = __cpu_to_le32(256), |
| 240 | .nbytes_max = __cpu_to_le32(256), |
| 241 | .flags = __cpu_to_le32(CE_ATTR_FLAGS), |
| 242 | .reserved = __cpu_to_le32(0), |
Kalle Valo | d88effb | 2013-09-01 10:01:39 +0300 | [diff] [blame] | 243 | }, |
| 244 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 245 | /* NB: 50% of src nentries, since tx has 2 frags */ |
Kalle Valo | d88effb | 2013-09-01 10:01:39 +0300 | [diff] [blame] | 246 | |
| 247 | /* CE5: unused */ |
| 248 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 249 | .pipenum = __cpu_to_le32(5), |
| 250 | .pipedir = __cpu_to_le32(PIPEDIR_OUT), |
| 251 | .nentries = __cpu_to_le32(32), |
| 252 | .nbytes_max = __cpu_to_le32(2048), |
| 253 | .flags = __cpu_to_le32(CE_ATTR_FLAGS), |
| 254 | .reserved = __cpu_to_le32(0), |
Kalle Valo | d88effb | 2013-09-01 10:01:39 +0300 | [diff] [blame] | 255 | }, |
| 256 | |
| 257 | /* CE6: Reserved for target autonomous hif_memcpy */ |
| 258 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 259 | .pipenum = __cpu_to_le32(6), |
| 260 | .pipedir = __cpu_to_le32(PIPEDIR_INOUT), |
| 261 | .nentries = __cpu_to_le32(32), |
| 262 | .nbytes_max = __cpu_to_le32(4096), |
| 263 | .flags = __cpu_to_le32(CE_ATTR_FLAGS), |
| 264 | .reserved = __cpu_to_le32(0), |
Kalle Valo | d88effb | 2013-09-01 10:01:39 +0300 | [diff] [blame] | 265 | }, |
| 266 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 267 | /* CE7 used only by Host */ |
Vasanthakumar Thiagarajan | 050af06 | 2015-06-18 12:31:04 +0530 | [diff] [blame] | 268 | { |
| 269 | .pipenum = __cpu_to_le32(7), |
| 270 | .pipedir = __cpu_to_le32(PIPEDIR_INOUT), |
| 271 | .nentries = __cpu_to_le32(0), |
| 272 | .nbytes_max = __cpu_to_le32(0), |
| 273 | .flags = __cpu_to_le32(0), |
| 274 | .reserved = __cpu_to_le32(0), |
| 275 | }, |
| 276 | |
| 277 | /* CE8 target->host packtlog */ |
| 278 | { |
| 279 | .pipenum = __cpu_to_le32(8), |
| 280 | .pipedir = __cpu_to_le32(PIPEDIR_IN), |
| 281 | .nentries = __cpu_to_le32(64), |
| 282 | .nbytes_max = __cpu_to_le32(2048), |
| 283 | .flags = __cpu_to_le32(CE_ATTR_FLAGS | CE_ATTR_DIS_INTR), |
| 284 | .reserved = __cpu_to_le32(0), |
| 285 | }, |
| 286 | |
| 287 | /* CE9 target autonomous qcache memcpy */ |
| 288 | { |
| 289 | .pipenum = __cpu_to_le32(9), |
| 290 | .pipedir = __cpu_to_le32(PIPEDIR_INOUT), |
| 291 | .nentries = __cpu_to_le32(32), |
| 292 | .nbytes_max = __cpu_to_le32(2048), |
| 293 | .flags = __cpu_to_le32(CE_ATTR_FLAGS | CE_ATTR_DIS_INTR), |
| 294 | .reserved = __cpu_to_le32(0), |
| 295 | }, |
| 296 | |
| 297 | /* It not necessary to send target wlan configuration for CE10 & CE11 |
| 298 | * as these CEs are not actively used in target. |
| 299 | */ |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 300 | }; |
| 301 | |
Michal Kazior | d7bfb7a | 2014-08-26 19:14:02 +0300 | [diff] [blame] | 302 | /* |
| 303 | * Map from service/endpoint to Copy Engine. |
| 304 | * This table is derived from the CE_PCI TABLE, above. |
| 305 | * It is passed to the Target at startup for use by firmware. |
| 306 | */ |
| 307 | static const struct service_to_pipe target_service_to_ce_map_wlan[] = { |
| 308 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 309 | __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_VO), |
| 310 | __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */ |
| 311 | __cpu_to_le32(3), |
Michal Kazior | d7bfb7a | 2014-08-26 19:14:02 +0300 | [diff] [blame] | 312 | }, |
| 313 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 314 | __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_VO), |
| 315 | __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */ |
| 316 | __cpu_to_le32(2), |
Michal Kazior | d7bfb7a | 2014-08-26 19:14:02 +0300 | [diff] [blame] | 317 | }, |
| 318 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 319 | __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_BK), |
| 320 | __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */ |
| 321 | __cpu_to_le32(3), |
Michal Kazior | d7bfb7a | 2014-08-26 19:14:02 +0300 | [diff] [blame] | 322 | }, |
| 323 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 324 | __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_BK), |
| 325 | __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */ |
| 326 | __cpu_to_le32(2), |
Michal Kazior | d7bfb7a | 2014-08-26 19:14:02 +0300 | [diff] [blame] | 327 | }, |
| 328 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 329 | __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_BE), |
| 330 | __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */ |
| 331 | __cpu_to_le32(3), |
Michal Kazior | d7bfb7a | 2014-08-26 19:14:02 +0300 | [diff] [blame] | 332 | }, |
| 333 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 334 | __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_BE), |
| 335 | __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */ |
| 336 | __cpu_to_le32(2), |
Michal Kazior | d7bfb7a | 2014-08-26 19:14:02 +0300 | [diff] [blame] | 337 | }, |
| 338 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 339 | __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_VI), |
| 340 | __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */ |
| 341 | __cpu_to_le32(3), |
Michal Kazior | d7bfb7a | 2014-08-26 19:14:02 +0300 | [diff] [blame] | 342 | }, |
| 343 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 344 | __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_VI), |
| 345 | __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */ |
| 346 | __cpu_to_le32(2), |
Michal Kazior | d7bfb7a | 2014-08-26 19:14:02 +0300 | [diff] [blame] | 347 | }, |
| 348 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 349 | __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_CONTROL), |
| 350 | __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */ |
| 351 | __cpu_to_le32(3), |
Michal Kazior | d7bfb7a | 2014-08-26 19:14:02 +0300 | [diff] [blame] | 352 | }, |
| 353 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 354 | __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_CONTROL), |
| 355 | __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */ |
| 356 | __cpu_to_le32(2), |
Michal Kazior | d7bfb7a | 2014-08-26 19:14:02 +0300 | [diff] [blame] | 357 | }, |
| 358 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 359 | __cpu_to_le32(ATH10K_HTC_SVC_ID_RSVD_CTRL), |
| 360 | __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */ |
| 361 | __cpu_to_le32(0), |
Michal Kazior | d7bfb7a | 2014-08-26 19:14:02 +0300 | [diff] [blame] | 362 | }, |
| 363 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 364 | __cpu_to_le32(ATH10K_HTC_SVC_ID_RSVD_CTRL), |
| 365 | __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */ |
| 366 | __cpu_to_le32(1), |
| 367 | }, |
| 368 | { /* not used */ |
| 369 | __cpu_to_le32(ATH10K_HTC_SVC_ID_TEST_RAW_STREAMS), |
| 370 | __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */ |
| 371 | __cpu_to_le32(0), |
| 372 | }, |
| 373 | { /* not used */ |
| 374 | __cpu_to_le32(ATH10K_HTC_SVC_ID_TEST_RAW_STREAMS), |
| 375 | __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */ |
| 376 | __cpu_to_le32(1), |
Michal Kazior | d7bfb7a | 2014-08-26 19:14:02 +0300 | [diff] [blame] | 377 | }, |
| 378 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 379 | __cpu_to_le32(ATH10K_HTC_SVC_ID_HTT_DATA_MSG), |
| 380 | __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */ |
| 381 | __cpu_to_le32(4), |
Michal Kazior | d7bfb7a | 2014-08-26 19:14:02 +0300 | [diff] [blame] | 382 | }, |
| 383 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 384 | __cpu_to_le32(ATH10K_HTC_SVC_ID_HTT_DATA_MSG), |
| 385 | __cpu_to_le32(PIPEDIR_IN), /* in = DL = target -> host */ |
| 386 | __cpu_to_le32(1), |
Michal Kazior | d7bfb7a | 2014-08-26 19:14:02 +0300 | [diff] [blame] | 387 | }, |
| 388 | |
| 389 | /* (Additions here) */ |
| 390 | |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 391 | { /* must be last */ |
| 392 | __cpu_to_le32(0), |
| 393 | __cpu_to_le32(0), |
| 394 | __cpu_to_le32(0), |
Michal Kazior | d7bfb7a | 2014-08-26 19:14:02 +0300 | [diff] [blame] | 395 | }, |
| 396 | }; |
| 397 | |
Michal Kazior | 77258d4 | 2015-05-18 09:38:18 +0000 | [diff] [blame] | 398 | static bool ath10k_pci_is_awake(struct ath10k *ar) |
| 399 | { |
| 400 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 401 | u32 val = ioread32(ar_pci->mem + PCIE_LOCAL_BASE_ADDRESS + |
| 402 | RTC_STATE_ADDRESS); |
| 403 | |
| 404 | return RTC_STATE_V_GET(val) == RTC_STATE_V_ON; |
| 405 | } |
| 406 | |
| 407 | static void __ath10k_pci_wake(struct ath10k *ar) |
| 408 | { |
| 409 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 410 | |
| 411 | lockdep_assert_held(&ar_pci->ps_lock); |
| 412 | |
| 413 | ath10k_dbg(ar, ATH10K_DBG_PCI_PS, "pci ps wake reg refcount %lu awake %d\n", |
| 414 | ar_pci->ps_wake_refcount, ar_pci->ps_awake); |
| 415 | |
| 416 | iowrite32(PCIE_SOC_WAKE_V_MASK, |
| 417 | ar_pci->mem + PCIE_LOCAL_BASE_ADDRESS + |
| 418 | PCIE_SOC_WAKE_ADDRESS); |
| 419 | } |
| 420 | |
| 421 | static void __ath10k_pci_sleep(struct ath10k *ar) |
| 422 | { |
| 423 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 424 | |
| 425 | lockdep_assert_held(&ar_pci->ps_lock); |
| 426 | |
| 427 | ath10k_dbg(ar, ATH10K_DBG_PCI_PS, "pci ps sleep reg refcount %lu awake %d\n", |
| 428 | ar_pci->ps_wake_refcount, ar_pci->ps_awake); |
| 429 | |
| 430 | iowrite32(PCIE_SOC_WAKE_RESET, |
| 431 | ar_pci->mem + PCIE_LOCAL_BASE_ADDRESS + |
| 432 | PCIE_SOC_WAKE_ADDRESS); |
| 433 | ar_pci->ps_awake = false; |
| 434 | } |
| 435 | |
| 436 | static int ath10k_pci_wake_wait(struct ath10k *ar) |
| 437 | { |
| 438 | int tot_delay = 0; |
| 439 | int curr_delay = 5; |
| 440 | |
| 441 | while (tot_delay < PCIE_WAKE_TIMEOUT) { |
| 442 | if (ath10k_pci_is_awake(ar)) |
| 443 | return 0; |
| 444 | |
| 445 | udelay(curr_delay); |
| 446 | tot_delay += curr_delay; |
| 447 | |
| 448 | if (curr_delay < 50) |
| 449 | curr_delay += 5; |
| 450 | } |
| 451 | |
| 452 | return -ETIMEDOUT; |
| 453 | } |
| 454 | |
| 455 | static int ath10k_pci_wake(struct ath10k *ar) |
| 456 | { |
| 457 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 458 | unsigned long flags; |
| 459 | int ret = 0; |
| 460 | |
| 461 | spin_lock_irqsave(&ar_pci->ps_lock, flags); |
| 462 | |
| 463 | ath10k_dbg(ar, ATH10K_DBG_PCI_PS, "pci ps wake refcount %lu awake %d\n", |
| 464 | ar_pci->ps_wake_refcount, ar_pci->ps_awake); |
| 465 | |
| 466 | /* This function can be called very frequently. To avoid excessive |
| 467 | * CPU stalls for MMIO reads use a cache var to hold the device state. |
| 468 | */ |
| 469 | if (!ar_pci->ps_awake) { |
| 470 | __ath10k_pci_wake(ar); |
| 471 | |
| 472 | ret = ath10k_pci_wake_wait(ar); |
| 473 | if (ret == 0) |
| 474 | ar_pci->ps_awake = true; |
| 475 | } |
| 476 | |
| 477 | if (ret == 0) { |
| 478 | ar_pci->ps_wake_refcount++; |
| 479 | WARN_ON(ar_pci->ps_wake_refcount == 0); |
| 480 | } |
| 481 | |
| 482 | spin_unlock_irqrestore(&ar_pci->ps_lock, flags); |
| 483 | |
| 484 | return ret; |
| 485 | } |
| 486 | |
| 487 | static void ath10k_pci_sleep(struct ath10k *ar) |
| 488 | { |
| 489 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 490 | unsigned long flags; |
| 491 | |
| 492 | spin_lock_irqsave(&ar_pci->ps_lock, flags); |
| 493 | |
| 494 | ath10k_dbg(ar, ATH10K_DBG_PCI_PS, "pci ps sleep refcount %lu awake %d\n", |
| 495 | ar_pci->ps_wake_refcount, ar_pci->ps_awake); |
| 496 | |
| 497 | if (WARN_ON(ar_pci->ps_wake_refcount == 0)) |
| 498 | goto skip; |
| 499 | |
| 500 | ar_pci->ps_wake_refcount--; |
| 501 | |
| 502 | mod_timer(&ar_pci->ps_timer, jiffies + |
| 503 | msecs_to_jiffies(ATH10K_PCI_SLEEP_GRACE_PERIOD_MSEC)); |
| 504 | |
| 505 | skip: |
| 506 | spin_unlock_irqrestore(&ar_pci->ps_lock, flags); |
| 507 | } |
| 508 | |
| 509 | static void ath10k_pci_ps_timer(unsigned long ptr) |
| 510 | { |
| 511 | struct ath10k *ar = (void *)ptr; |
| 512 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 513 | unsigned long flags; |
| 514 | |
| 515 | spin_lock_irqsave(&ar_pci->ps_lock, flags); |
| 516 | |
| 517 | ath10k_dbg(ar, ATH10K_DBG_PCI_PS, "pci ps timer refcount %lu awake %d\n", |
| 518 | ar_pci->ps_wake_refcount, ar_pci->ps_awake); |
| 519 | |
| 520 | if (ar_pci->ps_wake_refcount > 0) |
| 521 | goto skip; |
| 522 | |
| 523 | __ath10k_pci_sleep(ar); |
| 524 | |
| 525 | skip: |
| 526 | spin_unlock_irqrestore(&ar_pci->ps_lock, flags); |
| 527 | } |
| 528 | |
| 529 | static void ath10k_pci_sleep_sync(struct ath10k *ar) |
| 530 | { |
| 531 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 532 | unsigned long flags; |
| 533 | |
| 534 | del_timer_sync(&ar_pci->ps_timer); |
| 535 | |
| 536 | spin_lock_irqsave(&ar_pci->ps_lock, flags); |
| 537 | WARN_ON(ar_pci->ps_wake_refcount > 0); |
| 538 | __ath10k_pci_sleep(ar); |
| 539 | spin_unlock_irqrestore(&ar_pci->ps_lock, flags); |
| 540 | } |
| 541 | |
| 542 | void ath10k_pci_write32(struct ath10k *ar, u32 offset, u32 value) |
| 543 | { |
| 544 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 545 | int ret; |
| 546 | |
Michal Kazior | aeae5b4 | 2015-06-15 14:46:42 +0300 | [diff] [blame] | 547 | if (unlikely(offset + sizeof(value) > ar_pci->mem_len)) { |
| 548 | ath10k_warn(ar, "refusing to write mmio out of bounds at 0x%08x - 0x%08zx (max 0x%08zx)\n", |
| 549 | offset, offset + sizeof(value), ar_pci->mem_len); |
| 550 | return; |
| 551 | } |
| 552 | |
Michal Kazior | 77258d4 | 2015-05-18 09:38:18 +0000 | [diff] [blame] | 553 | ret = ath10k_pci_wake(ar); |
| 554 | if (ret) { |
| 555 | ath10k_warn(ar, "failed to wake target for write32 of 0x%08x at 0x%08x: %d\n", |
| 556 | value, offset, ret); |
| 557 | return; |
| 558 | } |
| 559 | |
| 560 | iowrite32(value, ar_pci->mem + offset); |
| 561 | ath10k_pci_sleep(ar); |
| 562 | } |
| 563 | |
| 564 | u32 ath10k_pci_read32(struct ath10k *ar, u32 offset) |
| 565 | { |
| 566 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 567 | u32 val; |
| 568 | int ret; |
| 569 | |
Michal Kazior | aeae5b4 | 2015-06-15 14:46:42 +0300 | [diff] [blame] | 570 | if (unlikely(offset + sizeof(val) > ar_pci->mem_len)) { |
| 571 | ath10k_warn(ar, "refusing to read mmio out of bounds at 0x%08x - 0x%08zx (max 0x%08zx)\n", |
| 572 | offset, offset + sizeof(val), ar_pci->mem_len); |
| 573 | return 0; |
| 574 | } |
| 575 | |
Michal Kazior | 77258d4 | 2015-05-18 09:38:18 +0000 | [diff] [blame] | 576 | ret = ath10k_pci_wake(ar); |
| 577 | if (ret) { |
| 578 | ath10k_warn(ar, "failed to wake target for read32 at 0x%08x: %d\n", |
| 579 | offset, ret); |
| 580 | return 0xffffffff; |
| 581 | } |
| 582 | |
| 583 | val = ioread32(ar_pci->mem + offset); |
| 584 | ath10k_pci_sleep(ar); |
| 585 | |
| 586 | return val; |
| 587 | } |
| 588 | |
| 589 | u32 ath10k_pci_soc_read32(struct ath10k *ar, u32 addr) |
| 590 | { |
| 591 | return ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS + addr); |
| 592 | } |
| 593 | |
| 594 | void ath10k_pci_soc_write32(struct ath10k *ar, u32 addr, u32 val) |
| 595 | { |
| 596 | ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS + addr, val); |
| 597 | } |
| 598 | |
| 599 | u32 ath10k_pci_reg_read32(struct ath10k *ar, u32 addr) |
| 600 | { |
| 601 | return ath10k_pci_read32(ar, PCIE_LOCAL_BASE_ADDRESS + addr); |
| 602 | } |
| 603 | |
| 604 | void ath10k_pci_reg_write32(struct ath10k *ar, u32 addr, u32 val) |
| 605 | { |
| 606 | ath10k_pci_write32(ar, PCIE_LOCAL_BASE_ADDRESS + addr, val); |
| 607 | } |
| 608 | |
Michal Kazior | e539887 | 2013-11-25 14:06:20 +0100 | [diff] [blame] | 609 | static bool ath10k_pci_irq_pending(struct ath10k *ar) |
| 610 | { |
| 611 | u32 cause; |
| 612 | |
| 613 | /* Check if the shared legacy irq is for us */ |
| 614 | cause = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS + |
| 615 | PCIE_INTR_CAUSE_ADDRESS); |
| 616 | if (cause & (PCIE_INTR_FIRMWARE_MASK | PCIE_INTR_CE_MASK_ALL)) |
| 617 | return true; |
| 618 | |
| 619 | return false; |
| 620 | } |
| 621 | |
Michal Kazior | 2685218 | 2013-11-25 14:06:25 +0100 | [diff] [blame] | 622 | static void ath10k_pci_disable_and_clear_legacy_irq(struct ath10k *ar) |
| 623 | { |
| 624 | /* IMPORTANT: INTR_CLR register has to be set after |
| 625 | * INTR_ENABLE is set to 0, otherwise interrupt can not be |
| 626 | * really cleared. */ |
| 627 | ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + PCIE_INTR_ENABLE_ADDRESS, |
| 628 | 0); |
| 629 | ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + PCIE_INTR_CLR_ADDRESS, |
| 630 | PCIE_INTR_FIRMWARE_MASK | PCIE_INTR_CE_MASK_ALL); |
| 631 | |
| 632 | /* IMPORTANT: this extra read transaction is required to |
| 633 | * flush the posted write buffer. */ |
Kalle Valo | cfbc06a | 2014-09-14 12:50:23 +0300 | [diff] [blame] | 634 | (void)ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS + |
| 635 | PCIE_INTR_ENABLE_ADDRESS); |
Michal Kazior | 2685218 | 2013-11-25 14:06:25 +0100 | [diff] [blame] | 636 | } |
| 637 | |
| 638 | static void ath10k_pci_enable_legacy_irq(struct ath10k *ar) |
| 639 | { |
| 640 | ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + |
| 641 | PCIE_INTR_ENABLE_ADDRESS, |
| 642 | PCIE_INTR_FIRMWARE_MASK | PCIE_INTR_CE_MASK_ALL); |
| 643 | |
| 644 | /* IMPORTANT: this extra read transaction is required to |
| 645 | * flush the posted write buffer. */ |
Kalle Valo | cfbc06a | 2014-09-14 12:50:23 +0300 | [diff] [blame] | 646 | (void)ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS + |
| 647 | PCIE_INTR_ENABLE_ADDRESS); |
Michal Kazior | 2685218 | 2013-11-25 14:06:25 +0100 | [diff] [blame] | 648 | } |
| 649 | |
Michal Kazior | 403d627 | 2014-08-22 14:23:31 +0200 | [diff] [blame] | 650 | static inline const char *ath10k_pci_get_irq_method(struct ath10k *ar) |
Michal Kazior | ab977bd | 2013-11-25 14:06:26 +0100 | [diff] [blame] | 651 | { |
Michal Kazior | ab977bd | 2013-11-25 14:06:26 +0100 | [diff] [blame] | 652 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 653 | |
Michal Kazior | 403d627 | 2014-08-22 14:23:31 +0200 | [diff] [blame] | 654 | if (ar_pci->num_msi_intrs > 1) |
| 655 | return "msi-x"; |
Kalle Valo | d8bb26b | 2014-09-14 12:50:33 +0300 | [diff] [blame] | 656 | |
| 657 | if (ar_pci->num_msi_intrs == 1) |
Michal Kazior | 403d627 | 2014-08-22 14:23:31 +0200 | [diff] [blame] | 658 | return "msi"; |
Kalle Valo | d8bb26b | 2014-09-14 12:50:33 +0300 | [diff] [blame] | 659 | |
| 660 | return "legacy"; |
Michal Kazior | ab977bd | 2013-11-25 14:06:26 +0100 | [diff] [blame] | 661 | } |
| 662 | |
Michal Kazior | 728f95e | 2014-08-22 14:33:14 +0200 | [diff] [blame] | 663 | static int __ath10k_pci_rx_post_buf(struct ath10k_pci_pipe *pipe) |
Michal Kazior | ab977bd | 2013-11-25 14:06:26 +0100 | [diff] [blame] | 664 | { |
Michal Kazior | 728f95e | 2014-08-22 14:33:14 +0200 | [diff] [blame] | 665 | struct ath10k *ar = pipe->hif_ce_state; |
Michal Kazior | ab977bd | 2013-11-25 14:06:26 +0100 | [diff] [blame] | 666 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
Michal Kazior | 728f95e | 2014-08-22 14:33:14 +0200 | [diff] [blame] | 667 | struct ath10k_ce_pipe *ce_pipe = pipe->ce_hdl; |
| 668 | struct sk_buff *skb; |
| 669 | dma_addr_t paddr; |
Michal Kazior | ab977bd | 2013-11-25 14:06:26 +0100 | [diff] [blame] | 670 | int ret; |
| 671 | |
Michal Kazior | 728f95e | 2014-08-22 14:33:14 +0200 | [diff] [blame] | 672 | lockdep_assert_held(&ar_pci->ce_lock); |
| 673 | |
| 674 | skb = dev_alloc_skb(pipe->buf_sz); |
| 675 | if (!skb) |
| 676 | return -ENOMEM; |
| 677 | |
| 678 | WARN_ONCE((unsigned long)skb->data & 3, "unaligned skb"); |
| 679 | |
| 680 | paddr = dma_map_single(ar->dev, skb->data, |
| 681 | skb->len + skb_tailroom(skb), |
| 682 | DMA_FROM_DEVICE); |
| 683 | if (unlikely(dma_mapping_error(ar->dev, paddr))) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 684 | ath10k_warn(ar, "failed to dma map pci rx buf\n"); |
Michal Kazior | 728f95e | 2014-08-22 14:33:14 +0200 | [diff] [blame] | 685 | dev_kfree_skb_any(skb); |
| 686 | return -EIO; |
| 687 | } |
| 688 | |
Michal Kazior | 8582bf3 | 2015-01-24 12:14:47 +0200 | [diff] [blame] | 689 | ATH10K_SKB_RXCB(skb)->paddr = paddr; |
Michal Kazior | 728f95e | 2014-08-22 14:33:14 +0200 | [diff] [blame] | 690 | |
| 691 | ret = __ath10k_ce_rx_post_buf(ce_pipe, skb, paddr); |
Michal Kazior | ab977bd | 2013-11-25 14:06:26 +0100 | [diff] [blame] | 692 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 693 | ath10k_warn(ar, "failed to post pci rx buf: %d\n", ret); |
Michal Kazior | 728f95e | 2014-08-22 14:33:14 +0200 | [diff] [blame] | 694 | dma_unmap_single(ar->dev, paddr, skb->len + skb_tailroom(skb), |
| 695 | DMA_FROM_DEVICE); |
| 696 | dev_kfree_skb_any(skb); |
Michal Kazior | ab977bd | 2013-11-25 14:06:26 +0100 | [diff] [blame] | 697 | return ret; |
| 698 | } |
| 699 | |
| 700 | return 0; |
| 701 | } |
| 702 | |
Michal Kazior | 728f95e | 2014-08-22 14:33:14 +0200 | [diff] [blame] | 703 | static void __ath10k_pci_rx_post_pipe(struct ath10k_pci_pipe *pipe) |
Michal Kazior | ab977bd | 2013-11-25 14:06:26 +0100 | [diff] [blame] | 704 | { |
Michal Kazior | 728f95e | 2014-08-22 14:33:14 +0200 | [diff] [blame] | 705 | struct ath10k *ar = pipe->hif_ce_state; |
| 706 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 707 | struct ath10k_ce_pipe *ce_pipe = pipe->ce_hdl; |
| 708 | int ret, num; |
| 709 | |
| 710 | lockdep_assert_held(&ar_pci->ce_lock); |
| 711 | |
| 712 | if (pipe->buf_sz == 0) |
| 713 | return; |
| 714 | |
| 715 | if (!ce_pipe->dest_ring) |
| 716 | return; |
| 717 | |
| 718 | num = __ath10k_ce_rx_num_free_bufs(ce_pipe); |
| 719 | while (num--) { |
| 720 | ret = __ath10k_pci_rx_post_buf(pipe); |
| 721 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 722 | ath10k_warn(ar, "failed to post pci rx buf: %d\n", ret); |
Michal Kazior | 728f95e | 2014-08-22 14:33:14 +0200 | [diff] [blame] | 723 | mod_timer(&ar_pci->rx_post_retry, jiffies + |
| 724 | ATH10K_PCI_RX_POST_RETRY_MS); |
| 725 | break; |
| 726 | } |
| 727 | } |
| 728 | } |
| 729 | |
| 730 | static void ath10k_pci_rx_post_pipe(struct ath10k_pci_pipe *pipe) |
| 731 | { |
| 732 | struct ath10k *ar = pipe->hif_ce_state; |
| 733 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 734 | |
| 735 | spin_lock_bh(&ar_pci->ce_lock); |
| 736 | __ath10k_pci_rx_post_pipe(pipe); |
| 737 | spin_unlock_bh(&ar_pci->ce_lock); |
| 738 | } |
| 739 | |
| 740 | static void ath10k_pci_rx_post(struct ath10k *ar) |
| 741 | { |
| 742 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 743 | int i; |
| 744 | |
| 745 | spin_lock_bh(&ar_pci->ce_lock); |
| 746 | for (i = 0; i < CE_COUNT; i++) |
| 747 | __ath10k_pci_rx_post_pipe(&ar_pci->pipe_info[i]); |
| 748 | spin_unlock_bh(&ar_pci->ce_lock); |
| 749 | } |
| 750 | |
| 751 | static void ath10k_pci_rx_replenish_retry(unsigned long ptr) |
| 752 | { |
| 753 | struct ath10k *ar = (void *)ptr; |
| 754 | |
| 755 | ath10k_pci_rx_post(ar); |
Michal Kazior | ab977bd | 2013-11-25 14:06:26 +0100 | [diff] [blame] | 756 | } |
| 757 | |
Vasanthakumar Thiagarajan | 418ca59 | 2015-06-18 12:31:05 +0530 | [diff] [blame^] | 758 | static u32 ath10k_pci_targ_cpu_to_ce_addr(struct ath10k *ar, u32 addr) |
| 759 | { |
| 760 | u32 val = 0; |
| 761 | |
| 762 | switch (ar->hw_rev) { |
| 763 | case ATH10K_HW_QCA988X: |
| 764 | case ATH10K_HW_QCA6174: |
| 765 | val = (ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS + |
| 766 | CORE_CTRL_ADDRESS) & |
| 767 | 0x7fff) << 21; |
| 768 | break; |
| 769 | case ATH10K_HW_QCA99X0: |
| 770 | val = ath10k_pci_read32(ar, PCIE_BAR_REG_ADDRESS); |
| 771 | break; |
| 772 | } |
| 773 | |
| 774 | val |= 0x100000 | (addr & 0xfffff); |
| 775 | return val; |
| 776 | } |
| 777 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 778 | /* |
| 779 | * Diagnostic read/write access is provided for startup/config/debug usage. |
| 780 | * Caller must guarantee proper alignment, when applicable, and single user |
| 781 | * at any moment. |
| 782 | */ |
| 783 | static int ath10k_pci_diag_read_mem(struct ath10k *ar, u32 address, void *data, |
| 784 | int nbytes) |
| 785 | { |
| 786 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 787 | int ret = 0; |
| 788 | u32 buf; |
| 789 | unsigned int completed_nbytes, orig_nbytes, remaining_bytes; |
| 790 | unsigned int id; |
| 791 | unsigned int flags; |
Michal Kazior | 2aa3911 | 2013-08-27 13:08:02 +0200 | [diff] [blame] | 792 | struct ath10k_ce_pipe *ce_diag; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 793 | /* Host buffer address in CE space */ |
| 794 | u32 ce_data; |
| 795 | dma_addr_t ce_data_base = 0; |
| 796 | void *data_buf = NULL; |
| 797 | int i; |
| 798 | |
Kalle Valo | eef2540 | 2014-09-24 14:16:52 +0300 | [diff] [blame] | 799 | spin_lock_bh(&ar_pci->ce_lock); |
| 800 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 801 | ce_diag = ar_pci->ce_diag; |
| 802 | |
| 803 | /* |
| 804 | * Allocate a temporary bounce buffer to hold caller's data |
| 805 | * to be DMA'ed from Target. This guarantees |
| 806 | * 1) 4-byte alignment |
| 807 | * 2) Buffer in DMA-able space |
| 808 | */ |
| 809 | orig_nbytes = nbytes; |
Michal Kazior | 68c0324 | 2014-03-28 10:02:35 +0200 | [diff] [blame] | 810 | data_buf = (unsigned char *)dma_alloc_coherent(ar->dev, |
| 811 | orig_nbytes, |
| 812 | &ce_data_base, |
| 813 | GFP_ATOMIC); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 814 | |
| 815 | if (!data_buf) { |
| 816 | ret = -ENOMEM; |
| 817 | goto done; |
| 818 | } |
| 819 | memset(data_buf, 0, orig_nbytes); |
| 820 | |
| 821 | remaining_bytes = orig_nbytes; |
| 822 | ce_data = ce_data_base; |
| 823 | while (remaining_bytes) { |
| 824 | nbytes = min_t(unsigned int, remaining_bytes, |
| 825 | DIAG_TRANSFER_LIMIT); |
| 826 | |
Kalle Valo | eef2540 | 2014-09-24 14:16:52 +0300 | [diff] [blame] | 827 | ret = __ath10k_ce_rx_post_buf(ce_diag, NULL, ce_data); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 828 | if (ret != 0) |
| 829 | goto done; |
| 830 | |
| 831 | /* Request CE to send from Target(!) address to Host buffer */ |
| 832 | /* |
| 833 | * The address supplied by the caller is in the |
| 834 | * Target CPU virtual address space. |
| 835 | * |
| 836 | * In order to use this address with the diagnostic CE, |
| 837 | * convert it from Target CPU virtual address space |
| 838 | * to CE address space |
| 839 | */ |
Vasanthakumar Thiagarajan | 418ca59 | 2015-06-18 12:31:05 +0530 | [diff] [blame^] | 840 | address = ath10k_pci_targ_cpu_to_ce_addr(ar, address); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 841 | |
Kalle Valo | eef2540 | 2014-09-24 14:16:52 +0300 | [diff] [blame] | 842 | ret = ath10k_ce_send_nolock(ce_diag, NULL, (u32)address, nbytes, 0, |
| 843 | 0); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 844 | if (ret) |
| 845 | goto done; |
| 846 | |
| 847 | i = 0; |
Kalle Valo | eef2540 | 2014-09-24 14:16:52 +0300 | [diff] [blame] | 848 | while (ath10k_ce_completed_send_next_nolock(ce_diag, NULL, &buf, |
| 849 | &completed_nbytes, |
| 850 | &id) != 0) { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 851 | mdelay(1); |
| 852 | if (i++ > DIAG_ACCESS_CE_TIMEOUT_MS) { |
| 853 | ret = -EBUSY; |
| 854 | goto done; |
| 855 | } |
| 856 | } |
| 857 | |
| 858 | if (nbytes != completed_nbytes) { |
| 859 | ret = -EIO; |
| 860 | goto done; |
| 861 | } |
| 862 | |
Kalle Valo | cfbc06a | 2014-09-14 12:50:23 +0300 | [diff] [blame] | 863 | if (buf != (u32)address) { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 864 | ret = -EIO; |
| 865 | goto done; |
| 866 | } |
| 867 | |
| 868 | i = 0; |
Kalle Valo | eef2540 | 2014-09-24 14:16:52 +0300 | [diff] [blame] | 869 | while (ath10k_ce_completed_recv_next_nolock(ce_diag, NULL, &buf, |
| 870 | &completed_nbytes, |
| 871 | &id, &flags) != 0) { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 872 | mdelay(1); |
| 873 | |
| 874 | if (i++ > DIAG_ACCESS_CE_TIMEOUT_MS) { |
| 875 | ret = -EBUSY; |
| 876 | goto done; |
| 877 | } |
| 878 | } |
| 879 | |
| 880 | if (nbytes != completed_nbytes) { |
| 881 | ret = -EIO; |
| 882 | goto done; |
| 883 | } |
| 884 | |
| 885 | if (buf != ce_data) { |
| 886 | ret = -EIO; |
| 887 | goto done; |
| 888 | } |
| 889 | |
| 890 | remaining_bytes -= nbytes; |
| 891 | address += nbytes; |
| 892 | ce_data += nbytes; |
| 893 | } |
| 894 | |
| 895 | done: |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 896 | if (ret == 0) |
| 897 | memcpy(data, data_buf, orig_nbytes); |
| 898 | else |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 899 | ath10k_warn(ar, "failed to read diag value at 0x%x: %d\n", |
Kalle Valo | 50f87a6 | 2014-03-28 09:32:52 +0200 | [diff] [blame] | 900 | address, ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 901 | |
| 902 | if (data_buf) |
Michal Kazior | 68c0324 | 2014-03-28 10:02:35 +0200 | [diff] [blame] | 903 | dma_free_coherent(ar->dev, orig_nbytes, data_buf, |
| 904 | ce_data_base); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 905 | |
Kalle Valo | eef2540 | 2014-09-24 14:16:52 +0300 | [diff] [blame] | 906 | spin_unlock_bh(&ar_pci->ce_lock); |
| 907 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 908 | return ret; |
| 909 | } |
| 910 | |
Kalle Valo | 3d29a3e | 2014-08-25 08:37:26 +0300 | [diff] [blame] | 911 | static int ath10k_pci_diag_read32(struct ath10k *ar, u32 address, u32 *value) |
| 912 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 913 | __le32 val = 0; |
| 914 | int ret; |
| 915 | |
| 916 | ret = ath10k_pci_diag_read_mem(ar, address, &val, sizeof(val)); |
| 917 | *value = __le32_to_cpu(val); |
| 918 | |
| 919 | return ret; |
Kalle Valo | 3d29a3e | 2014-08-25 08:37:26 +0300 | [diff] [blame] | 920 | } |
| 921 | |
| 922 | static int __ath10k_pci_diag_read_hi(struct ath10k *ar, void *dest, |
| 923 | u32 src, u32 len) |
| 924 | { |
| 925 | u32 host_addr, addr; |
| 926 | int ret; |
| 927 | |
| 928 | host_addr = host_interest_item_address(src); |
| 929 | |
| 930 | ret = ath10k_pci_diag_read32(ar, host_addr, &addr); |
| 931 | if (ret != 0) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 932 | ath10k_warn(ar, "failed to get memcpy hi address for firmware address %d: %d\n", |
Kalle Valo | 3d29a3e | 2014-08-25 08:37:26 +0300 | [diff] [blame] | 933 | src, ret); |
| 934 | return ret; |
| 935 | } |
| 936 | |
| 937 | ret = ath10k_pci_diag_read_mem(ar, addr, dest, len); |
| 938 | if (ret != 0) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 939 | ath10k_warn(ar, "failed to memcpy firmware memory from %d (%d B): %d\n", |
Kalle Valo | 3d29a3e | 2014-08-25 08:37:26 +0300 | [diff] [blame] | 940 | addr, len, ret); |
| 941 | return ret; |
| 942 | } |
| 943 | |
| 944 | return 0; |
| 945 | } |
| 946 | |
| 947 | #define ath10k_pci_diag_read_hi(ar, dest, src, len) \ |
Kalle Valo | 8cc7f26 | 2014-09-14 12:50:39 +0300 | [diff] [blame] | 948 | __ath10k_pci_diag_read_hi(ar, dest, HI_ITEM(src), len) |
Kalle Valo | 3d29a3e | 2014-08-25 08:37:26 +0300 | [diff] [blame] | 949 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 950 | static int ath10k_pci_diag_write_mem(struct ath10k *ar, u32 address, |
| 951 | const void *data, int nbytes) |
| 952 | { |
| 953 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 954 | int ret = 0; |
| 955 | u32 buf; |
| 956 | unsigned int completed_nbytes, orig_nbytes, remaining_bytes; |
| 957 | unsigned int id; |
| 958 | unsigned int flags; |
Michal Kazior | 2aa3911 | 2013-08-27 13:08:02 +0200 | [diff] [blame] | 959 | struct ath10k_ce_pipe *ce_diag; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 960 | void *data_buf = NULL; |
| 961 | u32 ce_data; /* Host buffer address in CE space */ |
| 962 | dma_addr_t ce_data_base = 0; |
| 963 | int i; |
| 964 | |
Kalle Valo | eef2540 | 2014-09-24 14:16:52 +0300 | [diff] [blame] | 965 | spin_lock_bh(&ar_pci->ce_lock); |
| 966 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 967 | ce_diag = ar_pci->ce_diag; |
| 968 | |
| 969 | /* |
| 970 | * Allocate a temporary bounce buffer to hold caller's data |
| 971 | * to be DMA'ed to Target. This guarantees |
| 972 | * 1) 4-byte alignment |
| 973 | * 2) Buffer in DMA-able space |
| 974 | */ |
| 975 | orig_nbytes = nbytes; |
Michal Kazior | 68c0324 | 2014-03-28 10:02:35 +0200 | [diff] [blame] | 976 | data_buf = (unsigned char *)dma_alloc_coherent(ar->dev, |
| 977 | orig_nbytes, |
| 978 | &ce_data_base, |
| 979 | GFP_ATOMIC); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 980 | if (!data_buf) { |
| 981 | ret = -ENOMEM; |
| 982 | goto done; |
| 983 | } |
| 984 | |
| 985 | /* Copy caller's data to allocated DMA buf */ |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 986 | memcpy(data_buf, data, orig_nbytes); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 987 | |
| 988 | /* |
| 989 | * The address supplied by the caller is in the |
| 990 | * Target CPU virtual address space. |
| 991 | * |
| 992 | * In order to use this address with the diagnostic CE, |
| 993 | * convert it from |
| 994 | * Target CPU virtual address space |
| 995 | * to |
| 996 | * CE address space |
| 997 | */ |
Vasanthakumar Thiagarajan | 418ca59 | 2015-06-18 12:31:05 +0530 | [diff] [blame^] | 998 | address = ath10k_pci_targ_cpu_to_ce_addr(ar, address); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 999 | |
| 1000 | remaining_bytes = orig_nbytes; |
| 1001 | ce_data = ce_data_base; |
| 1002 | while (remaining_bytes) { |
| 1003 | /* FIXME: check cast */ |
| 1004 | nbytes = min_t(int, remaining_bytes, DIAG_TRANSFER_LIMIT); |
| 1005 | |
| 1006 | /* Set up to receive directly into Target(!) address */ |
Kalle Valo | eef2540 | 2014-09-24 14:16:52 +0300 | [diff] [blame] | 1007 | ret = __ath10k_ce_rx_post_buf(ce_diag, NULL, address); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1008 | if (ret != 0) |
| 1009 | goto done; |
| 1010 | |
| 1011 | /* |
| 1012 | * Request CE to send caller-supplied data that |
| 1013 | * was copied to bounce buffer to Target(!) address. |
| 1014 | */ |
Kalle Valo | eef2540 | 2014-09-24 14:16:52 +0300 | [diff] [blame] | 1015 | ret = ath10k_ce_send_nolock(ce_diag, NULL, (u32)ce_data, |
| 1016 | nbytes, 0, 0); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1017 | if (ret != 0) |
| 1018 | goto done; |
| 1019 | |
| 1020 | i = 0; |
Kalle Valo | eef2540 | 2014-09-24 14:16:52 +0300 | [diff] [blame] | 1021 | while (ath10k_ce_completed_send_next_nolock(ce_diag, NULL, &buf, |
| 1022 | &completed_nbytes, |
| 1023 | &id) != 0) { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1024 | mdelay(1); |
| 1025 | |
| 1026 | if (i++ > DIAG_ACCESS_CE_TIMEOUT_MS) { |
| 1027 | ret = -EBUSY; |
| 1028 | goto done; |
| 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | if (nbytes != completed_nbytes) { |
| 1033 | ret = -EIO; |
| 1034 | goto done; |
| 1035 | } |
| 1036 | |
| 1037 | if (buf != ce_data) { |
| 1038 | ret = -EIO; |
| 1039 | goto done; |
| 1040 | } |
| 1041 | |
| 1042 | i = 0; |
Kalle Valo | eef2540 | 2014-09-24 14:16:52 +0300 | [diff] [blame] | 1043 | while (ath10k_ce_completed_recv_next_nolock(ce_diag, NULL, &buf, |
| 1044 | &completed_nbytes, |
| 1045 | &id, &flags) != 0) { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1046 | mdelay(1); |
| 1047 | |
| 1048 | if (i++ > DIAG_ACCESS_CE_TIMEOUT_MS) { |
| 1049 | ret = -EBUSY; |
| 1050 | goto done; |
| 1051 | } |
| 1052 | } |
| 1053 | |
| 1054 | if (nbytes != completed_nbytes) { |
| 1055 | ret = -EIO; |
| 1056 | goto done; |
| 1057 | } |
| 1058 | |
| 1059 | if (buf != address) { |
| 1060 | ret = -EIO; |
| 1061 | goto done; |
| 1062 | } |
| 1063 | |
| 1064 | remaining_bytes -= nbytes; |
| 1065 | address += nbytes; |
| 1066 | ce_data += nbytes; |
| 1067 | } |
| 1068 | |
| 1069 | done: |
| 1070 | if (data_buf) { |
Michal Kazior | 68c0324 | 2014-03-28 10:02:35 +0200 | [diff] [blame] | 1071 | dma_free_coherent(ar->dev, orig_nbytes, data_buf, |
| 1072 | ce_data_base); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1073 | } |
| 1074 | |
| 1075 | if (ret != 0) |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1076 | ath10k_warn(ar, "failed to write diag value at 0x%x: %d\n", |
Kalle Valo | 50f87a6 | 2014-03-28 09:32:52 +0200 | [diff] [blame] | 1077 | address, ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1078 | |
Kalle Valo | eef2540 | 2014-09-24 14:16:52 +0300 | [diff] [blame] | 1079 | spin_unlock_bh(&ar_pci->ce_lock); |
| 1080 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1081 | return ret; |
| 1082 | } |
| 1083 | |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1084 | static int ath10k_pci_diag_write32(struct ath10k *ar, u32 address, u32 value) |
| 1085 | { |
| 1086 | __le32 val = __cpu_to_le32(value); |
| 1087 | |
| 1088 | return ath10k_pci_diag_write_mem(ar, address, &val, sizeof(val)); |
| 1089 | } |
| 1090 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1091 | /* Called by lower (CE) layer when a send to Target completes. */ |
Michal Kazior | 5440ce2 | 2013-09-03 15:09:58 +0200 | [diff] [blame] | 1092 | static void ath10k_pci_ce_send_done(struct ath10k_ce_pipe *ce_state) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1093 | { |
| 1094 | struct ath10k *ar = ce_state->ar; |
| 1095 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
Michal Kazior | 2f5280d | 2014-02-27 18:50:05 +0200 | [diff] [blame] | 1096 | struct ath10k_hif_cb *cb = &ar_pci->msg_callbacks_current; |
Michal Kazior | 1cb86d4 | 2014-11-27 11:09:38 +0100 | [diff] [blame] | 1097 | struct sk_buff_head list; |
| 1098 | struct sk_buff *skb; |
Michal Kazior | 5440ce2 | 2013-09-03 15:09:58 +0200 | [diff] [blame] | 1099 | u32 ce_data; |
| 1100 | unsigned int nbytes; |
| 1101 | unsigned int transfer_id; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1102 | |
Michal Kazior | 1cb86d4 | 2014-11-27 11:09:38 +0100 | [diff] [blame] | 1103 | __skb_queue_head_init(&list); |
| 1104 | while (ath10k_ce_completed_send_next(ce_state, (void **)&skb, &ce_data, |
| 1105 | &nbytes, &transfer_id) == 0) { |
Michal Kazior | a16942e | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 1106 | /* no need to call tx completion for NULL pointers */ |
Michal Kazior | 1cb86d4 | 2014-11-27 11:09:38 +0100 | [diff] [blame] | 1107 | if (skb == NULL) |
Michal Kazior | 726346f | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 1108 | continue; |
| 1109 | |
Michal Kazior | 1cb86d4 | 2014-11-27 11:09:38 +0100 | [diff] [blame] | 1110 | __skb_queue_tail(&list, skb); |
Michal Kazior | 5440ce2 | 2013-09-03 15:09:58 +0200 | [diff] [blame] | 1111 | } |
Michal Kazior | 1cb86d4 | 2014-11-27 11:09:38 +0100 | [diff] [blame] | 1112 | |
| 1113 | while ((skb = __skb_dequeue(&list))) |
| 1114 | cb->tx_completion(ar, skb); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1115 | } |
| 1116 | |
| 1117 | /* Called by lower (CE) layer when data is received from the Target. */ |
Michal Kazior | 5440ce2 | 2013-09-03 15:09:58 +0200 | [diff] [blame] | 1118 | static void ath10k_pci_ce_recv_data(struct ath10k_ce_pipe *ce_state) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1119 | { |
| 1120 | struct ath10k *ar = ce_state->ar; |
| 1121 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
Michal Kazior | 87263e5 | 2013-08-27 13:08:01 +0200 | [diff] [blame] | 1122 | struct ath10k_pci_pipe *pipe_info = &ar_pci->pipe_info[ce_state->id]; |
Michal Kazior | 2f5280d | 2014-02-27 18:50:05 +0200 | [diff] [blame] | 1123 | struct ath10k_hif_cb *cb = &ar_pci->msg_callbacks_current; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1124 | struct sk_buff *skb; |
Michal Kazior | 1cb86d4 | 2014-11-27 11:09:38 +0100 | [diff] [blame] | 1125 | struct sk_buff_head list; |
Michal Kazior | 5440ce2 | 2013-09-03 15:09:58 +0200 | [diff] [blame] | 1126 | void *transfer_context; |
| 1127 | u32 ce_data; |
Michal Kazior | 2f5280d | 2014-02-27 18:50:05 +0200 | [diff] [blame] | 1128 | unsigned int nbytes, max_nbytes; |
Michal Kazior | 5440ce2 | 2013-09-03 15:09:58 +0200 | [diff] [blame] | 1129 | unsigned int transfer_id; |
| 1130 | unsigned int flags; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1131 | |
Michal Kazior | 1cb86d4 | 2014-11-27 11:09:38 +0100 | [diff] [blame] | 1132 | __skb_queue_head_init(&list); |
Michal Kazior | 5440ce2 | 2013-09-03 15:09:58 +0200 | [diff] [blame] | 1133 | while (ath10k_ce_completed_recv_next(ce_state, &transfer_context, |
| 1134 | &ce_data, &nbytes, &transfer_id, |
| 1135 | &flags) == 0) { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1136 | skb = transfer_context; |
Michal Kazior | 2f5280d | 2014-02-27 18:50:05 +0200 | [diff] [blame] | 1137 | max_nbytes = skb->len + skb_tailroom(skb); |
Michal Kazior | 8582bf3 | 2015-01-24 12:14:47 +0200 | [diff] [blame] | 1138 | dma_unmap_single(ar->dev, ATH10K_SKB_RXCB(skb)->paddr, |
Michal Kazior | 2f5280d | 2014-02-27 18:50:05 +0200 | [diff] [blame] | 1139 | max_nbytes, DMA_FROM_DEVICE); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1140 | |
Michal Kazior | 2f5280d | 2014-02-27 18:50:05 +0200 | [diff] [blame] | 1141 | if (unlikely(max_nbytes < nbytes)) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1142 | ath10k_warn(ar, "rxed more than expected (nbytes %d, max %d)", |
Michal Kazior | 2f5280d | 2014-02-27 18:50:05 +0200 | [diff] [blame] | 1143 | nbytes, max_nbytes); |
| 1144 | dev_kfree_skb_any(skb); |
| 1145 | continue; |
| 1146 | } |
| 1147 | |
| 1148 | skb_put(skb, nbytes); |
Michal Kazior | 1cb86d4 | 2014-11-27 11:09:38 +0100 | [diff] [blame] | 1149 | __skb_queue_tail(&list, skb); |
| 1150 | } |
Michal Kazior | a360e54 | 2014-09-23 10:22:54 +0200 | [diff] [blame] | 1151 | |
Michal Kazior | 1cb86d4 | 2014-11-27 11:09:38 +0100 | [diff] [blame] | 1152 | while ((skb = __skb_dequeue(&list))) { |
Michal Kazior | a360e54 | 2014-09-23 10:22:54 +0200 | [diff] [blame] | 1153 | ath10k_dbg(ar, ATH10K_DBG_PCI, "pci rx ce pipe %d len %d\n", |
| 1154 | ce_state->id, skb->len); |
| 1155 | ath10k_dbg_dump(ar, ATH10K_DBG_PCI_DUMP, NULL, "pci rx: ", |
| 1156 | skb->data, skb->len); |
| 1157 | |
Michal Kazior | 5f07ea4 | 2014-11-27 11:09:36 +0100 | [diff] [blame] | 1158 | cb->rx_completion(ar, skb); |
Michal Kazior | 2f5280d | 2014-02-27 18:50:05 +0200 | [diff] [blame] | 1159 | } |
Michal Kazior | c29a380 | 2014-07-21 21:03:10 +0300 | [diff] [blame] | 1160 | |
Michal Kazior | 728f95e | 2014-08-22 14:33:14 +0200 | [diff] [blame] | 1161 | ath10k_pci_rx_post_pipe(pipe_info); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1162 | } |
| 1163 | |
Michal Kazior | 726346f | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 1164 | static int ath10k_pci_hif_tx_sg(struct ath10k *ar, u8 pipe_id, |
| 1165 | struct ath10k_hif_sg_item *items, int n_items) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1166 | { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1167 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
Michal Kazior | 726346f | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 1168 | struct ath10k_pci_pipe *pci_pipe = &ar_pci->pipe_info[pipe_id]; |
| 1169 | struct ath10k_ce_pipe *ce_pipe = pci_pipe->ce_hdl; |
| 1170 | struct ath10k_ce_ring *src_ring = ce_pipe->src_ring; |
Michal Kazior | 7147a13 | 2014-05-26 12:02:58 +0200 | [diff] [blame] | 1171 | unsigned int nentries_mask; |
| 1172 | unsigned int sw_index; |
| 1173 | unsigned int write_index; |
Michal Kazior | 08b8aa0 | 2014-05-26 12:02:59 +0200 | [diff] [blame] | 1174 | int err, i = 0; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1175 | |
Michal Kazior | 726346f | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 1176 | spin_lock_bh(&ar_pci->ce_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1177 | |
Michal Kazior | 7147a13 | 2014-05-26 12:02:58 +0200 | [diff] [blame] | 1178 | nentries_mask = src_ring->nentries_mask; |
| 1179 | sw_index = src_ring->sw_index; |
| 1180 | write_index = src_ring->write_index; |
| 1181 | |
Michal Kazior | 726346f | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 1182 | if (unlikely(CE_RING_DELTA(nentries_mask, |
| 1183 | write_index, sw_index - 1) < n_items)) { |
| 1184 | err = -ENOBUFS; |
Michal Kazior | 08b8aa0 | 2014-05-26 12:02:59 +0200 | [diff] [blame] | 1185 | goto err; |
Michal Kazior | 726346f | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 1186 | } |
| 1187 | |
| 1188 | for (i = 0; i < n_items - 1; i++) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1189 | ath10k_dbg(ar, ATH10K_DBG_PCI, |
Michal Kazior | 726346f | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 1190 | "pci tx item %d paddr 0x%08x len %d n_items %d\n", |
| 1191 | i, items[i].paddr, items[i].len, n_items); |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1192 | ath10k_dbg_dump(ar, ATH10K_DBG_PCI_DUMP, NULL, "pci tx data: ", |
Michal Kazior | 726346f | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 1193 | items[i].vaddr, items[i].len); |
| 1194 | |
| 1195 | err = ath10k_ce_send_nolock(ce_pipe, |
| 1196 | items[i].transfer_context, |
| 1197 | items[i].paddr, |
| 1198 | items[i].len, |
| 1199 | items[i].transfer_id, |
| 1200 | CE_SEND_FLAG_GATHER); |
| 1201 | if (err) |
Michal Kazior | 08b8aa0 | 2014-05-26 12:02:59 +0200 | [diff] [blame] | 1202 | goto err; |
Michal Kazior | 726346f | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 1203 | } |
| 1204 | |
| 1205 | /* `i` is equal to `n_items -1` after for() */ |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1206 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1207 | ath10k_dbg(ar, ATH10K_DBG_PCI, |
Michal Kazior | 726346f | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 1208 | "pci tx item %d paddr 0x%08x len %d n_items %d\n", |
| 1209 | i, items[i].paddr, items[i].len, n_items); |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1210 | ath10k_dbg_dump(ar, ATH10K_DBG_PCI_DUMP, NULL, "pci tx data: ", |
Michal Kazior | 726346f | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 1211 | items[i].vaddr, items[i].len); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1212 | |
Michal Kazior | 726346f | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 1213 | err = ath10k_ce_send_nolock(ce_pipe, |
| 1214 | items[i].transfer_context, |
| 1215 | items[i].paddr, |
| 1216 | items[i].len, |
| 1217 | items[i].transfer_id, |
| 1218 | 0); |
| 1219 | if (err) |
Michal Kazior | 08b8aa0 | 2014-05-26 12:02:59 +0200 | [diff] [blame] | 1220 | goto err; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1221 | |
Michal Kazior | 08b8aa0 | 2014-05-26 12:02:59 +0200 | [diff] [blame] | 1222 | spin_unlock_bh(&ar_pci->ce_lock); |
| 1223 | return 0; |
| 1224 | |
| 1225 | err: |
| 1226 | for (; i > 0; i--) |
| 1227 | __ath10k_ce_send_revert(ce_pipe); |
| 1228 | |
Michal Kazior | 726346f | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 1229 | spin_unlock_bh(&ar_pci->ce_lock); |
| 1230 | return err; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1231 | } |
| 1232 | |
Kalle Valo | eef2540 | 2014-09-24 14:16:52 +0300 | [diff] [blame] | 1233 | static int ath10k_pci_hif_diag_read(struct ath10k *ar, u32 address, void *buf, |
| 1234 | size_t buf_len) |
| 1235 | { |
| 1236 | return ath10k_pci_diag_read_mem(ar, address, buf, buf_len); |
| 1237 | } |
| 1238 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1239 | static u16 ath10k_pci_hif_get_free_queue_number(struct ath10k *ar, u8 pipe) |
| 1240 | { |
| 1241 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
Kalle Valo | 50f87a6 | 2014-03-28 09:32:52 +0200 | [diff] [blame] | 1242 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1243 | ath10k_dbg(ar, ATH10K_DBG_PCI, "pci hif get free queue number\n"); |
Kalle Valo | 50f87a6 | 2014-03-28 09:32:52 +0200 | [diff] [blame] | 1244 | |
Michal Kazior | 3efcb3b | 2013-10-02 11:03:41 +0200 | [diff] [blame] | 1245 | return ath10k_ce_num_free_src_entries(ar_pci->pipe_info[pipe].ce_hdl); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1246 | } |
| 1247 | |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 1248 | static void ath10k_pci_dump_registers(struct ath10k *ar, |
| 1249 | struct ath10k_fw_crash_data *crash_data) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1250 | { |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1251 | __le32 reg_dump_values[REG_DUMP_COUNT_QCA988X] = {}; |
| 1252 | int i, ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1253 | |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 1254 | lockdep_assert_held(&ar->data_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1255 | |
Kalle Valo | 3d29a3e | 2014-08-25 08:37:26 +0300 | [diff] [blame] | 1256 | ret = ath10k_pci_diag_read_hi(ar, ®_dump_values[0], |
| 1257 | hi_failure_state, |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1258 | REG_DUMP_COUNT_QCA988X * sizeof(__le32)); |
Michal Kazior | 1d2b48d | 2013-11-08 08:01:34 +0100 | [diff] [blame] | 1259 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1260 | ath10k_err(ar, "failed to read firmware dump area: %d\n", ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1261 | return; |
| 1262 | } |
| 1263 | |
| 1264 | BUILD_BUG_ON(REG_DUMP_COUNT_QCA988X % 4); |
| 1265 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1266 | ath10k_err(ar, "firmware register dump:\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1267 | for (i = 0; i < REG_DUMP_COUNT_QCA988X; i += 4) |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1268 | ath10k_err(ar, "[%02d]: 0x%08X 0x%08X 0x%08X 0x%08X\n", |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1269 | i, |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1270 | __le32_to_cpu(reg_dump_values[i]), |
| 1271 | __le32_to_cpu(reg_dump_values[i + 1]), |
| 1272 | __le32_to_cpu(reg_dump_values[i + 2]), |
| 1273 | __le32_to_cpu(reg_dump_values[i + 3])); |
Michal Kazior | affd321 | 2013-07-16 09:54:35 +0200 | [diff] [blame] | 1274 | |
Michal Kazior | 1bbb119 | 2014-08-25 12:13:14 +0200 | [diff] [blame] | 1275 | if (!crash_data) |
| 1276 | return; |
| 1277 | |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 1278 | for (i = 0; i < REG_DUMP_COUNT_QCA988X; i++) |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1279 | crash_data->registers[i] = reg_dump_values[i]; |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 1280 | } |
| 1281 | |
Kalle Valo | 0e9848c | 2014-08-25 08:37:37 +0300 | [diff] [blame] | 1282 | static void ath10k_pci_fw_crashed_dump(struct ath10k *ar) |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 1283 | { |
| 1284 | struct ath10k_fw_crash_data *crash_data; |
| 1285 | char uuid[50]; |
| 1286 | |
| 1287 | spin_lock_bh(&ar->data_lock); |
| 1288 | |
Ben Greear | f51dbe7 | 2014-09-29 14:41:46 +0300 | [diff] [blame] | 1289 | ar->stats.fw_crash_counter++; |
| 1290 | |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 1291 | crash_data = ath10k_debug_get_new_fw_crash_data(ar); |
| 1292 | |
| 1293 | if (crash_data) |
| 1294 | scnprintf(uuid, sizeof(uuid), "%pUl", &crash_data->uuid); |
| 1295 | else |
| 1296 | scnprintf(uuid, sizeof(uuid), "n/a"); |
| 1297 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1298 | ath10k_err(ar, "firmware crashed! (uuid %s)\n", uuid); |
Kalle Valo | 8a0c797 | 2014-08-25 08:37:45 +0300 | [diff] [blame] | 1299 | ath10k_print_driver_info(ar); |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 1300 | ath10k_pci_dump_registers(ar, crash_data); |
| 1301 | |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 1302 | spin_unlock_bh(&ar->data_lock); |
Michal Kazior | affd321 | 2013-07-16 09:54:35 +0200 | [diff] [blame] | 1303 | |
Michal Kazior | 5e90de8 | 2013-10-16 16:46:05 +0300 | [diff] [blame] | 1304 | queue_work(ar->workqueue, &ar->restart_work); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1305 | } |
| 1306 | |
| 1307 | static void ath10k_pci_hif_send_complete_check(struct ath10k *ar, u8 pipe, |
| 1308 | int force) |
| 1309 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1310 | ath10k_dbg(ar, ATH10K_DBG_PCI, "pci hif send complete check\n"); |
Kalle Valo | 50f87a6 | 2014-03-28 09:32:52 +0200 | [diff] [blame] | 1311 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1312 | if (!force) { |
| 1313 | int resources; |
| 1314 | /* |
| 1315 | * Decide whether to actually poll for completions, or just |
| 1316 | * wait for a later chance. |
| 1317 | * If there seem to be plenty of resources left, then just wait |
| 1318 | * since checking involves reading a CE register, which is a |
| 1319 | * relatively expensive operation. |
| 1320 | */ |
| 1321 | resources = ath10k_pci_hif_get_free_queue_number(ar, pipe); |
| 1322 | |
| 1323 | /* |
| 1324 | * If at least 50% of the total resources are still available, |
| 1325 | * don't bother checking again yet. |
| 1326 | */ |
| 1327 | if (resources > (host_ce_config_wlan[pipe].src_nentries >> 1)) |
| 1328 | return; |
| 1329 | } |
| 1330 | ath10k_ce_per_engine_service(ar, pipe); |
| 1331 | } |
| 1332 | |
Michal Kazior | e799bbf | 2013-07-05 16:15:12 +0300 | [diff] [blame] | 1333 | static void ath10k_pci_hif_set_callbacks(struct ath10k *ar, |
| 1334 | struct ath10k_hif_cb *callbacks) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1335 | { |
| 1336 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 1337 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1338 | ath10k_dbg(ar, ATH10K_DBG_PCI, "pci hif set callbacks\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1339 | |
| 1340 | memcpy(&ar_pci->msg_callbacks_current, callbacks, |
| 1341 | sizeof(ar_pci->msg_callbacks_current)); |
| 1342 | } |
| 1343 | |
Michal Kazior | 96a9d0d | 2013-11-08 08:01:25 +0100 | [diff] [blame] | 1344 | static void ath10k_pci_kill_tasklet(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1345 | { |
| 1346 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1347 | int i; |
| 1348 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1349 | tasklet_kill(&ar_pci->intr_tq); |
Michal Kazior | 103d4f5 | 2013-11-08 08:01:24 +0100 | [diff] [blame] | 1350 | tasklet_kill(&ar_pci->msi_fw_err); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1351 | |
| 1352 | for (i = 0; i < CE_COUNT; i++) |
| 1353 | tasklet_kill(&ar_pci->pipe_info[i].intr); |
Michal Kazior | 728f95e | 2014-08-22 14:33:14 +0200 | [diff] [blame] | 1354 | |
| 1355 | del_timer_sync(&ar_pci->rx_post_retry); |
Michal Kazior | 96a9d0d | 2013-11-08 08:01:25 +0100 | [diff] [blame] | 1356 | } |
| 1357 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1358 | static int ath10k_pci_hif_map_service_to_pipe(struct ath10k *ar, |
| 1359 | u16 service_id, u8 *ul_pipe, |
| 1360 | u8 *dl_pipe, int *ul_is_polled, |
| 1361 | int *dl_is_polled) |
| 1362 | { |
Michal Kazior | 7c6aa25 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1363 | const struct service_to_pipe *entry; |
| 1364 | bool ul_set = false, dl_set = false; |
| 1365 | int i; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1366 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1367 | ath10k_dbg(ar, ATH10K_DBG_PCI, "pci hif map service\n"); |
Kalle Valo | 50f87a6 | 2014-03-28 09:32:52 +0200 | [diff] [blame] | 1368 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1369 | /* polling for received messages not supported */ |
| 1370 | *dl_is_polled = 0; |
| 1371 | |
Michal Kazior | 7c6aa25 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1372 | for (i = 0; i < ARRAY_SIZE(target_service_to_ce_map_wlan); i++) { |
| 1373 | entry = &target_service_to_ce_map_wlan[i]; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1374 | |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1375 | if (__le32_to_cpu(entry->service_id) != service_id) |
Michal Kazior | 7c6aa25 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1376 | continue; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1377 | |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1378 | switch (__le32_to_cpu(entry->pipedir)) { |
Michal Kazior | 7c6aa25 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1379 | case PIPEDIR_NONE: |
| 1380 | break; |
| 1381 | case PIPEDIR_IN: |
| 1382 | WARN_ON(dl_set); |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1383 | *dl_pipe = __le32_to_cpu(entry->pipenum); |
Michal Kazior | 7c6aa25 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1384 | dl_set = true; |
| 1385 | break; |
| 1386 | case PIPEDIR_OUT: |
| 1387 | WARN_ON(ul_set); |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1388 | *ul_pipe = __le32_to_cpu(entry->pipenum); |
Michal Kazior | 7c6aa25 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1389 | ul_set = true; |
| 1390 | break; |
| 1391 | case PIPEDIR_INOUT: |
| 1392 | WARN_ON(dl_set); |
| 1393 | WARN_ON(ul_set); |
Michal Kazior | 0fdc14e4 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1394 | *dl_pipe = __le32_to_cpu(entry->pipenum); |
| 1395 | *ul_pipe = __le32_to_cpu(entry->pipenum); |
Michal Kazior | 7c6aa25 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1396 | dl_set = true; |
| 1397 | ul_set = true; |
| 1398 | break; |
| 1399 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1400 | } |
Michal Kazior | 7c6aa25 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1401 | |
| 1402 | if (WARN_ON(!ul_set || !dl_set)) |
| 1403 | return -ENOENT; |
| 1404 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1405 | *ul_is_polled = |
| 1406 | (host_ce_config_wlan[*ul_pipe].flags & CE_ATTR_DIS_INTR) != 0; |
| 1407 | |
Michal Kazior | 7c6aa25 | 2014-08-26 19:14:03 +0300 | [diff] [blame] | 1408 | return 0; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1409 | } |
| 1410 | |
| 1411 | static void ath10k_pci_hif_get_default_pipe(struct ath10k *ar, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 1412 | u8 *ul_pipe, u8 *dl_pipe) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1413 | { |
| 1414 | int ul_is_polled, dl_is_polled; |
| 1415 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1416 | ath10k_dbg(ar, ATH10K_DBG_PCI, "pci hif get default pipe\n"); |
Kalle Valo | 50f87a6 | 2014-03-28 09:32:52 +0200 | [diff] [blame] | 1417 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1418 | (void)ath10k_pci_hif_map_service_to_pipe(ar, |
| 1419 | ATH10K_HTC_SVC_ID_RSVD_CTRL, |
| 1420 | ul_pipe, |
| 1421 | dl_pipe, |
| 1422 | &ul_is_polled, |
| 1423 | &dl_is_polled); |
| 1424 | } |
| 1425 | |
Michal Kazior | 7c0f0e3 | 2014-10-20 14:14:38 +0200 | [diff] [blame] | 1426 | static void ath10k_pci_irq_msi_fw_mask(struct ath10k *ar) |
| 1427 | { |
| 1428 | u32 val; |
| 1429 | |
| 1430 | val = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS + CORE_CTRL_ADDRESS); |
| 1431 | val &= ~CORE_CTRL_PCIE_REG_31_MASK; |
| 1432 | |
| 1433 | ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + CORE_CTRL_ADDRESS, val); |
| 1434 | } |
| 1435 | |
| 1436 | static void ath10k_pci_irq_msi_fw_unmask(struct ath10k *ar) |
| 1437 | { |
| 1438 | u32 val; |
| 1439 | |
| 1440 | val = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS + CORE_CTRL_ADDRESS); |
| 1441 | val |= CORE_CTRL_PCIE_REG_31_MASK; |
| 1442 | |
| 1443 | ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + CORE_CTRL_ADDRESS, val); |
| 1444 | } |
| 1445 | |
Michal Kazior | ec5ba4d | 2014-08-22 14:23:33 +0200 | [diff] [blame] | 1446 | static void ath10k_pci_irq_disable(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1447 | { |
Michal Kazior | 7c0f0e3 | 2014-10-20 14:14:38 +0200 | [diff] [blame] | 1448 | ath10k_ce_disable_interrupts(ar); |
| 1449 | ath10k_pci_disable_and_clear_legacy_irq(ar); |
| 1450 | ath10k_pci_irq_msi_fw_mask(ar); |
| 1451 | } |
| 1452 | |
| 1453 | static void ath10k_pci_irq_sync(struct ath10k *ar) |
| 1454 | { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1455 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
Michal Kazior | ec5ba4d | 2014-08-22 14:23:33 +0200 | [diff] [blame] | 1456 | int i; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1457 | |
Michal Kazior | ec5ba4d | 2014-08-22 14:23:33 +0200 | [diff] [blame] | 1458 | for (i = 0; i < max(1, ar_pci->num_msi_intrs); i++) |
| 1459 | synchronize_irq(ar_pci->pdev->irq + i); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1460 | } |
| 1461 | |
Michal Kazior | ec5ba4d | 2014-08-22 14:23:33 +0200 | [diff] [blame] | 1462 | static void ath10k_pci_irq_enable(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1463 | { |
Michal Kazior | ec5ba4d | 2014-08-22 14:23:33 +0200 | [diff] [blame] | 1464 | ath10k_ce_enable_interrupts(ar); |
Michal Kazior | e75db4e | 2014-08-28 22:14:16 +0300 | [diff] [blame] | 1465 | ath10k_pci_enable_legacy_irq(ar); |
Michal Kazior | 7c0f0e3 | 2014-10-20 14:14:38 +0200 | [diff] [blame] | 1466 | ath10k_pci_irq_msi_fw_unmask(ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1467 | } |
| 1468 | |
| 1469 | static int ath10k_pci_hif_start(struct ath10k *ar) |
| 1470 | { |
Janusz Dziedzic | 76d870e | 2015-05-18 09:38:16 +0000 | [diff] [blame] | 1471 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1472 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif start\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1473 | |
Michal Kazior | ec5ba4d | 2014-08-22 14:23:33 +0200 | [diff] [blame] | 1474 | ath10k_pci_irq_enable(ar); |
Michal Kazior | 728f95e | 2014-08-22 14:33:14 +0200 | [diff] [blame] | 1475 | ath10k_pci_rx_post(ar); |
Kalle Valo | 50f87a6 | 2014-03-28 09:32:52 +0200 | [diff] [blame] | 1476 | |
Janusz Dziedzic | 76d870e | 2015-05-18 09:38:16 +0000 | [diff] [blame] | 1477 | pcie_capability_write_word(ar_pci->pdev, PCI_EXP_LNKCTL, |
| 1478 | ar_pci->link_ctl); |
| 1479 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1480 | return 0; |
| 1481 | } |
| 1482 | |
Michal Kazior | 099ac7c | 2014-10-28 10:32:05 +0100 | [diff] [blame] | 1483 | static void ath10k_pci_rx_pipe_cleanup(struct ath10k_pci_pipe *pci_pipe) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1484 | { |
| 1485 | struct ath10k *ar; |
Michal Kazior | 099ac7c | 2014-10-28 10:32:05 +0100 | [diff] [blame] | 1486 | struct ath10k_ce_pipe *ce_pipe; |
| 1487 | struct ath10k_ce_ring *ce_ring; |
| 1488 | struct sk_buff *skb; |
| 1489 | int i; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1490 | |
Michal Kazior | 099ac7c | 2014-10-28 10:32:05 +0100 | [diff] [blame] | 1491 | ar = pci_pipe->hif_ce_state; |
| 1492 | ce_pipe = pci_pipe->ce_hdl; |
| 1493 | ce_ring = ce_pipe->dest_ring; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1494 | |
Michal Kazior | 099ac7c | 2014-10-28 10:32:05 +0100 | [diff] [blame] | 1495 | if (!ce_ring) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1496 | return; |
| 1497 | |
Michal Kazior | 099ac7c | 2014-10-28 10:32:05 +0100 | [diff] [blame] | 1498 | if (!pci_pipe->buf_sz) |
| 1499 | return; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1500 | |
Michal Kazior | 099ac7c | 2014-10-28 10:32:05 +0100 | [diff] [blame] | 1501 | for (i = 0; i < ce_ring->nentries; i++) { |
| 1502 | skb = ce_ring->per_transfer_context[i]; |
| 1503 | if (!skb) |
| 1504 | continue; |
| 1505 | |
| 1506 | ce_ring->per_transfer_context[i] = NULL; |
| 1507 | |
Michal Kazior | 8582bf3 | 2015-01-24 12:14:47 +0200 | [diff] [blame] | 1508 | dma_unmap_single(ar->dev, ATH10K_SKB_RXCB(skb)->paddr, |
Michal Kazior | 099ac7c | 2014-10-28 10:32:05 +0100 | [diff] [blame] | 1509 | skb->len + skb_tailroom(skb), |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1510 | DMA_FROM_DEVICE); |
Michal Kazior | 099ac7c | 2014-10-28 10:32:05 +0100 | [diff] [blame] | 1511 | dev_kfree_skb_any(skb); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1512 | } |
| 1513 | } |
| 1514 | |
Michal Kazior | 099ac7c | 2014-10-28 10:32:05 +0100 | [diff] [blame] | 1515 | static void ath10k_pci_tx_pipe_cleanup(struct ath10k_pci_pipe *pci_pipe) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1516 | { |
| 1517 | struct ath10k *ar; |
| 1518 | struct ath10k_pci *ar_pci; |
Michal Kazior | 099ac7c | 2014-10-28 10:32:05 +0100 | [diff] [blame] | 1519 | struct ath10k_ce_pipe *ce_pipe; |
| 1520 | struct ath10k_ce_ring *ce_ring; |
| 1521 | struct ce_desc *ce_desc; |
| 1522 | struct sk_buff *skb; |
Michal Kazior | 099ac7c | 2014-10-28 10:32:05 +0100 | [diff] [blame] | 1523 | int i; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1524 | |
Michal Kazior | 099ac7c | 2014-10-28 10:32:05 +0100 | [diff] [blame] | 1525 | ar = pci_pipe->hif_ce_state; |
| 1526 | ar_pci = ath10k_pci_priv(ar); |
| 1527 | ce_pipe = pci_pipe->ce_hdl; |
| 1528 | ce_ring = ce_pipe->src_ring; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1529 | |
Michal Kazior | 099ac7c | 2014-10-28 10:32:05 +0100 | [diff] [blame] | 1530 | if (!ce_ring) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1531 | return; |
| 1532 | |
Michal Kazior | 099ac7c | 2014-10-28 10:32:05 +0100 | [diff] [blame] | 1533 | if (!pci_pipe->buf_sz) |
| 1534 | return; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1535 | |
Michal Kazior | 099ac7c | 2014-10-28 10:32:05 +0100 | [diff] [blame] | 1536 | ce_desc = ce_ring->shadow_base; |
| 1537 | if (WARN_ON(!ce_desc)) |
| 1538 | return; |
| 1539 | |
| 1540 | for (i = 0; i < ce_ring->nentries; i++) { |
| 1541 | skb = ce_ring->per_transfer_context[i]; |
| 1542 | if (!skb) |
Michal Kazior | 2415fc1 | 2013-11-08 08:01:32 +0100 | [diff] [blame] | 1543 | continue; |
Michal Kazior | 2415fc1 | 2013-11-08 08:01:32 +0100 | [diff] [blame] | 1544 | |
Michal Kazior | 099ac7c | 2014-10-28 10:32:05 +0100 | [diff] [blame] | 1545 | ce_ring->per_transfer_context[i] = NULL; |
Michal Kazior | 099ac7c | 2014-10-28 10:32:05 +0100 | [diff] [blame] | 1546 | |
Michal Kazior | d84a512 | 2014-11-27 11:09:37 +0100 | [diff] [blame] | 1547 | ar_pci->msg_callbacks_current.tx_completion(ar, skb); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1548 | } |
| 1549 | } |
| 1550 | |
| 1551 | /* |
| 1552 | * Cleanup residual buffers for device shutdown: |
| 1553 | * buffers that were enqueued for receive |
| 1554 | * buffers that were to be sent |
| 1555 | * Note: Buffers that had completed but which were |
| 1556 | * not yet processed are on a completion queue. They |
| 1557 | * are handled when the completion thread shuts down. |
| 1558 | */ |
| 1559 | static void ath10k_pci_buffer_cleanup(struct ath10k *ar) |
| 1560 | { |
| 1561 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 1562 | int pipe_num; |
| 1563 | |
Michal Kazior | fad6ed7 | 2013-11-08 08:01:23 +0100 | [diff] [blame] | 1564 | for (pipe_num = 0; pipe_num < CE_COUNT; pipe_num++) { |
Michal Kazior | 87263e5 | 2013-08-27 13:08:01 +0200 | [diff] [blame] | 1565 | struct ath10k_pci_pipe *pipe_info; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1566 | |
| 1567 | pipe_info = &ar_pci->pipe_info[pipe_num]; |
| 1568 | ath10k_pci_rx_pipe_cleanup(pipe_info); |
| 1569 | ath10k_pci_tx_pipe_cleanup(pipe_info); |
| 1570 | } |
| 1571 | } |
| 1572 | |
| 1573 | static void ath10k_pci_ce_deinit(struct ath10k *ar) |
| 1574 | { |
Michal Kazior | 25d0dbc | 2014-03-28 10:02:38 +0200 | [diff] [blame] | 1575 | int i; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1576 | |
Michal Kazior | 25d0dbc | 2014-03-28 10:02:38 +0200 | [diff] [blame] | 1577 | for (i = 0; i < CE_COUNT; i++) |
| 1578 | ath10k_ce_deinit_pipe(ar, i); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1579 | } |
| 1580 | |
Michal Kazior | 728f95e | 2014-08-22 14:33:14 +0200 | [diff] [blame] | 1581 | static void ath10k_pci_flush(struct ath10k *ar) |
| 1582 | { |
| 1583 | ath10k_pci_kill_tasklet(ar); |
| 1584 | ath10k_pci_buffer_cleanup(ar); |
| 1585 | } |
| 1586 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1587 | static void ath10k_pci_hif_stop(struct ath10k *ar) |
| 1588 | { |
Michal Kazior | 77258d4 | 2015-05-18 09:38:18 +0000 | [diff] [blame] | 1589 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 1590 | unsigned long flags; |
| 1591 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1592 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif stop\n"); |
Michal Kazior | 32270b6 | 2013-08-02 09:15:47 +0200 | [diff] [blame] | 1593 | |
Michal Kazior | 10d23db | 2014-08-22 14:33:15 +0200 | [diff] [blame] | 1594 | /* Most likely the device has HTT Rx ring configured. The only way to |
| 1595 | * prevent the device from accessing (and possible corrupting) host |
| 1596 | * memory is to reset the chip now. |
Michal Kazior | e75db4e | 2014-08-28 22:14:16 +0300 | [diff] [blame] | 1597 | * |
| 1598 | * There's also no known way of masking MSI interrupts on the device. |
| 1599 | * For ranged MSI the CE-related interrupts can be masked. However |
| 1600 | * regardless how many MSI interrupts are assigned the first one |
| 1601 | * is always used for firmware indications (crashes) and cannot be |
| 1602 | * masked. To prevent the device from asserting the interrupt reset it |
| 1603 | * before proceeding with cleanup. |
Michal Kazior | 10d23db | 2014-08-22 14:33:15 +0200 | [diff] [blame] | 1604 | */ |
Michal Kazior | fc36e3f | 2014-02-10 17:14:22 +0100 | [diff] [blame] | 1605 | ath10k_pci_warm_reset(ar); |
Michal Kazior | e75db4e | 2014-08-28 22:14:16 +0300 | [diff] [blame] | 1606 | |
| 1607 | ath10k_pci_irq_disable(ar); |
Michal Kazior | 7c0f0e3 | 2014-10-20 14:14:38 +0200 | [diff] [blame] | 1608 | ath10k_pci_irq_sync(ar); |
Michal Kazior | e75db4e | 2014-08-28 22:14:16 +0300 | [diff] [blame] | 1609 | ath10k_pci_flush(ar); |
Michal Kazior | 77258d4 | 2015-05-18 09:38:18 +0000 | [diff] [blame] | 1610 | |
| 1611 | spin_lock_irqsave(&ar_pci->ps_lock, flags); |
| 1612 | WARN_ON(ar_pci->ps_wake_refcount > 0); |
| 1613 | spin_unlock_irqrestore(&ar_pci->ps_lock, flags); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1614 | } |
| 1615 | |
| 1616 | static int ath10k_pci_hif_exchange_bmi_msg(struct ath10k *ar, |
| 1617 | void *req, u32 req_len, |
| 1618 | void *resp, u32 *resp_len) |
| 1619 | { |
| 1620 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
Michal Kazior | 2aa3911 | 2013-08-27 13:08:02 +0200 | [diff] [blame] | 1621 | struct ath10k_pci_pipe *pci_tx = &ar_pci->pipe_info[BMI_CE_NUM_TO_TARG]; |
| 1622 | struct ath10k_pci_pipe *pci_rx = &ar_pci->pipe_info[BMI_CE_NUM_TO_HOST]; |
| 1623 | struct ath10k_ce_pipe *ce_tx = pci_tx->ce_hdl; |
| 1624 | struct ath10k_ce_pipe *ce_rx = pci_rx->ce_hdl; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1625 | dma_addr_t req_paddr = 0; |
| 1626 | dma_addr_t resp_paddr = 0; |
| 1627 | struct bmi_xfer xfer = {}; |
| 1628 | void *treq, *tresp = NULL; |
| 1629 | int ret = 0; |
| 1630 | |
Michal Kazior | 85622cd | 2013-11-25 14:06:22 +0100 | [diff] [blame] | 1631 | might_sleep(); |
| 1632 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1633 | if (resp && !resp_len) |
| 1634 | return -EINVAL; |
| 1635 | |
| 1636 | if (resp && resp_len && *resp_len == 0) |
| 1637 | return -EINVAL; |
| 1638 | |
| 1639 | treq = kmemdup(req, req_len, GFP_KERNEL); |
| 1640 | if (!treq) |
| 1641 | return -ENOMEM; |
| 1642 | |
| 1643 | req_paddr = dma_map_single(ar->dev, treq, req_len, DMA_TO_DEVICE); |
| 1644 | ret = dma_mapping_error(ar->dev, req_paddr); |
| 1645 | if (ret) |
| 1646 | goto err_dma; |
| 1647 | |
| 1648 | if (resp && resp_len) { |
| 1649 | tresp = kzalloc(*resp_len, GFP_KERNEL); |
| 1650 | if (!tresp) { |
| 1651 | ret = -ENOMEM; |
| 1652 | goto err_req; |
| 1653 | } |
| 1654 | |
| 1655 | resp_paddr = dma_map_single(ar->dev, tresp, *resp_len, |
| 1656 | DMA_FROM_DEVICE); |
| 1657 | ret = dma_mapping_error(ar->dev, resp_paddr); |
| 1658 | if (ret) |
| 1659 | goto err_req; |
| 1660 | |
| 1661 | xfer.wait_for_resp = true; |
| 1662 | xfer.resp_len = 0; |
| 1663 | |
Michal Kazior | 728f95e | 2014-08-22 14:33:14 +0200 | [diff] [blame] | 1664 | ath10k_ce_rx_post_buf(ce_rx, &xfer, resp_paddr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1665 | } |
| 1666 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1667 | ret = ath10k_ce_send(ce_tx, &xfer, req_paddr, req_len, -1, 0); |
| 1668 | if (ret) |
| 1669 | goto err_resp; |
| 1670 | |
Michal Kazior | 85622cd | 2013-11-25 14:06:22 +0100 | [diff] [blame] | 1671 | ret = ath10k_pci_bmi_wait(ce_tx, ce_rx, &xfer); |
| 1672 | if (ret) { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1673 | u32 unused_buffer; |
| 1674 | unsigned int unused_nbytes; |
| 1675 | unsigned int unused_id; |
| 1676 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1677 | ath10k_ce_cancel_send_next(ce_tx, NULL, &unused_buffer, |
| 1678 | &unused_nbytes, &unused_id); |
| 1679 | } else { |
| 1680 | /* non-zero means we did not time out */ |
| 1681 | ret = 0; |
| 1682 | } |
| 1683 | |
| 1684 | err_resp: |
| 1685 | if (resp) { |
| 1686 | u32 unused_buffer; |
| 1687 | |
| 1688 | ath10k_ce_revoke_recv_next(ce_rx, NULL, &unused_buffer); |
| 1689 | dma_unmap_single(ar->dev, resp_paddr, |
| 1690 | *resp_len, DMA_FROM_DEVICE); |
| 1691 | } |
| 1692 | err_req: |
| 1693 | dma_unmap_single(ar->dev, req_paddr, req_len, DMA_TO_DEVICE); |
| 1694 | |
| 1695 | if (ret == 0 && resp_len) { |
| 1696 | *resp_len = min(*resp_len, xfer.resp_len); |
| 1697 | memcpy(resp, tresp, xfer.resp_len); |
| 1698 | } |
| 1699 | err_dma: |
| 1700 | kfree(treq); |
| 1701 | kfree(tresp); |
| 1702 | |
| 1703 | return ret; |
| 1704 | } |
| 1705 | |
Michal Kazior | 5440ce2 | 2013-09-03 15:09:58 +0200 | [diff] [blame] | 1706 | static void ath10k_pci_bmi_send_done(struct ath10k_ce_pipe *ce_state) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1707 | { |
Michal Kazior | 5440ce2 | 2013-09-03 15:09:58 +0200 | [diff] [blame] | 1708 | struct bmi_xfer *xfer; |
| 1709 | u32 ce_data; |
| 1710 | unsigned int nbytes; |
| 1711 | unsigned int transfer_id; |
| 1712 | |
| 1713 | if (ath10k_ce_completed_send_next(ce_state, (void **)&xfer, &ce_data, |
| 1714 | &nbytes, &transfer_id)) |
| 1715 | return; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1716 | |
Michal Kazior | 2374b18 | 2014-07-14 16:25:25 +0300 | [diff] [blame] | 1717 | xfer->tx_done = true; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1718 | } |
| 1719 | |
Michal Kazior | 5440ce2 | 2013-09-03 15:09:58 +0200 | [diff] [blame] | 1720 | static void ath10k_pci_bmi_recv_data(struct ath10k_ce_pipe *ce_state) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1721 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1722 | struct ath10k *ar = ce_state->ar; |
Michal Kazior | 5440ce2 | 2013-09-03 15:09:58 +0200 | [diff] [blame] | 1723 | struct bmi_xfer *xfer; |
| 1724 | u32 ce_data; |
| 1725 | unsigned int nbytes; |
| 1726 | unsigned int transfer_id; |
| 1727 | unsigned int flags; |
| 1728 | |
| 1729 | if (ath10k_ce_completed_recv_next(ce_state, (void **)&xfer, &ce_data, |
| 1730 | &nbytes, &transfer_id, &flags)) |
| 1731 | return; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1732 | |
Michal Kazior | 04ed9df | 2014-10-28 10:34:36 +0100 | [diff] [blame] | 1733 | if (WARN_ON_ONCE(!xfer)) |
| 1734 | return; |
| 1735 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1736 | if (!xfer->wait_for_resp) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1737 | ath10k_warn(ar, "unexpected: BMI data received; ignoring\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1738 | return; |
| 1739 | } |
| 1740 | |
| 1741 | xfer->resp_len = nbytes; |
Michal Kazior | 2374b18 | 2014-07-14 16:25:25 +0300 | [diff] [blame] | 1742 | xfer->rx_done = true; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1743 | } |
| 1744 | |
Michal Kazior | 85622cd | 2013-11-25 14:06:22 +0100 | [diff] [blame] | 1745 | static int ath10k_pci_bmi_wait(struct ath10k_ce_pipe *tx_pipe, |
| 1746 | struct ath10k_ce_pipe *rx_pipe, |
| 1747 | struct bmi_xfer *xfer) |
| 1748 | { |
| 1749 | unsigned long timeout = jiffies + BMI_COMMUNICATION_TIMEOUT_HZ; |
| 1750 | |
| 1751 | while (time_before_eq(jiffies, timeout)) { |
| 1752 | ath10k_pci_bmi_send_done(tx_pipe); |
| 1753 | ath10k_pci_bmi_recv_data(rx_pipe); |
| 1754 | |
Michal Kazior | 2374b18 | 2014-07-14 16:25:25 +0300 | [diff] [blame] | 1755 | if (xfer->tx_done && (xfer->rx_done == xfer->wait_for_resp)) |
Michal Kazior | 85622cd | 2013-11-25 14:06:22 +0100 | [diff] [blame] | 1756 | return 0; |
| 1757 | |
| 1758 | schedule(); |
| 1759 | } |
| 1760 | |
| 1761 | return -ETIMEDOUT; |
| 1762 | } |
| 1763 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1764 | /* |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1765 | * Send an interrupt to the device to wake up the Target CPU |
| 1766 | * so it has an opportunity to notice any changed state. |
| 1767 | */ |
| 1768 | static int ath10k_pci_wake_target_cpu(struct ath10k *ar) |
| 1769 | { |
Michal Kazior | 9e26494 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 1770 | u32 addr, val; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1771 | |
Michal Kazior | 9e26494 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 1772 | addr = SOC_CORE_BASE_ADDRESS | CORE_CTRL_ADDRESS; |
| 1773 | val = ath10k_pci_read32(ar, addr); |
| 1774 | val |= CORE_CTRL_CPU_INTR_MASK; |
| 1775 | ath10k_pci_write32(ar, addr, val); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1776 | |
Michal Kazior | 1d2b48d | 2013-11-08 08:01:34 +0100 | [diff] [blame] | 1777 | return 0; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1778 | } |
| 1779 | |
Michal Kazior | d63955b | 2015-01-24 12:14:49 +0200 | [diff] [blame] | 1780 | static int ath10k_pci_get_num_banks(struct ath10k *ar) |
| 1781 | { |
| 1782 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 1783 | |
| 1784 | switch (ar_pci->pdev->device) { |
| 1785 | case QCA988X_2_0_DEVICE_ID: |
Vasanthakumar Thiagarajan | 8bd4702 | 2015-06-18 12:31:03 +0530 | [diff] [blame] | 1786 | case QCA99X0_2_0_DEVICE_ID: |
Michal Kazior | d63955b | 2015-01-24 12:14:49 +0200 | [diff] [blame] | 1787 | return 1; |
| 1788 | case QCA6174_2_1_DEVICE_ID: |
| 1789 | switch (MS(ar->chip_id, SOC_CHIP_ID_REV)) { |
| 1790 | case QCA6174_HW_1_0_CHIP_ID_REV: |
| 1791 | case QCA6174_HW_1_1_CHIP_ID_REV: |
Michal Kazior | 11a002e | 2015-04-20 09:20:41 +0000 | [diff] [blame] | 1792 | case QCA6174_HW_2_1_CHIP_ID_REV: |
| 1793 | case QCA6174_HW_2_2_CHIP_ID_REV: |
Michal Kazior | d63955b | 2015-01-24 12:14:49 +0200 | [diff] [blame] | 1794 | return 3; |
| 1795 | case QCA6174_HW_1_3_CHIP_ID_REV: |
| 1796 | return 2; |
Michal Kazior | d63955b | 2015-01-24 12:14:49 +0200 | [diff] [blame] | 1797 | case QCA6174_HW_3_0_CHIP_ID_REV: |
| 1798 | case QCA6174_HW_3_1_CHIP_ID_REV: |
| 1799 | case QCA6174_HW_3_2_CHIP_ID_REV: |
| 1800 | return 9; |
| 1801 | } |
| 1802 | break; |
| 1803 | } |
| 1804 | |
| 1805 | ath10k_warn(ar, "unknown number of banks, assuming 1\n"); |
| 1806 | return 1; |
| 1807 | } |
| 1808 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1809 | static int ath10k_pci_init_config(struct ath10k *ar) |
| 1810 | { |
| 1811 | u32 interconnect_targ_addr; |
| 1812 | u32 pcie_state_targ_addr = 0; |
| 1813 | u32 pipe_cfg_targ_addr = 0; |
| 1814 | u32 svc_to_pipe_map = 0; |
| 1815 | u32 pcie_config_flags = 0; |
| 1816 | u32 ealloc_value; |
| 1817 | u32 ealloc_targ_addr; |
| 1818 | u32 flag2_value; |
| 1819 | u32 flag2_targ_addr; |
| 1820 | int ret = 0; |
| 1821 | |
| 1822 | /* Download to Target the CE Config and the service-to-CE map */ |
| 1823 | interconnect_targ_addr = |
| 1824 | host_interest_item_address(HI_ITEM(hi_interconnect_state)); |
| 1825 | |
| 1826 | /* Supply Target-side CE configuration */ |
Michal Kazior | 9e26494 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 1827 | ret = ath10k_pci_diag_read32(ar, interconnect_targ_addr, |
| 1828 | &pcie_state_targ_addr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1829 | if (ret != 0) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1830 | ath10k_err(ar, "Failed to get pcie state addr: %d\n", ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1831 | return ret; |
| 1832 | } |
| 1833 | |
| 1834 | if (pcie_state_targ_addr == 0) { |
| 1835 | ret = -EIO; |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1836 | ath10k_err(ar, "Invalid pcie state addr\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1837 | return ret; |
| 1838 | } |
| 1839 | |
Michal Kazior | 9e26494 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 1840 | ret = ath10k_pci_diag_read32(ar, (pcie_state_targ_addr + |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1841 | offsetof(struct pcie_state, |
Michal Kazior | 9e26494 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 1842 | pipe_cfg_addr)), |
| 1843 | &pipe_cfg_targ_addr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1844 | if (ret != 0) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1845 | ath10k_err(ar, "Failed to get pipe cfg addr: %d\n", ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1846 | return ret; |
| 1847 | } |
| 1848 | |
| 1849 | if (pipe_cfg_targ_addr == 0) { |
| 1850 | ret = -EIO; |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1851 | ath10k_err(ar, "Invalid pipe cfg addr\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1852 | return ret; |
| 1853 | } |
| 1854 | |
| 1855 | ret = ath10k_pci_diag_write_mem(ar, pipe_cfg_targ_addr, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 1856 | target_ce_config_wlan, |
Vasanthakumar Thiagarajan | 050af06 | 2015-06-18 12:31:04 +0530 | [diff] [blame] | 1857 | sizeof(struct ce_pipe_config) * |
| 1858 | NUM_TARGET_CE_CONFIG_WLAN); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1859 | |
| 1860 | if (ret != 0) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1861 | ath10k_err(ar, "Failed to write pipe cfg: %d\n", ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1862 | return ret; |
| 1863 | } |
| 1864 | |
Michal Kazior | 9e26494 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 1865 | ret = ath10k_pci_diag_read32(ar, (pcie_state_targ_addr + |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1866 | offsetof(struct pcie_state, |
Michal Kazior | 9e26494 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 1867 | svc_to_pipe_map)), |
| 1868 | &svc_to_pipe_map); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1869 | if (ret != 0) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1870 | ath10k_err(ar, "Failed to get svc/pipe map: %d\n", ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1871 | return ret; |
| 1872 | } |
| 1873 | |
| 1874 | if (svc_to_pipe_map == 0) { |
| 1875 | ret = -EIO; |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1876 | ath10k_err(ar, "Invalid svc_to_pipe map\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1877 | return ret; |
| 1878 | } |
| 1879 | |
| 1880 | ret = ath10k_pci_diag_write_mem(ar, svc_to_pipe_map, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 1881 | target_service_to_ce_map_wlan, |
| 1882 | sizeof(target_service_to_ce_map_wlan)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1883 | if (ret != 0) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1884 | ath10k_err(ar, "Failed to write svc/pipe map: %d\n", ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1885 | return ret; |
| 1886 | } |
| 1887 | |
Michal Kazior | 9e26494 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 1888 | ret = ath10k_pci_diag_read32(ar, (pcie_state_targ_addr + |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1889 | offsetof(struct pcie_state, |
Michal Kazior | 9e26494 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 1890 | config_flags)), |
| 1891 | &pcie_config_flags); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1892 | if (ret != 0) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1893 | ath10k_err(ar, "Failed to get pcie config_flags: %d\n", ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1894 | return ret; |
| 1895 | } |
| 1896 | |
| 1897 | pcie_config_flags &= ~PCIE_CONFIG_FLAG_ENABLE_L1; |
| 1898 | |
Michal Kazior | 9e26494 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 1899 | ret = ath10k_pci_diag_write32(ar, (pcie_state_targ_addr + |
| 1900 | offsetof(struct pcie_state, |
| 1901 | config_flags)), |
| 1902 | pcie_config_flags); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1903 | if (ret != 0) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1904 | ath10k_err(ar, "Failed to write pcie config_flags: %d\n", ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1905 | return ret; |
| 1906 | } |
| 1907 | |
| 1908 | /* configure early allocation */ |
| 1909 | ealloc_targ_addr = host_interest_item_address(HI_ITEM(hi_early_alloc)); |
| 1910 | |
Michal Kazior | 9e26494 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 1911 | ret = ath10k_pci_diag_read32(ar, ealloc_targ_addr, &ealloc_value); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1912 | if (ret != 0) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1913 | ath10k_err(ar, "Faile to get early alloc val: %d\n", ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1914 | return ret; |
| 1915 | } |
| 1916 | |
| 1917 | /* first bank is switched to IRAM */ |
| 1918 | ealloc_value |= ((HI_EARLY_ALLOC_MAGIC << HI_EARLY_ALLOC_MAGIC_SHIFT) & |
| 1919 | HI_EARLY_ALLOC_MAGIC_MASK); |
Michal Kazior | d63955b | 2015-01-24 12:14:49 +0200 | [diff] [blame] | 1920 | ealloc_value |= ((ath10k_pci_get_num_banks(ar) << |
| 1921 | HI_EARLY_ALLOC_IRAM_BANKS_SHIFT) & |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1922 | HI_EARLY_ALLOC_IRAM_BANKS_MASK); |
| 1923 | |
Michal Kazior | 9e26494 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 1924 | ret = ath10k_pci_diag_write32(ar, ealloc_targ_addr, ealloc_value); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1925 | if (ret != 0) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1926 | ath10k_err(ar, "Failed to set early alloc val: %d\n", ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1927 | return ret; |
| 1928 | } |
| 1929 | |
| 1930 | /* Tell Target to proceed with initialization */ |
| 1931 | flag2_targ_addr = host_interest_item_address(HI_ITEM(hi_option_flag2)); |
| 1932 | |
Michal Kazior | 9e26494 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 1933 | ret = ath10k_pci_diag_read32(ar, flag2_targ_addr, &flag2_value); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1934 | if (ret != 0) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1935 | ath10k_err(ar, "Failed to get option val: %d\n", ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1936 | return ret; |
| 1937 | } |
| 1938 | |
| 1939 | flag2_value |= HI_OPTION_EARLY_CFG_DONE; |
| 1940 | |
Michal Kazior | 9e26494 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 1941 | ret = ath10k_pci_diag_write32(ar, flag2_targ_addr, flag2_value); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1942 | if (ret != 0) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1943 | ath10k_err(ar, "Failed to set option val: %d\n", ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1944 | return ret; |
| 1945 | } |
| 1946 | |
| 1947 | return 0; |
| 1948 | } |
| 1949 | |
Michal Kazior | 84cbf3a | 2014-10-20 14:14:39 +0200 | [diff] [blame] | 1950 | static int ath10k_pci_alloc_pipes(struct ath10k *ar) |
Michal Kazior | 25d0dbc | 2014-03-28 10:02:38 +0200 | [diff] [blame] | 1951 | { |
Michal Kazior | 84cbf3a | 2014-10-20 14:14:39 +0200 | [diff] [blame] | 1952 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 1953 | struct ath10k_pci_pipe *pipe; |
Michal Kazior | 25d0dbc | 2014-03-28 10:02:38 +0200 | [diff] [blame] | 1954 | int i, ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1955 | |
Michal Kazior | 25d0dbc | 2014-03-28 10:02:38 +0200 | [diff] [blame] | 1956 | for (i = 0; i < CE_COUNT; i++) { |
Michal Kazior | 84cbf3a | 2014-10-20 14:14:39 +0200 | [diff] [blame] | 1957 | pipe = &ar_pci->pipe_info[i]; |
| 1958 | pipe->ce_hdl = &ar_pci->ce_states[i]; |
| 1959 | pipe->pipe_num = i; |
| 1960 | pipe->hif_ce_state = ar; |
| 1961 | |
| 1962 | ret = ath10k_ce_alloc_pipe(ar, i, &host_ce_config_wlan[i], |
| 1963 | ath10k_pci_ce_send_done, |
| 1964 | ath10k_pci_ce_recv_data); |
Michal Kazior | 25d0dbc | 2014-03-28 10:02:38 +0200 | [diff] [blame] | 1965 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1966 | ath10k_err(ar, "failed to allocate copy engine pipe %d: %d\n", |
Michal Kazior | 25d0dbc | 2014-03-28 10:02:38 +0200 | [diff] [blame] | 1967 | i, ret); |
| 1968 | return ret; |
| 1969 | } |
Michal Kazior | 84cbf3a | 2014-10-20 14:14:39 +0200 | [diff] [blame] | 1970 | |
| 1971 | /* Last CE is Diagnostic Window */ |
Vasanthakumar Thiagarajan | 050af06 | 2015-06-18 12:31:04 +0530 | [diff] [blame] | 1972 | if (i == CE_DIAG_PIPE) { |
Michal Kazior | 84cbf3a | 2014-10-20 14:14:39 +0200 | [diff] [blame] | 1973 | ar_pci->ce_diag = pipe->ce_hdl; |
| 1974 | continue; |
| 1975 | } |
| 1976 | |
| 1977 | pipe->buf_sz = (size_t)(host_ce_config_wlan[i].src_sz_max); |
Michal Kazior | 25d0dbc | 2014-03-28 10:02:38 +0200 | [diff] [blame] | 1978 | } |
| 1979 | |
| 1980 | return 0; |
| 1981 | } |
| 1982 | |
Michal Kazior | 84cbf3a | 2014-10-20 14:14:39 +0200 | [diff] [blame] | 1983 | static void ath10k_pci_free_pipes(struct ath10k *ar) |
Michal Kazior | 25d0dbc | 2014-03-28 10:02:38 +0200 | [diff] [blame] | 1984 | { |
| 1985 | int i; |
| 1986 | |
| 1987 | for (i = 0; i < CE_COUNT; i++) |
| 1988 | ath10k_ce_free_pipe(ar, i); |
| 1989 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1990 | |
Michal Kazior | 84cbf3a | 2014-10-20 14:14:39 +0200 | [diff] [blame] | 1991 | static int ath10k_pci_init_pipes(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1992 | { |
Michal Kazior | 84cbf3a | 2014-10-20 14:14:39 +0200 | [diff] [blame] | 1993 | int i, ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1994 | |
Michal Kazior | 84cbf3a | 2014-10-20 14:14:39 +0200 | [diff] [blame] | 1995 | for (i = 0; i < CE_COUNT; i++) { |
| 1996 | ret = ath10k_ce_init_pipe(ar, i, &host_ce_config_wlan[i]); |
Michal Kazior | 25d0dbc | 2014-03-28 10:02:38 +0200 | [diff] [blame] | 1997 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1998 | ath10k_err(ar, "failed to initialize copy engine pipe %d: %d\n", |
Michal Kazior | 84cbf3a | 2014-10-20 14:14:39 +0200 | [diff] [blame] | 1999 | i, ret); |
Michal Kazior | 25d0dbc | 2014-03-28 10:02:38 +0200 | [diff] [blame] | 2000 | return ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2001 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2002 | } |
| 2003 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2004 | return 0; |
| 2005 | } |
| 2006 | |
Michal Kazior | 5c771e7 | 2014-08-22 14:23:34 +0200 | [diff] [blame] | 2007 | static bool ath10k_pci_has_fw_crashed(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2008 | { |
Michal Kazior | 5c771e7 | 2014-08-22 14:23:34 +0200 | [diff] [blame] | 2009 | return ath10k_pci_read32(ar, FW_INDICATOR_ADDRESS) & |
| 2010 | FW_IND_EVENT_PENDING; |
| 2011 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2012 | |
Michal Kazior | 5c771e7 | 2014-08-22 14:23:34 +0200 | [diff] [blame] | 2013 | static void ath10k_pci_fw_crashed_clear(struct ath10k *ar) |
| 2014 | { |
| 2015 | u32 val; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2016 | |
Michal Kazior | 5c771e7 | 2014-08-22 14:23:34 +0200 | [diff] [blame] | 2017 | val = ath10k_pci_read32(ar, FW_INDICATOR_ADDRESS); |
| 2018 | val &= ~FW_IND_EVENT_PENDING; |
| 2019 | ath10k_pci_write32(ar, FW_INDICATOR_ADDRESS, val); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2020 | } |
| 2021 | |
Michal Kazior | de01357 | 2014-05-14 16:56:16 +0300 | [diff] [blame] | 2022 | /* this function effectively clears target memory controller assert line */ |
| 2023 | static void ath10k_pci_warm_reset_si0(struct ath10k *ar) |
| 2024 | { |
| 2025 | u32 val; |
| 2026 | |
| 2027 | val = ath10k_pci_soc_read32(ar, SOC_RESET_CONTROL_ADDRESS); |
| 2028 | ath10k_pci_soc_write32(ar, SOC_RESET_CONTROL_ADDRESS, |
| 2029 | val | SOC_RESET_CONTROL_SI0_RST_MASK); |
| 2030 | val = ath10k_pci_soc_read32(ar, SOC_RESET_CONTROL_ADDRESS); |
| 2031 | |
| 2032 | msleep(10); |
| 2033 | |
| 2034 | val = ath10k_pci_soc_read32(ar, SOC_RESET_CONTROL_ADDRESS); |
| 2035 | ath10k_pci_soc_write32(ar, SOC_RESET_CONTROL_ADDRESS, |
| 2036 | val & ~SOC_RESET_CONTROL_SI0_RST_MASK); |
| 2037 | val = ath10k_pci_soc_read32(ar, SOC_RESET_CONTROL_ADDRESS); |
| 2038 | |
| 2039 | msleep(10); |
| 2040 | } |
| 2041 | |
Michal Kazior | 61c1648 | 2014-10-28 10:32:06 +0100 | [diff] [blame] | 2042 | static void ath10k_pci_warm_reset_cpu(struct ath10k *ar) |
Michal Kazior | fc36e3f | 2014-02-10 17:14:22 +0100 | [diff] [blame] | 2043 | { |
Michal Kazior | fc36e3f | 2014-02-10 17:14:22 +0100 | [diff] [blame] | 2044 | u32 val; |
| 2045 | |
Kalle Valo | b39712c | 2014-03-28 09:32:46 +0200 | [diff] [blame] | 2046 | ath10k_pci_write32(ar, FW_INDICATOR_ADDRESS, 0); |
Michal Kazior | fc36e3f | 2014-02-10 17:14:22 +0100 | [diff] [blame] | 2047 | |
Michal Kazior | 61c1648 | 2014-10-28 10:32:06 +0100 | [diff] [blame] | 2048 | val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS + |
| 2049 | SOC_RESET_CONTROL_ADDRESS); |
| 2050 | ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS + SOC_RESET_CONTROL_ADDRESS, |
| 2051 | val | SOC_RESET_CONTROL_CPU_WARM_RST_MASK); |
| 2052 | } |
| 2053 | |
| 2054 | static void ath10k_pci_warm_reset_ce(struct ath10k *ar) |
| 2055 | { |
| 2056 | u32 val; |
| 2057 | |
| 2058 | val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS + |
| 2059 | SOC_RESET_CONTROL_ADDRESS); |
| 2060 | |
| 2061 | ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS + SOC_RESET_CONTROL_ADDRESS, |
| 2062 | val | SOC_RESET_CONTROL_CE_RST_MASK); |
| 2063 | msleep(10); |
| 2064 | ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS + SOC_RESET_CONTROL_ADDRESS, |
| 2065 | val & ~SOC_RESET_CONTROL_CE_RST_MASK); |
| 2066 | } |
| 2067 | |
| 2068 | static void ath10k_pci_warm_reset_clear_lf(struct ath10k *ar) |
| 2069 | { |
| 2070 | u32 val; |
| 2071 | |
Michal Kazior | fc36e3f | 2014-02-10 17:14:22 +0100 | [diff] [blame] | 2072 | val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS + |
| 2073 | SOC_LF_TIMER_CONTROL0_ADDRESS); |
| 2074 | ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS + |
| 2075 | SOC_LF_TIMER_CONTROL0_ADDRESS, |
| 2076 | val & ~SOC_LF_TIMER_CONTROL0_ENABLE_MASK); |
Michal Kazior | 61c1648 | 2014-10-28 10:32:06 +0100 | [diff] [blame] | 2077 | } |
Michal Kazior | fc36e3f | 2014-02-10 17:14:22 +0100 | [diff] [blame] | 2078 | |
Michal Kazior | 61c1648 | 2014-10-28 10:32:06 +0100 | [diff] [blame] | 2079 | static int ath10k_pci_warm_reset(struct ath10k *ar) |
| 2080 | { |
| 2081 | int ret; |
Michal Kazior | fc36e3f | 2014-02-10 17:14:22 +0100 | [diff] [blame] | 2082 | |
Michal Kazior | 61c1648 | 2014-10-28 10:32:06 +0100 | [diff] [blame] | 2083 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot warm reset\n"); |
Michal Kazior | fc36e3f | 2014-02-10 17:14:22 +0100 | [diff] [blame] | 2084 | |
Michal Kazior | 61c1648 | 2014-10-28 10:32:06 +0100 | [diff] [blame] | 2085 | spin_lock_bh(&ar->data_lock); |
| 2086 | ar->stats.fw_warm_reset_counter++; |
| 2087 | spin_unlock_bh(&ar->data_lock); |
| 2088 | |
| 2089 | ath10k_pci_irq_disable(ar); |
| 2090 | |
| 2091 | /* Make sure the target CPU is not doing anything dangerous, e.g. if it |
| 2092 | * were to access copy engine while host performs copy engine reset |
| 2093 | * then it is possible for the device to confuse pci-e controller to |
| 2094 | * the point of bringing host system to a complete stop (i.e. hang). |
| 2095 | */ |
Michal Kazior | de01357 | 2014-05-14 16:56:16 +0300 | [diff] [blame] | 2096 | ath10k_pci_warm_reset_si0(ar); |
Michal Kazior | 61c1648 | 2014-10-28 10:32:06 +0100 | [diff] [blame] | 2097 | ath10k_pci_warm_reset_cpu(ar); |
| 2098 | ath10k_pci_init_pipes(ar); |
| 2099 | ath10k_pci_wait_for_target_init(ar); |
Michal Kazior | de01357 | 2014-05-14 16:56:16 +0300 | [diff] [blame] | 2100 | |
Michal Kazior | 61c1648 | 2014-10-28 10:32:06 +0100 | [diff] [blame] | 2101 | ath10k_pci_warm_reset_clear_lf(ar); |
| 2102 | ath10k_pci_warm_reset_ce(ar); |
| 2103 | ath10k_pci_warm_reset_cpu(ar); |
| 2104 | ath10k_pci_init_pipes(ar); |
Michal Kazior | fc36e3f | 2014-02-10 17:14:22 +0100 | [diff] [blame] | 2105 | |
Michal Kazior | 61c1648 | 2014-10-28 10:32:06 +0100 | [diff] [blame] | 2106 | ret = ath10k_pci_wait_for_target_init(ar); |
| 2107 | if (ret) { |
| 2108 | ath10k_warn(ar, "failed to wait for target init: %d\n", ret); |
| 2109 | return ret; |
| 2110 | } |
Michal Kazior | fc36e3f | 2014-02-10 17:14:22 +0100 | [diff] [blame] | 2111 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2112 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot warm reset complete\n"); |
Michal Kazior | fc36e3f | 2014-02-10 17:14:22 +0100 | [diff] [blame] | 2113 | |
Michal Kazior | c0c378f | 2014-08-07 11:03:28 +0200 | [diff] [blame] | 2114 | return 0; |
Michal Kazior | fc36e3f | 2014-02-10 17:14:22 +0100 | [diff] [blame] | 2115 | } |
| 2116 | |
Michal Kazior | d63955b | 2015-01-24 12:14:49 +0200 | [diff] [blame] | 2117 | static int ath10k_pci_qca988x_chip_reset(struct ath10k *ar) |
Michal Kazior | 0bc14d0 | 2014-10-28 10:32:07 +0100 | [diff] [blame] | 2118 | { |
| 2119 | int i, ret; |
| 2120 | u32 val; |
| 2121 | |
Michal Kazior | d63955b | 2015-01-24 12:14:49 +0200 | [diff] [blame] | 2122 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot 988x chip reset\n"); |
Michal Kazior | 0bc14d0 | 2014-10-28 10:32:07 +0100 | [diff] [blame] | 2123 | |
| 2124 | /* Some hardware revisions (e.g. CUS223v2) has issues with cold reset. |
| 2125 | * It is thus preferred to use warm reset which is safer but may not be |
| 2126 | * able to recover the device from all possible fail scenarios. |
| 2127 | * |
| 2128 | * Warm reset doesn't always work on first try so attempt it a few |
| 2129 | * times before giving up. |
| 2130 | */ |
| 2131 | for (i = 0; i < ATH10K_PCI_NUM_WARM_RESET_ATTEMPTS; i++) { |
| 2132 | ret = ath10k_pci_warm_reset(ar); |
| 2133 | if (ret) { |
| 2134 | ath10k_warn(ar, "failed to warm reset attempt %d of %d: %d\n", |
| 2135 | i + 1, ATH10K_PCI_NUM_WARM_RESET_ATTEMPTS, |
| 2136 | ret); |
| 2137 | continue; |
| 2138 | } |
| 2139 | |
| 2140 | /* FIXME: Sometimes copy engine doesn't recover after warm |
| 2141 | * reset. In most cases this needs cold reset. In some of these |
| 2142 | * cases the device is in such a state that a cold reset may |
| 2143 | * lock up the host. |
| 2144 | * |
| 2145 | * Reading any host interest register via copy engine is |
| 2146 | * sufficient to verify if device is capable of booting |
| 2147 | * firmware blob. |
| 2148 | */ |
| 2149 | ret = ath10k_pci_init_pipes(ar); |
| 2150 | if (ret) { |
| 2151 | ath10k_warn(ar, "failed to init copy engine: %d\n", |
| 2152 | ret); |
| 2153 | continue; |
| 2154 | } |
| 2155 | |
| 2156 | ret = ath10k_pci_diag_read32(ar, QCA988X_HOST_INTEREST_ADDRESS, |
| 2157 | &val); |
| 2158 | if (ret) { |
| 2159 | ath10k_warn(ar, "failed to poke copy engine: %d\n", |
| 2160 | ret); |
| 2161 | continue; |
| 2162 | } |
| 2163 | |
| 2164 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot chip reset complete (warm)\n"); |
| 2165 | return 0; |
| 2166 | } |
| 2167 | |
| 2168 | if (ath10k_pci_reset_mode == ATH10K_PCI_RESET_WARM_ONLY) { |
| 2169 | ath10k_warn(ar, "refusing cold reset as requested\n"); |
| 2170 | return -EPERM; |
| 2171 | } |
| 2172 | |
| 2173 | ret = ath10k_pci_cold_reset(ar); |
| 2174 | if (ret) { |
| 2175 | ath10k_warn(ar, "failed to cold reset: %d\n", ret); |
| 2176 | return ret; |
| 2177 | } |
| 2178 | |
| 2179 | ret = ath10k_pci_wait_for_target_init(ar); |
| 2180 | if (ret) { |
| 2181 | ath10k_warn(ar, "failed to wait for target after cold reset: %d\n", |
| 2182 | ret); |
| 2183 | return ret; |
| 2184 | } |
| 2185 | |
Michal Kazior | d63955b | 2015-01-24 12:14:49 +0200 | [diff] [blame] | 2186 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot qca988x chip reset complete (cold)\n"); |
Michal Kazior | 0bc14d0 | 2014-10-28 10:32:07 +0100 | [diff] [blame] | 2187 | |
| 2188 | return 0; |
| 2189 | } |
| 2190 | |
Michal Kazior | d63955b | 2015-01-24 12:14:49 +0200 | [diff] [blame] | 2191 | static int ath10k_pci_qca6174_chip_reset(struct ath10k *ar) |
| 2192 | { |
| 2193 | int ret; |
| 2194 | |
| 2195 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot qca6174 chip reset\n"); |
| 2196 | |
| 2197 | /* FIXME: QCA6174 requires cold + warm reset to work. */ |
| 2198 | |
| 2199 | ret = ath10k_pci_cold_reset(ar); |
| 2200 | if (ret) { |
| 2201 | ath10k_warn(ar, "failed to cold reset: %d\n", ret); |
| 2202 | return ret; |
| 2203 | } |
| 2204 | |
| 2205 | ret = ath10k_pci_wait_for_target_init(ar); |
| 2206 | if (ret) { |
| 2207 | ath10k_warn(ar, "failed to wait for target after cold reset: %d\n", |
| 2208 | ret); |
| 2209 | return ret; |
| 2210 | } |
| 2211 | |
| 2212 | ret = ath10k_pci_warm_reset(ar); |
| 2213 | if (ret) { |
| 2214 | ath10k_warn(ar, "failed to warm reset: %d\n", ret); |
| 2215 | return ret; |
| 2216 | } |
| 2217 | |
| 2218 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot qca6174 chip reset complete (cold)\n"); |
| 2219 | |
| 2220 | return 0; |
| 2221 | } |
| 2222 | |
| 2223 | static int ath10k_pci_chip_reset(struct ath10k *ar) |
| 2224 | { |
| 2225 | if (QCA_REV_988X(ar)) |
| 2226 | return ath10k_pci_qca988x_chip_reset(ar); |
| 2227 | else if (QCA_REV_6174(ar)) |
| 2228 | return ath10k_pci_qca6174_chip_reset(ar); |
| 2229 | else |
| 2230 | return -ENOTSUPP; |
| 2231 | } |
| 2232 | |
Michal Kazior | 0bc14d0 | 2014-10-28 10:32:07 +0100 | [diff] [blame] | 2233 | static int ath10k_pci_hif_power_up(struct ath10k *ar) |
Michal Kazior | 8c5c536 | 2013-07-16 09:38:50 +0200 | [diff] [blame] | 2234 | { |
Janusz Dziedzic | 76d870e | 2015-05-18 09:38:16 +0000 | [diff] [blame] | 2235 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
Michal Kazior | 8c5c536 | 2013-07-16 09:38:50 +0200 | [diff] [blame] | 2236 | int ret; |
| 2237 | |
Michal Kazior | 0bc14d0 | 2014-10-28 10:32:07 +0100 | [diff] [blame] | 2238 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif power up\n"); |
| 2239 | |
Janusz Dziedzic | 76d870e | 2015-05-18 09:38:16 +0000 | [diff] [blame] | 2240 | pcie_capability_read_word(ar_pci->pdev, PCI_EXP_LNKCTL, |
| 2241 | &ar_pci->link_ctl); |
| 2242 | pcie_capability_write_word(ar_pci->pdev, PCI_EXP_LNKCTL, |
| 2243 | ar_pci->link_ctl & ~PCI_EXP_LNKCTL_ASPMC); |
| 2244 | |
Michal Kazior | 8c5c536 | 2013-07-16 09:38:50 +0200 | [diff] [blame] | 2245 | /* |
| 2246 | * Bring the target up cleanly. |
| 2247 | * |
| 2248 | * The target may be in an undefined state with an AUX-powered Target |
| 2249 | * and a Host in WoW mode. If the Host crashes, loses power, or is |
| 2250 | * restarted (without unloading the driver) then the Target is left |
| 2251 | * (aux) powered and running. On a subsequent driver load, the Target |
| 2252 | * is in an unexpected state. We try to catch that here in order to |
| 2253 | * reset the Target and retry the probe. |
| 2254 | */ |
Michal Kazior | 0bc14d0 | 2014-10-28 10:32:07 +0100 | [diff] [blame] | 2255 | ret = ath10k_pci_chip_reset(ar); |
Michal Kazior | 5b2589f | 2013-11-08 08:01:30 +0100 | [diff] [blame] | 2256 | if (ret) { |
Michal Kazior | a2fa880 | 2015-01-12 15:29:37 +0100 | [diff] [blame] | 2257 | if (ath10k_pci_has_fw_crashed(ar)) { |
| 2258 | ath10k_warn(ar, "firmware crashed during chip reset\n"); |
| 2259 | ath10k_pci_fw_crashed_clear(ar); |
| 2260 | ath10k_pci_fw_crashed_dump(ar); |
| 2261 | } |
| 2262 | |
Michal Kazior | 0bc14d0 | 2014-10-28 10:32:07 +0100 | [diff] [blame] | 2263 | ath10k_err(ar, "failed to reset chip: %d\n", ret); |
Bartosz Markowski | 707b1bbd | 2014-10-31 09:03:43 +0100 | [diff] [blame] | 2264 | goto err_sleep; |
Michal Kazior | 5b2589f | 2013-11-08 08:01:30 +0100 | [diff] [blame] | 2265 | } |
Michal Kazior | 8c5c536 | 2013-07-16 09:38:50 +0200 | [diff] [blame] | 2266 | |
Michal Kazior | 84cbf3a | 2014-10-20 14:14:39 +0200 | [diff] [blame] | 2267 | ret = ath10k_pci_init_pipes(ar); |
Michal Kazior | 8c5c536 | 2013-07-16 09:38:50 +0200 | [diff] [blame] | 2268 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2269 | ath10k_err(ar, "failed to initialize CE: %d\n", ret); |
Bartosz Markowski | 707b1bbd | 2014-10-31 09:03:43 +0100 | [diff] [blame] | 2270 | goto err_sleep; |
Michal Kazior | ab977bd | 2013-11-25 14:06:26 +0100 | [diff] [blame] | 2271 | } |
| 2272 | |
Michal Kazior | 98563d5 | 2013-11-08 08:01:33 +0100 | [diff] [blame] | 2273 | ret = ath10k_pci_init_config(ar); |
| 2274 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2275 | ath10k_err(ar, "failed to setup init config: %d\n", ret); |
Michal Kazior | 5c771e7 | 2014-08-22 14:23:34 +0200 | [diff] [blame] | 2276 | goto err_ce; |
Michal Kazior | 98563d5 | 2013-11-08 08:01:33 +0100 | [diff] [blame] | 2277 | } |
Michal Kazior | 8c5c536 | 2013-07-16 09:38:50 +0200 | [diff] [blame] | 2278 | |
| 2279 | ret = ath10k_pci_wake_target_cpu(ar); |
| 2280 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2281 | ath10k_err(ar, "could not wake up target CPU: %d\n", ret); |
Michal Kazior | 5c771e7 | 2014-08-22 14:23:34 +0200 | [diff] [blame] | 2282 | goto err_ce; |
Michal Kazior | 8c5c536 | 2013-07-16 09:38:50 +0200 | [diff] [blame] | 2283 | } |
| 2284 | |
| 2285 | return 0; |
| 2286 | |
| 2287 | err_ce: |
| 2288 | ath10k_pci_ce_deinit(ar); |
Michal Kazior | 0bc14d0 | 2014-10-28 10:32:07 +0100 | [diff] [blame] | 2289 | |
Bartosz Markowski | 707b1bbd | 2014-10-31 09:03:43 +0100 | [diff] [blame] | 2290 | err_sleep: |
Michal Kazior | 8c5c536 | 2013-07-16 09:38:50 +0200 | [diff] [blame] | 2291 | return ret; |
| 2292 | } |
| 2293 | |
| 2294 | static void ath10k_pci_hif_power_down(struct ath10k *ar) |
| 2295 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2296 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif power down\n"); |
Bartosz Markowski | 8cc8df9 | 2013-08-02 09:58:49 +0200 | [diff] [blame] | 2297 | |
Michal Kazior | c011b28 | 2014-10-28 10:32:08 +0100 | [diff] [blame] | 2298 | /* Currently hif_power_up performs effectively a reset and hif_stop |
| 2299 | * resets the chip as well so there's no point in resetting here. |
| 2300 | */ |
Michal Kazior | 8c5c536 | 2013-07-16 09:38:50 +0200 | [diff] [blame] | 2301 | } |
| 2302 | |
Michal Kazior | 8cd13ca | 2013-07-16 09:38:54 +0200 | [diff] [blame] | 2303 | #ifdef CONFIG_PM |
| 2304 | |
Michal Kazior | 8cd13ca | 2013-07-16 09:38:54 +0200 | [diff] [blame] | 2305 | static int ath10k_pci_hif_suspend(struct ath10k *ar) |
| 2306 | { |
Michal Kazior | 77258d4 | 2015-05-18 09:38:18 +0000 | [diff] [blame] | 2307 | /* The grace timer can still be counting down and ar->ps_awake be true. |
| 2308 | * It is known that the device may be asleep after resuming regardless |
| 2309 | * of the SoC powersave state before suspending. Hence make sure the |
| 2310 | * device is asleep before proceeding. |
| 2311 | */ |
| 2312 | ath10k_pci_sleep_sync(ar); |
Michal Kazior | 320e14b | 2015-03-02 13:22:13 +0100 | [diff] [blame] | 2313 | |
Michal Kazior | 8cd13ca | 2013-07-16 09:38:54 +0200 | [diff] [blame] | 2314 | return 0; |
| 2315 | } |
| 2316 | |
| 2317 | static int ath10k_pci_hif_resume(struct ath10k *ar) |
| 2318 | { |
| 2319 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 2320 | struct pci_dev *pdev = ar_pci->pdev; |
| 2321 | u32 val; |
| 2322 | |
Michal Kazior | 9ff4be9 | 2015-03-02 13:22:14 +0100 | [diff] [blame] | 2323 | /* Suspend/Resume resets the PCI configuration space, so we have to |
| 2324 | * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries |
| 2325 | * from interfering with C3 CPU state. pci_restore_state won't help |
| 2326 | * here since it only restores the first 64 bytes pci config header. |
| 2327 | */ |
| 2328 | pci_read_config_dword(pdev, 0x40, &val); |
| 2329 | if ((val & 0x0000ff00) != 0) |
| 2330 | pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); |
Michal Kazior | 8cd13ca | 2013-07-16 09:38:54 +0200 | [diff] [blame] | 2331 | |
Michal Kazior | 77258d4 | 2015-05-18 09:38:18 +0000 | [diff] [blame] | 2332 | return 0; |
Michal Kazior | 8cd13ca | 2013-07-16 09:38:54 +0200 | [diff] [blame] | 2333 | } |
| 2334 | #endif |
| 2335 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2336 | static const struct ath10k_hif_ops ath10k_pci_hif_ops = { |
Michal Kazior | 726346f | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 2337 | .tx_sg = ath10k_pci_hif_tx_sg, |
Kalle Valo | eef2540 | 2014-09-24 14:16:52 +0300 | [diff] [blame] | 2338 | .diag_read = ath10k_pci_hif_diag_read, |
Yanbo Li | 9f65ad2 | 2014-11-25 12:24:48 +0200 | [diff] [blame] | 2339 | .diag_write = ath10k_pci_diag_write_mem, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2340 | .exchange_bmi_msg = ath10k_pci_hif_exchange_bmi_msg, |
| 2341 | .start = ath10k_pci_hif_start, |
| 2342 | .stop = ath10k_pci_hif_stop, |
| 2343 | .map_service_to_pipe = ath10k_pci_hif_map_service_to_pipe, |
| 2344 | .get_default_pipe = ath10k_pci_hif_get_default_pipe, |
| 2345 | .send_complete_check = ath10k_pci_hif_send_complete_check, |
Michal Kazior | e799bbf | 2013-07-05 16:15:12 +0300 | [diff] [blame] | 2346 | .set_callbacks = ath10k_pci_hif_set_callbacks, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2347 | .get_free_queue_number = ath10k_pci_hif_get_free_queue_number, |
Michal Kazior | 8c5c536 | 2013-07-16 09:38:50 +0200 | [diff] [blame] | 2348 | .power_up = ath10k_pci_hif_power_up, |
| 2349 | .power_down = ath10k_pci_hif_power_down, |
Yanbo Li | 077a380 | 2014-11-25 12:24:33 +0200 | [diff] [blame] | 2350 | .read32 = ath10k_pci_read32, |
| 2351 | .write32 = ath10k_pci_write32, |
Michal Kazior | 8cd13ca | 2013-07-16 09:38:54 +0200 | [diff] [blame] | 2352 | #ifdef CONFIG_PM |
| 2353 | .suspend = ath10k_pci_hif_suspend, |
| 2354 | .resume = ath10k_pci_hif_resume, |
| 2355 | #endif |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2356 | }; |
| 2357 | |
| 2358 | static void ath10k_pci_ce_tasklet(unsigned long ptr) |
| 2359 | { |
Michal Kazior | 87263e5 | 2013-08-27 13:08:01 +0200 | [diff] [blame] | 2360 | struct ath10k_pci_pipe *pipe = (struct ath10k_pci_pipe *)ptr; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2361 | struct ath10k_pci *ar_pci = pipe->ar_pci; |
| 2362 | |
| 2363 | ath10k_ce_per_engine_service(ar_pci->ar, pipe->pipe_num); |
| 2364 | } |
| 2365 | |
| 2366 | static void ath10k_msi_err_tasklet(unsigned long data) |
| 2367 | { |
| 2368 | struct ath10k *ar = (struct ath10k *)data; |
| 2369 | |
Michal Kazior | 5c771e7 | 2014-08-22 14:23:34 +0200 | [diff] [blame] | 2370 | if (!ath10k_pci_has_fw_crashed(ar)) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2371 | ath10k_warn(ar, "received unsolicited fw crash interrupt\n"); |
Michal Kazior | 5c771e7 | 2014-08-22 14:23:34 +0200 | [diff] [blame] | 2372 | return; |
| 2373 | } |
| 2374 | |
Michal Kazior | 6f3b7ff | 2015-01-24 12:14:52 +0200 | [diff] [blame] | 2375 | ath10k_pci_irq_disable(ar); |
Michal Kazior | 5c771e7 | 2014-08-22 14:23:34 +0200 | [diff] [blame] | 2376 | ath10k_pci_fw_crashed_clear(ar); |
| 2377 | ath10k_pci_fw_crashed_dump(ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2378 | } |
| 2379 | |
| 2380 | /* |
| 2381 | * Handler for a per-engine interrupt on a PARTICULAR CE. |
| 2382 | * This is used in cases where each CE has a private MSI interrupt. |
| 2383 | */ |
| 2384 | static irqreturn_t ath10k_pci_per_engine_handler(int irq, void *arg) |
| 2385 | { |
| 2386 | struct ath10k *ar = arg; |
| 2387 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 2388 | int ce_id = irq - ar_pci->pdev->irq - MSI_ASSIGN_CE_INITIAL; |
| 2389 | |
Dan Carpenter | e574267 | 2013-06-18 10:28:46 +0300 | [diff] [blame] | 2390 | if (ce_id < 0 || ce_id >= ARRAY_SIZE(ar_pci->pipe_info)) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2391 | ath10k_warn(ar, "unexpected/invalid irq %d ce_id %d\n", irq, |
| 2392 | ce_id); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2393 | return IRQ_HANDLED; |
| 2394 | } |
| 2395 | |
| 2396 | /* |
| 2397 | * NOTE: We are able to derive ce_id from irq because we |
| 2398 | * use a one-to-one mapping for CE's 0..5. |
| 2399 | * CE's 6 & 7 do not use interrupts at all. |
| 2400 | * |
| 2401 | * This mapping must be kept in sync with the mapping |
| 2402 | * used by firmware. |
| 2403 | */ |
| 2404 | tasklet_schedule(&ar_pci->pipe_info[ce_id].intr); |
| 2405 | return IRQ_HANDLED; |
| 2406 | } |
| 2407 | |
| 2408 | static irqreturn_t ath10k_pci_msi_fw_handler(int irq, void *arg) |
| 2409 | { |
| 2410 | struct ath10k *ar = arg; |
| 2411 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 2412 | |
| 2413 | tasklet_schedule(&ar_pci->msi_fw_err); |
| 2414 | return IRQ_HANDLED; |
| 2415 | } |
| 2416 | |
| 2417 | /* |
| 2418 | * Top-level interrupt handler for all PCI interrupts from a Target. |
| 2419 | * When a block of MSI interrupts is allocated, this top-level handler |
| 2420 | * is not used; instead, we directly call the correct sub-handler. |
| 2421 | */ |
| 2422 | static irqreturn_t ath10k_pci_interrupt_handler(int irq, void *arg) |
| 2423 | { |
| 2424 | struct ath10k *ar = arg; |
| 2425 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 2426 | |
| 2427 | if (ar_pci->num_msi_intrs == 0) { |
Michal Kazior | e539887 | 2013-11-25 14:06:20 +0100 | [diff] [blame] | 2428 | if (!ath10k_pci_irq_pending(ar)) |
| 2429 | return IRQ_NONE; |
| 2430 | |
Michal Kazior | 2685218 | 2013-11-25 14:06:25 +0100 | [diff] [blame] | 2431 | ath10k_pci_disable_and_clear_legacy_irq(ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2432 | } |
| 2433 | |
| 2434 | tasklet_schedule(&ar_pci->intr_tq); |
| 2435 | |
| 2436 | return IRQ_HANDLED; |
| 2437 | } |
| 2438 | |
| 2439 | static void ath10k_pci_tasklet(unsigned long data) |
| 2440 | { |
| 2441 | struct ath10k *ar = (struct ath10k *)data; |
| 2442 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 2443 | |
Michal Kazior | 5c771e7 | 2014-08-22 14:23:34 +0200 | [diff] [blame] | 2444 | if (ath10k_pci_has_fw_crashed(ar)) { |
Michal Kazior | 6f3b7ff | 2015-01-24 12:14:52 +0200 | [diff] [blame] | 2445 | ath10k_pci_irq_disable(ar); |
Michal Kazior | 5c771e7 | 2014-08-22 14:23:34 +0200 | [diff] [blame] | 2446 | ath10k_pci_fw_crashed_clear(ar); |
| 2447 | ath10k_pci_fw_crashed_dump(ar); |
| 2448 | return; |
| 2449 | } |
| 2450 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2451 | ath10k_ce_per_engine_service_any(ar); |
| 2452 | |
Michal Kazior | 2685218 | 2013-11-25 14:06:25 +0100 | [diff] [blame] | 2453 | /* Re-enable legacy irq that was disabled in the irq handler */ |
| 2454 | if (ar_pci->num_msi_intrs == 0) |
| 2455 | ath10k_pci_enable_legacy_irq(ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2456 | } |
| 2457 | |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2458 | static int ath10k_pci_request_irq_msix(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2459 | { |
| 2460 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2461 | int ret, i; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2462 | |
| 2463 | ret = request_irq(ar_pci->pdev->irq + MSI_ASSIGN_FW, |
| 2464 | ath10k_pci_msi_fw_handler, |
| 2465 | IRQF_SHARED, "ath10k_pci", ar); |
Michal Kazior | 591ecdb | 2013-07-31 10:55:15 +0200 | [diff] [blame] | 2466 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2467 | ath10k_warn(ar, "failed to request MSI-X fw irq %d: %d\n", |
Michal Kazior | 591ecdb | 2013-07-31 10:55:15 +0200 | [diff] [blame] | 2468 | ar_pci->pdev->irq + MSI_ASSIGN_FW, ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2469 | return ret; |
Michal Kazior | 591ecdb | 2013-07-31 10:55:15 +0200 | [diff] [blame] | 2470 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2471 | |
| 2472 | for (i = MSI_ASSIGN_CE_INITIAL; i <= MSI_ASSIGN_CE_MAX; i++) { |
| 2473 | ret = request_irq(ar_pci->pdev->irq + i, |
| 2474 | ath10k_pci_per_engine_handler, |
| 2475 | IRQF_SHARED, "ath10k_pci", ar); |
| 2476 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2477 | ath10k_warn(ar, "failed to request MSI-X ce irq %d: %d\n", |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2478 | ar_pci->pdev->irq + i, ret); |
| 2479 | |
Michal Kazior | 87b1423 | 2013-06-26 08:50:50 +0200 | [diff] [blame] | 2480 | for (i--; i >= MSI_ASSIGN_CE_INITIAL; i--) |
| 2481 | free_irq(ar_pci->pdev->irq + i, ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2482 | |
Michal Kazior | 87b1423 | 2013-06-26 08:50:50 +0200 | [diff] [blame] | 2483 | free_irq(ar_pci->pdev->irq + MSI_ASSIGN_FW, ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2484 | return ret; |
| 2485 | } |
| 2486 | } |
| 2487 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2488 | return 0; |
| 2489 | } |
| 2490 | |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2491 | static int ath10k_pci_request_irq_msi(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2492 | { |
| 2493 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 2494 | int ret; |
| 2495 | |
| 2496 | ret = request_irq(ar_pci->pdev->irq, |
| 2497 | ath10k_pci_interrupt_handler, |
| 2498 | IRQF_SHARED, "ath10k_pci", ar); |
Kalle Valo | f378274 | 2013-10-17 11:36:15 +0300 | [diff] [blame] | 2499 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2500 | ath10k_warn(ar, "failed to request MSI irq %d: %d\n", |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2501 | ar_pci->pdev->irq, ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2502 | return ret; |
Kalle Valo | f378274 | 2013-10-17 11:36:15 +0300 | [diff] [blame] | 2503 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2504 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2505 | return 0; |
| 2506 | } |
| 2507 | |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2508 | static int ath10k_pci_request_irq_legacy(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2509 | { |
| 2510 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2511 | int ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2512 | |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2513 | ret = request_irq(ar_pci->pdev->irq, |
| 2514 | ath10k_pci_interrupt_handler, |
| 2515 | IRQF_SHARED, "ath10k_pci", ar); |
Kalle Valo | f378274 | 2013-10-17 11:36:15 +0300 | [diff] [blame] | 2516 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2517 | ath10k_warn(ar, "failed to request legacy irq %d: %d\n", |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2518 | ar_pci->pdev->irq, ret); |
Kalle Valo | f378274 | 2013-10-17 11:36:15 +0300 | [diff] [blame] | 2519 | return ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2520 | } |
| 2521 | |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2522 | return 0; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2523 | } |
| 2524 | |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2525 | static int ath10k_pci_request_irq(struct ath10k *ar) |
| 2526 | { |
| 2527 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 2528 | |
| 2529 | switch (ar_pci->num_msi_intrs) { |
| 2530 | case 0: |
| 2531 | return ath10k_pci_request_irq_legacy(ar); |
| 2532 | case 1: |
| 2533 | return ath10k_pci_request_irq_msi(ar); |
| 2534 | case MSI_NUM_REQUEST: |
| 2535 | return ath10k_pci_request_irq_msix(ar); |
| 2536 | } |
| 2537 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2538 | ath10k_warn(ar, "unknown irq configuration upon request\n"); |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2539 | return -EINVAL; |
| 2540 | } |
| 2541 | |
| 2542 | static void ath10k_pci_free_irq(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2543 | { |
| 2544 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 2545 | int i; |
| 2546 | |
| 2547 | /* There's at least one interrupt irregardless whether its legacy INTR |
| 2548 | * or MSI or MSI-X */ |
| 2549 | for (i = 0; i < max(1, ar_pci->num_msi_intrs); i++) |
| 2550 | free_irq(ar_pci->pdev->irq + i, ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2551 | } |
| 2552 | |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2553 | static void ath10k_pci_init_irq_tasklets(struct ath10k *ar) |
| 2554 | { |
| 2555 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 2556 | int i; |
| 2557 | |
| 2558 | tasklet_init(&ar_pci->intr_tq, ath10k_pci_tasklet, (unsigned long)ar); |
| 2559 | tasklet_init(&ar_pci->msi_fw_err, ath10k_msi_err_tasklet, |
| 2560 | (unsigned long)ar); |
| 2561 | |
| 2562 | for (i = 0; i < CE_COUNT; i++) { |
| 2563 | ar_pci->pipe_info[i].ar_pci = ar_pci; |
| 2564 | tasklet_init(&ar_pci->pipe_info[i].intr, ath10k_pci_ce_tasklet, |
| 2565 | (unsigned long)&ar_pci->pipe_info[i]); |
| 2566 | } |
| 2567 | } |
| 2568 | |
| 2569 | static int ath10k_pci_init_irq(struct ath10k *ar) |
| 2570 | { |
| 2571 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 2572 | int ret; |
| 2573 | |
| 2574 | ath10k_pci_init_irq_tasklets(ar); |
| 2575 | |
Michal Kazior | 403d627 | 2014-08-22 14:23:31 +0200 | [diff] [blame] | 2576 | if (ath10k_pci_irq_mode != ATH10K_PCI_IRQ_AUTO) |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2577 | ath10k_info(ar, "limiting irq mode to: %d\n", |
| 2578 | ath10k_pci_irq_mode); |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2579 | |
| 2580 | /* Try MSI-X */ |
Michal Kazior | 0edf257 | 2014-08-07 11:03:29 +0200 | [diff] [blame] | 2581 | if (ath10k_pci_irq_mode == ATH10K_PCI_IRQ_AUTO) { |
Michal Kazior | cfe9c45 | 2013-11-25 14:06:27 +0100 | [diff] [blame] | 2582 | ar_pci->num_msi_intrs = MSI_NUM_REQUEST; |
Alexander Gordeev | 5ad6867 | 2014-02-13 17:50:02 +0200 | [diff] [blame] | 2583 | ret = pci_enable_msi_range(ar_pci->pdev, ar_pci->num_msi_intrs, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 2584 | ar_pci->num_msi_intrs); |
Alexander Gordeev | 5ad6867 | 2014-02-13 17:50:02 +0200 | [diff] [blame] | 2585 | if (ret > 0) |
Michal Kazior | cfe9c45 | 2013-11-25 14:06:27 +0100 | [diff] [blame] | 2586 | return 0; |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2587 | |
Michal Kazior | cfe9c45 | 2013-11-25 14:06:27 +0100 | [diff] [blame] | 2588 | /* fall-through */ |
| 2589 | } |
| 2590 | |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2591 | /* Try MSI */ |
Michal Kazior | cfe9c45 | 2013-11-25 14:06:27 +0100 | [diff] [blame] | 2592 | if (ath10k_pci_irq_mode != ATH10K_PCI_IRQ_LEGACY) { |
| 2593 | ar_pci->num_msi_intrs = 1; |
| 2594 | ret = pci_enable_msi(ar_pci->pdev); |
| 2595 | if (ret == 0) |
| 2596 | return 0; |
| 2597 | |
| 2598 | /* fall-through */ |
| 2599 | } |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2600 | |
| 2601 | /* Try legacy irq |
| 2602 | * |
| 2603 | * A potential race occurs here: The CORE_BASE write |
| 2604 | * depends on target correctly decoding AXI address but |
| 2605 | * host won't know when target writes BAR to CORE_CTRL. |
| 2606 | * This write might get lost if target has NOT written BAR. |
| 2607 | * For now, fix the race by repeating the write in below |
| 2608 | * synchronization checking. */ |
| 2609 | ar_pci->num_msi_intrs = 0; |
| 2610 | |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2611 | ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + PCIE_INTR_ENABLE_ADDRESS, |
| 2612 | PCIE_INTR_FIRMWARE_MASK | PCIE_INTR_CE_MASK_ALL); |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2613 | |
| 2614 | return 0; |
| 2615 | } |
| 2616 | |
Michal Kazior | c0c378f | 2014-08-07 11:03:28 +0200 | [diff] [blame] | 2617 | static void ath10k_pci_deinit_irq_legacy(struct ath10k *ar) |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2618 | { |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2619 | ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + PCIE_INTR_ENABLE_ADDRESS, |
| 2620 | 0); |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2621 | } |
| 2622 | |
| 2623 | static int ath10k_pci_deinit_irq(struct ath10k *ar) |
| 2624 | { |
| 2625 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 2626 | |
| 2627 | switch (ar_pci->num_msi_intrs) { |
| 2628 | case 0: |
Michal Kazior | c0c378f | 2014-08-07 11:03:28 +0200 | [diff] [blame] | 2629 | ath10k_pci_deinit_irq_legacy(ar); |
| 2630 | return 0; |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2631 | case 1: |
| 2632 | /* fall-through */ |
| 2633 | case MSI_NUM_REQUEST: |
| 2634 | pci_disable_msi(ar_pci->pdev); |
| 2635 | return 0; |
Alexander Gordeev | bb8b621 | 2014-02-13 17:50:01 +0200 | [diff] [blame] | 2636 | default: |
| 2637 | pci_disable_msi(ar_pci->pdev); |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2638 | } |
| 2639 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2640 | ath10k_warn(ar, "unknown irq configuration upon deinit\n"); |
Michal Kazior | fc15ca1 | 2013-11-25 14:06:21 +0100 | [diff] [blame] | 2641 | return -EINVAL; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2642 | } |
| 2643 | |
Michal Kazior | d7fb47f | 2013-11-08 08:01:26 +0100 | [diff] [blame] | 2644 | static int ath10k_pci_wait_for_target_init(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2645 | { |
| 2646 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
Kalle Valo | 0399eca | 2014-03-28 09:32:21 +0200 | [diff] [blame] | 2647 | unsigned long timeout; |
Kalle Valo | 0399eca | 2014-03-28 09:32:21 +0200 | [diff] [blame] | 2648 | u32 val; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2649 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2650 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot waiting target to initialise\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2651 | |
Kalle Valo | 0399eca | 2014-03-28 09:32:21 +0200 | [diff] [blame] | 2652 | timeout = jiffies + msecs_to_jiffies(ATH10K_PCI_TARGET_WAIT); |
| 2653 | |
| 2654 | do { |
| 2655 | val = ath10k_pci_read32(ar, FW_INDICATOR_ADDRESS); |
| 2656 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2657 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot target indicator %x\n", |
| 2658 | val); |
Kalle Valo | 50f87a6 | 2014-03-28 09:32:52 +0200 | [diff] [blame] | 2659 | |
Kalle Valo | 0399eca | 2014-03-28 09:32:21 +0200 | [diff] [blame] | 2660 | /* target should never return this */ |
| 2661 | if (val == 0xffffffff) |
| 2662 | continue; |
| 2663 | |
Michal Kazior | 7710cd2 | 2014-04-23 19:30:04 +0300 | [diff] [blame] | 2664 | /* the device has crashed so don't bother trying anymore */ |
| 2665 | if (val & FW_IND_EVENT_PENDING) |
| 2666 | break; |
| 2667 | |
Kalle Valo | 0399eca | 2014-03-28 09:32:21 +0200 | [diff] [blame] | 2668 | if (val & FW_IND_INITIALIZED) |
| 2669 | break; |
| 2670 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2671 | if (ar_pci->num_msi_intrs == 0) |
| 2672 | /* Fix potential race by repeating CORE_BASE writes */ |
Michal Kazior | a428249 | 2014-10-20 14:14:37 +0200 | [diff] [blame] | 2673 | ath10k_pci_enable_legacy_irq(ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2674 | |
Kalle Valo | 0399eca | 2014-03-28 09:32:21 +0200 | [diff] [blame] | 2675 | mdelay(10); |
| 2676 | } while (time_before(jiffies, timeout)); |
| 2677 | |
Michal Kazior | a428249 | 2014-10-20 14:14:37 +0200 | [diff] [blame] | 2678 | ath10k_pci_disable_and_clear_legacy_irq(ar); |
Michal Kazior | 7c0f0e3 | 2014-10-20 14:14:38 +0200 | [diff] [blame] | 2679 | ath10k_pci_irq_msi_fw_mask(ar); |
Michal Kazior | a428249 | 2014-10-20 14:14:37 +0200 | [diff] [blame] | 2680 | |
Michal Kazior | 6a4f6e1 | 2014-04-23 19:30:03 +0300 | [diff] [blame] | 2681 | if (val == 0xffffffff) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2682 | ath10k_err(ar, "failed to read device register, device is gone\n"); |
Michal Kazior | c0c378f | 2014-08-07 11:03:28 +0200 | [diff] [blame] | 2683 | return -EIO; |
Michal Kazior | 6a4f6e1 | 2014-04-23 19:30:03 +0300 | [diff] [blame] | 2684 | } |
| 2685 | |
Michal Kazior | 7710cd2 | 2014-04-23 19:30:04 +0300 | [diff] [blame] | 2686 | if (val & FW_IND_EVENT_PENDING) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2687 | ath10k_warn(ar, "device has crashed during init\n"); |
Michal Kazior | c0c378f | 2014-08-07 11:03:28 +0200 | [diff] [blame] | 2688 | return -ECOMM; |
Michal Kazior | 7710cd2 | 2014-04-23 19:30:04 +0300 | [diff] [blame] | 2689 | } |
| 2690 | |
Michal Kazior | 6a4f6e1 | 2014-04-23 19:30:03 +0300 | [diff] [blame] | 2691 | if (!(val & FW_IND_INITIALIZED)) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2692 | ath10k_err(ar, "failed to receive initialized event from target: %08x\n", |
Kalle Valo | 0399eca | 2014-03-28 09:32:21 +0200 | [diff] [blame] | 2693 | val); |
Michal Kazior | c0c378f | 2014-08-07 11:03:28 +0200 | [diff] [blame] | 2694 | return -ETIMEDOUT; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2695 | } |
| 2696 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2697 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot target initialised\n"); |
Michal Kazior | c0c378f | 2014-08-07 11:03:28 +0200 | [diff] [blame] | 2698 | return 0; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2699 | } |
| 2700 | |
Michal Kazior | fc36e3f | 2014-02-10 17:14:22 +0100 | [diff] [blame] | 2701 | static int ath10k_pci_cold_reset(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2702 | { |
Michal Kazior | c0c378f | 2014-08-07 11:03:28 +0200 | [diff] [blame] | 2703 | int i; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2704 | u32 val; |
| 2705 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2706 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot cold reset\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2707 | |
Ben Greear | f51dbe7 | 2014-09-29 14:41:46 +0300 | [diff] [blame] | 2708 | spin_lock_bh(&ar->data_lock); |
| 2709 | |
| 2710 | ar->stats.fw_cold_reset_counter++; |
| 2711 | |
| 2712 | spin_unlock_bh(&ar->data_lock); |
| 2713 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2714 | /* Put Target, including PCIe, into RESET. */ |
Kalle Valo | e479ed4 | 2013-09-01 10:01:53 +0300 | [diff] [blame] | 2715 | val = ath10k_pci_reg_read32(ar, SOC_GLOBAL_RESET_ADDRESS); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2716 | val |= 1; |
Kalle Valo | e479ed4 | 2013-09-01 10:01:53 +0300 | [diff] [blame] | 2717 | ath10k_pci_reg_write32(ar, SOC_GLOBAL_RESET_ADDRESS, val); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2718 | |
| 2719 | for (i = 0; i < ATH_PCI_RESET_WAIT_MAX; i++) { |
Kalle Valo | e479ed4 | 2013-09-01 10:01:53 +0300 | [diff] [blame] | 2720 | if (ath10k_pci_reg_read32(ar, RTC_STATE_ADDRESS) & |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2721 | RTC_STATE_COLD_RESET_MASK) |
| 2722 | break; |
| 2723 | msleep(1); |
| 2724 | } |
| 2725 | |
| 2726 | /* Pull Target, including PCIe, out of RESET. */ |
| 2727 | val &= ~1; |
Kalle Valo | e479ed4 | 2013-09-01 10:01:53 +0300 | [diff] [blame] | 2728 | ath10k_pci_reg_write32(ar, SOC_GLOBAL_RESET_ADDRESS, val); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2729 | |
| 2730 | for (i = 0; i < ATH_PCI_RESET_WAIT_MAX; i++) { |
Kalle Valo | e479ed4 | 2013-09-01 10:01:53 +0300 | [diff] [blame] | 2731 | if (!(ath10k_pci_reg_read32(ar, RTC_STATE_ADDRESS) & |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2732 | RTC_STATE_COLD_RESET_MASK)) |
| 2733 | break; |
| 2734 | msleep(1); |
| 2735 | } |
| 2736 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2737 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot cold reset complete\n"); |
Kalle Valo | 50f87a6 | 2014-03-28 09:32:52 +0200 | [diff] [blame] | 2738 | |
Michal Kazior | 5b2589f | 2013-11-08 08:01:30 +0100 | [diff] [blame] | 2739 | return 0; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2740 | } |
| 2741 | |
Michal Kazior | 2986e3e | 2014-08-07 11:03:30 +0200 | [diff] [blame] | 2742 | static int ath10k_pci_claim(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2743 | { |
Michal Kazior | 2986e3e | 2014-08-07 11:03:30 +0200 | [diff] [blame] | 2744 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 2745 | struct pci_dev *pdev = ar_pci->pdev; |
Michal Kazior | 2986e3e | 2014-08-07 11:03:30 +0200 | [diff] [blame] | 2746 | int ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2747 | |
| 2748 | pci_set_drvdata(pdev, ar); |
| 2749 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2750 | ret = pci_enable_device(pdev); |
| 2751 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2752 | ath10k_err(ar, "failed to enable pci device: %d\n", ret); |
Michal Kazior | 2986e3e | 2014-08-07 11:03:30 +0200 | [diff] [blame] | 2753 | return ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2754 | } |
| 2755 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2756 | ret = pci_request_region(pdev, BAR_NUM, "ath"); |
| 2757 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2758 | ath10k_err(ar, "failed to request region BAR%d: %d\n", BAR_NUM, |
Michal Kazior | 2986e3e | 2014-08-07 11:03:30 +0200 | [diff] [blame] | 2759 | ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2760 | goto err_device; |
| 2761 | } |
| 2762 | |
Michal Kazior | 2986e3e | 2014-08-07 11:03:30 +0200 | [diff] [blame] | 2763 | /* Target expects 32 bit DMA. Enforce it. */ |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2764 | ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
| 2765 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2766 | ath10k_err(ar, "failed to set dma mask to 32-bit: %d\n", ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2767 | goto err_region; |
| 2768 | } |
| 2769 | |
| 2770 | ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); |
| 2771 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2772 | ath10k_err(ar, "failed to set consistent dma mask to 32-bit: %d\n", |
Michal Kazior | 2986e3e | 2014-08-07 11:03:30 +0200 | [diff] [blame] | 2773 | ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2774 | goto err_region; |
| 2775 | } |
| 2776 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2777 | pci_set_master(pdev); |
| 2778 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2779 | /* Arrange for access to Target SoC registers. */ |
Michal Kazior | aeae5b4 | 2015-06-15 14:46:42 +0300 | [diff] [blame] | 2780 | ar_pci->mem_len = pci_resource_len(pdev, BAR_NUM); |
Michal Kazior | 2986e3e | 2014-08-07 11:03:30 +0200 | [diff] [blame] | 2781 | ar_pci->mem = pci_iomap(pdev, BAR_NUM, 0); |
| 2782 | if (!ar_pci->mem) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2783 | ath10k_err(ar, "failed to iomap BAR%d\n", BAR_NUM); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2784 | ret = -EIO; |
| 2785 | goto err_master; |
| 2786 | } |
| 2787 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2788 | ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot pci_mem 0x%p\n", ar_pci->mem); |
Michal Kazior | 2986e3e | 2014-08-07 11:03:30 +0200 | [diff] [blame] | 2789 | return 0; |
| 2790 | |
| 2791 | err_master: |
| 2792 | pci_clear_master(pdev); |
| 2793 | |
| 2794 | err_region: |
| 2795 | pci_release_region(pdev, BAR_NUM); |
| 2796 | |
| 2797 | err_device: |
| 2798 | pci_disable_device(pdev); |
| 2799 | |
| 2800 | return ret; |
| 2801 | } |
| 2802 | |
| 2803 | static void ath10k_pci_release(struct ath10k *ar) |
| 2804 | { |
| 2805 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); |
| 2806 | struct pci_dev *pdev = ar_pci->pdev; |
| 2807 | |
| 2808 | pci_iounmap(pdev, ar_pci->mem); |
| 2809 | pci_release_region(pdev, BAR_NUM); |
| 2810 | pci_clear_master(pdev); |
| 2811 | pci_disable_device(pdev); |
| 2812 | } |
| 2813 | |
Michal Kazior | 7505f7c | 2014-12-02 10:55:54 +0200 | [diff] [blame] | 2814 | static bool ath10k_pci_chip_is_supported(u32 dev_id, u32 chip_id) |
| 2815 | { |
| 2816 | const struct ath10k_pci_supp_chip *supp_chip; |
| 2817 | int i; |
| 2818 | u32 rev_id = MS(chip_id, SOC_CHIP_ID_REV); |
| 2819 | |
| 2820 | for (i = 0; i < ARRAY_SIZE(ath10k_pci_supp_chips); i++) { |
| 2821 | supp_chip = &ath10k_pci_supp_chips[i]; |
| 2822 | |
| 2823 | if (supp_chip->dev_id == dev_id && |
| 2824 | supp_chip->rev_id == rev_id) |
| 2825 | return true; |
| 2826 | } |
| 2827 | |
| 2828 | return false; |
| 2829 | } |
| 2830 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2831 | static int ath10k_pci_probe(struct pci_dev *pdev, |
| 2832 | const struct pci_device_id *pci_dev) |
| 2833 | { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2834 | int ret = 0; |
| 2835 | struct ath10k *ar; |
| 2836 | struct ath10k_pci *ar_pci; |
Michal Kazior | d63955b | 2015-01-24 12:14:49 +0200 | [diff] [blame] | 2837 | enum ath10k_hw_rev hw_rev; |
Michal Kazior | 2986e3e | 2014-08-07 11:03:30 +0200 | [diff] [blame] | 2838 | u32 chip_id; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2839 | |
Michal Kazior | d63955b | 2015-01-24 12:14:49 +0200 | [diff] [blame] | 2840 | switch (pci_dev->device) { |
| 2841 | case QCA988X_2_0_DEVICE_ID: |
| 2842 | hw_rev = ATH10K_HW_QCA988X; |
| 2843 | break; |
| 2844 | case QCA6174_2_1_DEVICE_ID: |
| 2845 | hw_rev = ATH10K_HW_QCA6174; |
| 2846 | break; |
Vasanthakumar Thiagarajan | 8bd4702 | 2015-06-18 12:31:03 +0530 | [diff] [blame] | 2847 | case QCA99X0_2_0_DEVICE_ID: |
| 2848 | hw_rev = ATH10K_HW_QCA99X0; |
| 2849 | break; |
Michal Kazior | d63955b | 2015-01-24 12:14:49 +0200 | [diff] [blame] | 2850 | default: |
| 2851 | WARN_ON(1); |
| 2852 | return -ENOTSUPP; |
| 2853 | } |
| 2854 | |
| 2855 | ar = ath10k_core_create(sizeof(*ar_pci), &pdev->dev, ATH10K_BUS_PCI, |
| 2856 | hw_rev, &ath10k_pci_hif_ops); |
Michal Kazior | e7b5419 | 2014-08-07 11:03:27 +0200 | [diff] [blame] | 2857 | if (!ar) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2858 | dev_err(&pdev->dev, "failed to allocate core\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2859 | return -ENOMEM; |
Michal Kazior | e7b5419 | 2014-08-07 11:03:27 +0200 | [diff] [blame] | 2860 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2861 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2862 | ath10k_dbg(ar, ATH10K_DBG_PCI, "pci probe\n"); |
| 2863 | |
Michal Kazior | e7b5419 | 2014-08-07 11:03:27 +0200 | [diff] [blame] | 2864 | ar_pci = ath10k_pci_priv(ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2865 | ar_pci->pdev = pdev; |
| 2866 | ar_pci->dev = &pdev->dev; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2867 | ar_pci->ar = ar; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2868 | |
Michal Kazior | de57e2c | 2015-04-17 09:19:17 +0000 | [diff] [blame] | 2869 | if (pdev->subsystem_vendor || pdev->subsystem_device) |
| 2870 | scnprintf(ar->spec_board_id, sizeof(ar->spec_board_id), |
| 2871 | "%04x:%04x:%04x:%04x", |
| 2872 | pdev->vendor, pdev->device, |
| 2873 | pdev->subsystem_vendor, pdev->subsystem_device); |
| 2874 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2875 | spin_lock_init(&ar_pci->ce_lock); |
Michal Kazior | 77258d4 | 2015-05-18 09:38:18 +0000 | [diff] [blame] | 2876 | spin_lock_init(&ar_pci->ps_lock); |
| 2877 | |
Michal Kazior | 728f95e | 2014-08-22 14:33:14 +0200 | [diff] [blame] | 2878 | setup_timer(&ar_pci->rx_post_retry, ath10k_pci_rx_replenish_retry, |
| 2879 | (unsigned long)ar); |
Michal Kazior | 77258d4 | 2015-05-18 09:38:18 +0000 | [diff] [blame] | 2880 | setup_timer(&ar_pci->ps_timer, ath10k_pci_ps_timer, |
| 2881 | (unsigned long)ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2882 | |
Michal Kazior | 2986e3e | 2014-08-07 11:03:30 +0200 | [diff] [blame] | 2883 | ret = ath10k_pci_claim(ar); |
Kalle Valo | e01ae68 | 2013-09-01 11:22:14 +0300 | [diff] [blame] | 2884 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2885 | ath10k_err(ar, "failed to claim device: %d\n", ret); |
Michal Kazior | e7b5419 | 2014-08-07 11:03:27 +0200 | [diff] [blame] | 2886 | goto err_core_destroy; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2887 | } |
| 2888 | |
Michal Kazior | 84cbf3a | 2014-10-20 14:14:39 +0200 | [diff] [blame] | 2889 | ret = ath10k_pci_alloc_pipes(ar); |
Michal Kazior | 25d0dbc | 2014-03-28 10:02:38 +0200 | [diff] [blame] | 2890 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2891 | ath10k_err(ar, "failed to allocate copy engine pipes: %d\n", |
| 2892 | ret); |
Michal Kazior | c0c378f | 2014-08-07 11:03:28 +0200 | [diff] [blame] | 2893 | goto err_sleep; |
Michal Kazior | 25d0dbc | 2014-03-28 10:02:38 +0200 | [diff] [blame] | 2894 | } |
| 2895 | |
Michal Kazior | 403d627 | 2014-08-22 14:23:31 +0200 | [diff] [blame] | 2896 | ath10k_pci_ce_deinit(ar); |
Michal Kazior | 7c0f0e3 | 2014-10-20 14:14:38 +0200 | [diff] [blame] | 2897 | ath10k_pci_irq_disable(ar); |
Michal Kazior | 5c771e7 | 2014-08-22 14:23:34 +0200 | [diff] [blame] | 2898 | |
Michal Kazior | 403d627 | 2014-08-22 14:23:31 +0200 | [diff] [blame] | 2899 | ret = ath10k_pci_init_irq(ar); |
| 2900 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2901 | ath10k_err(ar, "failed to init irqs: %d\n", ret); |
Michal Kazior | 84cbf3a | 2014-10-20 14:14:39 +0200 | [diff] [blame] | 2902 | goto err_free_pipes; |
Michal Kazior | 403d627 | 2014-08-22 14:23:31 +0200 | [diff] [blame] | 2903 | } |
| 2904 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2905 | ath10k_info(ar, "pci irq %s interrupts %d irq_mode %d reset_mode %d\n", |
Michal Kazior | 403d627 | 2014-08-22 14:23:31 +0200 | [diff] [blame] | 2906 | ath10k_pci_get_irq_method(ar), ar_pci->num_msi_intrs, |
| 2907 | ath10k_pci_irq_mode, ath10k_pci_reset_mode); |
| 2908 | |
Michal Kazior | 5c771e7 | 2014-08-22 14:23:34 +0200 | [diff] [blame] | 2909 | ret = ath10k_pci_request_irq(ar); |
Michal Kazior | 403d627 | 2014-08-22 14:23:31 +0200 | [diff] [blame] | 2910 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2911 | ath10k_warn(ar, "failed to request irqs: %d\n", ret); |
Michal Kazior | 403d627 | 2014-08-22 14:23:31 +0200 | [diff] [blame] | 2912 | goto err_deinit_irq; |
| 2913 | } |
| 2914 | |
Michal Kazior | 1a7fecb | 2015-01-24 12:14:48 +0200 | [diff] [blame] | 2915 | ret = ath10k_pci_chip_reset(ar); |
| 2916 | if (ret) { |
| 2917 | ath10k_err(ar, "failed to reset chip: %d\n", ret); |
| 2918 | goto err_free_irq; |
| 2919 | } |
| 2920 | |
| 2921 | chip_id = ath10k_pci_soc_read32(ar, SOC_CHIP_ID_ADDRESS); |
| 2922 | if (chip_id == 0xffffffff) { |
| 2923 | ath10k_err(ar, "failed to get chip id\n"); |
| 2924 | goto err_free_irq; |
| 2925 | } |
| 2926 | |
| 2927 | if (!ath10k_pci_chip_is_supported(pdev->device, chip_id)) { |
| 2928 | ath10k_err(ar, "device %04x with chip_id %08x isn't supported\n", |
| 2929 | pdev->device, chip_id); |
Michal Kazior | d9585a9 | 2015-04-10 13:01:27 +0000 | [diff] [blame] | 2930 | goto err_free_irq; |
Michal Kazior | 1a7fecb | 2015-01-24 12:14:48 +0200 | [diff] [blame] | 2931 | } |
| 2932 | |
Kalle Valo | e01ae68 | 2013-09-01 11:22:14 +0300 | [diff] [blame] | 2933 | ret = ath10k_core_register(ar, chip_id); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2934 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2935 | ath10k_err(ar, "failed to register driver core: %d\n", ret); |
Michal Kazior | 5c771e7 | 2014-08-22 14:23:34 +0200 | [diff] [blame] | 2936 | goto err_free_irq; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2937 | } |
| 2938 | |
| 2939 | return 0; |
| 2940 | |
Michal Kazior | 5c771e7 | 2014-08-22 14:23:34 +0200 | [diff] [blame] | 2941 | err_free_irq: |
| 2942 | ath10k_pci_free_irq(ar); |
Michal Kazior | 2139627 | 2014-08-28 10:24:40 +0200 | [diff] [blame] | 2943 | ath10k_pci_kill_tasklet(ar); |
Michal Kazior | 5c771e7 | 2014-08-22 14:23:34 +0200 | [diff] [blame] | 2944 | |
Michal Kazior | 403d627 | 2014-08-22 14:23:31 +0200 | [diff] [blame] | 2945 | err_deinit_irq: |
| 2946 | ath10k_pci_deinit_irq(ar); |
| 2947 | |
Michal Kazior | 84cbf3a | 2014-10-20 14:14:39 +0200 | [diff] [blame] | 2948 | err_free_pipes: |
| 2949 | ath10k_pci_free_pipes(ar); |
Michal Kazior | 2986e3e | 2014-08-07 11:03:30 +0200 | [diff] [blame] | 2950 | |
Michal Kazior | c0c378f | 2014-08-07 11:03:28 +0200 | [diff] [blame] | 2951 | err_sleep: |
Michal Kazior | 0bcbbe6 | 2015-05-29 07:35:24 +0200 | [diff] [blame] | 2952 | ath10k_pci_sleep_sync(ar); |
Michal Kazior | 2986e3e | 2014-08-07 11:03:30 +0200 | [diff] [blame] | 2953 | ath10k_pci_release(ar); |
| 2954 | |
Michal Kazior | e7b5419 | 2014-08-07 11:03:27 +0200 | [diff] [blame] | 2955 | err_core_destroy: |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2956 | ath10k_core_destroy(ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2957 | |
| 2958 | return ret; |
| 2959 | } |
| 2960 | |
| 2961 | static void ath10k_pci_remove(struct pci_dev *pdev) |
| 2962 | { |
| 2963 | struct ath10k *ar = pci_get_drvdata(pdev); |
| 2964 | struct ath10k_pci *ar_pci; |
| 2965 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2966 | ath10k_dbg(ar, ATH10K_DBG_PCI, "pci remove\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2967 | |
| 2968 | if (!ar) |
| 2969 | return; |
| 2970 | |
| 2971 | ar_pci = ath10k_pci_priv(ar); |
| 2972 | |
| 2973 | if (!ar_pci) |
| 2974 | return; |
| 2975 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2976 | ath10k_core_unregister(ar); |
Michal Kazior | 5c771e7 | 2014-08-22 14:23:34 +0200 | [diff] [blame] | 2977 | ath10k_pci_free_irq(ar); |
Michal Kazior | 2139627 | 2014-08-28 10:24:40 +0200 | [diff] [blame] | 2978 | ath10k_pci_kill_tasklet(ar); |
Michal Kazior | 403d627 | 2014-08-22 14:23:31 +0200 | [diff] [blame] | 2979 | ath10k_pci_deinit_irq(ar); |
| 2980 | ath10k_pci_ce_deinit(ar); |
Michal Kazior | 84cbf3a | 2014-10-20 14:14:39 +0200 | [diff] [blame] | 2981 | ath10k_pci_free_pipes(ar); |
Michal Kazior | 77258d4 | 2015-05-18 09:38:18 +0000 | [diff] [blame] | 2982 | ath10k_pci_sleep_sync(ar); |
Michal Kazior | 2986e3e | 2014-08-07 11:03:30 +0200 | [diff] [blame] | 2983 | ath10k_pci_release(ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2984 | ath10k_core_destroy(ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2985 | } |
| 2986 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2987 | MODULE_DEVICE_TABLE(pci, ath10k_pci_id_table); |
| 2988 | |
| 2989 | static struct pci_driver ath10k_pci_driver = { |
| 2990 | .name = "ath10k_pci", |
| 2991 | .id_table = ath10k_pci_id_table, |
| 2992 | .probe = ath10k_pci_probe, |
| 2993 | .remove = ath10k_pci_remove, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2994 | }; |
| 2995 | |
| 2996 | static int __init ath10k_pci_init(void) |
| 2997 | { |
| 2998 | int ret; |
| 2999 | |
| 3000 | ret = pci_register_driver(&ath10k_pci_driver); |
| 3001 | if (ret) |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3002 | printk(KERN_ERR "failed to register ath10k pci driver: %d\n", |
| 3003 | ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3004 | |
| 3005 | return ret; |
| 3006 | } |
| 3007 | module_init(ath10k_pci_init); |
| 3008 | |
| 3009 | static void __exit ath10k_pci_exit(void) |
| 3010 | { |
| 3011 | pci_unregister_driver(&ath10k_pci_driver); |
| 3012 | } |
| 3013 | |
| 3014 | module_exit(ath10k_pci_exit); |
| 3015 | |
| 3016 | MODULE_AUTHOR("Qualcomm Atheros"); |
| 3017 | MODULE_DESCRIPTION("Driver support for Atheros QCA988X PCIe devices"); |
| 3018 | MODULE_LICENSE("Dual BSD/GPL"); |
Bartosz Markowski | 5c427f5 | 2015-02-18 13:16:37 +0100 | [diff] [blame] | 3019 | |
| 3020 | /* QCA988x 2.0 firmware files */ |
Bartosz Markowski | 8026cae | 2014-10-06 14:16:41 +0200 | [diff] [blame] | 3021 | MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" QCA988X_HW_2_0_FW_FILE); |
| 3022 | MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" ATH10K_FW_API2_FILE); |
| 3023 | MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" ATH10K_FW_API3_FILE); |
Bartosz Markowski | 5c427f5 | 2015-02-18 13:16:37 +0100 | [diff] [blame] | 3024 | MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" ATH10K_FW_API4_FILE); |
Kalle Valo | 53513c3 | 2015-03-25 13:12:42 +0200 | [diff] [blame] | 3025 | MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" ATH10K_FW_API5_FILE); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3026 | MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" QCA988X_HW_2_0_BOARD_DATA_FILE); |
Bartosz Markowski | 5c427f5 | 2015-02-18 13:16:37 +0100 | [diff] [blame] | 3027 | |
| 3028 | /* QCA6174 2.1 firmware files */ |
| 3029 | MODULE_FIRMWARE(QCA6174_HW_2_1_FW_DIR "/" ATH10K_FW_API4_FILE); |
Michal Kazior | e451c1d | 2015-05-26 13:09:22 +0200 | [diff] [blame] | 3030 | MODULE_FIRMWARE(QCA6174_HW_2_1_FW_DIR "/" ATH10K_FW_API5_FILE); |
Bartosz Markowski | 5c427f5 | 2015-02-18 13:16:37 +0100 | [diff] [blame] | 3031 | MODULE_FIRMWARE(QCA6174_HW_2_1_FW_DIR "/" QCA6174_HW_2_1_BOARD_DATA_FILE); |
| 3032 | |
| 3033 | /* QCA6174 3.1 firmware files */ |
| 3034 | MODULE_FIRMWARE(QCA6174_HW_3_0_FW_DIR "/" ATH10K_FW_API4_FILE); |
Michal Kazior | e451c1d | 2015-05-26 13:09:22 +0200 | [diff] [blame] | 3035 | MODULE_FIRMWARE(QCA6174_HW_3_0_FW_DIR "/" ATH10K_FW_API5_FILE); |
Bartosz Markowski | 5c427f5 | 2015-02-18 13:16:37 +0100 | [diff] [blame] | 3036 | MODULE_FIRMWARE(QCA6174_HW_3_0_FW_DIR "/" QCA6174_HW_3_0_BOARD_DATA_FILE); |