blob: ef13c346bf3b0fc4da96fdf3128e21cfea4de22c [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 Wagantall015b50af2013-03-05 18:51:16 -0800117 writel_relaxed(1, drv->restart_reg);
118
Matt Wagantalld41ce772012-05-10 23:16:41 -0700119 drv->is_booted = false;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700120
121 return 0;
122}
123
124static int pil_lpass_reset(struct pil_desc *pil)
125{
Stephen Boyd3826cd42012-07-05 17:37:53 -0700126 struct q6v5_data *drv = container_of(pil, struct q6v5_data, desc);
Stephen Boyd3030c252012-08-08 17:24:05 -0700127 unsigned long start_addr = pil_get_entry_addr(pil);
Matt Wagantalld41ce772012-05-10 23:16:41 -0700128 int ret;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700129
Matt Wagantall015b50af2013-03-05 18:51:16 -0800130 /* Deassert reset to subsystem and wait for propagation */
131 writel_relaxed(0, drv->restart_reg);
132 mb();
133 udelay(2);
134
Matt Wagantall8c2246d2012-08-12 17:08:04 -0700135 ret = pil_lpass_enable_clks(drv);
Matt Wagantalld41ce772012-05-10 23:16:41 -0700136 if (ret)
137 return ret;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700138
139 /* Program Image Address */
Stephen Boyd3030c252012-08-08 17:24:05 -0700140 writel_relaxed((start_addr >> 4) & 0x0FFFFFF0,
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700141 drv->reg_base + QDSP6SS_RST_EVB);
142
Matt Wagantalld41ce772012-05-10 23:16:41 -0700143 ret = pil_q6v5_reset(pil);
144 if (ret) {
Matt Wagantall8c2246d2012-08-12 17:08:04 -0700145 pil_lpass_disable_clks(drv);
Matt Wagantalld41ce772012-05-10 23:16:41 -0700146 return ret;
147 }
148
149 drv->is_booted = true;
150
151 return 0;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700152}
153
154static struct pil_reset_ops pil_lpass_ops = {
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700155 .proxy_vote = pil_q6v5_make_proxy_votes,
156 .proxy_unvote = pil_q6v5_remove_proxy_votes,
157 .auth_and_reset = pil_lpass_reset,
158 .shutdown = pil_lpass_shutdown,
159};
160
Matt Wagantall10a59672012-07-26 11:52:02 -0700161static int pil_lpass_init_image_trusted(struct pil_desc *pil,
162 const u8 *metadata, size_t size)
163{
164 return pas_init_image(PAS_Q6, metadata, size);
165}
166
Stephen Boydc8c5db92012-12-03 11:13:20 -0800167static int pil_lpass_mem_setup_trusted(struct pil_desc *pil, phys_addr_t addr,
168 size_t size)
169{
170 return pas_mem_setup(PAS_Q6, addr, size);
171}
172
Matt Wagantall10a59672012-07-26 11:52:02 -0700173static int pil_lpass_reset_trusted(struct pil_desc *pil)
174{
175 return pas_auth_and_reset(PAS_Q6);
176}
177
178static int pil_lpass_shutdown_trusted(struct pil_desc *pil)
179{
180 return pas_shutdown(PAS_Q6);
181}
182
183static struct pil_reset_ops pil_lpass_ops_trusted = {
184 .init_image = pil_lpass_init_image_trusted,
Stephen Boydc8c5db92012-12-03 11:13:20 -0800185 .mem_setup = pil_lpass_mem_setup_trusted,
Matt Wagantall10a59672012-07-26 11:52:02 -0700186 .proxy_vote = pil_q6v5_make_proxy_votes,
187 .proxy_unvote = pil_q6v5_remove_proxy_votes,
188 .auth_and_reset = pil_lpass_reset_trusted,
189 .shutdown = pil_lpass_shutdown_trusted,
190};
191
Stephen Boyd633eb622012-06-13 12:05:35 -0700192static int riva_notifier_cb(struct notifier_block *this, unsigned long code,
193 void *ss_handle)
194{
195 int ret;
196 switch (code) {
197 case SUBSYS_BEFORE_SHUTDOWN:
198 pr_debug("%s: R-Notify: Shutdown started\n", __func__);
199 ret = sysmon_send_event(SYSMON_SS_LPASS, "wcnss",
200 SUBSYS_BEFORE_SHUTDOWN);
201 if (ret < 0)
202 pr_err("%s: sysmon_send_event error %d", __func__, ret);
203 break;
204 }
205 return NOTIFY_DONE;
206}
207
208static struct notifier_block rnb = {
209 .notifier_call = riva_notifier_cb,
210};
211
212static int modem_notifier_cb(struct notifier_block *this, unsigned long code,
213 void *ss_handle)
214{
215 int ret;
Ravishankar Sarawadifadfe3b2012-10-12 11:28:24 -0700216 pr_debug("%s: M-Notify: event %lu\n", __func__, code);
217 ret = sysmon_send_event(SYSMON_SS_LPASS, "modem", code);
218 if (ret < 0)
219 pr_err("%s: sysmon_send_event error %d", __func__, ret);
Stephen Boyd633eb622012-06-13 12:05:35 -0700220 return NOTIFY_DONE;
221}
222
223static struct notifier_block mnb = {
224 .notifier_call = modem_notifier_cb,
225};
226
227static void adsp_log_failure_reason(void)
228{
229 char *reason;
230 char buffer[81];
231 unsigned size;
232
233 reason = smem_get_entry(SMEM_SSR_REASON_LPASS0, &size);
234
235 if (!reason) {
236 pr_err("ADSP subsystem failure reason: (unknown, smem_get_entry failed).");
237 return;
238 }
239
240 if (reason[0] == '\0') {
241 pr_err("ADSP subsystem failure reason: (unknown, init value found)");
242 return;
243 }
244
245 size = min(size, sizeof(buffer) - 1);
246 memcpy(buffer, reason, size);
247 buffer[size] = '\0';
248 pr_err("ADSP subsystem failure reason: %s", buffer);
249 memset((void *)reason, 0x0, size);
250 wmb();
251}
252
253static void restart_adsp(struct lpass_data *drv)
254{
255 adsp_log_failure_reason();
256 subsystem_restart_dev(drv->subsys);
257}
258
259static void adsp_fatal_fn(struct work_struct *work)
260{
261 struct lpass_data *drv = container_of(work, struct lpass_data, work);
262
263 pr_err("Watchdog bite received from ADSP!\n");
264 restart_adsp(drv);
265}
266
267static void adsp_smsm_state_cb(void *data, uint32_t old_state,
268 uint32_t new_state)
269{
270 struct lpass_data *drv = data;
271
272 /* Ignore if we're the one that set SMSM_RESET */
273 if (drv->crash_shutdown)
274 return;
275
276 if (new_state & SMSM_RESET) {
277 pr_err("%s: ADSP SMSM state changed to SMSM_RESET, new_state = %#x, old_state = %#x\n",
278 __func__, new_state, old_state);
279 restart_adsp(drv);
280 }
281}
282
283#define SCM_Q6_NMI_CMD 0x1
284
285static void send_q6_nmi(void)
286{
287 /* Send NMI to QDSP6 via an SCM call. */
288 scm_call_atomic1(SCM_SVC_UTIL, SCM_Q6_NMI_CMD, 0x1);
289 pr_debug("%s: Q6 NMI was sent.\n", __func__);
290}
291
Phani Kumar Uppalapati598a1da2013-01-24 12:29:54 -0800292/*
293 * The "status" file where a static variable is read from and written to.
294 */
295static ssize_t adsp_state_show(struct kobject *kobj,
296 struct kobj_attribute *attr,
297 char *buf)
298{
299 return snprintf(buf, sizeof(status), "%s\n", status);
300}
301
302static struct kobj_attribute adsp_state_attribute =
303 __ATTR(status, 0444, adsp_state_show, NULL);
304
305static struct attribute *attrs[] = {
306 &adsp_state_attribute.attr,
307 NULL, /* need to NULL terminate the list of attributes */
308};
309
310static struct attribute_group attr_group = {
311 .attrs = attrs,
312};
313
314static void adsp_set_state(char *state)
315{
316 strlcpy(status, state, sizeof(status));
317 sysfs_notify(lpass_status, NULL, "status");
318}
319
Stephen Boyd633eb622012-06-13 12:05:35 -0700320#define subsys_to_lpass(d) container_of(d, struct lpass_data, subsys_desc)
321
322static int adsp_shutdown(const struct subsys_desc *subsys)
323{
324 struct lpass_data *drv = subsys_to_lpass(subsys);
325
326 send_q6_nmi();
327 /* The write needs to go through before the q6 is shutdown. */
328 mb();
Stephen Boyde83a0a22012-06-29 13:51:27 -0700329 pil_shutdown(&drv->q6->desc);
Stephen Boyd633eb622012-06-13 12:05:35 -0700330 disable_irq_nosync(drv->wdog_irq);
331
Phani Kumar Uppalapati598a1da2013-01-24 12:29:54 -0800332 pr_debug("ADSP is Down\n");
333 adsp_set_state("OFFLINE");
Stephen Boyd633eb622012-06-13 12:05:35 -0700334 return 0;
335}
336
337static int adsp_powerup(const struct subsys_desc *subsys)
338{
339 struct lpass_data *drv = subsys_to_lpass(subsys);
340 int ret = 0;
Stephen Boyde83a0a22012-06-29 13:51:27 -0700341 ret = pil_boot(&drv->q6->desc);
Stephen Boyd633eb622012-06-13 12:05:35 -0700342 enable_irq(drv->wdog_irq);
Phani Kumar Uppalapati598a1da2013-01-24 12:29:54 -0800343
344 pr_debug("ADSP is back online\n");
345 adsp_set_state("ONLINE");
Stephen Boyd633eb622012-06-13 12:05:35 -0700346 return ret;
347}
348
Stephen Boyd633eb622012-06-13 12:05:35 -0700349static int adsp_ramdump(int enable, const struct subsys_desc *subsys)
350{
351 struct lpass_data *drv = subsys_to_lpass(subsys);
352
353 if (!enable)
354 return 0;
Stephen Boyd5eb17ce2012-11-29 15:34:21 -0800355
356 return pil_do_ramdump(&drv->q6->desc, drv->ramdump_dev);
Stephen Boyd633eb622012-06-13 12:05:35 -0700357}
358
359static void adsp_crash_shutdown(const struct subsys_desc *subsys)
360{
361 struct lpass_data *drv = subsys_to_lpass(subsys);
362
363 drv->crash_shutdown = 1;
364 send_q6_nmi();
365}
366
367static irqreturn_t adsp_wdog_bite_irq(int irq, void *dev_id)
368{
369 struct lpass_data *drv = dev_id;
370
371 disable_irq_nosync(drv->wdog_irq);
372 schedule_work(&drv->work);
373
374 return IRQ_HANDLED;
375}
376
Stephen Boyd3e4e9752012-06-27 12:46:32 -0700377static int lpass_start(const struct subsys_desc *desc)
378{
Stephen Boyd3e4e9752012-06-27 12:46:32 -0700379 struct lpass_data *drv = subsys_to_drv(desc);
380
Stephen Boyde83a0a22012-06-29 13:51:27 -0700381 return pil_boot(&drv->q6->desc);
Stephen Boyd3e4e9752012-06-27 12:46:32 -0700382}
383
384static void lpass_stop(const struct subsys_desc *desc)
385{
386 struct lpass_data *drv = subsys_to_drv(desc);
Stephen Boyde83a0a22012-06-29 13:51:27 -0700387 pil_shutdown(&drv->q6->desc);
Stephen Boyd3e4e9752012-06-27 12:46:32 -0700388}
389
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700390static int __devinit pil_lpass_driver_probe(struct platform_device *pdev)
391{
Stephen Boyd633eb622012-06-13 12:05:35 -0700392 struct lpass_data *drv;
393 struct q6v5_data *q6;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700394 struct pil_desc *desc;
Matt Wagantall015b50af2013-03-05 18:51:16 -0800395 struct resource *res;
Stephen Boyd633eb622012-06-13 12:05:35 -0700396 int ret;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700397
Stephen Boyd633eb622012-06-13 12:05:35 -0700398 drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
399 if (!drv)
400 return -ENOMEM;
Stephen Boyd3826cd42012-07-05 17:37:53 -0700401 platform_set_drvdata(pdev, drv);
Matt Wagantall55252f12012-05-02 18:02:54 -0700402
Stephen Boyd633eb622012-06-13 12:05:35 -0700403 drv->wdog_irq = platform_get_irq(pdev, 0);
404 if (drv->wdog_irq < 0)
405 return drv->wdog_irq;
406
407 q6 = pil_q6v5_init(pdev);
408 if (IS_ERR(q6))
409 return PTR_ERR(q6);
410 drv->q6 = q6;
411
412 desc = &q6->desc;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700413 desc->owner = THIS_MODULE;
Matt Wagantall4d89c2e2012-05-25 19:28:34 -0700414 desc->proxy_timeout = PROXY_TIMEOUT_MS;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700415
Matt Wagantall015b50af2013-03-05 18:51:16 -0800416 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "restart_reg");
417 q6->restart_reg = devm_request_and_ioremap(&pdev->dev, res);
418 if (!q6->restart_reg)
419 return -ENOMEM;
420
Stephen Boyd633eb622012-06-13 12:05:35 -0700421 q6->core_clk = devm_clk_get(&pdev->dev, "core_clk");
422 if (IS_ERR(q6->core_clk))
423 return PTR_ERR(q6->core_clk);
Matt Wagantall8c2246d2012-08-12 17:08:04 -0700424
Stephen Boyd633eb622012-06-13 12:05:35 -0700425 q6->ahb_clk = devm_clk_get(&pdev->dev, "iface_clk");
426 if (IS_ERR(q6->ahb_clk))
427 return PTR_ERR(q6->ahb_clk);
Matt Wagantall8c2246d2012-08-12 17:08:04 -0700428
Stephen Boyd633eb622012-06-13 12:05:35 -0700429 q6->axi_clk = devm_clk_get(&pdev->dev, "bus_clk");
430 if (IS_ERR(q6->axi_clk))
431 return PTR_ERR(q6->axi_clk);
Matt Wagantall8c2246d2012-08-12 17:08:04 -0700432
Stephen Boyd633eb622012-06-13 12:05:35 -0700433 q6->reg_clk = devm_clk_get(&pdev->dev, "reg_clk");
434 if (IS_ERR(q6->reg_clk))
435 return PTR_ERR(q6->reg_clk);
Matt Wagantall56865f02012-08-09 15:03:36 -0700436
Matt Wagantall10a59672012-07-26 11:52:02 -0700437 if (pas_supported(PAS_Q6) > 0) {
438 desc->ops = &pil_lpass_ops_trusted;
439 dev_info(&pdev->dev, "using secure boot\n");
440 } else {
441 desc->ops = &pil_lpass_ops;
442 dev_info(&pdev->dev, "using non-secure boot\n");
443 }
444
Stephen Boyde83a0a22012-06-29 13:51:27 -0700445 ret = pil_desc_init(desc);
446 if (ret)
447 return ret;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700448
Stephen Boyd633eb622012-06-13 12:05:35 -0700449 drv->subsys_desc.name = desc->name;
450 drv->subsys_desc.owner = THIS_MODULE;
451 drv->subsys_desc.dev = &pdev->dev;
452 drv->subsys_desc.shutdown = adsp_shutdown;
453 drv->subsys_desc.powerup = adsp_powerup;
454 drv->subsys_desc.ramdump = adsp_ramdump;
455 drv->subsys_desc.crash_shutdown = adsp_crash_shutdown;
Stephen Boyd3e4e9752012-06-27 12:46:32 -0700456 drv->subsys_desc.start = lpass_start;
457 drv->subsys_desc.stop = lpass_stop;
Stephen Boyd633eb622012-06-13 12:05:35 -0700458
459 INIT_WORK(&drv->work, adsp_fatal_fn);
460
Stephen Boydc1a72612012-07-05 14:07:35 -0700461 drv->ramdump_dev = create_ramdump_device("adsp", &pdev->dev);
Stephen Boyd633eb622012-06-13 12:05:35 -0700462 if (!drv->ramdump_dev) {
463 ret = -ENOMEM;
464 goto err_ramdump;
465 }
466
467 drv->subsys = subsys_register(&drv->subsys_desc);
468 if (IS_ERR(drv->subsys)) {
469 ret = PTR_ERR(drv->subsys);
470 goto err_subsys;
471 }
472
473 ret = devm_request_irq(&pdev->dev, drv->wdog_irq, adsp_wdog_bite_irq,
474 IRQF_TRIGGER_RISING, dev_name(&pdev->dev), drv);
475 if (ret)
476 goto err_irq;
477
478 ret = smsm_state_cb_register(SMSM_Q6_STATE, SMSM_RESET,
479 adsp_smsm_state_cb, drv);
480 if (ret < 0)
481 goto err_smsm;
482
483 drv->riva_notif_hdle = subsys_notif_register_notifier("riva", &rnb);
484 if (IS_ERR(drv->riva_notif_hdle)) {
485 ret = PTR_ERR(drv->riva_notif_hdle);
486 goto err_notif_riva;
487 }
488
489 drv->modem_notif_hdle = subsys_notif_register_notifier("modem", &mnb);
490 if (IS_ERR(drv->modem_notif_hdle)) {
491 ret = PTR_ERR(drv->modem_notif_hdle);
492 goto err_notif_modem;
493 }
Phani Kumar Uppalapati598a1da2013-01-24 12:29:54 -0800494 lpass_status = kobject_create_and_add("audio_voice_service",
495 kernel_kobj);
496 if (!lpass_status) {
497 pr_err("%s: kobject create failed\n", __func__);
498 ret = -ENOMEM;
499 goto err_notif_modem;
500 }
501
502 ret = sysfs_create_group(lpass_status, &attr_group);
503 if (ret) {
504 pr_err("%s: sysfs create group failed\n", __func__);
505 goto err_kobj;
506 }
507
508 adsp_set_state("ONLINE");
Stephen Boyd633eb622012-06-13 12:05:35 -0700509 return 0;
Phani Kumar Uppalapati598a1da2013-01-24 12:29:54 -0800510err_kobj:
511 kobject_put(lpass_status);
Stephen Boyd633eb622012-06-13 12:05:35 -0700512err_notif_modem:
513 subsys_notif_unregister_notifier(drv->riva_notif_hdle, &rnb);
514err_notif_riva:
515 smsm_state_cb_deregister(SMSM_Q6_STATE, SMSM_RESET,
516 adsp_smsm_state_cb, drv);
517err_smsm:
518err_irq:
519 subsys_unregister(drv->subsys);
520err_subsys:
521 destroy_ramdump_device(drv->ramdump_dev);
522err_ramdump:
Stephen Boyde83a0a22012-06-29 13:51:27 -0700523 pil_desc_release(desc);
Phani Kumar Uppalapati598a1da2013-01-24 12:29:54 -0800524 return ret;
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700525}
526
527static int __devexit pil_lpass_driver_exit(struct platform_device *pdev)
528{
Stephen Boyd633eb622012-06-13 12:05:35 -0700529 struct lpass_data *drv = platform_get_drvdata(pdev);
530 subsys_notif_unregister_notifier(drv->riva_notif_hdle, &rnb);
531 subsys_notif_unregister_notifier(drv->modem_notif_hdle, &mnb);
532 smsm_state_cb_deregister(SMSM_Q6_STATE, SMSM_RESET,
533 adsp_smsm_state_cb, drv);
534 subsys_unregister(drv->subsys);
535 destroy_ramdump_device(drv->ramdump_dev);
Stephen Boyde83a0a22012-06-29 13:51:27 -0700536 pil_desc_release(&drv->q6->desc);
Phani Kumar Uppalapati598a1da2013-01-24 12:29:54 -0800537 sysfs_remove_group(lpass_status, &attr_group);
538 kobject_del(lpass_status);
Matt Wagantallc2bbdc32012-03-21 19:44:50 -0700539 return 0;
540}
541
542static struct of_device_id lpass_match_table[] = {
543 { .compatible = "qcom,pil-q6v5-lpass" },
544 {}
545};
546
547static struct platform_driver pil_lpass_driver = {
548 .probe = pil_lpass_driver_probe,
549 .remove = __devexit_p(pil_lpass_driver_exit),
550 .driver = {
551 .name = "pil-q6v5-lpass",
552 .of_match_table = lpass_match_table,
553 .owner = THIS_MODULE,
554 },
555};
556
557static int __init pil_lpass_init(void)
558{
559 return platform_driver_register(&pil_lpass_driver);
560}
561module_init(pil_lpass_init);
562
563static void __exit pil_lpass_exit(void)
564{
565 platform_driver_unregister(&pil_lpass_driver);
566}
567module_exit(pil_lpass_exit);
568
569MODULE_DESCRIPTION("Support for booting low-power audio subsystems with QDSP6v5 (Hexagon) processors");
570MODULE_LICENSE("GPL v2");