aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/wil6210/pcie_bus.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/wil6210/pcie_bus.c')
-rw-r--r--drivers/net/wireless/ath/wil6210/pcie_bus.c105
1 files changed, 64 insertions, 41 deletions
diff --git a/drivers/net/wireless/ath/wil6210/pcie_bus.c b/drivers/net/wireless/ath/wil6210/pcie_bus.c
index 109986114abf..aa3ecc607ca3 100644
--- a/drivers/net/wireless/ath/wil6210/pcie_bus.c
+++ b/drivers/net/wireless/ath/wil6210/pcie_bus.c
@@ -27,10 +27,6 @@ MODULE_PARM_DESC(use_msi,
27 " Use MSI interrupt: " 27 " Use MSI interrupt: "
28 "0 - don't, 1 - (default) - single, or 3"); 28 "0 - don't, 1 - (default) - single, or 3");
29 29
30static bool debug_fw; /* = false; */
31module_param(debug_fw, bool, S_IRUGO);
32MODULE_PARM_DESC(debug_fw, " load driver if FW not ready. For FW debug");
33
34static 30static
35void wil_set_capabilities(struct wil6210_priv *wil) 31void wil_set_capabilities(struct wil6210_priv *wil)
36{ 32{
@@ -133,8 +129,6 @@ static int wil_if_pcie_enable(struct wil6210_priv *wil)
133 mutex_lock(&wil->mutex); 129 mutex_lock(&wil->mutex);
134 rc = wil_reset(wil, false); 130 rc = wil_reset(wil, false);
135 mutex_unlock(&wil->mutex); 131 mutex_unlock(&wil->mutex);
136 if (debug_fw)
137 rc = 0;
138 if (rc) 132 if (rc)
139 goto release_irq; 133 goto release_irq;
140 134
@@ -169,7 +163,6 @@ static int wil_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
169{ 163{
170 struct wil6210_priv *wil; 164 struct wil6210_priv *wil;
171 struct device *dev = &pdev->dev; 165 struct device *dev = &pdev->dev;
172 void __iomem *csr;
173 int rc; 166 int rc;
174 167
175 /* check HW */ 168 /* check HW */
@@ -184,9 +177,28 @@ static int wil_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
184 return -ENODEV; 177 return -ENODEV;
185 } 178 }
186 179
180 wil = wil_if_alloc(dev);
181 if (IS_ERR(wil)) {
182 rc = (int)PTR_ERR(wil);
183 dev_err(dev, "wil_if_alloc failed: %d\n", rc);
184 return rc;
185 }
186 wil->pdev = pdev;
187 pci_set_drvdata(pdev, wil);
188 /* rollback to if_free */
189
190 wil->platform_handle =
191 wil_platform_init(&pdev->dev, &wil->platform_ops);
192 if (!wil->platform_handle) {
193 rc = -ENODEV;
194 wil_err(wil, "wil_platform_init failed\n");
195 goto if_free;
196 }
197 /* rollback to err_plat */
198
187 rc = pci_enable_device(pdev); 199 rc = pci_enable_device(pdev);
188 if (rc) { 200 if (rc) {
189 dev_err(&pdev->dev, 201 wil_err(wil,
190 "pci_enable_device failed, retry with MSI only\n"); 202 "pci_enable_device failed, retry with MSI only\n");
191 /* Work around for platforms that can't allocate IRQ: 203 /* Work around for platforms that can't allocate IRQ:
192 * retry with MSI only 204 * retry with MSI only
@@ -194,47 +206,37 @@ static int wil_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
194 pdev->msi_enabled = 1; 206 pdev->msi_enabled = 1;
195 rc = pci_enable_device(pdev); 207 rc = pci_enable_device(pdev);
196 } 208 }
197 if (rc) 209 if (rc) {
198 return -ENODEV; 210 wil_err(wil,
211 "pci_enable_device failed, even with MSI only\n");
212 goto err_plat;
213 }
199 /* rollback to err_disable_pdev */ 214 /* rollback to err_disable_pdev */
200 215
201 rc = pci_request_region(pdev, 0, WIL_NAME); 216 rc = pci_request_region(pdev, 0, WIL_NAME);
202 if (rc) { 217 if (rc) {
203 dev_err(&pdev->dev, "pci_request_region failed\n"); 218 wil_err(wil, "pci_request_region failed\n");
204 goto err_disable_pdev; 219 goto err_disable_pdev;
205 } 220 }
206 /* rollback to err_release_reg */ 221 /* rollback to err_release_reg */
207 222
208 csr = pci_ioremap_bar(pdev, 0); 223 wil->csr = pci_ioremap_bar(pdev, 0);
209 if (!csr) { 224 if (!wil->csr) {
210 dev_err(&pdev->dev, "pci_ioremap_bar failed\n"); 225 wil_err(wil, "pci_ioremap_bar failed\n");
211 rc = -ENODEV; 226 rc = -ENODEV;
212 goto err_release_reg; 227 goto err_release_reg;
213 } 228 }
214 /* rollback to err_iounmap */ 229 /* rollback to err_iounmap */
215 dev_info(&pdev->dev, "CSR at %pR -> 0x%p\n", &pdev->resource[0], csr); 230 wil_info(wil, "CSR at %pR -> 0x%p\n", &pdev->resource[0], wil->csr);
216
217 wil = wil_if_alloc(dev, csr);
218 if (IS_ERR(wil)) {
219 rc = (int)PTR_ERR(wil);
220 dev_err(dev, "wil_if_alloc failed: %d\n", rc);
221 goto err_iounmap;
222 }
223 /* rollback to if_free */
224 231
225 pci_set_drvdata(pdev, wil);
226 wil->pdev = pdev;
227 wil_set_capabilities(wil); 232 wil_set_capabilities(wil);
228 wil6210_clear_irq(wil); 233 wil6210_clear_irq(wil);
229 234
230 wil->platform_handle =
231 wil_platform_init(&pdev->dev, &wil->platform_ops);
232
233 /* FW should raise IRQ when ready */ 235 /* FW should raise IRQ when ready */
234 rc = wil_if_pcie_enable(wil); 236 rc = wil_if_pcie_enable(wil);
235 if (rc) { 237 if (rc) {
236 wil_err(wil, "Enable device failed\n"); 238 wil_err(wil, "Enable device failed\n");
237 goto if_free; 239 goto err_iounmap;
238 } 240 }
239 /* rollback to bus_disable */ 241 /* rollback to bus_disable */
240 242
@@ -249,18 +251,19 @@ static int wil_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
249 251
250 return 0; 252 return 0;
251 253
252 bus_disable: 254bus_disable:
253 wil_if_pcie_disable(wil); 255 wil_if_pcie_disable(wil);
254 if_free: 256err_iounmap:
257 pci_iounmap(pdev, wil->csr);
258err_release_reg:
259 pci_release_region(pdev, 0);
260err_disable_pdev:
261 pci_disable_device(pdev);
262err_plat:
255 if (wil->platform_ops.uninit) 263 if (wil->platform_ops.uninit)
256 wil->platform_ops.uninit(wil->platform_handle); 264 wil->platform_ops.uninit(wil->platform_handle);
265if_free:
257 wil_if_free(wil); 266 wil_if_free(wil);
258 err_iounmap:
259 pci_iounmap(pdev, csr);
260 err_release_reg:
261 pci_release_region(pdev, 0);
262 err_disable_pdev:
263 pci_disable_device(pdev);
264 267
265 return rc; 268 return rc;
266} 269}
@@ -275,12 +278,12 @@ static void wil_pcie_remove(struct pci_dev *pdev)
275 wil6210_debugfs_remove(wil); 278 wil6210_debugfs_remove(wil);
276 wil_if_remove(wil); 279 wil_if_remove(wil);
277 wil_if_pcie_disable(wil); 280 wil_if_pcie_disable(wil);
278 if (wil->platform_ops.uninit)
279 wil->platform_ops.uninit(wil->platform_handle);
280 wil_if_free(wil);
281 pci_iounmap(pdev, csr); 281 pci_iounmap(pdev, csr);
282 pci_release_region(pdev, 0); 282 pci_release_region(pdev, 0);
283 pci_disable_device(pdev); 283 pci_disable_device(pdev);
284 if (wil->platform_ops.uninit)
285 wil->platform_ops.uninit(wil->platform_handle);
286 wil_if_free(wil);
284} 287}
285 288
286static const struct pci_device_id wil6210_pcie_ids[] = { 289static const struct pci_device_id wil6210_pcie_ids[] = {
@@ -297,7 +300,27 @@ static struct pci_driver wil6210_driver = {
297 .name = WIL_NAME, 300 .name = WIL_NAME,
298}; 301};
299 302
300module_pci_driver(wil6210_driver); 303static int __init wil6210_driver_init(void)
304{
305 int rc;
306
307 rc = wil_platform_modinit();
308 if (rc)
309 return rc;
310
311 rc = pci_register_driver(&wil6210_driver);
312 if (rc)
313 wil_platform_modexit();
314 return rc;
315}
316module_init(wil6210_driver_init);
317
318static void __exit wil6210_driver_exit(void)
319{
320 pci_unregister_driver(&wil6210_driver);
321 wil_platform_modexit();
322}
323module_exit(wil6210_driver_exit);
301 324
302MODULE_LICENSE("Dual BSD/GPL"); 325MODULE_LICENSE("Dual BSD/GPL");
303MODULE_AUTHOR("Qualcomm Atheros <wil6210@qca.qualcomm.com>"); 326MODULE_AUTHOR("Qualcomm Atheros <wil6210@qca.qualcomm.com>");