remoteproc: qcom_q6v5_pas: disable wakeup on probe fail or remove
[platform/kernel/linux-rpi.git] / drivers / remoteproc / qcom_q6v5_pas.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Qualcomm ADSP/SLPI Peripheral Image Loader for MSM8974 and MSM8996
4  *
5  * Copyright (C) 2016 Linaro Ltd
6  * Copyright (C) 2014 Sony Mobile Communications AB
7  * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
8  */
9
10 #include <linux/clk.h>
11 #include <linux/firmware.h>
12 #include <linux/interrupt.h>
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/of_address.h>
16 #include <linux/of_device.h>
17 #include <linux/platform_device.h>
18 #include <linux/pm_domain.h>
19 #include <linux/pm_runtime.h>
20 #include <linux/qcom_scm.h>
21 #include <linux/regulator/consumer.h>
22 #include <linux/remoteproc.h>
23 #include <linux/soc/qcom/mdt_loader.h>
24 #include <linux/soc/qcom/smem.h>
25 #include <linux/soc/qcom/smem_state.h>
26
27 #include "qcom_common.h"
28 #include "qcom_pil_info.h"
29 #include "qcom_q6v5.h"
30 #include "remoteproc_internal.h"
31
32 struct adsp_data {
33         int crash_reason_smem;
34         const char *firmware_name;
35         int pas_id;
36         unsigned int minidump_id;
37         bool has_aggre2_clk;
38         bool auto_boot;
39
40         char **active_pd_names;
41         char **proxy_pd_names;
42
43         const char *ssr_name;
44         const char *sysmon_name;
45         int ssctl_id;
46 };
47
48 struct qcom_adsp {
49         struct device *dev;
50         struct rproc *rproc;
51
52         struct qcom_q6v5 q6v5;
53
54         struct clk *xo;
55         struct clk *aggre2_clk;
56
57         struct regulator *cx_supply;
58         struct regulator *px_supply;
59
60         struct device *active_pds[1];
61         struct device *proxy_pds[3];
62
63         int active_pd_count;
64         int proxy_pd_count;
65
66         int pas_id;
67         unsigned int minidump_id;
68         int crash_reason_smem;
69         bool has_aggre2_clk;
70         const char *info_name;
71
72         struct completion start_done;
73         struct completion stop_done;
74
75         phys_addr_t mem_phys;
76         phys_addr_t mem_reloc;
77         void *mem_region;
78         size_t mem_size;
79
80         struct qcom_rproc_glink glink_subdev;
81         struct qcom_rproc_subdev smd_subdev;
82         struct qcom_rproc_ssr ssr_subdev;
83         struct qcom_sysmon *sysmon;
84 };
85
86 static void adsp_minidump(struct rproc *rproc)
87 {
88         struct qcom_adsp *adsp = rproc->priv;
89
90         if (rproc->dump_conf == RPROC_COREDUMP_DISABLED)
91                 return;
92
93         qcom_minidump(rproc, adsp->minidump_id);
94 }
95
96 static int adsp_pds_enable(struct qcom_adsp *adsp, struct device **pds,
97                            size_t pd_count)
98 {
99         int ret;
100         int i;
101
102         for (i = 0; i < pd_count; i++) {
103                 dev_pm_genpd_set_performance_state(pds[i], INT_MAX);
104                 ret = pm_runtime_get_sync(pds[i]);
105                 if (ret < 0) {
106                         pm_runtime_put_noidle(pds[i]);
107                         dev_pm_genpd_set_performance_state(pds[i], 0);
108                         goto unroll_pd_votes;
109                 }
110         }
111
112         return 0;
113
114 unroll_pd_votes:
115         for (i--; i >= 0; i--) {
116                 dev_pm_genpd_set_performance_state(pds[i], 0);
117                 pm_runtime_put(pds[i]);
118         }
119
120         return ret;
121 };
122
123 static void adsp_pds_disable(struct qcom_adsp *adsp, struct device **pds,
124                              size_t pd_count)
125 {
126         int i;
127
128         for (i = 0; i < pd_count; i++) {
129                 dev_pm_genpd_set_performance_state(pds[i], 0);
130                 pm_runtime_put(pds[i]);
131         }
132 }
133
134 static int adsp_load(struct rproc *rproc, const struct firmware *fw)
135 {
136         struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
137         int ret;
138
139         ret = qcom_mdt_load(adsp->dev, fw, rproc->firmware, adsp->pas_id,
140                             adsp->mem_region, adsp->mem_phys, adsp->mem_size,
141                             &adsp->mem_reloc);
142         if (ret)
143                 return ret;
144
145         qcom_pil_info_store(adsp->info_name, adsp->mem_phys, adsp->mem_size);
146
147         return 0;
148 }
149
150 static int adsp_start(struct rproc *rproc)
151 {
152         struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
153         int ret;
154
155         qcom_q6v5_prepare(&adsp->q6v5);
156
157         ret = adsp_pds_enable(adsp, adsp->active_pds, adsp->active_pd_count);
158         if (ret < 0)
159                 goto disable_irqs;
160
161         ret = adsp_pds_enable(adsp, adsp->proxy_pds, adsp->proxy_pd_count);
162         if (ret < 0)
163                 goto disable_active_pds;
164
165         ret = clk_prepare_enable(adsp->xo);
166         if (ret)
167                 goto disable_proxy_pds;
168
169         ret = clk_prepare_enable(adsp->aggre2_clk);
170         if (ret)
171                 goto disable_xo_clk;
172
173         ret = regulator_enable(adsp->cx_supply);
174         if (ret)
175                 goto disable_aggre2_clk;
176
177         ret = regulator_enable(adsp->px_supply);
178         if (ret)
179                 goto disable_cx_supply;
180
181         ret = qcom_scm_pas_auth_and_reset(adsp->pas_id);
182         if (ret) {
183                 dev_err(adsp->dev,
184                         "failed to authenticate image and release reset\n");
185                 goto disable_px_supply;
186         }
187
188         ret = qcom_q6v5_wait_for_start(&adsp->q6v5, msecs_to_jiffies(5000));
189         if (ret == -ETIMEDOUT) {
190                 dev_err(adsp->dev, "start timed out\n");
191                 qcom_scm_pas_shutdown(adsp->pas_id);
192                 goto disable_px_supply;
193         }
194
195         return 0;
196
197 disable_px_supply:
198         regulator_disable(adsp->px_supply);
199 disable_cx_supply:
200         regulator_disable(adsp->cx_supply);
201 disable_aggre2_clk:
202         clk_disable_unprepare(adsp->aggre2_clk);
203 disable_xo_clk:
204         clk_disable_unprepare(adsp->xo);
205 disable_proxy_pds:
206         adsp_pds_disable(adsp, adsp->proxy_pds, adsp->proxy_pd_count);
207 disable_active_pds:
208         adsp_pds_disable(adsp, adsp->active_pds, adsp->active_pd_count);
209 disable_irqs:
210         qcom_q6v5_unprepare(&adsp->q6v5);
211
212         return ret;
213 }
214
215 static void qcom_pas_handover(struct qcom_q6v5 *q6v5)
216 {
217         struct qcom_adsp *adsp = container_of(q6v5, struct qcom_adsp, q6v5);
218
219         regulator_disable(adsp->px_supply);
220         regulator_disable(adsp->cx_supply);
221         clk_disable_unprepare(adsp->aggre2_clk);
222         clk_disable_unprepare(adsp->xo);
223         adsp_pds_disable(adsp, adsp->proxy_pds, adsp->proxy_pd_count);
224 }
225
226 static int adsp_stop(struct rproc *rproc)
227 {
228         struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
229         int handover;
230         int ret;
231
232         ret = qcom_q6v5_request_stop(&adsp->q6v5, adsp->sysmon);
233         if (ret == -ETIMEDOUT)
234                 dev_err(adsp->dev, "timed out on wait\n");
235
236         ret = qcom_scm_pas_shutdown(adsp->pas_id);
237         if (ret)
238                 dev_err(adsp->dev, "failed to shutdown: %d\n", ret);
239
240         adsp_pds_disable(adsp, adsp->active_pds, adsp->active_pd_count);
241         handover = qcom_q6v5_unprepare(&adsp->q6v5);
242         if (handover)
243                 qcom_pas_handover(&adsp->q6v5);
244
245         return ret;
246 }
247
248 static void *adsp_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem)
249 {
250         struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
251         int offset;
252
253         offset = da - adsp->mem_reloc;
254         if (offset < 0 || offset + len > adsp->mem_size)
255                 return NULL;
256
257         return adsp->mem_region + offset;
258 }
259
260 static unsigned long adsp_panic(struct rproc *rproc)
261 {
262         struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
263
264         return qcom_q6v5_panic(&adsp->q6v5);
265 }
266
267 static const struct rproc_ops adsp_ops = {
268         .start = adsp_start,
269         .stop = adsp_stop,
270         .da_to_va = adsp_da_to_va,
271         .parse_fw = qcom_register_dump_segments,
272         .load = adsp_load,
273         .panic = adsp_panic,
274 };
275
276 static const struct rproc_ops adsp_minidump_ops = {
277         .start = adsp_start,
278         .stop = adsp_stop,
279         .da_to_va = adsp_da_to_va,
280         .load = adsp_load,
281         .panic = adsp_panic,
282         .coredump = adsp_minidump,
283 };
284
285 static int adsp_init_clock(struct qcom_adsp *adsp)
286 {
287         int ret;
288
289         adsp->xo = devm_clk_get(adsp->dev, "xo");
290         if (IS_ERR(adsp->xo)) {
291                 ret = PTR_ERR(adsp->xo);
292                 if (ret != -EPROBE_DEFER)
293                         dev_err(adsp->dev, "failed to get xo clock");
294                 return ret;
295         }
296
297         if (adsp->has_aggre2_clk) {
298                 adsp->aggre2_clk = devm_clk_get(adsp->dev, "aggre2");
299                 if (IS_ERR(adsp->aggre2_clk)) {
300                         ret = PTR_ERR(adsp->aggre2_clk);
301                         if (ret != -EPROBE_DEFER)
302                                 dev_err(adsp->dev,
303                                         "failed to get aggre2 clock");
304                         return ret;
305                 }
306         }
307
308         return 0;
309 }
310
311 static int adsp_init_regulator(struct qcom_adsp *adsp)
312 {
313         adsp->cx_supply = devm_regulator_get(adsp->dev, "cx");
314         if (IS_ERR(adsp->cx_supply))
315                 return PTR_ERR(adsp->cx_supply);
316
317         regulator_set_load(adsp->cx_supply, 100000);
318
319         adsp->px_supply = devm_regulator_get(adsp->dev, "px");
320         return PTR_ERR_OR_ZERO(adsp->px_supply);
321 }
322
323 static int adsp_pds_attach(struct device *dev, struct device **devs,
324                            char **pd_names)
325 {
326         size_t num_pds = 0;
327         int ret;
328         int i;
329
330         if (!pd_names)
331                 return 0;
332
333         /* Handle single power domain */
334         if (dev->pm_domain) {
335                 devs[0] = dev;
336                 pm_runtime_enable(dev);
337                 return 1;
338         }
339
340         while (pd_names[num_pds])
341                 num_pds++;
342
343         for (i = 0; i < num_pds; i++) {
344                 devs[i] = dev_pm_domain_attach_by_name(dev, pd_names[i]);
345                 if (IS_ERR_OR_NULL(devs[i])) {
346                         ret = PTR_ERR(devs[i]) ? : -ENODATA;
347                         goto unroll_attach;
348                 }
349         }
350
351         return num_pds;
352
353 unroll_attach:
354         for (i--; i >= 0; i--)
355                 dev_pm_domain_detach(devs[i], false);
356
357         return ret;
358 };
359
360 static void adsp_pds_detach(struct qcom_adsp *adsp, struct device **pds,
361                             size_t pd_count)
362 {
363         struct device *dev = adsp->dev;
364         int i;
365
366         /* Handle single power domain */
367         if (dev->pm_domain && pd_count) {
368                 pm_runtime_disable(dev);
369                 return;
370         }
371
372         for (i = 0; i < pd_count; i++)
373                 dev_pm_domain_detach(pds[i], false);
374 }
375
376 static int adsp_alloc_memory_region(struct qcom_adsp *adsp)
377 {
378         struct device_node *node;
379         struct resource r;
380         int ret;
381
382         node = of_parse_phandle(adsp->dev->of_node, "memory-region", 0);
383         if (!node) {
384                 dev_err(adsp->dev, "no memory-region specified\n");
385                 return -EINVAL;
386         }
387
388         ret = of_address_to_resource(node, 0, &r);
389         if (ret)
390                 return ret;
391
392         adsp->mem_phys = adsp->mem_reloc = r.start;
393         adsp->mem_size = resource_size(&r);
394         adsp->mem_region = devm_ioremap_wc(adsp->dev, adsp->mem_phys, adsp->mem_size);
395         if (!adsp->mem_region) {
396                 dev_err(adsp->dev, "unable to map memory region: %pa+%zx\n",
397                         &r.start, adsp->mem_size);
398                 return -EBUSY;
399         }
400
401         return 0;
402 }
403
404 static int adsp_probe(struct platform_device *pdev)
405 {
406         const struct adsp_data *desc;
407         struct qcom_adsp *adsp;
408         struct rproc *rproc;
409         const char *fw_name;
410         const struct rproc_ops *ops = &adsp_ops;
411         int ret;
412
413         desc = of_device_get_match_data(&pdev->dev);
414         if (!desc)
415                 return -EINVAL;
416
417         if (!qcom_scm_is_available())
418                 return -EPROBE_DEFER;
419
420         fw_name = desc->firmware_name;
421         ret = of_property_read_string(pdev->dev.of_node, "firmware-name",
422                                       &fw_name);
423         if (ret < 0 && ret != -EINVAL)
424                 return ret;
425
426         if (desc->minidump_id)
427                 ops = &adsp_minidump_ops;
428
429         rproc = rproc_alloc(&pdev->dev, pdev->name, ops, fw_name, sizeof(*adsp));
430
431         if (!rproc) {
432                 dev_err(&pdev->dev, "unable to allocate remoteproc\n");
433                 return -ENOMEM;
434         }
435
436         rproc->auto_boot = desc->auto_boot;
437         rproc_coredump_set_elf_info(rproc, ELFCLASS32, EM_NONE);
438
439         adsp = (struct qcom_adsp *)rproc->priv;
440         adsp->dev = &pdev->dev;
441         adsp->rproc = rproc;
442         adsp->minidump_id = desc->minidump_id;
443         adsp->pas_id = desc->pas_id;
444         adsp->has_aggre2_clk = desc->has_aggre2_clk;
445         adsp->info_name = desc->sysmon_name;
446         platform_set_drvdata(pdev, adsp);
447
448         device_wakeup_enable(adsp->dev);
449
450         ret = adsp_alloc_memory_region(adsp);
451         if (ret)
452                 goto free_rproc;
453
454         ret = adsp_init_clock(adsp);
455         if (ret)
456                 goto free_rproc;
457
458         ret = adsp_init_regulator(adsp);
459         if (ret)
460                 goto free_rproc;
461
462         ret = adsp_pds_attach(&pdev->dev, adsp->active_pds,
463                               desc->active_pd_names);
464         if (ret < 0)
465                 goto free_rproc;
466         adsp->active_pd_count = ret;
467
468         ret = adsp_pds_attach(&pdev->dev, adsp->proxy_pds,
469                               desc->proxy_pd_names);
470         if (ret < 0)
471                 goto detach_active_pds;
472         adsp->proxy_pd_count = ret;
473
474         ret = qcom_q6v5_init(&adsp->q6v5, pdev, rproc, desc->crash_reason_smem,
475                              qcom_pas_handover);
476         if (ret)
477                 goto detach_proxy_pds;
478
479         qcom_add_glink_subdev(rproc, &adsp->glink_subdev, desc->ssr_name);
480         qcom_add_smd_subdev(rproc, &adsp->smd_subdev);
481         qcom_add_ssr_subdev(rproc, &adsp->ssr_subdev, desc->ssr_name);
482         adsp->sysmon = qcom_add_sysmon_subdev(rproc,
483                                               desc->sysmon_name,
484                                               desc->ssctl_id);
485         if (IS_ERR(adsp->sysmon)) {
486                 ret = PTR_ERR(adsp->sysmon);
487                 goto detach_proxy_pds;
488         }
489
490         ret = rproc_add(rproc);
491         if (ret)
492                 goto detach_proxy_pds;
493
494         return 0;
495
496 detach_proxy_pds:
497         adsp_pds_detach(adsp, adsp->proxy_pds, adsp->proxy_pd_count);
498 detach_active_pds:
499         adsp_pds_detach(adsp, adsp->active_pds, adsp->active_pd_count);
500 free_rproc:
501         device_init_wakeup(adsp->dev, false);
502         rproc_free(rproc);
503
504         return ret;
505 }
506
507 static int adsp_remove(struct platform_device *pdev)
508 {
509         struct qcom_adsp *adsp = platform_get_drvdata(pdev);
510
511         rproc_del(adsp->rproc);
512
513         qcom_remove_glink_subdev(adsp->rproc, &adsp->glink_subdev);
514         qcom_remove_sysmon_subdev(adsp->sysmon);
515         qcom_remove_smd_subdev(adsp->rproc, &adsp->smd_subdev);
516         qcom_remove_ssr_subdev(adsp->rproc, &adsp->ssr_subdev);
517         device_init_wakeup(adsp->dev, false);
518         rproc_free(adsp->rproc);
519
520         return 0;
521 }
522
523 static const struct adsp_data adsp_resource_init = {
524                 .crash_reason_smem = 423,
525                 .firmware_name = "adsp.mdt",
526                 .pas_id = 1,
527                 .has_aggre2_clk = false,
528                 .auto_boot = true,
529                 .ssr_name = "lpass",
530                 .sysmon_name = "adsp",
531                 .ssctl_id = 0x14,
532 };
533
534 static const struct adsp_data sm8150_adsp_resource = {
535                 .crash_reason_smem = 423,
536                 .firmware_name = "adsp.mdt",
537                 .pas_id = 1,
538                 .has_aggre2_clk = false,
539                 .auto_boot = true,
540                 .active_pd_names = (char*[]){
541                         "load_state",
542                         NULL
543                 },
544                 .proxy_pd_names = (char*[]){
545                         "cx",
546                         NULL
547                 },
548                 .ssr_name = "lpass",
549                 .sysmon_name = "adsp",
550                 .ssctl_id = 0x14,
551 };
552
553 static const struct adsp_data sm8250_adsp_resource = {
554         .crash_reason_smem = 423,
555         .firmware_name = "adsp.mdt",
556         .pas_id = 1,
557         .has_aggre2_clk = false,
558         .auto_boot = true,
559         .active_pd_names = (char*[]){
560                 "load_state",
561                 NULL
562         },
563         .proxy_pd_names = (char*[]){
564                 "lcx",
565                 "lmx",
566                 NULL
567         },
568         .ssr_name = "lpass",
569         .sysmon_name = "adsp",
570         .ssctl_id = 0x14,
571 };
572
573 static const struct adsp_data sm8350_adsp_resource = {
574         .crash_reason_smem = 423,
575         .firmware_name = "adsp.mdt",
576         .pas_id = 1,
577         .has_aggre2_clk = false,
578         .auto_boot = true,
579         .active_pd_names = (char*[]){
580                 "load_state",
581                 NULL
582         },
583         .proxy_pd_names = (char*[]){
584                 "lcx",
585                 "lmx",
586                 NULL
587         },
588         .ssr_name = "lpass",
589         .sysmon_name = "adsp",
590         .ssctl_id = 0x14,
591 };
592
593 static const struct adsp_data msm8998_adsp_resource = {
594                 .crash_reason_smem = 423,
595                 .firmware_name = "adsp.mdt",
596                 .pas_id = 1,
597                 .has_aggre2_clk = false,
598                 .auto_boot = true,
599                 .proxy_pd_names = (char*[]){
600                         "cx",
601                         NULL
602                 },
603                 .ssr_name = "lpass",
604                 .sysmon_name = "adsp",
605                 .ssctl_id = 0x14,
606 };
607
608 static const struct adsp_data cdsp_resource_init = {
609         .crash_reason_smem = 601,
610         .firmware_name = "cdsp.mdt",
611         .pas_id = 18,
612         .has_aggre2_clk = false,
613         .auto_boot = true,
614         .ssr_name = "cdsp",
615         .sysmon_name = "cdsp",
616         .ssctl_id = 0x17,
617 };
618
619 static const struct adsp_data sm8150_cdsp_resource = {
620         .crash_reason_smem = 601,
621         .firmware_name = "cdsp.mdt",
622         .pas_id = 18,
623         .has_aggre2_clk = false,
624         .auto_boot = true,
625         .active_pd_names = (char*[]){
626                 "load_state",
627                 NULL
628         },
629         .proxy_pd_names = (char*[]){
630                 "cx",
631                 NULL
632         },
633         .ssr_name = "cdsp",
634         .sysmon_name = "cdsp",
635         .ssctl_id = 0x17,
636 };
637
638 static const struct adsp_data sm8250_cdsp_resource = {
639         .crash_reason_smem = 601,
640         .firmware_name = "cdsp.mdt",
641         .pas_id = 18,
642         .has_aggre2_clk = false,
643         .auto_boot = true,
644         .active_pd_names = (char*[]){
645                 "load_state",
646                 NULL
647         },
648         .proxy_pd_names = (char*[]){
649                 "cx",
650                 NULL
651         },
652         .ssr_name = "cdsp",
653         .sysmon_name = "cdsp",
654         .ssctl_id = 0x17,
655 };
656
657 static const struct adsp_data sm8350_cdsp_resource = {
658         .crash_reason_smem = 601,
659         .firmware_name = "cdsp.mdt",
660         .pas_id = 18,
661         .has_aggre2_clk = false,
662         .auto_boot = true,
663         .active_pd_names = (char*[]){
664                 "load_state",
665                 NULL
666         },
667         .proxy_pd_names = (char*[]){
668                 "cx",
669                 "mxc",
670                 NULL
671         },
672         .ssr_name = "cdsp",
673         .sysmon_name = "cdsp",
674         .ssctl_id = 0x17,
675 };
676
677 static const struct adsp_data mpss_resource_init = {
678         .crash_reason_smem = 421,
679         .firmware_name = "modem.mdt",
680         .pas_id = 4,
681         .minidump_id = 3,
682         .has_aggre2_clk = false,
683         .auto_boot = false,
684         .active_pd_names = (char*[]){
685                 "load_state",
686                 NULL
687         },
688         .proxy_pd_names = (char*[]){
689                 "cx",
690                 "mss",
691                 NULL
692         },
693         .ssr_name = "mpss",
694         .sysmon_name = "modem",
695         .ssctl_id = 0x12,
696 };
697
698 static const struct adsp_data sc8180x_mpss_resource = {
699         .crash_reason_smem = 421,
700         .firmware_name = "modem.mdt",
701         .pas_id = 4,
702         .has_aggre2_clk = false,
703         .auto_boot = false,
704         .active_pd_names = (char*[]){
705                 "load_state",
706                 NULL
707         },
708         .proxy_pd_names = (char*[]){
709                 "cx",
710                 NULL
711         },
712         .ssr_name = "mpss",
713         .sysmon_name = "modem",
714         .ssctl_id = 0x12,
715 };
716
717 static const struct adsp_data slpi_resource_init = {
718                 .crash_reason_smem = 424,
719                 .firmware_name = "slpi.mdt",
720                 .pas_id = 12,
721                 .has_aggre2_clk = true,
722                 .auto_boot = true,
723                 .ssr_name = "dsps",
724                 .sysmon_name = "slpi",
725                 .ssctl_id = 0x16,
726 };
727
728 static const struct adsp_data sm8150_slpi_resource = {
729                 .crash_reason_smem = 424,
730                 .firmware_name = "slpi.mdt",
731                 .pas_id = 12,
732                 .has_aggre2_clk = false,
733                 .auto_boot = true,
734                 .active_pd_names = (char*[]){
735                         "load_state",
736                         NULL
737                 },
738                 .proxy_pd_names = (char*[]){
739                         "lcx",
740                         "lmx",
741                         NULL
742                 },
743                 .ssr_name = "dsps",
744                 .sysmon_name = "slpi",
745                 .ssctl_id = 0x16,
746 };
747
748 static const struct adsp_data sm8250_slpi_resource = {
749         .crash_reason_smem = 424,
750         .firmware_name = "slpi.mdt",
751         .pas_id = 12,
752         .has_aggre2_clk = false,
753         .auto_boot = true,
754         .active_pd_names = (char*[]){
755                 "load_state",
756                 NULL
757         },
758         .proxy_pd_names = (char*[]){
759                 "lcx",
760                 "lmx",
761                 NULL
762         },
763         .ssr_name = "dsps",
764         .sysmon_name = "slpi",
765         .ssctl_id = 0x16,
766 };
767
768 static const struct adsp_data sm8350_slpi_resource = {
769         .crash_reason_smem = 424,
770         .firmware_name = "slpi.mdt",
771         .pas_id = 12,
772         .has_aggre2_clk = false,
773         .auto_boot = true,
774         .active_pd_names = (char*[]){
775                 "load_state",
776                 NULL
777         },
778         .proxy_pd_names = (char*[]){
779                 "lcx",
780                 "lmx",
781                 NULL
782         },
783         .ssr_name = "dsps",
784         .sysmon_name = "slpi",
785         .ssctl_id = 0x16,
786 };
787
788 static const struct adsp_data msm8998_slpi_resource = {
789                 .crash_reason_smem = 424,
790                 .firmware_name = "slpi.mdt",
791                 .pas_id = 12,
792                 .has_aggre2_clk = true,
793                 .auto_boot = true,
794                 .proxy_pd_names = (char*[]){
795                         "ssc_cx",
796                         NULL
797                 },
798                 .ssr_name = "dsps",
799                 .sysmon_name = "slpi",
800                 .ssctl_id = 0x16,
801 };
802
803 static const struct adsp_data wcss_resource_init = {
804         .crash_reason_smem = 421,
805         .firmware_name = "wcnss.mdt",
806         .pas_id = 6,
807         .auto_boot = true,
808         .ssr_name = "mpss",
809         .sysmon_name = "wcnss",
810         .ssctl_id = 0x12,
811 };
812
813 static const struct adsp_data sdx55_mpss_resource = {
814         .crash_reason_smem = 421,
815         .firmware_name = "modem.mdt",
816         .pas_id = 4,
817         .has_aggre2_clk = false,
818         .auto_boot = true,
819         .proxy_pd_names = (char*[]){
820                 "cx",
821                 "mss",
822                 NULL
823         },
824         .ssr_name = "mpss",
825         .sysmon_name = "modem",
826         .ssctl_id = 0x22,
827 };
828
829 static const struct of_device_id adsp_of_match[] = {
830         { .compatible = "qcom,msm8974-adsp-pil", .data = &adsp_resource_init},
831         { .compatible = "qcom,msm8996-adsp-pil", .data = &adsp_resource_init},
832         { .compatible = "qcom,msm8996-slpi-pil", .data = &slpi_resource_init},
833         { .compatible = "qcom,msm8998-adsp-pas", .data = &msm8998_adsp_resource},
834         { .compatible = "qcom,msm8998-slpi-pas", .data = &msm8998_slpi_resource},
835         { .compatible = "qcom,qcs404-adsp-pas", .data = &adsp_resource_init },
836         { .compatible = "qcom,qcs404-cdsp-pas", .data = &cdsp_resource_init },
837         { .compatible = "qcom,qcs404-wcss-pas", .data = &wcss_resource_init },
838         { .compatible = "qcom,sc7180-mpss-pas", .data = &mpss_resource_init},
839         { .compatible = "qcom,sc8180x-adsp-pas", .data = &sm8150_adsp_resource},
840         { .compatible = "qcom,sc8180x-cdsp-pas", .data = &sm8150_cdsp_resource},
841         { .compatible = "qcom,sc8180x-mpss-pas", .data = &sc8180x_mpss_resource},
842         { .compatible = "qcom,sdm660-adsp-pas", .data = &adsp_resource_init},
843         { .compatible = "qcom,sdm845-adsp-pas", .data = &adsp_resource_init},
844         { .compatible = "qcom,sdm845-cdsp-pas", .data = &cdsp_resource_init},
845         { .compatible = "qcom,sdx55-mpss-pas", .data = &sdx55_mpss_resource},
846         { .compatible = "qcom,sm8150-adsp-pas", .data = &sm8150_adsp_resource},
847         { .compatible = "qcom,sm8150-cdsp-pas", .data = &sm8150_cdsp_resource},
848         { .compatible = "qcom,sm8150-mpss-pas", .data = &mpss_resource_init},
849         { .compatible = "qcom,sm8150-slpi-pas", .data = &sm8150_slpi_resource},
850         { .compatible = "qcom,sm8250-adsp-pas", .data = &sm8250_adsp_resource},
851         { .compatible = "qcom,sm8250-cdsp-pas", .data = &sm8250_cdsp_resource},
852         { .compatible = "qcom,sm8250-slpi-pas", .data = &sm8250_slpi_resource},
853         { .compatible = "qcom,sm8350-adsp-pas", .data = &sm8350_adsp_resource},
854         { .compatible = "qcom,sm8350-cdsp-pas", .data = &sm8350_cdsp_resource},
855         { .compatible = "qcom,sm8350-slpi-pas", .data = &sm8350_slpi_resource},
856         { .compatible = "qcom,sm8350-mpss-pas", .data = &mpss_resource_init},
857         { },
858 };
859 MODULE_DEVICE_TABLE(of, adsp_of_match);
860
861 static struct platform_driver adsp_driver = {
862         .probe = adsp_probe,
863         .remove = adsp_remove,
864         .driver = {
865                 .name = "qcom_q6v5_pas",
866                 .of_match_table = adsp_of_match,
867         },
868 };
869
870 module_platform_driver(adsp_driver);
871 MODULE_DESCRIPTION("Qualcomm Hexagon v5 Peripheral Authentication Service driver");
872 MODULE_LICENSE("GPL v2");