Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1 | /* |
Vladimir Kondratiev | 02525a7 | 2014-08-06 10:31:51 +0300 | [diff] [blame] | 2 | * Copyright (c) 2012-2014 Qualcomm Atheros, Inc. |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 17 | #include <linux/module.h> |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 18 | #include <linux/pci.h> |
| 19 | #include <linux/moduleparam.h> |
Vladimir Kondratiev | 73d839a | 2014-09-10 16:34:50 +0300 | [diff] [blame] | 20 | #include <linux/interrupt.h> |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 21 | |
| 22 | #include "wil6210.h" |
| 23 | |
Vladimir Kondratiev | bd2d18b | 2015-07-30 13:52:02 +0300 | [diff] [blame] | 24 | static bool use_msi = true; |
| 25 | module_param(use_msi, bool, S_IRUGO); |
| 26 | MODULE_PARM_DESC(use_msi, " Use MSI interrupt, default - true"); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 27 | |
Vladimir Kondratiev | d8cfb80 | 2014-12-23 09:47:17 +0200 | [diff] [blame] | 28 | static |
| 29 | void wil_set_capabilities(struct wil6210_priv *wil) |
| 30 | { |
Vladimir Kondratiev | b9eeb51 | 2015-07-30 13:52:03 +0300 | [diff] [blame] | 31 | u32 rev_id = wil_r(wil, RGF_USER_JTAG_DEV_ID); |
Vladimir Kondratiev | d8cfb80 | 2014-12-23 09:47:17 +0200 | [diff] [blame] | 32 | |
| 33 | bitmap_zero(wil->hw_capabilities, hw_capability_last); |
| 34 | |
| 35 | switch (rev_id) { |
Vladimir Kondratiev | d8cfb80 | 2014-12-23 09:47:17 +0200 | [diff] [blame] | 36 | case JTAG_DEV_ID_SPARROW_B0: |
Vladimir Kondratiev | 1aeda13 | 2014-12-23 09:47:18 +0200 | [diff] [blame] | 37 | wil->hw_name = "Sparrow B0"; |
Vladimir Kondratiev | d8cfb80 | 2014-12-23 09:47:17 +0200 | [diff] [blame] | 38 | wil->hw_version = HW_VER_SPARROW_B0; |
| 39 | break; |
| 40 | default: |
| 41 | wil_err(wil, "Unknown board hardware 0x%08x\n", rev_id); |
Vladimir Kondratiev | 1aeda13 | 2014-12-23 09:47:18 +0200 | [diff] [blame] | 42 | wil->hw_name = "Unknown"; |
Vladimir Kondratiev | d8cfb80 | 2014-12-23 09:47:17 +0200 | [diff] [blame] | 43 | wil->hw_version = HW_VER_UNKNOWN; |
| 44 | } |
Vladimir Kondratiev | 1aeda13 | 2014-12-23 09:47:18 +0200 | [diff] [blame] | 45 | |
| 46 | wil_info(wil, "Board hardware is %s\n", wil->hw_name); |
Vladimir Kondratiev | d8cfb80 | 2014-12-23 09:47:17 +0200 | [diff] [blame] | 47 | } |
| 48 | |
Vladimir Kondratiev | 73d839a | 2014-09-10 16:34:50 +0300 | [diff] [blame] | 49 | void wil_disable_irq(struct wil6210_priv *wil) |
| 50 | { |
Vladimir Kondratiev | bd2d18b | 2015-07-30 13:52:02 +0300 | [diff] [blame] | 51 | disable_irq(wil->pdev->irq); |
Vladimir Kondratiev | 73d839a | 2014-09-10 16:34:50 +0300 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | void wil_enable_irq(struct wil6210_priv *wil) |
| 55 | { |
Vladimir Kondratiev | bd2d18b | 2015-07-30 13:52:02 +0300 | [diff] [blame] | 56 | enable_irq(wil->pdev->irq); |
Vladimir Kondratiev | 73d839a | 2014-09-10 16:34:50 +0300 | [diff] [blame] | 57 | } |
| 58 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 59 | /* Bus ops */ |
| 60 | static int wil_if_pcie_enable(struct wil6210_priv *wil) |
| 61 | { |
| 62 | struct pci_dev *pdev = wil->pdev; |
| 63 | int rc; |
Vladimir Kondratiev | 2bdc070 | 2014-06-16 19:37:20 +0300 | [diff] [blame] | 64 | /* on platforms with buggy ACPI, pdev->msi_enabled may be set to |
| 65 | * allow pci_enable_device to work. This indicates INTx was not routed |
| 66 | * and only MSI should be used |
| 67 | */ |
| 68 | int msi_only = pdev->msi_enabled; |
Vladimir Kondratiev | bd2d18b | 2015-07-30 13:52:02 +0300 | [diff] [blame] | 69 | bool _use_msi = use_msi; |
Vladimir Kondratiev | 2bdc070 | 2014-06-16 19:37:20 +0300 | [diff] [blame] | 70 | |
Vladimir Kondratiev | 9cf10d6 | 2014-09-10 16:34:36 +0300 | [diff] [blame] | 71 | wil_dbg_misc(wil, "%s()\n", __func__); |
| 72 | |
Vladimir Kondratiev | 2bdc070 | 2014-06-16 19:37:20 +0300 | [diff] [blame] | 73 | pdev->msi_enabled = 0; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 74 | |
| 75 | pci_set_master(pdev); |
| 76 | |
Vladimir Kondratiev | bd2d18b | 2015-07-30 13:52:02 +0300 | [diff] [blame] | 77 | wil_dbg_misc(wil, "Setup %s interrupt\n", use_msi ? "MSI" : "INTx"); |
Alexander Gordeev | b4b3906 | 2014-02-18 11:12:04 +0100 | [diff] [blame] | 78 | |
Vladimir Kondratiev | bd2d18b | 2015-07-30 13:52:02 +0300 | [diff] [blame] | 79 | if (use_msi && pci_enable_msi(pdev)) { |
Alexander Gordeev | b4b3906 | 2014-02-18 11:12:04 +0100 | [diff] [blame] | 80 | wil_err(wil, "pci_enable_msi failed, use INTx\n"); |
Vladimir Kondratiev | bd2d18b | 2015-07-30 13:52:02 +0300 | [diff] [blame] | 81 | _use_msi = false; |
Alexander Gordeev | b4b3906 | 2014-02-18 11:12:04 +0100 | [diff] [blame] | 82 | } |
| 83 | |
Vladimir Kondratiev | bd2d18b | 2015-07-30 13:52:02 +0300 | [diff] [blame] | 84 | if (!_use_msi && msi_only) { |
Vladimir Kondratiev | 2bdc070 | 2014-06-16 19:37:20 +0300 | [diff] [blame] | 85 | wil_err(wil, "Interrupt pin not routed, unable to use INTx\n"); |
| 86 | rc = -ENODEV; |
| 87 | goto stop_master; |
| 88 | } |
| 89 | |
Vladimir Kondratiev | bd2d18b | 2015-07-30 13:52:02 +0300 | [diff] [blame] | 90 | rc = wil6210_init_irq(wil, pdev->irq, _use_msi); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 91 | if (rc) |
| 92 | goto stop_master; |
| 93 | |
| 94 | /* need reset here to obtain MAC */ |
Vladimir Kondratiev | 097638a | 2014-03-17 15:34:25 +0200 | [diff] [blame] | 95 | mutex_lock(&wil->mutex); |
Vladimir Kondratiev | 2cd0f02 | 2015-02-15 14:02:30 +0200 | [diff] [blame] | 96 | rc = wil_reset(wil, false); |
Vladimir Kondratiev | 097638a | 2014-03-17 15:34:25 +0200 | [diff] [blame] | 97 | mutex_unlock(&wil->mutex); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 98 | if (rc) |
| 99 | goto release_irq; |
| 100 | |
| 101 | return 0; |
| 102 | |
| 103 | release_irq: |
| 104 | wil6210_fini_irq(wil, pdev->irq); |
| 105 | /* safe to call if no MSI */ |
| 106 | pci_disable_msi(pdev); |
| 107 | stop_master: |
| 108 | pci_clear_master(pdev); |
| 109 | return rc; |
| 110 | } |
| 111 | |
| 112 | static int wil_if_pcie_disable(struct wil6210_priv *wil) |
| 113 | { |
| 114 | struct pci_dev *pdev = wil->pdev; |
| 115 | |
Vladimir Kondratiev | 9cf10d6 | 2014-09-10 16:34:36 +0300 | [diff] [blame] | 116 | wil_dbg_misc(wil, "%s()\n", __func__); |
| 117 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 118 | pci_clear_master(pdev); |
| 119 | /* disable and release IRQ */ |
| 120 | wil6210_fini_irq(wil, pdev->irq); |
| 121 | /* safe to call if no MSI */ |
| 122 | pci_disable_msi(pdev); |
| 123 | /* TODO: disable HW */ |
| 124 | |
| 125 | return 0; |
| 126 | } |
| 127 | |
| 128 | static int wil_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) |
| 129 | { |
| 130 | struct wil6210_priv *wil; |
| 131 | struct device *dev = &pdev->dev; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 132 | int rc; |
| 133 | |
| 134 | /* check HW */ |
Vladimir Kondratiev | 6508281 | 2014-07-14 09:49:37 +0300 | [diff] [blame] | 135 | dev_info(&pdev->dev, WIL_NAME |
Vladimir Kondratiev | 1aeda13 | 2014-12-23 09:47:18 +0200 | [diff] [blame] | 136 | " device found [%04x:%04x] (rev %x)\n", |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 137 | (int)pdev->vendor, (int)pdev->device, (int)pdev->revision); |
| 138 | |
| 139 | if (pci_resource_len(pdev, 0) != WIL6210_MEM_SIZE) { |
| 140 | dev_err(&pdev->dev, "Not " WIL_NAME "? " |
| 141 | "BAR0 size is %lu while expecting %lu\n", |
| 142 | (ulong)pci_resource_len(pdev, 0), WIL6210_MEM_SIZE); |
| 143 | return -ENODEV; |
| 144 | } |
| 145 | |
Vladimir Kondratiev | 3e2d8e1 | 2015-06-09 14:11:19 +0300 | [diff] [blame] | 146 | wil = wil_if_alloc(dev); |
| 147 | if (IS_ERR(wil)) { |
| 148 | rc = (int)PTR_ERR(wil); |
| 149 | dev_err(dev, "wil_if_alloc failed: %d\n", rc); |
| 150 | return rc; |
| 151 | } |
| 152 | wil->pdev = pdev; |
| 153 | pci_set_drvdata(pdev, wil); |
| 154 | /* rollback to if_free */ |
| 155 | |
| 156 | wil->platform_handle = |
| 157 | wil_platform_init(&pdev->dev, &wil->platform_ops); |
| 158 | if (!wil->platform_handle) { |
| 159 | rc = -ENODEV; |
| 160 | wil_err(wil, "wil_platform_init failed\n"); |
| 161 | goto if_free; |
| 162 | } |
| 163 | /* rollback to err_plat */ |
| 164 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 165 | rc = pci_enable_device(pdev); |
| 166 | if (rc) { |
Vladimir Kondratiev | 3e2d8e1 | 2015-06-09 14:11:19 +0300 | [diff] [blame] | 167 | wil_err(wil, |
Vladimir Kondratiev | 2bdc070 | 2014-06-16 19:37:20 +0300 | [diff] [blame] | 168 | "pci_enable_device failed, retry with MSI only\n"); |
| 169 | /* Work around for platforms that can't allocate IRQ: |
| 170 | * retry with MSI only |
| 171 | */ |
| 172 | pdev->msi_enabled = 1; |
| 173 | rc = pci_enable_device(pdev); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 174 | } |
Vladimir Kondratiev | 3e2d8e1 | 2015-06-09 14:11:19 +0300 | [diff] [blame] | 175 | if (rc) { |
| 176 | wil_err(wil, |
| 177 | "pci_enable_device failed, even with MSI only\n"); |
| 178 | goto err_plat; |
| 179 | } |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 180 | /* rollback to err_disable_pdev */ |
| 181 | |
| 182 | rc = pci_request_region(pdev, 0, WIL_NAME); |
| 183 | if (rc) { |
Vladimir Kondratiev | 3e2d8e1 | 2015-06-09 14:11:19 +0300 | [diff] [blame] | 184 | wil_err(wil, "pci_request_region failed\n"); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 185 | goto err_disable_pdev; |
| 186 | } |
| 187 | /* rollback to err_release_reg */ |
| 188 | |
Vladimir Kondratiev | 3e2d8e1 | 2015-06-09 14:11:19 +0300 | [diff] [blame] | 189 | wil->csr = pci_ioremap_bar(pdev, 0); |
| 190 | if (!wil->csr) { |
| 191 | wil_err(wil, "pci_ioremap_bar failed\n"); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 192 | rc = -ENODEV; |
| 193 | goto err_release_reg; |
| 194 | } |
| 195 | /* rollback to err_iounmap */ |
Vladimir Kondratiev | 3e2d8e1 | 2015-06-09 14:11:19 +0300 | [diff] [blame] | 196 | wil_info(wil, "CSR at %pR -> 0x%p\n", &pdev->resource[0], wil->csr); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 197 | |
Vladimir Kondratiev | d8cfb80 | 2014-12-23 09:47:17 +0200 | [diff] [blame] | 198 | wil_set_capabilities(wil); |
Vladimir Kondratiev | f4b5a80 | 2014-03-17 15:34:13 +0200 | [diff] [blame] | 199 | wil6210_clear_irq(wil); |
Vladimir Kondratiev | f772ebf | 2014-09-10 16:34:35 +0300 | [diff] [blame] | 200 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 201 | /* FW should raise IRQ when ready */ |
| 202 | rc = wil_if_pcie_enable(wil); |
| 203 | if (rc) { |
| 204 | wil_err(wil, "Enable device failed\n"); |
Vladimir Kondratiev | 3e2d8e1 | 2015-06-09 14:11:19 +0300 | [diff] [blame] | 205 | goto err_iounmap; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 206 | } |
| 207 | /* rollback to bus_disable */ |
| 208 | |
| 209 | rc = wil_if_add(wil); |
| 210 | if (rc) { |
| 211 | wil_err(wil, "wil_if_add failed: %d\n", rc); |
| 212 | goto bus_disable; |
| 213 | } |
| 214 | |
| 215 | wil6210_debugfs_init(wil); |
| 216 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 217 | |
| 218 | return 0; |
| 219 | |
Vladimir Kondratiev | 3e2d8e1 | 2015-06-09 14:11:19 +0300 | [diff] [blame] | 220 | bus_disable: |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 221 | wil_if_pcie_disable(wil); |
Vladimir Kondratiev | 3e2d8e1 | 2015-06-09 14:11:19 +0300 | [diff] [blame] | 222 | err_iounmap: |
| 223 | pci_iounmap(pdev, wil->csr); |
| 224 | err_release_reg: |
| 225 | pci_release_region(pdev, 0); |
| 226 | err_disable_pdev: |
| 227 | pci_disable_device(pdev); |
| 228 | err_plat: |
Vladimir Kondratiev | f772ebf | 2014-09-10 16:34:35 +0300 | [diff] [blame] | 229 | if (wil->platform_ops.uninit) |
| 230 | wil->platform_ops.uninit(wil->platform_handle); |
Vladimir Kondratiev | 3e2d8e1 | 2015-06-09 14:11:19 +0300 | [diff] [blame] | 231 | if_free: |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 232 | wil_if_free(wil); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 233 | |
| 234 | return rc; |
| 235 | } |
| 236 | |
| 237 | static void wil_pcie_remove(struct pci_dev *pdev) |
| 238 | { |
| 239 | struct wil6210_priv *wil = pci_get_drvdata(pdev); |
Vladimir Kondratiev | 560ce30 | 2014-08-06 10:32:01 +0300 | [diff] [blame] | 240 | void __iomem *csr = wil->csr; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 241 | |
Vladimir Kondratiev | 9cf10d6 | 2014-09-10 16:34:36 +0300 | [diff] [blame] | 242 | wil_dbg_misc(wil, "%s()\n", __func__); |
| 243 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 244 | wil6210_debugfs_remove(wil); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 245 | wil_if_remove(wil); |
Dedy Lansky | f172b56 | 2014-09-10 16:34:38 +0300 | [diff] [blame] | 246 | wil_if_pcie_disable(wil); |
Vladimir Kondratiev | 560ce30 | 2014-08-06 10:32:01 +0300 | [diff] [blame] | 247 | pci_iounmap(pdev, csr); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 248 | pci_release_region(pdev, 0); |
| 249 | pci_disable_device(pdev); |
Vladimir Kondratiev | 3e2d8e1 | 2015-06-09 14:11:19 +0300 | [diff] [blame] | 250 | if (wil->platform_ops.uninit) |
| 251 | wil->platform_ops.uninit(wil->platform_handle); |
| 252 | wil_if_free(wil); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 253 | } |
| 254 | |
Vladimir Kondratiev | 6508281 | 2014-07-14 09:49:37 +0300 | [diff] [blame] | 255 | static const struct pci_device_id wil6210_pcie_ids[] = { |
Vladimir Kondratiev | 1aeda13 | 2014-12-23 09:47:18 +0200 | [diff] [blame] | 256 | { PCI_DEVICE(0x1ae9, 0x0310) }, |
| 257 | { PCI_DEVICE(0x1ae9, 0x0302) }, /* same as above, firmware broken */ |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 258 | { /* end: all zeroes */ }, |
| 259 | }; |
| 260 | MODULE_DEVICE_TABLE(pci, wil6210_pcie_ids); |
| 261 | |
Vladimir Kondratiev | 93cb679 | 2015-07-30 13:52:05 +0300 | [diff] [blame] | 262 | #ifdef CONFIG_PM |
Vladimir Kondratiev | 5a813da | 2015-10-04 10:23:18 +0300 | [diff] [blame] | 263 | #ifdef CONFIG_PM_SLEEP |
Vladimir Kondratiev | 93cb679 | 2015-07-30 13:52:05 +0300 | [diff] [blame] | 264 | |
| 265 | static int wil6210_suspend(struct device *dev, bool is_runtime) |
| 266 | { |
| 267 | int rc = 0; |
| 268 | struct pci_dev *pdev = to_pci_dev(dev); |
| 269 | struct wil6210_priv *wil = pci_get_drvdata(pdev); |
| 270 | |
| 271 | wil_dbg_pm(wil, "%s(%s)\n", __func__, |
| 272 | is_runtime ? "runtime" : "system"); |
| 273 | |
| 274 | rc = wil_can_suspend(wil, is_runtime); |
| 275 | if (rc) |
| 276 | goto out; |
| 277 | |
| 278 | rc = wil_suspend(wil, is_runtime); |
| 279 | if (rc) |
| 280 | goto out; |
| 281 | |
| 282 | /* TODO: how do I bring card in low power state? */ |
| 283 | |
| 284 | /* disable bus mastering */ |
| 285 | pci_clear_master(pdev); |
| 286 | /* PCI will call pci_save_state(pdev) and pci_prepare_to_sleep(pdev) */ |
| 287 | |
| 288 | out: |
| 289 | return rc; |
| 290 | } |
| 291 | |
| 292 | static int wil6210_resume(struct device *dev, bool is_runtime) |
| 293 | { |
| 294 | int rc = 0; |
| 295 | struct pci_dev *pdev = to_pci_dev(dev); |
| 296 | struct wil6210_priv *wil = pci_get_drvdata(pdev); |
| 297 | |
| 298 | wil_dbg_pm(wil, "%s(%s)\n", __func__, |
| 299 | is_runtime ? "runtime" : "system"); |
| 300 | |
| 301 | /* allow master */ |
| 302 | pci_set_master(pdev); |
| 303 | |
| 304 | rc = wil_resume(wil, is_runtime); |
| 305 | if (rc) |
| 306 | pci_clear_master(pdev); |
| 307 | |
| 308 | return rc; |
| 309 | } |
| 310 | |
Vladimir Kondratiev | 93cb679 | 2015-07-30 13:52:05 +0300 | [diff] [blame] | 311 | static int wil6210_pm_suspend(struct device *dev) |
| 312 | { |
| 313 | return wil6210_suspend(dev, false); |
| 314 | } |
| 315 | |
| 316 | static int wil6210_pm_resume(struct device *dev) |
| 317 | { |
| 318 | return wil6210_resume(dev, false); |
| 319 | } |
| 320 | #endif /* CONFIG_PM_SLEEP */ |
| 321 | |
| 322 | #endif /* CONFIG_PM */ |
| 323 | |
| 324 | static const struct dev_pm_ops wil6210_pm_ops = { |
| 325 | SET_SYSTEM_SLEEP_PM_OPS(wil6210_pm_suspend, wil6210_pm_resume) |
| 326 | }; |
| 327 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 328 | static struct pci_driver wil6210_driver = { |
| 329 | .probe = wil_pcie_probe, |
| 330 | .remove = wil_pcie_remove, |
| 331 | .id_table = wil6210_pcie_ids, |
| 332 | .name = WIL_NAME, |
Vladimir Kondratiev | 93cb679 | 2015-07-30 13:52:05 +0300 | [diff] [blame] | 333 | .driver = { |
| 334 | .pm = &wil6210_pm_ops, |
| 335 | }, |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 336 | }; |
| 337 | |
Vladimir Kondratiev | b39d693 | 2015-06-09 14:11:19 +0300 | [diff] [blame] | 338 | static int __init wil6210_driver_init(void) |
| 339 | { |
| 340 | int rc; |
| 341 | |
| 342 | rc = wil_platform_modinit(); |
| 343 | if (rc) |
| 344 | return rc; |
| 345 | |
| 346 | rc = pci_register_driver(&wil6210_driver); |
| 347 | if (rc) |
| 348 | wil_platform_modexit(); |
| 349 | return rc; |
| 350 | } |
| 351 | module_init(wil6210_driver_init); |
| 352 | |
| 353 | static void __exit wil6210_driver_exit(void) |
| 354 | { |
| 355 | pci_unregister_driver(&wil6210_driver); |
| 356 | wil_platform_modexit(); |
| 357 | } |
| 358 | module_exit(wil6210_driver_exit); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 359 | |
| 360 | MODULE_LICENSE("Dual BSD/GPL"); |
| 361 | MODULE_AUTHOR("Qualcomm Atheros <wil6210@qca.qualcomm.com>"); |
| 362 | MODULE_DESCRIPTION("Driver for 60g WiFi WIL6210 card"); |