Radhakrishna Jiguru | 1c9b225 | 2013-08-27 23:57:48 +0530 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************** |
Zac Livingston | 866b0e2 | 2013-10-23 18:14:17 -0600 | [diff] [blame] | 3 | * Copyright (c) 2013, The Linux Foundation. All rights reserved. |
Radhakrishna Jiguru | 1c9b225 | 2013-08-27 23:57:48 +0530 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all copies. |
| 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 10 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 12 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 13 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 14 | ************************************************************************** |
| 15 | */ |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 16 | |
| 17 | /* |
| 18 | * nss_init.c |
| 19 | * NSS init APIs |
| 20 | * |
| 21 | */ |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 22 | #include "nss_core.h" |
Pamidipati, Vijay | 7f413b5 | 2013-09-24 19:07:12 +0530 | [diff] [blame] | 23 | #include "nss_pm.h" |
| 24 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 25 | #include <nss_hal.h> |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 26 | #include <nss_clocks.h> |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 27 | |
| 28 | #include <linux/module.h> |
| 29 | #include <linux/platform_device.h> |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 30 | #include <linux/proc_fs.h> |
| 31 | #include <linux/device.h> |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 32 | #include <mach/msm_nss.h> |
| 33 | |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 34 | #include <linux/sysctl.h> |
| 35 | #include <linux/regulator/consumer.h> |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 36 | #include <linux/clk.h> |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 37 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 38 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 39 | * Declare module parameters |
| 40 | */ |
| 41 | static int load0 = 0x40000000; |
| 42 | module_param(load0, int, S_IRUSR | S_IWUSR); |
| 43 | MODULE_PARM_DESC(load0, "NSS Core 0 load address"); |
| 44 | |
| 45 | static int entry0 = 0x40000000; |
| 46 | module_param(entry0, int, S_IRUSR | S_IWUSR); |
| 47 | MODULE_PARM_DESC(load0, "NSS Core 0 entry address"); |
| 48 | |
| 49 | static char *string0 = "nss0"; |
| 50 | module_param(string0, charp, 0); |
| 51 | MODULE_PARM_DESC(string0, "NSS Core 0 identification string"); |
| 52 | |
| 53 | static int load1 = 0x40100000; |
| 54 | module_param(load1, int, S_IRUSR | S_IWUSR); |
| 55 | MODULE_PARM_DESC(load0, "NSS Core 1 load address"); |
| 56 | |
| 57 | static int entry1 = 0x40100000; |
| 58 | module_param(entry1, int, S_IRUSR | S_IWUSR); |
| 59 | MODULE_PARM_DESC(load0, "NSS Core 1 entry address"); |
| 60 | |
| 61 | static char *string1 = "nss1"; |
| 62 | module_param(string1, charp, 0); |
| 63 | MODULE_PARM_DESC(string1, "NSS Core 1 identification string"); |
| 64 | |
| 65 | |
| 66 | /* |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 67 | * Global declarations |
| 68 | */ |
Abhishek Rastogi | 5cd2e4c | 2013-11-13 18:09:08 +0530 | [diff] [blame] | 69 | int nss_ctl_redirect __read_mostly = 0; |
Abhishek Rastogi | 1626a90 | 2013-11-21 17:09:49 +0530 | [diff] [blame^] | 70 | int nss_ctl_debug __read_mostly = 0; |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 71 | |
| 72 | /* |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 73 | * Handler to send NSS messages |
| 74 | */ |
| 75 | void *nss_freq_change_context; |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 76 | struct clk *nss_core0_clk; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 77 | |
| 78 | /* |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 79 | * Top level nss context structure |
| 80 | */ |
| 81 | struct nss_top_instance nss_top_main; |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 82 | struct nss_cmd_buffer nss_cmd_buf; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 83 | struct nss_runtime_sampling nss_runtime_samples; |
| 84 | struct workqueue_struct *nss_wq; |
| 85 | |
| 86 | /* |
| 87 | * Work Queue to handle messages to Kernel |
| 88 | */ |
| 89 | nss_work_t *nss_work; |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 90 | |
| 91 | /* |
| 92 | * File local/Static variables/functions |
| 93 | */ |
| 94 | |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 95 | static const struct net_device_ops nss_netdev_ops; |
| 96 | static const struct ethtool_ops nss_ethtool_ops; |
| 97 | |
| 98 | /* |
| 99 | * nss_dummy_netdev_setup() |
| 100 | * Dummy setup for net_device handler |
| 101 | */ |
| 102 | static void nss_dummy_netdev_setup(struct net_device *ndev) |
| 103 | { |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 104 | |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 105 | } |
| 106 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 107 | /* |
| 108 | * nss_handle_irq() |
| 109 | * HLOS interrupt handler for nss interrupts |
| 110 | */ |
| 111 | static irqreturn_t nss_handle_irq (int irq, void *ctx) |
| 112 | { |
| 113 | struct int_ctx_instance *int_ctx = (struct int_ctx_instance *) ctx; |
Abhishek Rastogi | 80f4eb1 | 2013-09-24 14:31:21 +0530 | [diff] [blame] | 114 | struct nss_ctx_instance *nss_ctx = int_ctx->nss_ctx; |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 115 | |
| 116 | /* |
Abhishek Rastogi | 80f4eb1 | 2013-09-24 14:31:21 +0530 | [diff] [blame] | 117 | * Mask interrupt until our bottom half re-enables it |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 118 | */ |
Abhishek Rastogi | 80f4eb1 | 2013-09-24 14:31:21 +0530 | [diff] [blame] | 119 | nss_hal_disable_interrupt(nss_ctx->nmap, int_ctx->irq, |
| 120 | int_ctx->shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS); |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 121 | |
| 122 | /* |
| 123 | * Schedule tasklet to process interrupt cause |
| 124 | */ |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 125 | napi_schedule(&int_ctx->napi); |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 126 | return IRQ_HANDLED; |
| 127 | } |
| 128 | |
| 129 | /* |
| 130 | * nss_probe() |
| 131 | * HLOS device probe callback |
| 132 | */ |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 133 | static int __devinit nss_probe(struct platform_device *nss_dev) |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 134 | { |
| 135 | struct nss_top_instance *nss_top = &nss_top_main; |
| 136 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[nss_dev->id]; |
| 137 | struct nss_platform_data *npd = (struct nss_platform_data *) nss_dev->dev.platform_data; |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 138 | struct netdev_priv_instance *ndev_priv; |
| 139 | int i, err = 0; |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 140 | |
| 141 | nss_ctx->nss_top = nss_top; |
| 142 | nss_ctx->id = nss_dev->id; |
| 143 | |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 144 | nss_info("%p: NSS_DEV_ID %s \n", nss_ctx, dev_name(&nss_dev->dev)); |
| 145 | |
| 146 | /* |
| 147 | * Both NSS cores controlled by same regulator, Hook only Once |
| 148 | */ |
| 149 | if (!nss_dev->id) { |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 150 | nss_core0_clk = clk_get(&nss_dev->dev, "nss_core_clk"); |
| 151 | if (IS_ERR(nss_core0_clk)) { |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 152 | |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 153 | err = PTR_ERR(nss_core0_clk); |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 154 | nss_info("%p: Regulator %s get failed, err=%d\n", nss_ctx, dev_name(&nss_dev->dev), err); |
| 155 | return err; |
| 156 | |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 157 | } |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 158 | clk_set_rate(nss_core0_clk, NSS_FREQ_550); |
| 159 | clk_prepare(nss_core0_clk); |
| 160 | clk_enable(nss_core0_clk); |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 161 | } |
| 162 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 163 | /* |
| 164 | * Get virtual and physical memory addresses for nss logical/hardware address maps |
| 165 | */ |
| 166 | |
| 167 | /* |
| 168 | * Virtual address of CSM space |
| 169 | */ |
| 170 | nss_ctx->nmap = npd->nmap; |
| 171 | nss_assert(nss_ctx->nmap); |
| 172 | |
| 173 | /* |
| 174 | * Physical address of CSM space |
| 175 | */ |
| 176 | nss_ctx->nphys = npd->nphys; |
| 177 | nss_assert(nss_ctx->nphys); |
| 178 | |
| 179 | /* |
| 180 | * Virtual address of logical registers space |
| 181 | */ |
| 182 | nss_ctx->vmap = npd->vmap; |
| 183 | nss_assert(nss_ctx->vmap); |
| 184 | |
| 185 | /* |
| 186 | * Physical address of logical registers space |
| 187 | */ |
| 188 | nss_ctx->vphys = npd->vphys; |
| 189 | nss_assert(nss_ctx->vphys); |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 190 | nss_info("%d:ctx=%p, vphys=%x, vmap=%x, nphys=%x, nmap=%x", |
| 191 | nss_dev->id, nss_ctx, nss_ctx->vphys, nss_ctx->vmap, nss_ctx->nphys, nss_ctx->nmap); |
| 192 | |
| 193 | /* |
| 194 | * Register netdevice handlers |
| 195 | */ |
| 196 | nss_ctx->int_ctx[0].ndev = alloc_netdev(sizeof(struct netdev_priv_instance), |
| 197 | "qca-nss-dev%d", nss_dummy_netdev_setup); |
| 198 | if (nss_ctx->int_ctx[0].ndev == NULL) { |
| 199 | nss_warning("%p: Could not allocate net_device #0", nss_ctx); |
| 200 | err = -ENOMEM; |
| 201 | goto err_init_0; |
| 202 | } |
| 203 | |
| 204 | nss_ctx->int_ctx[0].ndev->netdev_ops = &nss_netdev_ops; |
| 205 | nss_ctx->int_ctx[0].ndev->ethtool_ops = &nss_ethtool_ops; |
| 206 | err = register_netdev(nss_ctx->int_ctx[0].ndev); |
| 207 | if (err) { |
| 208 | nss_warning("%p: Could not register net_device #0", nss_ctx); |
| 209 | goto err_init_1; |
| 210 | } |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 211 | |
| 212 | /* |
| 213 | * request for IRQs |
| 214 | * |
| 215 | * WARNING: CPU affinities should be set using OS supported methods |
| 216 | */ |
| 217 | nss_ctx->int_ctx[0].nss_ctx = nss_ctx; |
| 218 | nss_ctx->int_ctx[0].shift_factor = 0; |
| 219 | nss_ctx->int_ctx[0].irq = npd->irq[0]; |
| 220 | err = request_irq(npd->irq[0], nss_handle_irq, IRQF_DISABLED, "nss", &nss_ctx->int_ctx[0]); |
| 221 | if (err) { |
| 222 | nss_warning("%d: IRQ0 request failed", nss_dev->id); |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 223 | goto err_init_2; |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | /* |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 227 | * Register NAPI for NSS core interrupt #0 |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 228 | */ |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 229 | ndev_priv = netdev_priv(nss_ctx->int_ctx[0].ndev); |
| 230 | ndev_priv->int_ctx = &nss_ctx->int_ctx[0]; |
| 231 | netif_napi_add(nss_ctx->int_ctx[0].ndev, &nss_ctx->int_ctx[0].napi, nss_core_handle_napi, 64); |
| 232 | napi_enable(&nss_ctx->int_ctx[0].napi); |
| 233 | nss_ctx->int_ctx[0].napi_active = true; |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 234 | |
| 235 | /* |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 236 | * Check if second interrupt is supported on this nss core |
| 237 | */ |
| 238 | if (npd->num_irq > 1) { |
| 239 | nss_info("%d: This NSS core supports two interrupts", nss_dev->id); |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 240 | |
| 241 | /* |
| 242 | * Register netdevice handlers |
| 243 | */ |
| 244 | nss_ctx->int_ctx[1].ndev = alloc_netdev(sizeof(struct netdev_priv_instance), |
| 245 | "qca-nss-dev%d", nss_dummy_netdev_setup); |
| 246 | if (nss_ctx->int_ctx[1].ndev == NULL) { |
| 247 | nss_warning("%p: Could not allocate net_device #1", nss_ctx); |
| 248 | err = -ENOMEM; |
| 249 | goto err_init_3; |
| 250 | } |
| 251 | |
| 252 | nss_ctx->int_ctx[1].ndev->netdev_ops = &nss_netdev_ops; |
| 253 | nss_ctx->int_ctx[1].ndev->ethtool_ops = &nss_ethtool_ops; |
| 254 | err = register_netdev(nss_ctx->int_ctx[1].ndev); |
| 255 | if (err) { |
| 256 | nss_warning("%p: Could not register net_device #1", nss_ctx); |
| 257 | goto err_init_4; |
| 258 | } |
| 259 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 260 | nss_ctx->int_ctx[1].nss_ctx = nss_ctx; |
| 261 | nss_ctx->int_ctx[1].shift_factor = 15; |
| 262 | nss_ctx->int_ctx[1].irq = npd->irq[1]; |
| 263 | err = request_irq(npd->irq[1], nss_handle_irq, IRQF_DISABLED, "nss", &nss_ctx->int_ctx[1]); |
| 264 | if (err) { |
| 265 | nss_warning("%d: IRQ1 request failed for nss", nss_dev->id); |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 266 | goto err_init_5; |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | /* |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 270 | * Register NAPI for NSS core interrupt #1 |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 271 | */ |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 272 | ndev_priv = netdev_priv(nss_ctx->int_ctx[1].ndev); |
| 273 | ndev_priv->int_ctx = &nss_ctx->int_ctx[1]; |
| 274 | netif_napi_add(nss_ctx->int_ctx[1].ndev, &nss_ctx->int_ctx[1].napi, nss_core_handle_napi, 64); |
| 275 | napi_enable(&nss_ctx->int_ctx[1].napi); |
| 276 | nss_ctx->int_ctx[1].napi_active = true; |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | spin_lock_bh(&(nss_top->lock)); |
| 280 | |
| 281 | /* |
| 282 | * Check functionalities are supported by this NSS core |
| 283 | */ |
| 284 | if (npd->ipv4_enabled == NSS_FEATURE_ENABLED) { |
| 285 | nss_top->ipv4_handler_id = nss_dev->id; |
| 286 | } |
| 287 | |
| 288 | if (npd->ipv6_enabled == NSS_FEATURE_ENABLED) { |
| 289 | nss_top->ipv6_handler_id = nss_dev->id; |
| 290 | } |
| 291 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 292 | if (npd->crypto_enabled == NSS_FEATURE_ENABLED) { |
| 293 | nss_top->crypto_handler_id = nss_dev->id; |
| 294 | } |
| 295 | |
| 296 | if (npd->ipsec_enabled == NSS_FEATURE_ENABLED) { |
| 297 | nss_top->ipsec_handler_id = nss_dev->id; |
| 298 | } |
| 299 | |
| 300 | if (npd->wlan_enabled == NSS_FEATURE_ENABLED) { |
| 301 | nss_top->wlan_handler_id = nss_dev->id; |
| 302 | } |
| 303 | |
Bharath M Kumar | 0d87e91 | 2013-08-12 18:32:57 +0530 | [diff] [blame] | 304 | if (npd->tun6rd_enabled == NSS_FEATURE_ENABLED) { |
| 305 | nss_top->tun6rd_handler_id = nss_dev->id; |
| 306 | } |
| 307 | |
Bharath M Kumar | 614bbf8 | 2013-08-31 20:18:44 +0530 | [diff] [blame] | 308 | if (npd->tunipip6_enabled == NSS_FEATURE_ENABLED) { |
| 309 | nss_top->tunipip6_handler_id = nss_dev->id; |
| 310 | } |
| 311 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 312 | if (npd->gmac_enabled[0] == NSS_FEATURE_ENABLED) { |
| 313 | nss_top->phys_if_handler_id[0] = nss_dev->id; |
| 314 | } |
| 315 | |
| 316 | if (npd->gmac_enabled[1] == NSS_FEATURE_ENABLED) { |
| 317 | nss_top->phys_if_handler_id[1] = nss_dev->id; |
| 318 | } |
| 319 | |
| 320 | if (npd->gmac_enabled[2] == NSS_FEATURE_ENABLED) { |
| 321 | nss_top->phys_if_handler_id[2] = nss_dev->id; |
| 322 | } |
| 323 | |
| 324 | if (npd->gmac_enabled[3] == NSS_FEATURE_ENABLED) { |
| 325 | nss_top->phys_if_handler_id[3] = nss_dev->id; |
| 326 | } |
| 327 | |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 328 | nss_top->frequency_handler_id = nss_dev->id; |
| 329 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 330 | spin_unlock_bh(&(nss_top->lock)); |
| 331 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 332 | /* |
| 333 | * Initialize decongestion callbacks to NULL |
| 334 | */ |
| 335 | for (i = 0; i< NSS_MAX_CLIENTS; i++) { |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 336 | nss_ctx->queue_decongestion_callback[i] = 0; |
| 337 | nss_ctx->queue_decongestion_ctx[i] = 0; |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | spin_lock_init(&(nss_ctx->decongest_cb_lock)); |
| 341 | nss_ctx->magic = NSS_CTX_MAGIC; |
| 342 | |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 343 | nss_info("%p: Reseting NSS core %d now", nss_ctx, nss_ctx->id); |
| 344 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 345 | /* |
| 346 | * Enable clocks and bring NSS core out of reset |
| 347 | */ |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 348 | nss_hal_core_reset(nss_dev->id, nss_ctx->nmap, nss_ctx->load, nss_top->clk_src); |
| 349 | |
| 350 | /* |
| 351 | * Enable interrupts for NSS core |
| 352 | */ |
| 353 | nss_hal_enable_interrupt(nss_ctx->nmap, nss_ctx->int_ctx[0].irq, |
| 354 | nss_ctx->int_ctx[0].shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS); |
| 355 | |
| 356 | if (npd->num_irq > 1) { |
| 357 | nss_hal_enable_interrupt(nss_ctx->nmap, nss_ctx->int_ctx[1].irq, |
| 358 | nss_ctx->int_ctx[1].shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS); |
| 359 | } |
| 360 | |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 361 | nss_info("%p: All resources initialized and nss core%d has been brought out of reset", nss_ctx, nss_dev->id); |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 362 | goto err_init_0; |
| 363 | |
| 364 | err_init_5: |
| 365 | unregister_netdev(nss_ctx->int_ctx[1].ndev); |
| 366 | err_init_4: |
| 367 | free_netdev(nss_ctx->int_ctx[1].ndev); |
| 368 | err_init_3: |
| 369 | free_irq(npd->irq[0], &nss_ctx->int_ctx[0]); |
| 370 | err_init_2: |
| 371 | unregister_netdev(nss_ctx->int_ctx[0].ndev); |
| 372 | err_init_1: |
| 373 | free_netdev(nss_ctx->int_ctx[0].ndev); |
| 374 | err_init_0: |
| 375 | return err; |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | /* |
| 379 | * nss_remove() |
| 380 | * HLOS device remove callback |
| 381 | */ |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 382 | static int __devexit nss_remove(struct platform_device *nss_dev) |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 383 | { |
| 384 | struct nss_top_instance *nss_top = &nss_top_main; |
| 385 | struct nss_ctx_instance *nss_ctx = &nss_top->nss[nss_dev->id]; |
| 386 | |
| 387 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 388 | * Clean-up debugfs |
| 389 | */ |
| 390 | nss_stats_clean(); |
| 391 | |
| 392 | /* |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 393 | * Disable interrupts and bottom halves in HLOS |
| 394 | * Disable interrupts from NSS to HLOS |
| 395 | */ |
| 396 | nss_hal_disable_interrupt(nss_ctx->nmap, nss_ctx->int_ctx[0].irq, |
| 397 | nss_ctx->int_ctx[0].shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS); |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 398 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 399 | free_irq(nss_ctx->int_ctx[0].irq, &nss_ctx->int_ctx[0]); |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 400 | unregister_netdev(nss_ctx->int_ctx[0].ndev); |
| 401 | free_netdev(nss_ctx->int_ctx[0].ndev); |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 402 | |
| 403 | /* |
| 404 | * Check if second interrupt is supported |
| 405 | * If so then clear resources for second interrupt as well |
| 406 | */ |
| 407 | if (nss_ctx->int_ctx[1].irq) { |
| 408 | nss_hal_disable_interrupt(nss_ctx->nmap, nss_ctx->int_ctx[1].irq, |
| 409 | nss_ctx->int_ctx[1].shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS); |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 410 | free_irq(nss_ctx->int_ctx[1].irq, &nss_ctx->int_ctx[1]); |
Abhishek Rastogi | 271eee7 | 2013-07-29 21:08:36 +0530 | [diff] [blame] | 411 | unregister_netdev(nss_ctx->int_ctx[1].ndev); |
| 412 | free_netdev(nss_ctx->int_ctx[1].ndev); |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | nss_info("%p: All resources freed for nss core%d", nss_ctx, nss_dev->id); |
| 416 | return 0; |
| 417 | } |
| 418 | |
| 419 | /* |
| 420 | * nss_driver |
| 421 | * Platform driver structure for NSS |
| 422 | */ |
| 423 | struct platform_driver nss_driver = { |
| 424 | .probe = nss_probe, |
| 425 | .remove = __devexit_p(nss_remove), |
| 426 | .driver = { |
| 427 | .name = "qca-nss", |
| 428 | .owner = THIS_MODULE, |
| 429 | }, |
| 430 | }; |
| 431 | |
| 432 | /* |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 433 | *************************************************************************************************** |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 434 | * nss_wq_function() is used to queue up requests to change NSS frequencies. |
| 435 | * The function will take care of NSS notices and also control clock. |
| 436 | * The auto rate algorithmn will queue up requests or the procfs may also queue up these requests. |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 437 | *************************************************************************************************** |
| 438 | */ |
| 439 | |
| 440 | /* |
| 441 | * nss_wq_function() |
| 442 | * Added to Handle BH requests to kernel |
| 443 | */ |
| 444 | void nss_wq_function (struct work_struct *work) |
| 445 | { |
| 446 | nss_work_t *my_work = (nss_work_t *)work; |
| 447 | |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 448 | nss_freq_change(nss_freq_change_context, my_work->frequency, 0); |
| 449 | clk_set_rate(nss_core0_clk, my_work->frequency); |
| 450 | nss_freq_change(nss_freq_change_context, my_work->frequency, 1); |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 451 | |
| 452 | kfree((void *)work); |
| 453 | } |
| 454 | |
| 455 | /* |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 456 | * nss_current_freq_handler() |
| 457 | * Handle Userspace Frequency Change Requests |
| 458 | */ |
| 459 | static int nss_current_freq_handler (ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
| 460 | { |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 461 | int ret; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 462 | |
| 463 | BUG_ON(!nss_wq); |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 464 | |
| 465 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 466 | |
wthomas | d39fa82 | 2013-08-22 16:44:23 -0700 | [diff] [blame] | 467 | if (!write) { |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 468 | printk("Frequency Set to %d\n", nss_cmd_buf.current_freq); |
wthomas | d39fa82 | 2013-08-22 16:44:23 -0700 | [diff] [blame] | 469 | return ret; |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 470 | } |
wthomas | d39fa82 | 2013-08-22 16:44:23 -0700 | [diff] [blame] | 471 | |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 472 | /* Turn off Auto Scale */ |
| 473 | nss_cmd_buf.auto_scale = 0; |
| 474 | nss_runtime_samples.freq_scale_ready = 0; |
wthomas | d39fa82 | 2013-08-22 16:44:23 -0700 | [diff] [blame] | 475 | |
| 476 | /* If support NSS freq is in the table send the new frequency request to NSS */ |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 477 | if ((nss_cmd_buf.current_freq != NSS_FREQ_110) && (nss_cmd_buf.current_freq != NSS_FREQ_275) && (nss_cmd_buf.current_freq != NSS_FREQ_550) && (nss_cmd_buf.current_freq != NSS_FREQ_733)) { |
| 478 | printk("Frequency not found. Please check Frequency Table\n"); |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 479 | return ret; |
wthomas | d39fa82 | 2013-08-22 16:44:23 -0700 | [diff] [blame] | 480 | } |
| 481 | |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 482 | nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_KERNEL); |
| 483 | if (!nss_work) { |
| 484 | nss_info("NSS Freq WQ kmalloc fail"); |
| 485 | return ret; |
| 486 | } |
| 487 | INIT_WORK((struct work_struct *)nss_work, nss_wq_function); |
| 488 | nss_work->frequency = nss_cmd_buf.current_freq; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 489 | queue_work(nss_wq, (struct work_struct *)nss_work); |
| 490 | |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 491 | return ret; |
| 492 | } |
| 493 | |
| 494 | /* |
| 495 | * nss_auto_scale_handler() |
| 496 | * Enables or Disable Auto Scaling |
| 497 | */ |
| 498 | static int nss_auto_scale_handler (ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
| 499 | { |
| 500 | int ret; |
| 501 | |
| 502 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 503 | |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 504 | if (!write) { |
| 505 | return ret; |
| 506 | } |
| 507 | |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 508 | if (nss_cmd_buf.auto_scale != 1) { |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 509 | /* |
| 510 | * Auto Scaling is already disabled |
| 511 | */ |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 512 | nss_runtime_samples.freq_scale_ready = 0; |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 513 | return ret; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 514 | } |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 515 | |
Thomas Wu | fb6a684 | 2013-10-23 13:14:27 -0700 | [diff] [blame] | 516 | /* |
| 517 | * Auto Scaling is already being done |
| 518 | */ |
| 519 | if (nss_runtime_samples.freq_scale_ready == 1) { |
| 520 | return ret; |
| 521 | } |
| 522 | |
| 523 | /* |
| 524 | * Setup default values - Middle of Freq Scale Band |
| 525 | */ |
| 526 | nss_runtime_samples.freq_scale_index = 1; |
| 527 | nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency; |
| 528 | |
| 529 | nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_KERNEL); |
| 530 | if (!nss_work) { |
| 531 | nss_info("NSS Freq WQ kmalloc fail"); |
| 532 | return ret; |
| 533 | } |
| 534 | INIT_WORK((struct work_struct *)nss_work, nss_wq_function); |
| 535 | nss_work->frequency = nss_cmd_buf.current_freq; |
| 536 | queue_work(nss_wq, (struct work_struct *)nss_work); |
| 537 | |
| 538 | nss_runtime_samples.freq_scale_ready = 1; |
| 539 | |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 540 | return ret; |
| 541 | } |
| 542 | |
| 543 | /* |
| 544 | * nss_get_freq_table_handler() |
| 545 | * Display Support Freq and Ex how to Change. |
| 546 | */ |
| 547 | static int nss_get_freq_table_handler (ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
| 548 | { |
| 549 | int ret; |
| 550 | |
| 551 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 552 | |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 553 | printk("Frequency Supported - 110Mhz 275Mhz 550Mhz 733Mhz \n"); |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 554 | printk("Ex. To Change Frequency - echo 110000000 > current_freq \n"); |
| 555 | |
| 556 | return ret; |
| 557 | } |
| 558 | |
| 559 | /* |
Abhishek Rastogi | 1626a90 | 2013-11-21 17:09:49 +0530 | [diff] [blame^] | 560 | * nss_debug_handler() |
| 561 | * Enable NSS debug output |
| 562 | */ |
| 563 | static int nss_debug_handler(ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) |
| 564 | { |
| 565 | int ret; |
| 566 | |
| 567 | ret = proc_dointvec(ctl, write, buffer, lenp, ppos); |
| 568 | if (!ret) { |
| 569 | if ((write) && (nss_ctl_debug != 0)) { |
| 570 | printk("Enabling NSS SPI Debug\n"); |
| 571 | nss_hal_debug_enable(); |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | return ret; |
| 576 | } |
| 577 | |
| 578 | /* |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 579 | * sysctl-tuning infrastructure. |
| 580 | */ |
| 581 | static ctl_table nss_freq_table[] = { |
| 582 | { |
| 583 | .procname = "current_freq", |
| 584 | .data = &nss_cmd_buf.current_freq, |
| 585 | .maxlen = sizeof(int), |
| 586 | .mode = 0644, |
| 587 | .proc_handler = &nss_current_freq_handler, |
| 588 | }, |
| 589 | { |
| 590 | .procname = "freq_table", |
| 591 | .data = &nss_cmd_buf.max_freq, |
| 592 | .maxlen = sizeof(int), |
| 593 | .mode = 0644, |
| 594 | .proc_handler = &nss_get_freq_table_handler, |
| 595 | }, |
| 596 | { |
| 597 | .procname = "auto_scale", |
| 598 | .data = &nss_cmd_buf.auto_scale, |
| 599 | .maxlen = sizeof(int), |
| 600 | .mode = 0644, |
| 601 | .proc_handler = &nss_auto_scale_handler, |
| 602 | }, |
| 603 | { } |
| 604 | }; |
| 605 | |
Abhishek Rastogi | 5cd2e4c | 2013-11-13 18:09:08 +0530 | [diff] [blame] | 606 | static ctl_table nss_general_table[] = { |
| 607 | { |
| 608 | .procname = "redirect", |
| 609 | .data = &nss_ctl_redirect, |
| 610 | .maxlen = sizeof(int), |
| 611 | .mode = 0644, |
| 612 | .proc_handler = proc_dointvec, |
| 613 | }, |
Abhishek Rastogi | 1626a90 | 2013-11-21 17:09:49 +0530 | [diff] [blame^] | 614 | { |
| 615 | .procname = "debug", |
| 616 | .data = &nss_ctl_debug, |
| 617 | .maxlen = sizeof(int), |
| 618 | .mode = 0644, |
| 619 | .proc_handler = &nss_debug_handler, |
| 620 | }, |
Abhishek Rastogi | 5cd2e4c | 2013-11-13 18:09:08 +0530 | [diff] [blame] | 621 | { } |
| 622 | }; |
| 623 | |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 624 | static ctl_table nss_clock_dir[] = { |
| 625 | { |
Abhishek Rastogi | 5cd2e4c | 2013-11-13 18:09:08 +0530 | [diff] [blame] | 626 | .procname = "clock", |
| 627 | .mode = 0555, |
| 628 | .child = nss_freq_table, |
| 629 | }, |
| 630 | { |
| 631 | .procname = "general", |
| 632 | .mode = 0555, |
| 633 | .child = nss_general_table, |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 634 | }, |
| 635 | { } |
| 636 | }; |
| 637 | |
| 638 | static ctl_table nss_root_dir[] = { |
| 639 | { |
| 640 | .procname = "nss", |
| 641 | .mode = 0555, |
| 642 | .child = nss_clock_dir, |
| 643 | }, |
| 644 | { } |
| 645 | }; |
| 646 | |
| 647 | static ctl_table nss_root[] = { |
| 648 | { |
| 649 | .procname = "dev", |
| 650 | .mode = 0555, |
| 651 | .child = nss_root_dir, |
| 652 | }, |
| 653 | { } |
| 654 | }; |
| 655 | |
| 656 | static struct ctl_table_header *nss_dev_header; |
| 657 | |
| 658 | /* |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 659 | * nss_init() |
| 660 | * Registers nss driver |
| 661 | */ |
| 662 | static int __init nss_init(void) |
| 663 | { |
| 664 | nss_info("Init NSS driver"); |
| 665 | |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 666 | nss_freq_change_context = nss_get_frequency_mgr(); |
| 667 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 668 | /* |
| 669 | * Perform clock init common to all NSS cores |
| 670 | */ |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 671 | nss_hal_common_reset(&(nss_top_main.clk_src)); |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 672 | |
| 673 | /* |
| 674 | * Enable spin locks |
| 675 | */ |
| 676 | spin_lock_init(&(nss_top_main.lock)); |
| 677 | spin_lock_init(&(nss_top_main.stats_lock)); |
| 678 | |
| 679 | /* |
Abhishek Rastogi | 38cffff | 2013-06-02 11:25:47 +0530 | [diff] [blame] | 680 | * Enable NSS statistics |
| 681 | */ |
| 682 | nss_stats_init(); |
| 683 | |
| 684 | /* |
| 685 | * Store load addresses |
| 686 | */ |
| 687 | nss_top_main.nss[0].load = (uint32_t)load0; |
| 688 | nss_top_main.nss[1].load = (uint32_t)load1; |
| 689 | |
| 690 | /* |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 691 | * Register sysctl table. |
| 692 | */ |
| 693 | nss_dev_header = register_sysctl_table(nss_root); |
| 694 | |
| 695 | /* |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 696 | * Setup Runtime Sample values |
| 697 | */ |
| 698 | nss_runtime_samples.freq_scale[0].frequency = NSS_FREQ_110; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 699 | nss_runtime_samples.freq_scale[0].minimum = NSS_FREQ_110_MIN; |
| 700 | nss_runtime_samples.freq_scale[0].maximum = NSS_FREQ_110_MAX; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 701 | nss_runtime_samples.freq_scale[1].frequency = NSS_FREQ_550; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 702 | nss_runtime_samples.freq_scale[1].minimum = NSS_FREQ_550_MIN; |
| 703 | nss_runtime_samples.freq_scale[1].maximum = NSS_FREQ_550_MAX; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 704 | nss_runtime_samples.freq_scale[2].frequency = NSS_FREQ_733; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 705 | nss_runtime_samples.freq_scale[2].minimum = NSS_FREQ_733_MIN; |
| 706 | nss_runtime_samples.freq_scale[2].maximum = NSS_FREQ_733_MAX; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 707 | nss_runtime_samples.freq_scale_index = 1; |
| 708 | nss_runtime_samples.freq_scale_ready = 0; |
Thomas Wu | 9681f7e | 2013-11-06 13:12:57 -0800 | [diff] [blame] | 709 | nss_runtime_samples.freq_scale_rate_limit_up = 0; |
| 710 | nss_runtime_samples.freq_scale_rate_limit_down = 0; |
wthomas | 626147f | 2013-09-18 13:12:40 -0700 | [diff] [blame] | 711 | nss_runtime_samples.buffer_index = 0; |
| 712 | nss_runtime_samples.sum = 0; |
| 713 | nss_runtime_samples.sample_count = 0; |
| 714 | nss_runtime_samples.average = 0; |
| 715 | nss_runtime_samples.message_rate_limit = 0; |
| 716 | |
| 717 | /* |
| 718 | * Initial Workqueue |
| 719 | */ |
| 720 | nss_wq = create_workqueue("nss_freq_queue"); |
| 721 | |
| 722 | /* |
Pamidipati, Vijay | 7f413b5 | 2013-09-24 19:07:12 +0530 | [diff] [blame] | 723 | * Initialize NSS Bus PM module |
| 724 | */ |
| 725 | nss_pm_init(); |
| 726 | |
| 727 | /* |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 728 | * Register platform_driver |
| 729 | */ |
| 730 | return platform_driver_register(&nss_driver); |
| 731 | } |
| 732 | |
| 733 | /* |
| 734 | * nss_cleanup() |
| 735 | * Unregisters nss driver |
| 736 | */ |
| 737 | static void __exit nss_cleanup(void) |
| 738 | { |
| 739 | nss_info("Exit NSS driver"); |
wthomas | 442c797 | 2013-08-05 14:28:17 -0700 | [diff] [blame] | 740 | |
| 741 | if (nss_dev_header) |
| 742 | unregister_sysctl_table(nss_dev_header); |
| 743 | |
Abhishek Rastogi | bc74e43 | 2013-04-02 10:28:22 +0530 | [diff] [blame] | 744 | platform_driver_unregister(&nss_driver); |
| 745 | } |
| 746 | |
| 747 | module_init(nss_init); |
| 748 | module_exit(nss_cleanup); |
| 749 | |
| 750 | MODULE_DESCRIPTION("QCA NSS Driver"); |
| 751 | MODULE_AUTHOR("Qualcomm Atheros Inc"); |
| 752 | MODULE_LICENSE("Dual BSD/GPL"); |