blob: bd5467bba401b83f1522fc2f99d6f89d5698bbe6 [file] [log] [blame]
Radhakrishna Jiguru1c9b2252013-08-27 23:57:48 +05301/*
2 **************************************************************************
Zac Livingston866b0e22013-10-23 18:14:17 -06003 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
Radhakrishna Jiguru1c9b2252013-08-27 23:57:48 +05304 * 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 Rastogibc74e432013-04-02 10:28:22 +053016
17/*
18 * nss_init.c
19 * NSS init APIs
20 *
21 */
Abhishek Rastogibc74e432013-04-02 10:28:22 +053022#include "nss_core.h"
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +053023#include "nss_pm.h"
Abhishek Rastogi9da47472014-03-18 19:46:15 +053024#include "nss_tx_rx_common.h"
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +053025
Abhishek Rastogibc74e432013-04-02 10:28:22 +053026#include <nss_hal.h>
Thomas Wufb6a6842013-10-23 13:14:27 -070027#include <nss_clocks.h>
Abhishek Rastogibc74e432013-04-02 10:28:22 +053028
29#include <linux/module.h>
30#include <linux/platform_device.h>
wthomas442c7972013-08-05 14:28:17 -070031#include <linux/proc_fs.h>
32#include <linux/device.h>
Abhishek Rastogibc74e432013-04-02 10:28:22 +053033#include <mach/msm_nss.h>
34
wthomas442c7972013-08-05 14:28:17 -070035#include <linux/sysctl.h>
36#include <linux/regulator/consumer.h>
Thomas Wufb6a6842013-10-23 13:14:27 -070037#include <linux/clk.h>
Thomas Wu49008962014-04-02 14:50:47 -070038#include <linux/firmware.h>
39
40/*
41 * Macros
42 */
43#define MIN_IMG_SIZE 64*1024
Radha krishna Simha Jiguru6e74d572014-05-13 11:30:20 +053044#define NETAP0_IMAGE "qca-nss0.bin"
45#define NETAP1_IMAGE "qca-nss1.bin"
wthomas442c7972013-08-05 14:28:17 -070046
Abhishek Rastogibc74e432013-04-02 10:28:22 +053047/*
48 * Global declarations
49 */
Abhishek Rastogi5cd2e4c2013-11-13 18:09:08 +053050int nss_ctl_redirect __read_mostly = 0;
Sakthi Vignesh Radhakrishnanaf39aad2014-03-31 11:31:03 -070051int nss_ctl_debug __read_mostly = 0;
Abhishek Rastogibc74e432013-04-02 10:28:22 +053052
53/*
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +053054 * PM client handle
55 */
56static void *pm_client;
57
58/*
wthomas626147f2013-09-18 13:12:40 -070059 * Handler to send NSS messages
60 */
61void *nss_freq_change_context;
Thomas Wufb6a6842013-10-23 13:14:27 -070062struct clk *nss_core0_clk;
wthomas626147f2013-09-18 13:12:40 -070063
64/*
Abhishek Rastogibc74e432013-04-02 10:28:22 +053065 * Top level nss context structure
66 */
67struct nss_top_instance nss_top_main;
wthomas442c7972013-08-05 14:28:17 -070068struct nss_cmd_buffer nss_cmd_buf;
wthomas626147f2013-09-18 13:12:40 -070069struct nss_runtime_sampling nss_runtime_samples;
70struct workqueue_struct *nss_wq;
71
72/*
73 * Work Queue to handle messages to Kernel
74 */
75nss_work_t *nss_work;
Abhishek Rastogibc74e432013-04-02 10:28:22 +053076
77/*
78 * File local/Static variables/functions
79 */
80
Abhishek Rastogi271eee72013-07-29 21:08:36 +053081static const struct net_device_ops nss_netdev_ops;
82static const struct ethtool_ops nss_ethtool_ops;
83
84/*
85 * nss_dummy_netdev_setup()
86 * Dummy setup for net_device handler
87 */
88static void nss_dummy_netdev_setup(struct net_device *ndev)
89{
wthomas626147f2013-09-18 13:12:40 -070090
Abhishek Rastogi271eee72013-07-29 21:08:36 +053091}
92
Abhishek Rastogibc74e432013-04-02 10:28:22 +053093/*
94 * nss_handle_irq()
95 * HLOS interrupt handler for nss interrupts
96 */
97static irqreturn_t nss_handle_irq (int irq, void *ctx)
98{
99 struct int_ctx_instance *int_ctx = (struct int_ctx_instance *) ctx;
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +0530100 struct nss_ctx_instance *nss_ctx = int_ctx->nss_ctx;
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530101
102 /*
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +0530103 * Mask interrupt until our bottom half re-enables it
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530104 */
Abhishek Rastogi80f4eb12013-09-24 14:31:21 +0530105 nss_hal_disable_interrupt(nss_ctx->nmap, int_ctx->irq,
106 int_ctx->shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS);
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530107
108 /*
109 * Schedule tasklet to process interrupt cause
110 */
Abhishek Rastogi271eee72013-07-29 21:08:36 +0530111 napi_schedule(&int_ctx->napi);
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530112 return IRQ_HANDLED;
113}
114
115/*
116 * nss_probe()
117 * HLOS device probe callback
118 */
Abhishek Rastogi271eee72013-07-29 21:08:36 +0530119static int __devinit nss_probe(struct platform_device *nss_dev)
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530120{
121 struct nss_top_instance *nss_top = &nss_top_main;
122 struct nss_ctx_instance *nss_ctx = &nss_top->nss[nss_dev->id];
123 struct nss_platform_data *npd = (struct nss_platform_data *) nss_dev->dev.platform_data;
Abhishek Rastogi271eee72013-07-29 21:08:36 +0530124 struct netdev_priv_instance *ndev_priv;
125 int i, err = 0;
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530126
Thomas Wu49008962014-04-02 14:50:47 -0700127 const struct firmware *nss_fw = NULL;
128 int rc = -ENODEV;
129 void __iomem *load_mem;
130
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530131 nss_ctx->nss_top = nss_top;
132 nss_ctx->id = nss_dev->id;
133
wthomas442c7972013-08-05 14:28:17 -0700134 nss_info("%p: NSS_DEV_ID %s \n", nss_ctx, dev_name(&nss_dev->dev));
135
Radha krishna Simha Jiguru27bff9a2014-03-18 16:31:34 +0530136 /*
137 * F/W load from NSS Driver
138 */
139 if (nss_dev->id == 0) {
140 rc = request_firmware(&nss_fw, NETAP0_IMAGE, &(nss_dev->dev));
141 } else if (nss_dev->id == 1) {
142 rc = request_firmware(&nss_fw, NETAP1_IMAGE, &(nss_dev->dev));
143 } else {
Samarjeet Banerjee7bce8c52014-05-02 15:32:13 +0530144 nss_warning("%p: Invalid nss dev: %d \n", nss_ctx, nss_dev->id);
Radha krishna Simha Jiguru27bff9a2014-03-18 16:31:34 +0530145 }
146
147 /*
148 * Check if the file read is successful
149 */
150 if (rc) {
151 nss_warning("%p: request_firmware failed with err code: %d", nss_ctx, rc);
152 err = rc;
153 goto err_init_0;
Radha krishna Simha Jiguru27bff9a2014-03-18 16:31:34 +0530154 }
155
Radha krishna Simha Jiguru9ed88c62014-04-11 12:12:33 +0530156 if (nss_fw->size < MIN_IMG_SIZE) {
157 nss_warning("%p: nss firmware is truncated, size:%d", nss_ctx, nss_fw->size);
Thomas Wu49008962014-04-02 14:50:47 -0700158 }
159
Radha krishna Simha Jiguru9ed88c62014-04-11 12:12:33 +0530160 load_mem = ioremap_nocache(npd->load_addr, nss_fw->size);
161 if (load_mem == NULL) {
162 nss_warning("%p: ioremap_nocache failed: %x", nss_ctx, npd->load_addr);
163 release_firmware(nss_fw);
Thomas Wu49008962014-04-02 14:50:47 -0700164 goto err_init_0;
Thomas Wu49008962014-04-02 14:50:47 -0700165 }
166
Radha krishna Simha Jiguru9ed88c62014-04-11 12:12:33 +0530167 printk("nss_driver - fw of size %u bytes copied to load addr: %x\n", nss_fw->size, npd->load_addr);
168 memcpy_toio(load_mem, nss_fw->data, nss_fw->size);
169 release_firmware(nss_fw);
170 iounmap(load_mem);
171
wthomas442c7972013-08-05 14:28:17 -0700172 /*
173 * Both NSS cores controlled by same regulator, Hook only Once
174 */
175 if (!nss_dev->id) {
Thomas Wufb6a6842013-10-23 13:14:27 -0700176 nss_core0_clk = clk_get(&nss_dev->dev, "nss_core_clk");
177 if (IS_ERR(nss_core0_clk)) {
wthomas442c7972013-08-05 14:28:17 -0700178
Thomas Wufb6a6842013-10-23 13:14:27 -0700179 err = PTR_ERR(nss_core0_clk);
wthomas442c7972013-08-05 14:28:17 -0700180 nss_info("%p: Regulator %s get failed, err=%d\n", nss_ctx, dev_name(&nss_dev->dev), err);
181 return err;
182
wthomas442c7972013-08-05 14:28:17 -0700183 }
Thomas Wufb6a6842013-10-23 13:14:27 -0700184 clk_set_rate(nss_core0_clk, NSS_FREQ_550);
185 clk_prepare(nss_core0_clk);
186 clk_enable(nss_core0_clk);
Thomas Wu0a0a9c92013-11-21 15:28:19 -0800187
188 /*
189 * Check if turbo is supported
190 */
191 if (npd->turbo_frequency) {
192 /*
193 * Turbo is supported
194 */
195 printk("nss_driver - Turbo Support %d\n", npd->turbo_frequency);
196 nss_runtime_samples.freq_scale_sup_max = NSS_MAX_CPU_SCALES;
Pamidipati, Vijayf9b5a272014-01-22 14:24:10 +0530197 nss_pm_set_turbo();
Thomas Wu0a0a9c92013-11-21 15:28:19 -0800198 } else {
199 printk("nss_driver - Turbo No Support %d\n", npd->turbo_frequency);
200 nss_runtime_samples.freq_scale_sup_max = NSS_MAX_CPU_SCALES - 1;
201 }
wthomas442c7972013-08-05 14:28:17 -0700202 }
203
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530204 /*
Sakthi Vignesh Radhakrishnand923e342013-12-09 11:53:03 -0800205 * Get load address of NSS firmware
206 */
207 nss_info("%p: Setting NSS%d Firmware load address to %x\n", nss_ctx, nss_dev->id, npd->load_addr);
208 nss_top->nss[nss_dev->id].load = npd->load_addr;
209
210 /*
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530211 * Get virtual and physical memory addresses for nss logical/hardware address maps
212 */
213
214 /*
215 * Virtual address of CSM space
216 */
217 nss_ctx->nmap = npd->nmap;
218 nss_assert(nss_ctx->nmap);
219
220 /*
221 * Physical address of CSM space
222 */
223 nss_ctx->nphys = npd->nphys;
224 nss_assert(nss_ctx->nphys);
225
226 /*
227 * Virtual address of logical registers space
228 */
229 nss_ctx->vmap = npd->vmap;
230 nss_assert(nss_ctx->vmap);
231
232 /*
233 * Physical address of logical registers space
234 */
235 nss_ctx->vphys = npd->vphys;
236 nss_assert(nss_ctx->vphys);
Abhishek Rastogi271eee72013-07-29 21:08:36 +0530237 nss_info("%d:ctx=%p, vphys=%x, vmap=%x, nphys=%x, nmap=%x",
238 nss_dev->id, nss_ctx, nss_ctx->vphys, nss_ctx->vmap, nss_ctx->nphys, nss_ctx->nmap);
239
240 /*
241 * Register netdevice handlers
242 */
243 nss_ctx->int_ctx[0].ndev = alloc_netdev(sizeof(struct netdev_priv_instance),
244 "qca-nss-dev%d", nss_dummy_netdev_setup);
245 if (nss_ctx->int_ctx[0].ndev == NULL) {
246 nss_warning("%p: Could not allocate net_device #0", nss_ctx);
247 err = -ENOMEM;
248 goto err_init_0;
249 }
250
251 nss_ctx->int_ctx[0].ndev->netdev_ops = &nss_netdev_ops;
252 nss_ctx->int_ctx[0].ndev->ethtool_ops = &nss_ethtool_ops;
253 err = register_netdev(nss_ctx->int_ctx[0].ndev);
254 if (err) {
255 nss_warning("%p: Could not register net_device #0", nss_ctx);
256 goto err_init_1;
257 }
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530258
259 /*
260 * request for IRQs
261 *
262 * WARNING: CPU affinities should be set using OS supported methods
263 */
264 nss_ctx->int_ctx[0].nss_ctx = nss_ctx;
265 nss_ctx->int_ctx[0].shift_factor = 0;
266 nss_ctx->int_ctx[0].irq = npd->irq[0];
267 err = request_irq(npd->irq[0], nss_handle_irq, IRQF_DISABLED, "nss", &nss_ctx->int_ctx[0]);
268 if (err) {
269 nss_warning("%d: IRQ0 request failed", nss_dev->id);
Abhishek Rastogi271eee72013-07-29 21:08:36 +0530270 goto err_init_2;
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530271 }
272
273 /*
Abhishek Rastogi271eee72013-07-29 21:08:36 +0530274 * Register NAPI for NSS core interrupt #0
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530275 */
Abhishek Rastogi271eee72013-07-29 21:08:36 +0530276 ndev_priv = netdev_priv(nss_ctx->int_ctx[0].ndev);
277 ndev_priv->int_ctx = &nss_ctx->int_ctx[0];
278 netif_napi_add(nss_ctx->int_ctx[0].ndev, &nss_ctx->int_ctx[0].napi, nss_core_handle_napi, 64);
279 napi_enable(&nss_ctx->int_ctx[0].napi);
280 nss_ctx->int_ctx[0].napi_active = true;
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530281
282 /*
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530283 * Check if second interrupt is supported on this nss core
284 */
285 if (npd->num_irq > 1) {
286 nss_info("%d: This NSS core supports two interrupts", nss_dev->id);
Abhishek Rastogi271eee72013-07-29 21:08:36 +0530287
288 /*
289 * Register netdevice handlers
290 */
291 nss_ctx->int_ctx[1].ndev = alloc_netdev(sizeof(struct netdev_priv_instance),
292 "qca-nss-dev%d", nss_dummy_netdev_setup);
293 if (nss_ctx->int_ctx[1].ndev == NULL) {
294 nss_warning("%p: Could not allocate net_device #1", nss_ctx);
295 err = -ENOMEM;
296 goto err_init_3;
297 }
298
299 nss_ctx->int_ctx[1].ndev->netdev_ops = &nss_netdev_ops;
300 nss_ctx->int_ctx[1].ndev->ethtool_ops = &nss_ethtool_ops;
301 err = register_netdev(nss_ctx->int_ctx[1].ndev);
302 if (err) {
303 nss_warning("%p: Could not register net_device #1", nss_ctx);
304 goto err_init_4;
305 }
306
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530307 nss_ctx->int_ctx[1].nss_ctx = nss_ctx;
308 nss_ctx->int_ctx[1].shift_factor = 15;
309 nss_ctx->int_ctx[1].irq = npd->irq[1];
310 err = request_irq(npd->irq[1], nss_handle_irq, IRQF_DISABLED, "nss", &nss_ctx->int_ctx[1]);
311 if (err) {
312 nss_warning("%d: IRQ1 request failed for nss", nss_dev->id);
Abhishek Rastogi271eee72013-07-29 21:08:36 +0530313 goto err_init_5;
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530314 }
315
316 /*
Abhishek Rastogi271eee72013-07-29 21:08:36 +0530317 * Register NAPI for NSS core interrupt #1
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530318 */
Abhishek Rastogi271eee72013-07-29 21:08:36 +0530319 ndev_priv = netdev_priv(nss_ctx->int_ctx[1].ndev);
320 ndev_priv->int_ctx = &nss_ctx->int_ctx[1];
321 netif_napi_add(nss_ctx->int_ctx[1].ndev, &nss_ctx->int_ctx[1].napi, nss_core_handle_napi, 64);
322 napi_enable(&nss_ctx->int_ctx[1].napi);
323 nss_ctx->int_ctx[1].napi_active = true;
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530324 }
325
326 spin_lock_bh(&(nss_top->lock));
327
328 /*
329 * Check functionalities are supported by this NSS core
330 */
Murat Sezgin7a705422014-01-30 16:09:22 -0800331 if (npd->shaping_enabled == NSS_FEATURE_ENABLED) {
332 nss_top->shaping_handler_id = nss_dev->id;
Radha krishna Simha Jiguru9ed88c62014-04-11 12:12:33 +0530333 printk(KERN_INFO "%p: NSS Shaping is enabled, handler id: %u\n", __func__, nss_top->shaping_handler_id);
Murat Sezgin7a705422014-01-30 16:09:22 -0800334 }
335
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530336 if (npd->ipv4_enabled == NSS_FEATURE_ENABLED) {
337 nss_top->ipv4_handler_id = nss_dev->id;
Abhishek Rastogi9da47472014-03-18 19:46:15 +0530338 nss_ipv4_register_handler();
339 nss_pppoe_register_handler();
Abhishek Rastogi84d95d02014-03-26 19:31:31 +0530340 nss_eth_rx_register_handler();
341 nss_n2h_register_handler();
Sol Kavy2783c072014-04-05 12:53:13 -0700342 nss_virt_if_register_handler();
Tushar Mathura3e03052014-04-07 20:17:28 +0530343 nss_lag_register_handler();
Sol Kavy4013e282014-04-06 15:57:00 -0700344 for (i = 0; i < NSS_MAX_VIRTUAL_INTERFACES; i++) {
345 nss_top->virt_if_handler_id[i] = nss_dev->id;
346 }
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530347 }
348
349 if (npd->ipv6_enabled == NSS_FEATURE_ENABLED) {
350 nss_top->ipv6_handler_id = nss_dev->id;
Abhishek Rastogi9da47472014-03-18 19:46:15 +0530351 nss_ipv6_register_handler();
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530352 }
353
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530354 if (npd->crypto_enabled == NSS_FEATURE_ENABLED) {
355 nss_top->crypto_handler_id = nss_dev->id;
Abhishek Rastogi9da47472014-03-18 19:46:15 +0530356 nss_crypto_register_handler();
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530357 }
358
359 if (npd->ipsec_enabled == NSS_FEATURE_ENABLED) {
360 nss_top->ipsec_handler_id = nss_dev->id;
Abhishek Rastogi9da47472014-03-18 19:46:15 +0530361 nss_ipsec_register_handler();
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530362 }
363
364 if (npd->wlan_enabled == NSS_FEATURE_ENABLED) {
365 nss_top->wlan_handler_id = nss_dev->id;
366 }
367
Bharath M Kumar0d87e912013-08-12 18:32:57 +0530368 if (npd->tun6rd_enabled == NSS_FEATURE_ENABLED) {
369 nss_top->tun6rd_handler_id = nss_dev->id;
Abhishek Rastogi9da47472014-03-18 19:46:15 +0530370 nss_tun6rd_register_handler();
Bharath M Kumar0d87e912013-08-12 18:32:57 +0530371 }
372
Bharath M Kumar614bbf82013-08-31 20:18:44 +0530373 if (npd->tunipip6_enabled == NSS_FEATURE_ENABLED) {
374 nss_top->tunipip6_handler_id = nss_dev->id;
Abhishek Rastogi9da47472014-03-18 19:46:15 +0530375 nss_tunipip6_register_handler();
Bharath M Kumar614bbf82013-08-31 20:18:44 +0530376 }
377
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530378 if (npd->gmac_enabled[0] == NSS_FEATURE_ENABLED) {
379 nss_top->phys_if_handler_id[0] = nss_dev->id;
Abhishek Rastogi9da47472014-03-18 19:46:15 +0530380 nss_phys_if_register_handler(0);
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530381 }
382
383 if (npd->gmac_enabled[1] == NSS_FEATURE_ENABLED) {
384 nss_top->phys_if_handler_id[1] = nss_dev->id;
Abhishek Rastogi9da47472014-03-18 19:46:15 +0530385 nss_phys_if_register_handler(1);
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530386 }
387
388 if (npd->gmac_enabled[2] == NSS_FEATURE_ENABLED) {
389 nss_top->phys_if_handler_id[2] = nss_dev->id;
Abhishek Rastogi9da47472014-03-18 19:46:15 +0530390 nss_phys_if_register_handler(2);
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530391 }
392
393 if (npd->gmac_enabled[3] == NSS_FEATURE_ENABLED) {
394 nss_top->phys_if_handler_id[3] = nss_dev->id;
Abhishek Rastogi9da47472014-03-18 19:46:15 +0530395 nss_phys_if_register_handler(3);
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530396 }
397
Thomas Wu168ca262014-03-21 16:20:27 -0700398 nss_core_freq_register_handler();
399
wthomas626147f2013-09-18 13:12:40 -0700400 nss_top->frequency_handler_id = nss_dev->id;
401
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530402 spin_unlock_bh(&(nss_top->lock));
403
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530404 /*
405 * Initialize decongestion callbacks to NULL
406 */
407 for (i = 0; i< NSS_MAX_CLIENTS; i++) {
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530408 nss_ctx->queue_decongestion_callback[i] = 0;
409 nss_ctx->queue_decongestion_ctx[i] = 0;
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530410 }
411
412 spin_lock_init(&(nss_ctx->decongest_cb_lock));
413 nss_ctx->magic = NSS_CTX_MAGIC;
414
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530415 nss_info("%p: Reseting NSS core %d now", nss_ctx, nss_ctx->id);
416
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530417 /*
418 * Enable clocks and bring NSS core out of reset
419 */
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530420 nss_hal_core_reset(nss_dev->id, nss_ctx->nmap, nss_ctx->load, nss_top->clk_src);
421
422 /*
423 * Enable interrupts for NSS core
424 */
425 nss_hal_enable_interrupt(nss_ctx->nmap, nss_ctx->int_ctx[0].irq,
426 nss_ctx->int_ctx[0].shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS);
427
428 if (npd->num_irq > 1) {
429 nss_hal_enable_interrupt(nss_ctx->nmap, nss_ctx->int_ctx[1].irq,
430 nss_ctx->int_ctx[1].shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS);
431 }
432
Radhakrishna Jigurub7346cf2013-12-16 13:08:43 +0530433 /*
434 * Initialize max buffer size for NSS core
435 */
436 nss_ctx->max_buf_size = NSS_NBUF_PAYLOAD_SIZE;
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530437 nss_info("%p: All resources initialized and nss core%d has been brought out of reset", nss_ctx, nss_dev->id);
Abhishek Rastogi271eee72013-07-29 21:08:36 +0530438 goto err_init_0;
439
440err_init_5:
441 unregister_netdev(nss_ctx->int_ctx[1].ndev);
442err_init_4:
443 free_netdev(nss_ctx->int_ctx[1].ndev);
444err_init_3:
445 free_irq(npd->irq[0], &nss_ctx->int_ctx[0]);
446err_init_2:
447 unregister_netdev(nss_ctx->int_ctx[0].ndev);
448err_init_1:
449 free_netdev(nss_ctx->int_ctx[0].ndev);
450err_init_0:
451 return err;
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530452}
453
454/*
455 * nss_remove()
456 * HLOS device remove callback
457 */
Abhishek Rastogi271eee72013-07-29 21:08:36 +0530458static int __devexit nss_remove(struct platform_device *nss_dev)
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530459{
460 struct nss_top_instance *nss_top = &nss_top_main;
461 struct nss_ctx_instance *nss_ctx = &nss_top->nss[nss_dev->id];
462
463 /*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530464 * Clean-up debugfs
465 */
466 nss_stats_clean();
467
468 /*
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530469 * Disable interrupts and bottom halves in HLOS
470 * Disable interrupts from NSS to HLOS
471 */
472 nss_hal_disable_interrupt(nss_ctx->nmap, nss_ctx->int_ctx[0].irq,
473 nss_ctx->int_ctx[0].shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS);
Abhishek Rastogi271eee72013-07-29 21:08:36 +0530474
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530475 free_irq(nss_ctx->int_ctx[0].irq, &nss_ctx->int_ctx[0]);
Abhishek Rastogi271eee72013-07-29 21:08:36 +0530476 unregister_netdev(nss_ctx->int_ctx[0].ndev);
477 free_netdev(nss_ctx->int_ctx[0].ndev);
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530478
479 /*
480 * Check if second interrupt is supported
481 * If so then clear resources for second interrupt as well
482 */
483 if (nss_ctx->int_ctx[1].irq) {
484 nss_hal_disable_interrupt(nss_ctx->nmap, nss_ctx->int_ctx[1].irq,
485 nss_ctx->int_ctx[1].shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS);
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530486 free_irq(nss_ctx->int_ctx[1].irq, &nss_ctx->int_ctx[1]);
Abhishek Rastogi271eee72013-07-29 21:08:36 +0530487 unregister_netdev(nss_ctx->int_ctx[1].ndev);
488 free_netdev(nss_ctx->int_ctx[1].ndev);
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530489 }
490
491 nss_info("%p: All resources freed for nss core%d", nss_ctx, nss_dev->id);
492 return 0;
493}
494
495/*
496 * nss_driver
497 * Platform driver structure for NSS
498 */
499struct platform_driver nss_driver = {
500 .probe = nss_probe,
501 .remove = __devexit_p(nss_remove),
502 .driver = {
503 .name = "qca-nss",
504 .owner = THIS_MODULE,
505 },
506};
507
508/*
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530509 * nss_reset_frequency_stats_samples()
510 * Reset all frequency sampling state when auto scaling is turned off.
511 */
512static void nss_reset_frequency_stats_samples (void)
513{
514 nss_runtime_samples.buffer_index = 0;
515 nss_runtime_samples.sum = 0;
516 nss_runtime_samples.average = 0;
517 nss_runtime_samples.sample_count = 0;
518 nss_runtime_samples.message_rate_limit = 0;
519 nss_runtime_samples.freq_scale_rate_limit_up = 0;
520 nss_runtime_samples.freq_scale_rate_limit_down = 0;
521}
522
523/*
wthomas626147f2013-09-18 13:12:40 -0700524 ***************************************************************************************************
Thomas Wufb6a6842013-10-23 13:14:27 -0700525 * nss_wq_function() is used to queue up requests to change NSS frequencies.
526 * The function will take care of NSS notices and also control clock.
527 * The auto rate algorithmn will queue up requests or the procfs may also queue up these requests.
wthomas626147f2013-09-18 13:12:40 -0700528 ***************************************************************************************************
529 */
530
531/*
532 * nss_wq_function()
533 * Added to Handle BH requests to kernel
534 */
535void nss_wq_function (struct work_struct *work)
536{
537 nss_work_t *my_work = (nss_work_t *)work;
538
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530539 nss_freq_change(nss_freq_change_context, my_work->frequency, my_work->stats_enable, 0);
Thomas Wufb6a6842013-10-23 13:14:27 -0700540 clk_set_rate(nss_core0_clk, my_work->frequency);
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530541 nss_freq_change(nss_freq_change_context, my_work->frequency, my_work->stats_enable, 1);
wthomas626147f2013-09-18 13:12:40 -0700542
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +0530543 if(!pm_client) {
544 goto out;
545 }
546
547 if (my_work->frequency == NSS_FREQ_733) {
548 nss_pm_set_perf_level(pm_client, NSS_PM_PERF_LEVEL_TURBO);
549 } else if ((my_work->frequency == NSS_FREQ_275) || (my_work->frequency == NSS_FREQ_550)) {
550 nss_pm_set_perf_level(pm_client, NSS_PM_PERF_LEVEL_NOMINAL);
551 } else {
552 nss_pm_set_perf_level(pm_client, NSS_PM_PERF_LEVEL_IDLE);
553 }
554out:
wthomas626147f2013-09-18 13:12:40 -0700555 kfree((void *)work);
556}
557
558/*
wthomas442c7972013-08-05 14:28:17 -0700559 * nss_current_freq_handler()
560 * Handle Userspace Frequency Change Requests
561 */
562static int nss_current_freq_handler (ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
563{
wthomas442c7972013-08-05 14:28:17 -0700564 int ret;
wthomas626147f2013-09-18 13:12:40 -0700565
566 BUG_ON(!nss_wq);
wthomas442c7972013-08-05 14:28:17 -0700567
568 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
569
wthomasd39fa822013-08-22 16:44:23 -0700570 if (!write) {
wthomas626147f2013-09-18 13:12:40 -0700571 printk("Frequency Set to %d\n", nss_cmd_buf.current_freq);
wthomasd39fa822013-08-22 16:44:23 -0700572 return ret;
wthomas442c7972013-08-05 14:28:17 -0700573 }
wthomasd39fa822013-08-22 16:44:23 -0700574
wthomas626147f2013-09-18 13:12:40 -0700575 /* Turn off Auto Scale */
576 nss_cmd_buf.auto_scale = 0;
577 nss_runtime_samples.freq_scale_ready = 0;
wthomasd39fa822013-08-22 16:44:23 -0700578
Thomas Wu0a0a9c92013-11-21 15:28:19 -0800579 /* If support NSS freq is in the table send the new frequency request to NSS or If No Turbo and ask for turbo freq */
580 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)) || ((nss_runtime_samples.freq_scale_sup_max != NSS_MAX_CPU_SCALES) && (nss_cmd_buf.current_freq == NSS_FREQ_733))) {
Thomas Wufb6a6842013-10-23 13:14:27 -0700581 printk("Frequency not found. Please check Frequency Table\n");
wthomas626147f2013-09-18 13:12:40 -0700582 return ret;
wthomasd39fa822013-08-22 16:44:23 -0700583 }
584
Thomas Wu7409bce2014-05-21 10:56:07 -0700585 nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_ATOMIC);
wthomas626147f2013-09-18 13:12:40 -0700586 if (!nss_work) {
587 nss_info("NSS Freq WQ kmalloc fail");
588 return ret;
589 }
590 INIT_WORK((struct work_struct *)nss_work, nss_wq_function);
591 nss_work->frequency = nss_cmd_buf.current_freq;
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530592 nss_work->stats_enable = 0;
593
594 /* Ensure we start with a fresh set of samples later */
595 nss_reset_frequency_stats_samples();
596
wthomas626147f2013-09-18 13:12:40 -0700597 queue_work(nss_wq, (struct work_struct *)nss_work);
598
wthomas442c7972013-08-05 14:28:17 -0700599 return ret;
600}
601
602/*
603 * nss_auto_scale_handler()
604 * Enables or Disable Auto Scaling
605 */
606static int nss_auto_scale_handler (ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
607{
608 int ret;
609
610 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
611
wthomas626147f2013-09-18 13:12:40 -0700612 if (!write) {
613 return ret;
614 }
615
Thomas Wufb6a6842013-10-23 13:14:27 -0700616 if (nss_cmd_buf.auto_scale != 1) {
wthomas626147f2013-09-18 13:12:40 -0700617 /*
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530618 * Is auto scaling currently enabled? If so, send the command to
619 * disable stats reporting to NSS
wthomas626147f2013-09-18 13:12:40 -0700620 */
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530621 if (nss_runtime_samples.freq_scale_ready != 0) {
622 nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency;
Thomas Wu7409bce2014-05-21 10:56:07 -0700623 nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_ATOMIC);
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530624 if (!nss_work) {
625 nss_info("NSS Freq WQ kmalloc fail");
626 return ret;
627 }
628 INIT_WORK((struct work_struct *)nss_work, nss_wq_function);
629 nss_work->frequency = nss_cmd_buf.current_freq;
630 nss_work->stats_enable = 0;
631 queue_work(nss_wq, (struct work_struct *)nss_work);
632 nss_runtime_samples.freq_scale_ready = 0;
633
634 /*
635 * The current samples would be stale later when scaling is
636 * enabled again, hence reset them
637 */
638 nss_reset_frequency_stats_samples();
639 }
Thomas Wufb6a6842013-10-23 13:14:27 -0700640 return ret;
wthomas626147f2013-09-18 13:12:40 -0700641 }
wthomas442c7972013-08-05 14:28:17 -0700642
Thomas Wufb6a6842013-10-23 13:14:27 -0700643 /*
644 * Auto Scaling is already being done
645 */
646 if (nss_runtime_samples.freq_scale_ready == 1) {
647 return ret;
648 }
649
650 /*
651 * Setup default values - Middle of Freq Scale Band
652 */
653 nss_runtime_samples.freq_scale_index = 1;
654 nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency;
655
Thomas Wu7409bce2014-05-21 10:56:07 -0700656 nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_ATOMIC);
Thomas Wufb6a6842013-10-23 13:14:27 -0700657 if (!nss_work) {
658 nss_info("NSS Freq WQ kmalloc fail");
659 return ret;
660 }
661 INIT_WORK((struct work_struct *)nss_work, nss_wq_function);
662 nss_work->frequency = nss_cmd_buf.current_freq;
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530663 nss_work->stats_enable = 1;
Thomas Wufb6a6842013-10-23 13:14:27 -0700664 queue_work(nss_wq, (struct work_struct *)nss_work);
665
666 nss_runtime_samples.freq_scale_ready = 1;
667
wthomas442c7972013-08-05 14:28:17 -0700668 return ret;
669}
670
671/*
672 * nss_get_freq_table_handler()
673 * Display Support Freq and Ex how to Change.
674 */
Thomas Wu05495be2013-12-19 14:24:24 -0800675static int nss_get_freq_table_handler(ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
wthomas442c7972013-08-05 14:28:17 -0700676{
677 int ret;
678
679 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
680
Thomas Wu0a0a9c92013-11-21 15:28:19 -0800681 if (nss_runtime_samples.freq_scale_sup_max != NSS_MAX_CPU_SCALES) {
682 printk("Frequency Supported - 110Mhz 275Mhz 550Mhz\n");
683 printk("Ex. To Change Frequency - echo 110000000 > current_freq \n");
684
685 return ret;
686 }
687
wthomas626147f2013-09-18 13:12:40 -0700688 printk("Frequency Supported - 110Mhz 275Mhz 550Mhz 733Mhz \n");
wthomas442c7972013-08-05 14:28:17 -0700689 printk("Ex. To Change Frequency - echo 110000000 > current_freq \n");
690
691 return ret;
692}
693
694/*
Thomas Wu05495be2013-12-19 14:24:24 -0800695 * nss_get_average_inst_handler()
696 * Display AVG Inst Per Ms.
697 */
698static int nss_get_average_inst_handler(ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
699{
700 int ret;
701
702 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
703
704 if (!ret && !write) {
705 printk("Current Inst Per Ms %x\n", nss_runtime_samples.average);
706 }
707
708 return ret;
709}
710
711/*
Abhishek Rastogi1626a902013-11-21 17:09:49 +0530712 * nss_debug_handler()
713 * Enable NSS debug output
714 */
715static int nss_debug_handler(ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
716{
717 int ret;
718
719 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
720 if (!ret) {
721 if ((write) && (nss_ctl_debug != 0)) {
722 printk("Enabling NSS SPI Debug\n");
723 nss_hal_debug_enable();
724 }
725 }
726
727 return ret;
728}
729
730/*
Thomas Wu52075f42014-02-06 16:32:42 -0800731 * nss_coredump_handler()
732 * Send Signal To Coredump NSS Cores
733 */
734static int nss_coredump_handler(ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
735{
736 struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *) nss_freq_change_context;
737 int ret;
738
739 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
740 if (!ret) {
741 if ((write) && (nss_ctl_debug != 0)) {
742 printk("Coredumping to DDR\n");
743 nss_hal_send_interrupt(nss_ctx->nmap, nss_ctx->h2n_desc_rings[NSS_IF_CMD_QUEUE].desc_ring.int_bit, NSS_REGS_H2N_INTR_STATUS_COREDUMP_START);
744 }
745 }
746
747 return ret;
748}
749
750/*
wthomas442c7972013-08-05 14:28:17 -0700751 * sysctl-tuning infrastructure.
752 */
753static ctl_table nss_freq_table[] = {
754 {
755 .procname = "current_freq",
756 .data = &nss_cmd_buf.current_freq,
757 .maxlen = sizeof(int),
758 .mode = 0644,
759 .proc_handler = &nss_current_freq_handler,
760 },
761 {
762 .procname = "freq_table",
763 .data = &nss_cmd_buf.max_freq,
764 .maxlen = sizeof(int),
765 .mode = 0644,
766 .proc_handler = &nss_get_freq_table_handler,
767 },
768 {
769 .procname = "auto_scale",
770 .data = &nss_cmd_buf.auto_scale,
771 .maxlen = sizeof(int),
772 .mode = 0644,
773 .proc_handler = &nss_auto_scale_handler,
774 },
Thomas Wu05495be2013-12-19 14:24:24 -0800775 {
776 .procname = "inst_per_sec",
777 .data = &nss_cmd_buf.average_inst,
778 .maxlen = sizeof(int),
779 .mode = 0644,
780 .proc_handler = &nss_get_average_inst_handler,
781 },
wthomas442c7972013-08-05 14:28:17 -0700782 { }
783};
784
Abhishek Rastogi5cd2e4c2013-11-13 18:09:08 +0530785static ctl_table nss_general_table[] = {
786 {
787 .procname = "redirect",
788 .data = &nss_ctl_redirect,
789 .maxlen = sizeof(int),
790 .mode = 0644,
791 .proc_handler = proc_dointvec,
792 },
Abhishek Rastogi1626a902013-11-21 17:09:49 +0530793 {
794 .procname = "debug",
795 .data = &nss_ctl_debug,
796 .maxlen = sizeof(int),
797 .mode = 0644,
798 .proc_handler = &nss_debug_handler,
799 },
Thomas Wu52075f42014-02-06 16:32:42 -0800800 {
801 .procname = "coredump",
802 .data = &nss_cmd_buf.coredump,
803 .maxlen = sizeof(int),
804 .mode = 0644,
805 .proc_handler = &nss_coredump_handler,
806 },
Abhishek Rastogi5cd2e4c2013-11-13 18:09:08 +0530807 { }
808};
809
wthomas442c7972013-08-05 14:28:17 -0700810static ctl_table nss_clock_dir[] = {
811 {
Abhishek Rastogi5cd2e4c2013-11-13 18:09:08 +0530812 .procname = "clock",
813 .mode = 0555,
814 .child = nss_freq_table,
815 },
816 {
817 .procname = "general",
818 .mode = 0555,
819 .child = nss_general_table,
wthomas442c7972013-08-05 14:28:17 -0700820 },
821 { }
822};
823
824static ctl_table nss_root_dir[] = {
825 {
826 .procname = "nss",
827 .mode = 0555,
828 .child = nss_clock_dir,
829 },
830 { }
831};
832
833static ctl_table nss_root[] = {
834 {
835 .procname = "dev",
836 .mode = 0555,
837 .child = nss_root_dir,
838 },
839 { }
840};
841
842static struct ctl_table_header *nss_dev_header;
843
844/*
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530845 * nss_init()
846 * Registers nss driver
847 */
848static int __init nss_init(void)
849{
850 nss_info("Init NSS driver");
851
wthomas626147f2013-09-18 13:12:40 -0700852 nss_freq_change_context = nss_get_frequency_mgr();
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530853 /*
854 * Perform clock init common to all NSS cores
855 */
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530856 nss_hal_common_reset(&(nss_top_main.clk_src));
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530857
858 /*
859 * Enable spin locks
860 */
861 spin_lock_init(&(nss_top_main.lock));
862 spin_lock_init(&(nss_top_main.stats_lock));
863
864 /*
Abhishek Rastogi38cffff2013-06-02 11:25:47 +0530865 * Enable NSS statistics
866 */
867 nss_stats_init();
868
869 /*
wthomas442c7972013-08-05 14:28:17 -0700870 * Register sysctl table.
871 */
872 nss_dev_header = register_sysctl_table(nss_root);
873
874 /*
wthomas626147f2013-09-18 13:12:40 -0700875 * Setup Runtime Sample values
876 */
877 nss_runtime_samples.freq_scale[0].frequency = NSS_FREQ_110;
wthomas626147f2013-09-18 13:12:40 -0700878 nss_runtime_samples.freq_scale[0].minimum = NSS_FREQ_110_MIN;
879 nss_runtime_samples.freq_scale[0].maximum = NSS_FREQ_110_MAX;
wthomas626147f2013-09-18 13:12:40 -0700880 nss_runtime_samples.freq_scale[1].frequency = NSS_FREQ_550;
wthomas626147f2013-09-18 13:12:40 -0700881 nss_runtime_samples.freq_scale[1].minimum = NSS_FREQ_550_MIN;
882 nss_runtime_samples.freq_scale[1].maximum = NSS_FREQ_550_MAX;
wthomas626147f2013-09-18 13:12:40 -0700883 nss_runtime_samples.freq_scale[2].frequency = NSS_FREQ_733;
wthomas626147f2013-09-18 13:12:40 -0700884 nss_runtime_samples.freq_scale[2].minimum = NSS_FREQ_733_MIN;
885 nss_runtime_samples.freq_scale[2].maximum = NSS_FREQ_733_MAX;
wthomas626147f2013-09-18 13:12:40 -0700886 nss_runtime_samples.freq_scale_index = 1;
887 nss_runtime_samples.freq_scale_ready = 0;
Thomas Wu9681f7e2013-11-06 13:12:57 -0800888 nss_runtime_samples.freq_scale_rate_limit_up = 0;
889 nss_runtime_samples.freq_scale_rate_limit_down = 0;
wthomas626147f2013-09-18 13:12:40 -0700890 nss_runtime_samples.buffer_index = 0;
891 nss_runtime_samples.sum = 0;
892 nss_runtime_samples.sample_count = 0;
893 nss_runtime_samples.average = 0;
894 nss_runtime_samples.message_rate_limit = 0;
Kiran Kumar C.S.K69fd5992014-01-06 20:58:14 +0530895 nss_runtime_samples.initialized = 0;
wthomas626147f2013-09-18 13:12:40 -0700896
Thomas Wu05495be2013-12-19 14:24:24 -0800897 nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency;
898
wthomas626147f2013-09-18 13:12:40 -0700899 /*
900 * Initial Workqueue
901 */
902 nss_wq = create_workqueue("nss_freq_queue");
903
904 /*
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +0530905 * Initialize NSS Bus PM module
906 */
907 nss_pm_init();
908
909 /*
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +0530910 * Register with Bus driver
911 */
912 pm_client = nss_pm_client_register(NSS_PM_CLIENT_NETAP);
913 if (!pm_client) {
914 nss_warning("Error registering with PM driver");
915 }
916
917 /*
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530918 * Register platform_driver
919 */
920 return platform_driver_register(&nss_driver);
921}
922
923/*
924 * nss_cleanup()
925 * Unregisters nss driver
926 */
927static void __exit nss_cleanup(void)
928{
929 nss_info("Exit NSS driver");
wthomas442c7972013-08-05 14:28:17 -0700930
931 if (nss_dev_header)
932 unregister_sysctl_table(nss_dev_header);
933
Abhishek Rastogibc74e432013-04-02 10:28:22 +0530934 platform_driver_unregister(&nss_driver);
935}
936
937module_init(nss_init);
938module_exit(nss_cleanup);
939
940MODULE_DESCRIPTION("QCA NSS Driver");
941MODULE_AUTHOR("Qualcomm Atheros Inc");
942MODULE_LICENSE("Dual BSD/GPL");