blob: dfbda74e29c7b9337ad6dc342ce1164ef5ac2a1d [file] [log] [blame]
Matt Wagantallc2bbdc32012-03-21 19:44:50 -07001/*
Phani Kumar Uppalapati598a1da2013-01-24 12:29:54 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Matt Wagantallc2bbdc32012-03-21 19:44:50 -07003 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <linux/init.h>
15#include <linux/module.h>
16#include <linux/platform_device.h>
17#include <linux/io.h>
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070018#include <linux/err.h>
19#include <linux/of.h>
Matt Wagantalld41ce772012-05-10 23:16:41 -070020#include <linux/clk.h>
Stephen Boyd633eb622012-06-13 12:05:35 -070021#include <linux/workqueue.h>
22#include <linux/interrupt.h>
23#include <linux/delay.h>
Phani Kumar Uppalapati598a1da2013-01-24 12:29:54 -080024#include <linux/sysfs.h>
Stephen Boyd633eb622012-06-13 12:05:35 -070025
Matt Wagantall8c2246d2012-08-12 17:08:04 -070026#include <mach/clk.h>
Stephen Boyd633eb622012-06-13 12:05:35 -070027#include <mach/subsystem_restart.h>
28#include <mach/subsystem_notif.h>
29#include <mach/scm.h>
Stephen Boyd633eb622012-06-13 12:05:35 -070030
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070031#include "peripheral-loader.h"
32#include "pil-q6v5.h"
Matt Wagantall10a59672012-07-26 11:52:02 -070033#include "scm-pas.h"
Stephen Boyd633eb622012-06-13 12:05:35 -070034#include "ramdump.h"
35#include "sysmon.h"
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070036
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070037#define QDSP6SS_RST_EVB 0x010
Matt Wagantall4d89c2e2012-05-25 19:28:34 -070038#define PROXY_TIMEOUT_MS 10000
Matt Wagantallc2bbdc32012-03-21 19:44:50 -070039
Phani Kumar Uppalapati598a1da2013-01-24 12:29:54 -080040static struct kobject *lpass_status;
41static char status[32];
42
Stephen Boyd633eb622012-06-13 12:05:35 -070043struct lpass_data {
44 struct q6v5_data *q6;
45 struct subsys_device *subsys;
46 struct subsys_desc subsys_desc;
47 void *ramdump_dev;
48 int wdog_irq;
49 struct work_struct work;
50 void *riva_notif_hdle;
51 void *modem_notif_hdle;
52 int crash_shutdown;
53};
54
55#define subsys_to_drv(d) container_of(d, struct lpass_data, subsys_desc)
56
Matt Wagantall8c2246d2012-08-12 17:08:04 -070057static int pil_lpass_enable_clks(struct q6v5_data *drv)
58{
59 int ret;
60
61 ret = clk_reset(drv->core_clk, CLK_RESET_DEASSERT);
62 if (ret)
63 goto err_reset;
64 ret = clk_prepare_enable(drv->core_clk);
65 if (ret)
66 goto err_core_clk;
67 ret = clk_prepare_enable(drv->ahb_clk);
68 if (ret)
69 goto err_ahb_clk;
70 ret = clk_prepare_enable(drv->axi_clk);
71 if (ret)
72 goto err_axi_clk;
73 ret = clk_prepare_enable(drv->reg_clk);
74 if (ret)
75 goto err_reg_clk;
76
77 return 0;
78
79err_reg_clk:
80 clk_disable_unprepare(drv->axi_clk);
81err_axi_clk:
82 clk_disable_unprepare(drv->ahb_clk);
83err_ahb_clk:
84 clk_disable_unprepare(drv->core_clk);
85err_core_clk:
86 clk_reset(drv->core_clk, CLK_RESET_ASSERT);
87err_reset:
88 return ret;
89}
90
91static void pil_lpass_disable_clks(struct q6v5_data *drv)
92{
93 clk_disable_unprepare(drv->reg_clk);
94 clk_disable_unprepare(drv->axi_clk);
95 clk_disable_unprepare(drv->ahb_clk);
96 clk_disable_unprepare(drv->core_clk);
97 clk_reset(drv->core_clk, CLK_RESET_ASSERT);
98}
99
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700100static int pil_lpass_shutdown(struct pil_desc *pil)
101{
Stephen Boyd3826cd42012-07-05 17:37:53 -0700102 struct q6v5_data *drv = container_of(pil, struct q6v5_data, desc);
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700103
Matt Wagantallb7747992012-05-11 19:37:51 -0700104 pil_q6v5_halt_axi_port(pil, drv->axi_halt_base);
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700105
Matt Wagantalld41ce772012-05-10 23:16:41 -0700106 /*
107 * If the shutdown function is called before the reset function, clocks
108 * will not be enabled yet. Enable them here so that register writes
109 * performed during the shutdown succeed.
110 */
111 if (drv->is_booted == false)
Matt Wagantall8c2246d2012-08-12 17:08:04 -0700112 pil_lpass_enable_clks(drv);
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700113
114 pil_q6v5_shutdown(pil);
Matt Wagantall8c2246d2012-08-12 17:08:04 -0700115 pil_lpass_disable_clks(drv);
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700116
Matt Wagantalld41ce772012-05-10 23:16:41 -0700117 drv->is_booted = false;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700118
119 return 0;
120}
121
122static int pil_lpass_reset(struct pil_desc *pil)
123{
Stephen Boyd3826cd42012-07-05 17:37:53 -0700124 struct q6v5_data *drv = container_of(pil, struct q6v5_data, desc);
Stephen Boyd3030c252012-08-08 17:24:05 -0700125 unsigned long start_addr = pil_get_entry_addr(pil);
Matt Wagantalld41ce772012-05-10 23:16:41 -0700126 int ret;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700127
Matt Wagantall8c2246d2012-08-12 17:08:04 -0700128 ret = pil_lpass_enable_clks(drv);
Matt Wagantalld41ce772012-05-10 23:16:41 -0700129 if (ret)
130 return ret;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700131
132 /* Program Image Address */
Stephen Boyd3030c252012-08-08 17:24:05 -0700133 writel_relaxed((start_addr >> 4) & 0x0FFFFFF0,
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700134 drv->reg_base + QDSP6SS_RST_EVB);
135
Matt Wagantalld41ce772012-05-10 23:16:41 -0700136 ret = pil_q6v5_reset(pil);
137 if (ret) {
Matt Wagantall8c2246d2012-08-12 17:08:04 -0700138 pil_lpass_disable_clks(drv);
Matt Wagantalld41ce772012-05-10 23:16:41 -0700139 return ret;
140 }
141
142 drv->is_booted = true;
143
144 return 0;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700145}
146
147static struct pil_reset_ops pil_lpass_ops = {
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700148 .proxy_vote = pil_q6v5_make_proxy_votes,
149 .proxy_unvote = pil_q6v5_remove_proxy_votes,
150 .auth_and_reset = pil_lpass_reset,
151 .shutdown = pil_lpass_shutdown,
152};
153
Matt Wagantall10a59672012-07-26 11:52:02 -0700154static int pil_lpass_init_image_trusted(struct pil_desc *pil,
155 const u8 *metadata, size_t size)
156{
157 return pas_init_image(PAS_Q6, metadata, size);
158}
159
Stephen Boydc8c5db92012-12-03 11:13:20 -0800160static int pil_lpass_mem_setup_trusted(struct pil_desc *pil, phys_addr_t addr,
161 size_t size)
162{
163 return pas_mem_setup(PAS_Q6, addr, size);
164}
165
Matt Wagantall10a59672012-07-26 11:52:02 -0700166static int pil_lpass_reset_trusted(struct pil_desc *pil)
167{
168 return pas_auth_and_reset(PAS_Q6);
169}
170
171static int pil_lpass_shutdown_trusted(struct pil_desc *pil)
172{
173 return pas_shutdown(PAS_Q6);
174}
175
176static struct pil_reset_ops pil_lpass_ops_trusted = {
177 .init_image = pil_lpass_init_image_trusted,
Stephen Boydc8c5db92012-12-03 11:13:20 -0800178 .mem_setup = pil_lpass_mem_setup_trusted,
Matt Wagantall10a59672012-07-26 11:52:02 -0700179 .proxy_vote = pil_q6v5_make_proxy_votes,
180 .proxy_unvote = pil_q6v5_remove_proxy_votes,
181 .auth_and_reset = pil_lpass_reset_trusted,
182 .shutdown = pil_lpass_shutdown_trusted,
183};
184
Stephen Boyd633eb622012-06-13 12:05:35 -0700185static int riva_notifier_cb(struct notifier_block *this, unsigned long code,
186 void *ss_handle)
187{
188 int ret;
189 switch (code) {
190 case SUBSYS_BEFORE_SHUTDOWN:
191 pr_debug("%s: R-Notify: Shutdown started\n", __func__);
192 ret = sysmon_send_event(SYSMON_SS_LPASS, "wcnss",
193 SUBSYS_BEFORE_SHUTDOWN);
194 if (ret < 0)
195 pr_err("%s: sysmon_send_event error %d", __func__, ret);
196 break;
197 }
198 return NOTIFY_DONE;
199}
200
201static struct notifier_block rnb = {
202 .notifier_call = riva_notifier_cb,
203};
204
205static int modem_notifier_cb(struct notifier_block *this, unsigned long code,
206 void *ss_handle)
207{
208 int ret;
Ravishankar Sarawadifadfe3b2012-10-12 11:28:24 -0700209 pr_debug("%s: M-Notify: event %lu\n", __func__, code);
210 ret = sysmon_send_event(SYSMON_SS_LPASS, "modem", code);
211 if (ret < 0)
212 pr_err("%s: sysmon_send_event error %d", __func__, ret);
Stephen Boyd633eb622012-06-13 12:05:35 -0700213 return NOTIFY_DONE;
214}
215
216static struct notifier_block mnb = {
217 .notifier_call = modem_notifier_cb,
218};
219
220static void adsp_log_failure_reason(void)
221{
222 char *reason;
223 char buffer[81];
224 unsigned size;
225
226 reason = smem_get_entry(SMEM_SSR_REASON_LPASS0, &size);
227
228 if (!reason) {
229 pr_err("ADSP subsystem failure reason: (unknown, smem_get_entry failed).");
230 return;
231 }
232
233 if (reason[0] == '\0') {
234 pr_err("ADSP subsystem failure reason: (unknown, init value found)");
235 return;
236 }
237
238 size = min(size, sizeof(buffer) - 1);
239 memcpy(buffer, reason, size);
240 buffer[size] = '\0';
241 pr_err("ADSP subsystem failure reason: %s", buffer);
242 memset((void *)reason, 0x0, size);
243 wmb();
244}
245
246static void restart_adsp(struct lpass_data *drv)
247{
248 adsp_log_failure_reason();
249 subsystem_restart_dev(drv->subsys);
250}
251
252static void adsp_fatal_fn(struct work_struct *work)
253{
254 struct lpass_data *drv = container_of(work, struct lpass_data, work);
255
256 pr_err("Watchdog bite received from ADSP!\n");
257 restart_adsp(drv);
258}
259
260static void adsp_smsm_state_cb(void *data, uint32_t old_state,
261 uint32_t new_state)
262{
263 struct lpass_data *drv = data;
264
265 /* Ignore if we're the one that set SMSM_RESET */
266 if (drv->crash_shutdown)
267 return;
268
269 if (new_state & SMSM_RESET) {
270 pr_err("%s: ADSP SMSM state changed to SMSM_RESET, new_state = %#x, old_state = %#x\n",
271 __func__, new_state, old_state);
272 restart_adsp(drv);
273 }
274}
275
276#define SCM_Q6_NMI_CMD 0x1
277
278static void send_q6_nmi(void)
279{
280 /* Send NMI to QDSP6 via an SCM call. */
281 scm_call_atomic1(SCM_SVC_UTIL, SCM_Q6_NMI_CMD, 0x1);
282 pr_debug("%s: Q6 NMI was sent.\n", __func__);
283}
284
Phani Kumar Uppalapati598a1da2013-01-24 12:29:54 -0800285/*
286 * The "status" file where a static variable is read from and written to.
287 */
288static ssize_t adsp_state_show(struct kobject *kobj,
289 struct kobj_attribute *attr,
290 char *buf)
291{
292 return snprintf(buf, sizeof(status), "%s\n", status);
293}
294
295static struct kobj_attribute adsp_state_attribute =
296 __ATTR(status, 0444, adsp_state_show, NULL);
297
298static struct attribute *attrs[] = {
299 &adsp_state_attribute.attr,
300 NULL, /* need to NULL terminate the list of attributes */
301};
302
303static struct attribute_group attr_group = {
304 .attrs = attrs,
305};
306
307static void adsp_set_state(char *state)
308{
309 strlcpy(status, state, sizeof(status));
310 sysfs_notify(lpass_status, NULL, "status");
311}
312
Stephen Boyd633eb622012-06-13 12:05:35 -0700313#define subsys_to_lpass(d) container_of(d, struct lpass_data, subsys_desc)
314
315static int adsp_shutdown(const struct subsys_desc *subsys)
316{
317 struct lpass_data *drv = subsys_to_lpass(subsys);
318
319 send_q6_nmi();
320 /* The write needs to go through before the q6 is shutdown. */
321 mb();
Stephen Boyde83a0a22012-06-29 13:51:27 -0700322 pil_shutdown(&drv->q6->desc);
Stephen Boyd633eb622012-06-13 12:05:35 -0700323 disable_irq_nosync(drv->wdog_irq);
324
Phani Kumar Uppalapati598a1da2013-01-24 12:29:54 -0800325 pr_debug("ADSP is Down\n");
326 adsp_set_state("OFFLINE");
Stephen Boyd633eb622012-06-13 12:05:35 -0700327 return 0;
328}
329
330static int adsp_powerup(const struct subsys_desc *subsys)
331{
332 struct lpass_data *drv = subsys_to_lpass(subsys);
333 int ret = 0;
Stephen Boyde83a0a22012-06-29 13:51:27 -0700334 ret = pil_boot(&drv->q6->desc);
Stephen Boyd633eb622012-06-13 12:05:35 -0700335 enable_irq(drv->wdog_irq);
Phani Kumar Uppalapati598a1da2013-01-24 12:29:54 -0800336
337 pr_debug("ADSP is back online\n");
338 adsp_set_state("ONLINE");
Stephen Boyd633eb622012-06-13 12:05:35 -0700339 return ret;
340}
341
Stephen Boyd633eb622012-06-13 12:05:35 -0700342static int adsp_ramdump(int enable, const struct subsys_desc *subsys)
343{
344 struct lpass_data *drv = subsys_to_lpass(subsys);
345
346 if (!enable)
347 return 0;
Stephen Boyd5eb17ce2012-11-29 15:34:21 -0800348
349 return pil_do_ramdump(&drv->q6->desc, drv->ramdump_dev);
Stephen Boyd633eb622012-06-13 12:05:35 -0700350}
351
352static void adsp_crash_shutdown(const struct subsys_desc *subsys)
353{
354 struct lpass_data *drv = subsys_to_lpass(subsys);
355
356 drv->crash_shutdown = 1;
357 send_q6_nmi();
358}
359
360static irqreturn_t adsp_wdog_bite_irq(int irq, void *dev_id)
361{
362 struct lpass_data *drv = dev_id;
363
364 disable_irq_nosync(drv->wdog_irq);
365 schedule_work(&drv->work);
366
367 return IRQ_HANDLED;
368}
369
Stephen Boyd3e4e9752012-06-27 12:46:32 -0700370static int lpass_start(const struct subsys_desc *desc)
371{
Stephen Boyd3e4e9752012-06-27 12:46:32 -0700372 struct lpass_data *drv = subsys_to_drv(desc);
373
Stephen Boyde83a0a22012-06-29 13:51:27 -0700374 return pil_boot(&drv->q6->desc);
Stephen Boyd3e4e9752012-06-27 12:46:32 -0700375}
376
377static void lpass_stop(const struct subsys_desc *desc)
378{
379 struct lpass_data *drv = subsys_to_drv(desc);
Stephen Boyde83a0a22012-06-29 13:51:27 -0700380 pil_shutdown(&drv->q6->desc);
Stephen Boyd3e4e9752012-06-27 12:46:32 -0700381}
382
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700383static int __devinit pil_lpass_driver_probe(struct platform_device *pdev)
384{
Stephen Boyd633eb622012-06-13 12:05:35 -0700385 struct lpass_data *drv;
386 struct q6v5_data *q6;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700387 struct pil_desc *desc;
Stephen Boyd633eb622012-06-13 12:05:35 -0700388 int ret;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700389
Stephen Boyd633eb622012-06-13 12:05:35 -0700390 drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
391 if (!drv)
392 return -ENOMEM;
Stephen Boyd3826cd42012-07-05 17:37:53 -0700393 platform_set_drvdata(pdev, drv);
Matt Wagantall55252f12012-05-02 18:02:54 -0700394
Stephen Boyd633eb622012-06-13 12:05:35 -0700395 drv->wdog_irq = platform_get_irq(pdev, 0);
396 if (drv->wdog_irq < 0)
397 return drv->wdog_irq;
398
399 q6 = pil_q6v5_init(pdev);
400 if (IS_ERR(q6))
401 return PTR_ERR(q6);
402 drv->q6 = q6;
403
404 desc = &q6->desc;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700405 desc->owner = THIS_MODULE;
Matt Wagantall4d89c2e2012-05-25 19:28:34 -0700406 desc->proxy_timeout = PROXY_TIMEOUT_MS;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700407
Stephen Boyd633eb622012-06-13 12:05:35 -0700408 q6->core_clk = devm_clk_get(&pdev->dev, "core_clk");
409 if (IS_ERR(q6->core_clk))
410 return PTR_ERR(q6->core_clk);
Matt Wagantall8c2246d2012-08-12 17:08:04 -0700411
Stephen Boyd633eb622012-06-13 12:05:35 -0700412 q6->ahb_clk = devm_clk_get(&pdev->dev, "iface_clk");
413 if (IS_ERR(q6->ahb_clk))
414 return PTR_ERR(q6->ahb_clk);
Matt Wagantall8c2246d2012-08-12 17:08:04 -0700415
Stephen Boyd633eb622012-06-13 12:05:35 -0700416 q6->axi_clk = devm_clk_get(&pdev->dev, "bus_clk");
417 if (IS_ERR(q6->axi_clk))
418 return PTR_ERR(q6->axi_clk);
Matt Wagantall8c2246d2012-08-12 17:08:04 -0700419
Stephen Boyd633eb622012-06-13 12:05:35 -0700420 q6->reg_clk = devm_clk_get(&pdev->dev, "reg_clk");
421 if (IS_ERR(q6->reg_clk))
422 return PTR_ERR(q6->reg_clk);
Matt Wagantall56865f02012-08-09 15:03:36 -0700423
Matt Wagantall10a59672012-07-26 11:52:02 -0700424 if (pas_supported(PAS_Q6) > 0) {
425 desc->ops = &pil_lpass_ops_trusted;
426 dev_info(&pdev->dev, "using secure boot\n");
427 } else {
428 desc->ops = &pil_lpass_ops;
429 dev_info(&pdev->dev, "using non-secure boot\n");
430 }
431
Stephen Boyde83a0a22012-06-29 13:51:27 -0700432 ret = pil_desc_init(desc);
433 if (ret)
434 return ret;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700435
Stephen Boyd633eb622012-06-13 12:05:35 -0700436 drv->subsys_desc.name = desc->name;
437 drv->subsys_desc.owner = THIS_MODULE;
438 drv->subsys_desc.dev = &pdev->dev;
439 drv->subsys_desc.shutdown = adsp_shutdown;
440 drv->subsys_desc.powerup = adsp_powerup;
441 drv->subsys_desc.ramdump = adsp_ramdump;
442 drv->subsys_desc.crash_shutdown = adsp_crash_shutdown;
Stephen Boyd3e4e9752012-06-27 12:46:32 -0700443 drv->subsys_desc.start = lpass_start;
444 drv->subsys_desc.stop = lpass_stop;
Stephen Boyd633eb622012-06-13 12:05:35 -0700445
446 INIT_WORK(&drv->work, adsp_fatal_fn);
447
Stephen Boydc1a72612012-07-05 14:07:35 -0700448 drv->ramdump_dev = create_ramdump_device("adsp", &pdev->dev);
Stephen Boyd633eb622012-06-13 12:05:35 -0700449 if (!drv->ramdump_dev) {
450 ret = -ENOMEM;
451 goto err_ramdump;
452 }
453
454 drv->subsys = subsys_register(&drv->subsys_desc);
455 if (IS_ERR(drv->subsys)) {
456 ret = PTR_ERR(drv->subsys);
457 goto err_subsys;
458 }
459
460 ret = devm_request_irq(&pdev->dev, drv->wdog_irq, adsp_wdog_bite_irq,
461 IRQF_TRIGGER_RISING, dev_name(&pdev->dev), drv);
462 if (ret)
463 goto err_irq;
464
465 ret = smsm_state_cb_register(SMSM_Q6_STATE, SMSM_RESET,
466 adsp_smsm_state_cb, drv);
467 if (ret < 0)
468 goto err_smsm;
469
470 drv->riva_notif_hdle = subsys_notif_register_notifier("riva", &rnb);
471 if (IS_ERR(drv->riva_notif_hdle)) {
472 ret = PTR_ERR(drv->riva_notif_hdle);
473 goto err_notif_riva;
474 }
475
476 drv->modem_notif_hdle = subsys_notif_register_notifier("modem", &mnb);
477 if (IS_ERR(drv->modem_notif_hdle)) {
478 ret = PTR_ERR(drv->modem_notif_hdle);
479 goto err_notif_modem;
480 }
Phani Kumar Uppalapati598a1da2013-01-24 12:29:54 -0800481 lpass_status = kobject_create_and_add("audio_voice_service",
482 kernel_kobj);
483 if (!lpass_status) {
484 pr_err("%s: kobject create failed\n", __func__);
485 ret = -ENOMEM;
486 goto err_notif_modem;
487 }
488
489 ret = sysfs_create_group(lpass_status, &attr_group);
490 if (ret) {
491 pr_err("%s: sysfs create group failed\n", __func__);
492 goto err_kobj;
493 }
494
495 adsp_set_state("ONLINE");
Stephen Boyd633eb622012-06-13 12:05:35 -0700496 return 0;
Phani Kumar Uppalapati598a1da2013-01-24 12:29:54 -0800497err_kobj:
498 kobject_put(lpass_status);
Stephen Boyd633eb622012-06-13 12:05:35 -0700499err_notif_modem:
500 subsys_notif_unregister_notifier(drv->riva_notif_hdle, &rnb);
501err_notif_riva:
502 smsm_state_cb_deregister(SMSM_Q6_STATE, SMSM_RESET,
503 adsp_smsm_state_cb, drv);
504err_smsm:
505err_irq:
506 subsys_unregister(drv->subsys);
507err_subsys:
508 destroy_ramdump_device(drv->ramdump_dev);
509err_ramdump:
Stephen Boyde83a0a22012-06-29 13:51:27 -0700510 pil_desc_release(desc);
Phani Kumar Uppalapati598a1da2013-01-24 12:29:54 -0800511 return ret;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700512}
513
514static int __devexit pil_lpass_driver_exit(struct platform_device *pdev)
515{
Stephen Boyd633eb622012-06-13 12:05:35 -0700516 struct lpass_data *drv = platform_get_drvdata(pdev);
517 subsys_notif_unregister_notifier(drv->riva_notif_hdle, &rnb);
518 subsys_notif_unregister_notifier(drv->modem_notif_hdle, &mnb);
519 smsm_state_cb_deregister(SMSM_Q6_STATE, SMSM_RESET,
520 adsp_smsm_state_cb, drv);
521 subsys_unregister(drv->subsys);
522 destroy_ramdump_device(drv->ramdump_dev);
Stephen Boyde83a0a22012-06-29 13:51:27 -0700523 pil_desc_release(&drv->q6->desc);
Phani Kumar Uppalapati598a1da2013-01-24 12:29:54 -0800524 sysfs_remove_group(lpass_status, &attr_group);
525 kobject_del(lpass_status);
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700526 return 0;
527}
528
529static struct of_device_id lpass_match_table[] = {
530 { .compatible = "qcom,pil-q6v5-lpass" },
531 {}
532};
533
534static struct platform_driver pil_lpass_driver = {
535 .probe = pil_lpass_driver_probe,
536 .remove = __devexit_p(pil_lpass_driver_exit),
537 .driver = {
538 .name = "pil-q6v5-lpass",
539 .of_match_table = lpass_match_table,
540 .owner = THIS_MODULE,
541 },
542};
543
544static int __init pil_lpass_init(void)
545{
546 return platform_driver_register(&pil_lpass_driver);
547}
548module_init(pil_lpass_init);
549
550static void __exit pil_lpass_exit(void)
551{
552 platform_driver_unregister(&pil_lpass_driver);
553}
554module_exit(pil_lpass_exit);
555
556MODULE_DESCRIPTION("Support for booting low-power audio subsystems with QDSP6v5 (Hexagon) processors");
557MODULE_LICENSE("GPL v2");