1 // SPDX-License-Identifier: GPL-2.0-only
3 * Qualcomm self-authenticating modem subsystem remoteproc driver
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.
10 #include <linux/clk.h>
11 #include <linux/delay.h>
12 #include <linux/devcoredump.h>
13 #include <linux/dma-mapping.h>
14 #include <linux/interrupt.h>
15 #include <linux/kernel.h>
16 #include <linux/mfd/syscon.h>
17 #include <linux/module.h>
19 #include <linux/of_reserved_mem.h>
20 #include <linux/of_platform.h>
21 #include <linux/platform_device.h>
22 #include <linux/pm_domain.h>
23 #include <linux/pm_runtime.h>
24 #include <linux/regmap.h>
25 #include <linux/regulator/consumer.h>
26 #include <linux/remoteproc.h>
27 #include <linux/reset.h>
28 #include <linux/soc/qcom/mdt_loader.h>
29 #include <linux/iopoll.h>
30 #include <linux/slab.h>
32 #include "remoteproc_internal.h"
33 #include "qcom_common.h"
34 #include "qcom_pil_info.h"
35 #include "qcom_q6v5.h"
37 #include <linux/firmware/qcom/qcom_scm.h>
39 #define MPSS_CRASH_REASON_SMEM 421
41 #define MBA_LOG_SIZE SZ_4K
45 /* RMB Status Register Values */
46 #define RMB_PBL_SUCCESS 0x1
48 #define RMB_MBA_XPU_UNLOCKED 0x1
49 #define RMB_MBA_XPU_UNLOCKED_SCRIBBLED 0x2
50 #define RMB_MBA_META_DATA_AUTH_SUCCESS 0x3
51 #define RMB_MBA_AUTH_COMPLETE 0x4
53 /* PBL/MBA interface registers */
54 #define RMB_MBA_IMAGE_REG 0x00
55 #define RMB_PBL_STATUS_REG 0x04
56 #define RMB_MBA_COMMAND_REG 0x08
57 #define RMB_MBA_STATUS_REG 0x0C
58 #define RMB_PMI_META_DATA_REG 0x10
59 #define RMB_PMI_CODE_START_REG 0x14
60 #define RMB_PMI_CODE_LENGTH_REG 0x18
61 #define RMB_MBA_MSS_STATUS 0x40
62 #define RMB_MBA_ALT_RESET 0x44
64 #define RMB_CMD_META_DATA_READY 0x1
65 #define RMB_CMD_LOAD_READY 0x2
67 /* QDSP6SS Register Offsets */
68 #define QDSP6SS_RESET_REG 0x014
69 #define QDSP6SS_GFMUX_CTL_REG 0x020
70 #define QDSP6SS_PWR_CTL_REG 0x030
71 #define QDSP6SS_MEM_PWR_CTL 0x0B0
72 #define QDSP6V6SS_MEM_PWR_CTL 0x034
73 #define QDSP6SS_STRAP_ACC 0x110
74 #define QDSP6V62SS_BHS_STATUS 0x0C4
76 /* AXI Halt Register Offsets */
77 #define AXI_HALTREQ_REG 0x0
78 #define AXI_HALTACK_REG 0x4
79 #define AXI_IDLE_REG 0x8
80 #define AXI_GATING_VALID_OVERRIDE BIT(0)
82 #define HALT_ACK_TIMEOUT_US 100000
84 /* QACCEPT Register Offsets */
85 #define QACCEPT_ACCEPT_REG 0x0
86 #define QACCEPT_ACTIVE_REG 0x4
87 #define QACCEPT_DENY_REG 0x8
88 #define QACCEPT_REQ_REG 0xC
90 #define QACCEPT_TIMEOUT_US 50
93 #define Q6SS_STOP_CORE BIT(0)
94 #define Q6SS_CORE_ARES BIT(1)
95 #define Q6SS_BUS_ARES_ENABLE BIT(2)
98 #define Q6SS_CBCR_CLKEN BIT(0)
99 #define Q6SS_CBCR_CLKOFF BIT(31)
100 #define Q6SS_CBCR_TIMEOUT_US 200
102 /* QDSP6SS_GFMUX_CTL */
103 #define Q6SS_CLK_ENABLE BIT(1)
105 /* QDSP6SS_PWR_CTL */
106 #define Q6SS_L2DATA_SLP_NRET_N_0 BIT(0)
107 #define Q6SS_L2DATA_SLP_NRET_N_1 BIT(1)
108 #define Q6SS_L2DATA_SLP_NRET_N_2 BIT(2)
109 #define Q6SS_L2TAG_SLP_NRET_N BIT(16)
110 #define Q6SS_ETB_SLP_NRET_N BIT(17)
111 #define Q6SS_L2DATA_STBY_N BIT(18)
112 #define Q6SS_SLP_RET_N BIT(19)
113 #define Q6SS_CLAMP_IO BIT(20)
114 #define QDSS_BHS_ON BIT(21)
115 #define QDSS_LDO_BYP BIT(22)
117 /* QDSP6v55 parameters */
118 #define QDSP6V55_MEM_BITS GENMASK(16, 8)
120 /* QDSP6v56 parameters */
121 #define QDSP6v56_LDO_BYP BIT(25)
122 #define QDSP6v56_BHS_ON BIT(24)
123 #define QDSP6v56_CLAMP_WL BIT(21)
124 #define QDSP6v56_CLAMP_QMC_MEM BIT(22)
125 #define QDSP6SS_XO_CBCR 0x0038
126 #define QDSP6SS_ACC_OVERRIDE_VAL 0x20
127 #define QDSP6v55_BHS_EN_REST_ACK BIT(0)
129 /* QDSP6v65 parameters */
130 #define QDSP6SS_CORE_CBCR 0x20
131 #define QDSP6SS_SLEEP 0x3C
132 #define QDSP6SS_BOOT_CORE_START 0x400
133 #define QDSP6SS_BOOT_CMD 0x404
134 #define BOOT_FSM_TIMEOUT 10000
135 #define BHS_CHECK_MAX_LOOPS 200
138 struct regulator
*reg
;
143 struct qcom_mss_reg_res
{
149 struct rproc_hexagon_res
{
150 const char *hexagon_mba_image
;
151 struct qcom_mss_reg_res
*proxy_supply
;
152 struct qcom_mss_reg_res
*fallback_proxy_supply
;
153 struct qcom_mss_reg_res
*active_supply
;
154 char **proxy_clk_names
;
155 char **reset_clk_names
;
156 char **active_clk_names
;
157 char **proxy_pd_names
;
159 bool need_mem_protection
;
163 bool has_qaccept_regs
;
164 bool has_ext_cntl_regs
;
172 void __iomem
*reg_base
;
173 void __iomem
*rmb_base
;
175 struct regmap
*halt_map
;
176 struct regmap
*conn_map
;
193 struct reset_control
*mss_restart
;
194 struct reset_control
*pdc_reset
;
196 struct qcom_q6v5 q6v5
;
198 struct clk
*active_clks
[8];
199 struct clk
*reset_clks
[4];
200 struct clk
*proxy_clks
[4];
201 struct device
*proxy_pds
[3];
202 int active_clk_count
;
207 struct reg_info active_regs
[1];
208 struct reg_info proxy_regs
[1];
209 struct reg_info fallback_proxy_regs
[2];
210 int active_reg_count
;
212 int fallback_proxy_reg_count
;
214 bool dump_mba_loaded
;
215 size_t current_dump_size
;
216 size_t total_dump_size
;
218 phys_addr_t mba_phys
;
222 phys_addr_t mdata_phys
;
225 phys_addr_t mpss_phys
;
226 phys_addr_t mpss_reloc
;
229 struct qcom_rproc_glink glink_subdev
;
230 struct qcom_rproc_subdev smd_subdev
;
231 struct qcom_rproc_pdm pdm_subdev
;
232 struct qcom_rproc_ssr ssr_subdev
;
233 struct qcom_sysmon
*sysmon
;
234 struct platform_device
*bam_dmux
;
235 bool need_mem_protection
;
239 bool has_qaccept_regs
;
240 bool has_ext_cntl_regs
;
244 const char *hexagon_mdt_image
;
261 static int q6v5_regulator_init(struct device
*dev
, struct reg_info
*regs
,
262 const struct qcom_mss_reg_res
*reg_res
)
269 for (i
= 0; reg_res
[i
].supply
; i
++) {
270 regs
[i
].reg
= devm_regulator_get(dev
, reg_res
[i
].supply
);
271 if (IS_ERR(regs
[i
].reg
))
272 return dev_err_probe(dev
, PTR_ERR(regs
[i
].reg
),
273 "Failed to get %s\n regulator",
276 regs
[i
].uV
= reg_res
[i
].uV
;
277 regs
[i
].uA
= reg_res
[i
].uA
;
283 static int q6v5_regulator_enable(struct q6v5
*qproc
,
284 struct reg_info
*regs
, int count
)
289 for (i
= 0; i
< count
; i
++) {
290 if (regs
[i
].uV
> 0) {
291 ret
= regulator_set_voltage(regs
[i
].reg
,
292 regs
[i
].uV
, INT_MAX
);
295 "Failed to request voltage for %d.\n",
301 if (regs
[i
].uA
> 0) {
302 ret
= regulator_set_load(regs
[i
].reg
,
306 "Failed to set regulator mode\n");
311 ret
= regulator_enable(regs
[i
].reg
);
313 dev_err(qproc
->dev
, "Regulator enable failed\n");
320 for (; i
>= 0; i
--) {
322 regulator_set_voltage(regs
[i
].reg
, 0, INT_MAX
);
325 regulator_set_load(regs
[i
].reg
, 0);
327 regulator_disable(regs
[i
].reg
);
333 static void q6v5_regulator_disable(struct q6v5
*qproc
,
334 struct reg_info
*regs
, int count
)
338 for (i
= 0; i
< count
; i
++) {
340 regulator_set_voltage(regs
[i
].reg
, 0, INT_MAX
);
343 regulator_set_load(regs
[i
].reg
, 0);
345 regulator_disable(regs
[i
].reg
);
349 static int q6v5_clk_enable(struct device
*dev
,
350 struct clk
**clks
, int count
)
355 for (i
= 0; i
< count
; i
++) {
356 rc
= clk_prepare_enable(clks
[i
]);
358 dev_err(dev
, "Clock enable failed\n");
365 for (i
--; i
>= 0; i
--)
366 clk_disable_unprepare(clks
[i
]);
371 static void q6v5_clk_disable(struct device
*dev
,
372 struct clk
**clks
, int count
)
376 for (i
= 0; i
< count
; i
++)
377 clk_disable_unprepare(clks
[i
]);
380 static int q6v5_pds_enable(struct q6v5
*qproc
, struct device
**pds
,
386 for (i
= 0; i
< pd_count
; i
++) {
387 dev_pm_genpd_set_performance_state(pds
[i
], INT_MAX
);
388 ret
= pm_runtime_get_sync(pds
[i
]);
390 pm_runtime_put_noidle(pds
[i
]);
391 dev_pm_genpd_set_performance_state(pds
[i
], 0);
392 goto unroll_pd_votes
;
399 for (i
--; i
>= 0; i
--) {
400 dev_pm_genpd_set_performance_state(pds
[i
], 0);
401 pm_runtime_put(pds
[i
]);
407 static void q6v5_pds_disable(struct q6v5
*qproc
, struct device
**pds
,
412 for (i
= 0; i
< pd_count
; i
++) {
413 dev_pm_genpd_set_performance_state(pds
[i
], 0);
414 pm_runtime_put(pds
[i
]);
418 static int q6v5_xfer_mem_ownership(struct q6v5
*qproc
, u64
*current_perm
,
419 bool local
, bool remote
, phys_addr_t addr
,
422 struct qcom_scm_vmperm next
[2];
425 if (!qproc
->need_mem_protection
)
428 if (local
== !!(*current_perm
& BIT(QCOM_SCM_VMID_HLOS
)) &&
429 remote
== !!(*current_perm
& BIT(QCOM_SCM_VMID_MSS_MSA
)))
433 next
[perms
].vmid
= QCOM_SCM_VMID_HLOS
;
434 next
[perms
].perm
= QCOM_SCM_PERM_RWX
;
439 next
[perms
].vmid
= QCOM_SCM_VMID_MSS_MSA
;
440 next
[perms
].perm
= QCOM_SCM_PERM_RW
;
444 return qcom_scm_assign_mem(addr
, ALIGN(size
, SZ_4K
),
445 current_perm
, next
, perms
);
448 static void q6v5_debug_policy_load(struct q6v5
*qproc
, void *mba_region
)
450 const struct firmware
*dp_fw
;
452 if (request_firmware_direct(&dp_fw
, "msadp", qproc
->dev
))
455 if (SZ_1M
+ dp_fw
->size
<= qproc
->mba_size
) {
456 memcpy(mba_region
+ SZ_1M
, dp_fw
->data
, dp_fw
->size
);
457 qproc
->dp_size
= dp_fw
->size
;
460 release_firmware(dp_fw
);
463 static int q6v5_load(struct rproc
*rproc
, const struct firmware
*fw
)
465 struct q6v5
*qproc
= rproc
->priv
;
468 /* MBA is restricted to a maximum size of 1M */
469 if (fw
->size
> qproc
->mba_size
|| fw
->size
> SZ_1M
) {
470 dev_err(qproc
->dev
, "MBA firmware load failed\n");
474 mba_region
= memremap(qproc
->mba_phys
, qproc
->mba_size
, MEMREMAP_WC
);
476 dev_err(qproc
->dev
, "unable to map memory region: %pa+%zx\n",
477 &qproc
->mba_phys
, qproc
->mba_size
);
481 memcpy(mba_region
, fw
->data
, fw
->size
);
482 q6v5_debug_policy_load(qproc
, mba_region
);
483 memunmap(mba_region
);
488 static int q6v5_reset_assert(struct q6v5
*qproc
)
492 if (qproc
->has_alt_reset
) {
493 reset_control_assert(qproc
->pdc_reset
);
494 ret
= reset_control_reset(qproc
->mss_restart
);
495 reset_control_deassert(qproc
->pdc_reset
);
496 } else if (qproc
->has_spare_reg
) {
498 * When the AXI pipeline is being reset with the Q6 modem partly
499 * operational there is possibility of AXI valid signal to
500 * glitch, leading to spurious transactions and Q6 hangs. A work
501 * around is employed by asserting the AXI_GATING_VALID_OVERRIDE
502 * BIT before triggering Q6 MSS reset. AXI_GATING_VALID_OVERRIDE
503 * is withdrawn post MSS assert followed by a MSS deassert,
504 * while holding the PDC reset.
506 reset_control_assert(qproc
->pdc_reset
);
507 regmap_update_bits(qproc
->conn_map
, qproc
->conn_box
,
508 AXI_GATING_VALID_OVERRIDE
, 1);
509 reset_control_assert(qproc
->mss_restart
);
510 reset_control_deassert(qproc
->pdc_reset
);
511 regmap_update_bits(qproc
->conn_map
, qproc
->conn_box
,
512 AXI_GATING_VALID_OVERRIDE
, 0);
513 ret
= reset_control_deassert(qproc
->mss_restart
);
514 } else if (qproc
->has_ext_cntl_regs
) {
515 regmap_write(qproc
->conn_map
, qproc
->rscc_disable
, 0);
516 reset_control_assert(qproc
->pdc_reset
);
517 reset_control_assert(qproc
->mss_restart
);
518 reset_control_deassert(qproc
->pdc_reset
);
519 ret
= reset_control_deassert(qproc
->mss_restart
);
521 ret
= reset_control_assert(qproc
->mss_restart
);
527 static int q6v5_reset_deassert(struct q6v5
*qproc
)
531 if (qproc
->has_alt_reset
) {
532 reset_control_assert(qproc
->pdc_reset
);
533 writel(1, qproc
->rmb_base
+ RMB_MBA_ALT_RESET
);
534 ret
= reset_control_reset(qproc
->mss_restart
);
535 writel(0, qproc
->rmb_base
+ RMB_MBA_ALT_RESET
);
536 reset_control_deassert(qproc
->pdc_reset
);
537 } else if (qproc
->has_spare_reg
|| qproc
->has_ext_cntl_regs
) {
538 ret
= reset_control_reset(qproc
->mss_restart
);
540 ret
= reset_control_deassert(qproc
->mss_restart
);
546 static int q6v5_rmb_pbl_wait(struct q6v5
*qproc
, int ms
)
548 unsigned long timeout
;
551 timeout
= jiffies
+ msecs_to_jiffies(ms
);
553 val
= readl(qproc
->rmb_base
+ RMB_PBL_STATUS_REG
);
557 if (time_after(jiffies
, timeout
))
566 static int q6v5_rmb_mba_wait(struct q6v5
*qproc
, u32 status
, int ms
)
569 unsigned long timeout
;
572 timeout
= jiffies
+ msecs_to_jiffies(ms
);
574 val
= readl(qproc
->rmb_base
+ RMB_MBA_STATUS_REG
);
580 else if (status
&& val
== status
)
583 if (time_after(jiffies
, timeout
))
592 static void q6v5_dump_mba_logs(struct q6v5
*qproc
)
594 struct rproc
*rproc
= qproc
->rproc
;
598 if (!qproc
->has_mba_logs
)
601 if (q6v5_xfer_mem_ownership(qproc
, &qproc
->mba_perm
, true, false, qproc
->mba_phys
,
605 mba_region
= memremap(qproc
->mba_phys
, qproc
->mba_size
, MEMREMAP_WC
);
609 data
= vmalloc(MBA_LOG_SIZE
);
611 memcpy(data
, mba_region
, MBA_LOG_SIZE
);
612 dev_coredumpv(&rproc
->dev
, data
, MBA_LOG_SIZE
, GFP_KERNEL
);
614 memunmap(mba_region
);
617 static int q6v5proc_reset(struct q6v5
*qproc
)
623 if (qproc
->version
== MSS_SDM845
) {
624 val
= readl(qproc
->reg_base
+ QDSP6SS_SLEEP
);
625 val
|= Q6SS_CBCR_CLKEN
;
626 writel(val
, qproc
->reg_base
+ QDSP6SS_SLEEP
);
628 ret
= readl_poll_timeout(qproc
->reg_base
+ QDSP6SS_SLEEP
,
629 val
, !(val
& Q6SS_CBCR_CLKOFF
), 1,
630 Q6SS_CBCR_TIMEOUT_US
);
632 dev_err(qproc
->dev
, "QDSP6SS Sleep clock timed out\n");
636 /* De-assert QDSP6 stop core */
637 writel(1, qproc
->reg_base
+ QDSP6SS_BOOT_CORE_START
);
638 /* Trigger boot FSM */
639 writel(1, qproc
->reg_base
+ QDSP6SS_BOOT_CMD
);
641 ret
= readl_poll_timeout(qproc
->rmb_base
+ RMB_MBA_MSS_STATUS
,
642 val
, (val
& BIT(0)) != 0, 10, BOOT_FSM_TIMEOUT
);
644 dev_err(qproc
->dev
, "Boot FSM failed to complete.\n");
645 /* Reset the modem so that boot FSM is in reset state */
646 q6v5_reset_deassert(qproc
);
651 } else if (qproc
->version
== MSS_SC7180
|| qproc
->version
== MSS_SC7280
) {
652 val
= readl(qproc
->reg_base
+ QDSP6SS_SLEEP
);
653 val
|= Q6SS_CBCR_CLKEN
;
654 writel(val
, qproc
->reg_base
+ QDSP6SS_SLEEP
);
656 ret
= readl_poll_timeout(qproc
->reg_base
+ QDSP6SS_SLEEP
,
657 val
, !(val
& Q6SS_CBCR_CLKOFF
), 1,
658 Q6SS_CBCR_TIMEOUT_US
);
660 dev_err(qproc
->dev
, "QDSP6SS Sleep clock timed out\n");
664 /* Turn on the XO clock needed for PLL setup */
665 val
= readl(qproc
->reg_base
+ QDSP6SS_XO_CBCR
);
666 val
|= Q6SS_CBCR_CLKEN
;
667 writel(val
, qproc
->reg_base
+ QDSP6SS_XO_CBCR
);
669 ret
= readl_poll_timeout(qproc
->reg_base
+ QDSP6SS_XO_CBCR
,
670 val
, !(val
& Q6SS_CBCR_CLKOFF
), 1,
671 Q6SS_CBCR_TIMEOUT_US
);
673 dev_err(qproc
->dev
, "QDSP6SS XO clock timed out\n");
677 /* Configure Q6 core CBCR to auto-enable after reset sequence */
678 val
= readl(qproc
->reg_base
+ QDSP6SS_CORE_CBCR
);
679 val
|= Q6SS_CBCR_CLKEN
;
680 writel(val
, qproc
->reg_base
+ QDSP6SS_CORE_CBCR
);
682 /* De-assert the Q6 stop core signal */
683 writel(1, qproc
->reg_base
+ QDSP6SS_BOOT_CORE_START
);
685 /* Wait for 10 us for any staggering logic to settle */
686 usleep_range(10, 20);
688 /* Trigger the boot FSM to start the Q6 out-of-reset sequence */
689 writel(1, qproc
->reg_base
+ QDSP6SS_BOOT_CMD
);
691 /* Poll the MSS_STATUS for FSM completion */
692 ret
= readl_poll_timeout(qproc
->rmb_base
+ RMB_MBA_MSS_STATUS
,
693 val
, (val
& BIT(0)) != 0, 10, BOOT_FSM_TIMEOUT
);
695 dev_err(qproc
->dev
, "Boot FSM failed to complete.\n");
696 /* Reset the modem so that boot FSM is in reset state */
697 q6v5_reset_deassert(qproc
);
701 } else if (qproc
->version
== MSS_MSM8909
||
702 qproc
->version
== MSS_MSM8953
||
703 qproc
->version
== MSS_MSM8996
||
704 qproc
->version
== MSS_MSM8998
||
705 qproc
->version
== MSS_SDM660
) {
707 if (qproc
->version
!= MSS_MSM8909
&&
708 qproc
->version
!= MSS_MSM8953
)
709 /* Override the ACC value if required */
710 writel(QDSP6SS_ACC_OVERRIDE_VAL
,
711 qproc
->reg_base
+ QDSP6SS_STRAP_ACC
);
713 /* Assert resets, stop core */
714 val
= readl(qproc
->reg_base
+ QDSP6SS_RESET_REG
);
715 val
|= Q6SS_CORE_ARES
| Q6SS_BUS_ARES_ENABLE
| Q6SS_STOP_CORE
;
716 writel(val
, qproc
->reg_base
+ QDSP6SS_RESET_REG
);
718 /* BHS require xo cbcr to be enabled */
719 val
= readl(qproc
->reg_base
+ QDSP6SS_XO_CBCR
);
720 val
|= Q6SS_CBCR_CLKEN
;
721 writel(val
, qproc
->reg_base
+ QDSP6SS_XO_CBCR
);
723 /* Read CLKOFF bit to go low indicating CLK is enabled */
724 ret
= readl_poll_timeout(qproc
->reg_base
+ QDSP6SS_XO_CBCR
,
725 val
, !(val
& Q6SS_CBCR_CLKOFF
), 1,
726 Q6SS_CBCR_TIMEOUT_US
);
729 "xo cbcr enabling timed out (rc:%d)\n", ret
);
732 /* Enable power block headswitch and wait for it to stabilize */
733 val
= readl(qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
734 val
|= QDSP6v56_BHS_ON
;
735 writel(val
, qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
736 val
|= readl(qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
739 if (qproc
->version
== MSS_SDM660
) {
740 ret
= readl_relaxed_poll_timeout(qproc
->reg_base
+ QDSP6V62SS_BHS_STATUS
,
741 i
, (i
& QDSP6v55_BHS_EN_REST_ACK
),
742 1, BHS_CHECK_MAX_LOOPS
);
743 if (ret
== -ETIMEDOUT
) {
744 dev_err(qproc
->dev
, "BHS_EN_REST_ACK not set!\n");
749 /* Put LDO in bypass mode */
750 val
|= QDSP6v56_LDO_BYP
;
751 writel(val
, qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
753 if (qproc
->version
!= MSS_MSM8909
) {
756 /* Deassert QDSP6 compiler memory clamp */
757 val
= readl(qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
758 val
&= ~QDSP6v56_CLAMP_QMC_MEM
;
759 writel(val
, qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
761 /* Deassert memory peripheral sleep and L2 memory standby */
762 val
|= Q6SS_L2DATA_STBY_N
| Q6SS_SLP_RET_N
;
763 writel(val
, qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
765 /* Turn on L1, L2, ETB and JU memories 1 at a time */
766 if (qproc
->version
== MSS_MSM8953
||
767 qproc
->version
== MSS_MSM8996
) {
768 mem_pwr_ctl
= QDSP6SS_MEM_PWR_CTL
;
771 /* MSS_MSM8998, MSS_SDM660 */
772 mem_pwr_ctl
= QDSP6V6SS_MEM_PWR_CTL
;
775 val
= readl(qproc
->reg_base
+ mem_pwr_ctl
);
776 for (; i
>= 0; i
--) {
778 writel(val
, qproc
->reg_base
+ mem_pwr_ctl
);
780 * Read back value to ensure the write is done then
781 * wait for 1us for both memory peripheral and data
784 val
|= readl(qproc
->reg_base
+ mem_pwr_ctl
);
788 /* Turn on memories */
789 val
= readl(qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
790 val
|= Q6SS_SLP_RET_N
| Q6SS_L2DATA_STBY_N
|
791 Q6SS_ETB_SLP_NRET_N
| QDSP6V55_MEM_BITS
;
792 writel(val
, qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
794 /* Turn on L2 banks 1 at a time */
795 for (i
= 0; i
<= 7; i
++) {
797 writel(val
, qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
801 /* Remove word line clamp */
802 val
= readl(qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
803 val
&= ~QDSP6v56_CLAMP_WL
;
804 writel(val
, qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
806 /* Assert resets, stop core */
807 val
= readl(qproc
->reg_base
+ QDSP6SS_RESET_REG
);
808 val
|= Q6SS_CORE_ARES
| Q6SS_BUS_ARES_ENABLE
| Q6SS_STOP_CORE
;
809 writel(val
, qproc
->reg_base
+ QDSP6SS_RESET_REG
);
811 /* Enable power block headswitch and wait for it to stabilize */
812 val
= readl(qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
813 val
|= QDSS_BHS_ON
| QDSS_LDO_BYP
;
814 writel(val
, qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
815 val
|= readl(qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
818 * Turn on memories. L2 banks should be done individually
819 * to minimize inrush current.
821 val
= readl(qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
822 val
|= Q6SS_SLP_RET_N
| Q6SS_L2TAG_SLP_NRET_N
|
823 Q6SS_ETB_SLP_NRET_N
| Q6SS_L2DATA_STBY_N
;
824 writel(val
, qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
825 val
|= Q6SS_L2DATA_SLP_NRET_N_2
;
826 writel(val
, qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
827 val
|= Q6SS_L2DATA_SLP_NRET_N_1
;
828 writel(val
, qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
829 val
|= Q6SS_L2DATA_SLP_NRET_N_0
;
830 writel(val
, qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
832 /* Remove IO clamp */
833 val
&= ~Q6SS_CLAMP_IO
;
834 writel(val
, qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
836 /* Bring core out of reset */
837 val
= readl(qproc
->reg_base
+ QDSP6SS_RESET_REG
);
838 val
&= ~Q6SS_CORE_ARES
;
839 writel(val
, qproc
->reg_base
+ QDSP6SS_RESET_REG
);
841 /* Turn on core clock */
842 val
= readl(qproc
->reg_base
+ QDSP6SS_GFMUX_CTL_REG
);
843 val
|= Q6SS_CLK_ENABLE
;
844 writel(val
, qproc
->reg_base
+ QDSP6SS_GFMUX_CTL_REG
);
846 /* Start core execution */
847 val
= readl(qproc
->reg_base
+ QDSP6SS_RESET_REG
);
848 val
&= ~Q6SS_STOP_CORE
;
849 writel(val
, qproc
->reg_base
+ QDSP6SS_RESET_REG
);
852 /* Wait for PBL status */
853 ret
= q6v5_rmb_pbl_wait(qproc
, 1000);
854 if (ret
== -ETIMEDOUT
) {
855 dev_err(qproc
->dev
, "PBL boot timed out\n");
856 } else if (ret
!= RMB_PBL_SUCCESS
) {
857 dev_err(qproc
->dev
, "PBL returned unexpected status %d\n", ret
);
866 static int q6v5proc_enable_qchannel(struct q6v5
*qproc
, struct regmap
*map
, u32 offset
)
871 if (!qproc
->has_qaccept_regs
)
874 if (qproc
->has_ext_cntl_regs
) {
875 regmap_write(qproc
->conn_map
, qproc
->rscc_disable
, 0);
876 regmap_write(qproc
->conn_map
, qproc
->force_clk_on
, 1);
878 ret
= regmap_read_poll_timeout(qproc
->halt_map
, qproc
->axim1_clk_off
, val
,
879 !val
, 1, Q6SS_CBCR_TIMEOUT_US
);
881 dev_err(qproc
->dev
, "failed to enable axim1 clock\n");
886 regmap_write(map
, offset
+ QACCEPT_REQ_REG
, 1);
888 /* Wait for accept */
889 ret
= regmap_read_poll_timeout(map
, offset
+ QACCEPT_ACCEPT_REG
, val
, val
, 5,
892 dev_err(qproc
->dev
, "qchannel enable failed\n");
899 static void q6v5proc_disable_qchannel(struct q6v5
*qproc
, struct regmap
*map
, u32 offset
)
902 unsigned int val
, retry
;
903 unsigned int nretry
= 10;
904 bool takedown_complete
= false;
906 if (!qproc
->has_qaccept_regs
)
909 while (!takedown_complete
&& nretry
) {
912 /* Wait for active transactions to complete */
913 regmap_read_poll_timeout(map
, offset
+ QACCEPT_ACTIVE_REG
, val
, !val
, 5,
916 /* Request Q-channel transaction takedown */
917 regmap_write(map
, offset
+ QACCEPT_REQ_REG
, 0);
920 * If the request is denied, reset the Q-channel takedown request,
921 * wait for active transactions to complete and retry takedown.
927 ret
= regmap_read(map
, offset
+ QACCEPT_DENY_REG
, &val
);
929 regmap_write(map
, offset
+ QACCEPT_REQ_REG
, 1);
933 ret
= regmap_read(map
, offset
+ QACCEPT_ACCEPT_REG
, &val
);
935 takedown_complete
= true;
944 /* Rely on mss_restart to clear out pending transactions on takedown failure */
945 if (!takedown_complete
)
946 dev_err(qproc
->dev
, "qchannel takedown failed\n");
949 static void q6v5proc_halt_axi_port(struct q6v5
*qproc
,
950 struct regmap
*halt_map
,
956 /* Check if we're already idle */
957 ret
= regmap_read(halt_map
, offset
+ AXI_IDLE_REG
, &val
);
961 /* Assert halt request */
962 regmap_write(halt_map
, offset
+ AXI_HALTREQ_REG
, 1);
965 regmap_read_poll_timeout(halt_map
, offset
+ AXI_HALTACK_REG
, val
,
966 val
, 1000, HALT_ACK_TIMEOUT_US
);
968 ret
= regmap_read(halt_map
, offset
+ AXI_IDLE_REG
, &val
);
970 dev_err(qproc
->dev
, "port failed halt\n");
972 /* Clear halt request (port will remain halted until reset) */
973 regmap_write(halt_map
, offset
+ AXI_HALTREQ_REG
, 0);
976 static int q6v5_mpss_init_image(struct q6v5
*qproc
, const struct firmware
*fw
,
979 unsigned long dma_attrs
= DMA_ATTR_FORCE_CONTIGUOUS
;
988 metadata
= qcom_mdt_read_metadata(fw
, &size
, fw_name
, qproc
->dev
);
989 if (IS_ERR(metadata
))
990 return PTR_ERR(metadata
);
992 if (qproc
->mdata_phys
) {
993 if (size
> qproc
->mdata_size
) {
995 dev_err(qproc
->dev
, "metadata size outside memory range\n");
999 phys
= qproc
->mdata_phys
;
1000 ptr
= memremap(qproc
->mdata_phys
, size
, MEMREMAP_WC
);
1003 dev_err(qproc
->dev
, "unable to map memory region: %pa+%zx\n",
1004 &qproc
->mdata_phys
, size
);
1008 ptr
= dma_alloc_attrs(qproc
->dev
, size
, &phys
, GFP_KERNEL
, dma_attrs
);
1011 dev_err(qproc
->dev
, "failed to allocate mdt buffer\n");
1016 memcpy(ptr
, metadata
, size
);
1018 if (qproc
->mdata_phys
)
1021 /* Hypervisor mapping to access metadata by modem */
1022 mdata_perm
= BIT(QCOM_SCM_VMID_HLOS
);
1023 ret
= q6v5_xfer_mem_ownership(qproc
, &mdata_perm
, false, true,
1027 "assigning Q6 access to metadata failed: %d\n", ret
);
1029 goto free_dma_attrs
;
1032 writel(phys
, qproc
->rmb_base
+ RMB_PMI_META_DATA_REG
);
1033 writel(RMB_CMD_META_DATA_READY
, qproc
->rmb_base
+ RMB_MBA_COMMAND_REG
);
1035 ret
= q6v5_rmb_mba_wait(qproc
, RMB_MBA_META_DATA_AUTH_SUCCESS
, 1000);
1036 if (ret
== -ETIMEDOUT
)
1037 dev_err(qproc
->dev
, "MPSS header authentication timed out\n");
1039 dev_err(qproc
->dev
, "MPSS header authentication failed: %d\n", ret
);
1041 /* Metadata authentication done, remove modem access */
1042 xferop_ret
= q6v5_xfer_mem_ownership(qproc
, &mdata_perm
, true, false,
1045 dev_warn(qproc
->dev
,
1046 "mdt buffer not reclaimed system may become unstable\n");
1049 if (!qproc
->mdata_phys
)
1050 dma_free_attrs(qproc
->dev
, size
, ptr
, phys
, dma_attrs
);
1054 return ret
< 0 ? ret
: 0;
1057 static bool q6v5_phdr_valid(const struct elf32_phdr
*phdr
)
1059 if (phdr
->p_type
!= PT_LOAD
)
1062 if ((phdr
->p_flags
& QCOM_MDT_TYPE_MASK
) == QCOM_MDT_TYPE_HASH
)
1071 static int q6v5_mba_load(struct q6v5
*qproc
)
1075 bool mba_load_err
= false;
1077 ret
= qcom_q6v5_prepare(&qproc
->q6v5
);
1081 ret
= q6v5_pds_enable(qproc
, qproc
->proxy_pds
, qproc
->proxy_pd_count
);
1083 dev_err(qproc
->dev
, "failed to enable proxy power domains\n");
1087 ret
= q6v5_regulator_enable(qproc
, qproc
->fallback_proxy_regs
,
1088 qproc
->fallback_proxy_reg_count
);
1090 dev_err(qproc
->dev
, "failed to enable fallback proxy supplies\n");
1091 goto disable_proxy_pds
;
1094 ret
= q6v5_regulator_enable(qproc
, qproc
->proxy_regs
,
1095 qproc
->proxy_reg_count
);
1097 dev_err(qproc
->dev
, "failed to enable proxy supplies\n");
1098 goto disable_fallback_proxy_reg
;
1101 ret
= q6v5_clk_enable(qproc
->dev
, qproc
->proxy_clks
,
1102 qproc
->proxy_clk_count
);
1104 dev_err(qproc
->dev
, "failed to enable proxy clocks\n");
1105 goto disable_proxy_reg
;
1108 ret
= q6v5_regulator_enable(qproc
, qproc
->active_regs
,
1109 qproc
->active_reg_count
);
1111 dev_err(qproc
->dev
, "failed to enable supplies\n");
1112 goto disable_proxy_clk
;
1115 ret
= q6v5_clk_enable(qproc
->dev
, qproc
->reset_clks
,
1116 qproc
->reset_clk_count
);
1118 dev_err(qproc
->dev
, "failed to enable reset clocks\n");
1122 ret
= q6v5_reset_deassert(qproc
);
1124 dev_err(qproc
->dev
, "failed to deassert mss restart\n");
1125 goto disable_reset_clks
;
1128 ret
= q6v5_clk_enable(qproc
->dev
, qproc
->active_clks
,
1129 qproc
->active_clk_count
);
1131 dev_err(qproc
->dev
, "failed to enable clocks\n");
1135 ret
= q6v5proc_enable_qchannel(qproc
, qproc
->halt_map
, qproc
->qaccept_axi
);
1137 dev_err(qproc
->dev
, "failed to enable axi bridge\n");
1138 goto disable_active_clks
;
1142 * Some versions of the MBA firmware will upon boot wipe the MPSS region as well, so provide
1143 * the Q6 access to this region.
1145 ret
= q6v5_xfer_mem_ownership(qproc
, &qproc
->mpss_perm
, false, true,
1146 qproc
->mpss_phys
, qproc
->mpss_size
);
1148 dev_err(qproc
->dev
, "assigning Q6 access to mpss memory failed: %d\n", ret
);
1149 goto disable_active_clks
;
1152 /* Assign MBA image access in DDR to q6 */
1153 ret
= q6v5_xfer_mem_ownership(qproc
, &qproc
->mba_perm
, false, true,
1154 qproc
->mba_phys
, qproc
->mba_size
);
1157 "assigning Q6 access to mba memory failed: %d\n", ret
);
1158 goto disable_active_clks
;
1161 if (qproc
->has_mba_logs
)
1162 qcom_pil_info_store("mba", qproc
->mba_phys
, MBA_LOG_SIZE
);
1164 writel(qproc
->mba_phys
, qproc
->rmb_base
+ RMB_MBA_IMAGE_REG
);
1165 if (qproc
->dp_size
) {
1166 writel(qproc
->mba_phys
+ SZ_1M
, qproc
->rmb_base
+ RMB_PMI_CODE_START_REG
);
1167 writel(qproc
->dp_size
, qproc
->rmb_base
+ RMB_PMI_CODE_LENGTH_REG
);
1170 ret
= q6v5proc_reset(qproc
);
1174 ret
= q6v5_rmb_mba_wait(qproc
, 0, 5000);
1175 if (ret
== -ETIMEDOUT
) {
1176 dev_err(qproc
->dev
, "MBA boot timed out\n");
1177 goto halt_axi_ports
;
1178 } else if (ret
!= RMB_MBA_XPU_UNLOCKED
&&
1179 ret
!= RMB_MBA_XPU_UNLOCKED_SCRIBBLED
) {
1180 dev_err(qproc
->dev
, "MBA returned unexpected status %d\n", ret
);
1182 goto halt_axi_ports
;
1185 qproc
->dump_mba_loaded
= true;
1189 q6v5proc_halt_axi_port(qproc
, qproc
->halt_map
, qproc
->halt_q6
);
1191 q6v5proc_halt_axi_port(qproc
, qproc
->halt_map
, qproc
->halt_vq6
);
1192 q6v5proc_halt_axi_port(qproc
, qproc
->halt_map
, qproc
->halt_modem
);
1193 q6v5proc_halt_axi_port(qproc
, qproc
->halt_map
, qproc
->halt_nc
);
1194 q6v5proc_disable_qchannel(qproc
, qproc
->halt_map
, qproc
->qaccept_mdm
);
1195 q6v5proc_disable_qchannel(qproc
, qproc
->halt_map
, qproc
->qaccept_cx
);
1196 q6v5proc_disable_qchannel(qproc
, qproc
->halt_map
, qproc
->qaccept_axi
);
1197 mba_load_err
= true;
1199 xfermemop_ret
= q6v5_xfer_mem_ownership(qproc
, &qproc
->mba_perm
, true,
1200 false, qproc
->mba_phys
,
1202 if (xfermemop_ret
) {
1204 "Failed to reclaim mba buffer, system may become unstable\n");
1205 } else if (mba_load_err
) {
1206 q6v5_dump_mba_logs(qproc
);
1209 disable_active_clks
:
1210 q6v5_clk_disable(qproc
->dev
, qproc
->active_clks
,
1211 qproc
->active_clk_count
);
1213 q6v5_reset_assert(qproc
);
1215 q6v5_clk_disable(qproc
->dev
, qproc
->reset_clks
,
1216 qproc
->reset_clk_count
);
1218 q6v5_regulator_disable(qproc
, qproc
->active_regs
,
1219 qproc
->active_reg_count
);
1221 q6v5_clk_disable(qproc
->dev
, qproc
->proxy_clks
,
1222 qproc
->proxy_clk_count
);
1224 q6v5_regulator_disable(qproc
, qproc
->proxy_regs
,
1225 qproc
->proxy_reg_count
);
1226 disable_fallback_proxy_reg
:
1227 q6v5_regulator_disable(qproc
, qproc
->fallback_proxy_regs
,
1228 qproc
->fallback_proxy_reg_count
);
1230 q6v5_pds_disable(qproc
, qproc
->proxy_pds
, qproc
->proxy_pd_count
);
1232 qcom_q6v5_unprepare(&qproc
->q6v5
);
1237 static void q6v5_mba_reclaim(struct q6v5
*qproc
)
1242 qproc
->dump_mba_loaded
= false;
1245 q6v5proc_halt_axi_port(qproc
, qproc
->halt_map
, qproc
->halt_q6
);
1247 q6v5proc_halt_axi_port(qproc
, qproc
->halt_map
, qproc
->halt_vq6
);
1248 q6v5proc_halt_axi_port(qproc
, qproc
->halt_map
, qproc
->halt_modem
);
1249 q6v5proc_halt_axi_port(qproc
, qproc
->halt_map
, qproc
->halt_nc
);
1250 if (qproc
->version
== MSS_MSM8996
) {
1252 * To avoid high MX current during LPASS/MSS restart.
1254 val
= readl(qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
1255 val
|= Q6SS_CLAMP_IO
| QDSP6v56_CLAMP_WL
|
1256 QDSP6v56_CLAMP_QMC_MEM
;
1257 writel(val
, qproc
->reg_base
+ QDSP6SS_PWR_CTL_REG
);
1260 if (qproc
->has_ext_cntl_regs
) {
1261 regmap_write(qproc
->conn_map
, qproc
->rscc_disable
, 1);
1263 ret
= regmap_read_poll_timeout(qproc
->halt_map
, qproc
->axim1_clk_off
, val
,
1264 !val
, 1, Q6SS_CBCR_TIMEOUT_US
);
1266 dev_err(qproc
->dev
, "failed to enable axim1 clock\n");
1268 ret
= regmap_read_poll_timeout(qproc
->halt_map
, qproc
->crypto_clk_off
, val
,
1269 !val
, 1, Q6SS_CBCR_TIMEOUT_US
);
1271 dev_err(qproc
->dev
, "failed to enable crypto clock\n");
1274 q6v5proc_disable_qchannel(qproc
, qproc
->halt_map
, qproc
->qaccept_mdm
);
1275 q6v5proc_disable_qchannel(qproc
, qproc
->halt_map
, qproc
->qaccept_cx
);
1276 q6v5proc_disable_qchannel(qproc
, qproc
->halt_map
, qproc
->qaccept_axi
);
1278 q6v5_reset_assert(qproc
);
1280 q6v5_clk_disable(qproc
->dev
, qproc
->reset_clks
,
1281 qproc
->reset_clk_count
);
1282 q6v5_clk_disable(qproc
->dev
, qproc
->active_clks
,
1283 qproc
->active_clk_count
);
1284 q6v5_regulator_disable(qproc
, qproc
->active_regs
,
1285 qproc
->active_reg_count
);
1287 /* In case of failure or coredump scenario where reclaiming MBA memory
1288 * could not happen reclaim it here.
1290 ret
= q6v5_xfer_mem_ownership(qproc
, &qproc
->mba_perm
, true, false,
1295 ret
= qcom_q6v5_unprepare(&qproc
->q6v5
);
1297 q6v5_pds_disable(qproc
, qproc
->proxy_pds
,
1298 qproc
->proxy_pd_count
);
1299 q6v5_clk_disable(qproc
->dev
, qproc
->proxy_clks
,
1300 qproc
->proxy_clk_count
);
1301 q6v5_regulator_disable(qproc
, qproc
->fallback_proxy_regs
,
1302 qproc
->fallback_proxy_reg_count
);
1303 q6v5_regulator_disable(qproc
, qproc
->proxy_regs
,
1304 qproc
->proxy_reg_count
);
1308 static int q6v5_reload_mba(struct rproc
*rproc
)
1310 struct q6v5
*qproc
= rproc
->priv
;
1311 const struct firmware
*fw
;
1314 ret
= request_firmware(&fw
, rproc
->firmware
, qproc
->dev
);
1318 q6v5_load(rproc
, fw
);
1319 ret
= q6v5_mba_load(qproc
);
1320 release_firmware(fw
);
1325 static int q6v5_mpss_load(struct q6v5
*qproc
)
1327 const struct elf32_phdr
*phdrs
;
1328 const struct elf32_phdr
*phdr
;
1329 const struct firmware
*seg_fw
;
1330 const struct firmware
*fw
;
1331 struct elf32_hdr
*ehdr
;
1332 phys_addr_t mpss_reloc
;
1333 phys_addr_t boot_addr
;
1334 phys_addr_t min_addr
= PHYS_ADDR_MAX
;
1335 phys_addr_t max_addr
= 0;
1337 bool relocate
= false;
1346 fw_name_len
= strlen(qproc
->hexagon_mdt_image
);
1347 if (fw_name_len
<= 4)
1350 fw_name
= kstrdup(qproc
->hexagon_mdt_image
, GFP_KERNEL
);
1354 ret
= request_firmware(&fw
, fw_name
, qproc
->dev
);
1356 dev_err(qproc
->dev
, "unable to load %s\n", fw_name
);
1360 /* Initialize the RMB validator */
1361 writel(0, qproc
->rmb_base
+ RMB_PMI_CODE_LENGTH_REG
);
1363 ret
= q6v5_mpss_init_image(qproc
, fw
, qproc
->hexagon_mdt_image
);
1365 goto release_firmware
;
1367 ehdr
= (struct elf32_hdr
*)fw
->data
;
1368 phdrs
= (struct elf32_phdr
*)(ehdr
+ 1);
1370 for (i
= 0; i
< ehdr
->e_phnum
; i
++) {
1373 if (!q6v5_phdr_valid(phdr
))
1376 if (phdr
->p_flags
& QCOM_MDT_RELOCATABLE
)
1379 if (phdr
->p_paddr
< min_addr
)
1380 min_addr
= phdr
->p_paddr
;
1382 if (phdr
->p_paddr
+ phdr
->p_memsz
> max_addr
)
1383 max_addr
= ALIGN(phdr
->p_paddr
+ phdr
->p_memsz
, SZ_4K
);
1386 if (qproc
->version
== MSS_MSM8953
) {
1387 ret
= qcom_scm_pas_mem_setup(MPSS_PAS_ID
, qproc
->mpss_phys
, qproc
->mpss_size
);
1390 "setting up mpss memory failed: %d\n", ret
);
1391 goto release_firmware
;
1396 * In case of a modem subsystem restart on secure devices, the modem
1397 * memory can be reclaimed only after MBA is loaded.
1399 q6v5_xfer_mem_ownership(qproc
, &qproc
->mpss_perm
, true, false,
1400 qproc
->mpss_phys
, qproc
->mpss_size
);
1402 /* Share ownership between Linux and MSS, during segment loading */
1403 ret
= q6v5_xfer_mem_ownership(qproc
, &qproc
->mpss_perm
, true, true,
1404 qproc
->mpss_phys
, qproc
->mpss_size
);
1407 "assigning Q6 access to mpss memory failed: %d\n", ret
);
1409 goto release_firmware
;
1412 mpss_reloc
= relocate
? min_addr
: qproc
->mpss_phys
;
1413 qproc
->mpss_reloc
= mpss_reloc
;
1414 /* Load firmware segments */
1415 for (i
= 0; i
< ehdr
->e_phnum
; i
++) {
1418 if (!q6v5_phdr_valid(phdr
))
1421 offset
= phdr
->p_paddr
- mpss_reloc
;
1422 if (offset
< 0 || offset
+ phdr
->p_memsz
> qproc
->mpss_size
) {
1423 dev_err(qproc
->dev
, "segment outside memory range\n");
1425 goto release_firmware
;
1428 if (phdr
->p_filesz
> phdr
->p_memsz
) {
1430 "refusing to load segment %d with p_filesz > p_memsz\n",
1433 goto release_firmware
;
1436 ptr
= memremap(qproc
->mpss_phys
+ offset
, phdr
->p_memsz
, MEMREMAP_WC
);
1439 "unable to map memory region: %pa+%zx-%x\n",
1440 &qproc
->mpss_phys
, offset
, phdr
->p_memsz
);
1441 goto release_firmware
;
1444 if (phdr
->p_filesz
&& phdr
->p_offset
< fw
->size
) {
1445 /* Firmware is large enough to be non-split */
1446 if (phdr
->p_offset
+ phdr
->p_filesz
> fw
->size
) {
1448 "failed to load segment %d from truncated file %s\n",
1452 goto release_firmware
;
1455 memcpy(ptr
, fw
->data
+ phdr
->p_offset
, phdr
->p_filesz
);
1456 } else if (phdr
->p_filesz
) {
1457 /* Replace "xxx.xxx" with "xxx.bxx" */
1458 sprintf(fw_name
+ fw_name_len
- 3, "b%02d", i
);
1459 ret
= request_firmware_into_buf(&seg_fw
, fw_name
, qproc
->dev
,
1460 ptr
, phdr
->p_filesz
);
1462 dev_err(qproc
->dev
, "failed to load %s\n", fw_name
);
1464 goto release_firmware
;
1467 if (seg_fw
->size
!= phdr
->p_filesz
) {
1469 "failed to load segment %d from truncated file %s\n",
1472 release_firmware(seg_fw
);
1474 goto release_firmware
;
1477 release_firmware(seg_fw
);
1480 if (phdr
->p_memsz
> phdr
->p_filesz
) {
1481 memset(ptr
+ phdr
->p_filesz
, 0,
1482 phdr
->p_memsz
- phdr
->p_filesz
);
1485 size
+= phdr
->p_memsz
;
1487 code_length
= readl(qproc
->rmb_base
+ RMB_PMI_CODE_LENGTH_REG
);
1489 boot_addr
= relocate
? qproc
->mpss_phys
: min_addr
;
1490 writel(boot_addr
, qproc
->rmb_base
+ RMB_PMI_CODE_START_REG
);
1491 writel(RMB_CMD_LOAD_READY
, qproc
->rmb_base
+ RMB_MBA_COMMAND_REG
);
1493 writel(size
, qproc
->rmb_base
+ RMB_PMI_CODE_LENGTH_REG
);
1495 ret
= readl(qproc
->rmb_base
+ RMB_MBA_STATUS_REG
);
1497 dev_err(qproc
->dev
, "MPSS authentication failed: %d\n",
1499 goto release_firmware
;
1503 /* Transfer ownership of modem ddr region to q6 */
1504 ret
= q6v5_xfer_mem_ownership(qproc
, &qproc
->mpss_perm
, false, true,
1505 qproc
->mpss_phys
, qproc
->mpss_size
);
1508 "assigning Q6 access to mpss memory failed: %d\n", ret
);
1510 goto release_firmware
;
1513 ret
= q6v5_rmb_mba_wait(qproc
, RMB_MBA_AUTH_COMPLETE
, 10000);
1514 if (ret
== -ETIMEDOUT
)
1515 dev_err(qproc
->dev
, "MPSS authentication timed out\n");
1517 dev_err(qproc
->dev
, "MPSS authentication failed: %d\n", ret
);
1519 qcom_pil_info_store("modem", qproc
->mpss_phys
, qproc
->mpss_size
);
1522 release_firmware(fw
);
1526 return ret
< 0 ? ret
: 0;
1529 static void qcom_q6v5_dump_segment(struct rproc
*rproc
,
1530 struct rproc_dump_segment
*segment
,
1531 void *dest
, size_t cp_offset
, size_t size
)
1534 struct q6v5
*qproc
= rproc
->priv
;
1535 int offset
= segment
->da
- qproc
->mpss_reloc
;
1538 /* Unlock mba before copying segments */
1539 if (!qproc
->dump_mba_loaded
) {
1540 ret
= q6v5_reload_mba(rproc
);
1542 /* Reset ownership back to Linux to copy segments */
1543 ret
= q6v5_xfer_mem_ownership(qproc
, &qproc
->mpss_perm
,
1551 ptr
= memremap(qproc
->mpss_phys
+ offset
+ cp_offset
, size
, MEMREMAP_WC
);
1554 memcpy(dest
, ptr
, size
);
1557 memset(dest
, 0xff, size
);
1560 qproc
->current_dump_size
+= size
;
1562 /* Reclaim mba after copying segments */
1563 if (qproc
->current_dump_size
== qproc
->total_dump_size
) {
1564 if (qproc
->dump_mba_loaded
) {
1565 /* Try to reset ownership back to Q6 */
1566 q6v5_xfer_mem_ownership(qproc
, &qproc
->mpss_perm
,
1570 q6v5_mba_reclaim(qproc
);
1575 static int q6v5_start(struct rproc
*rproc
)
1577 struct q6v5
*qproc
= rproc
->priv
;
1581 ret
= q6v5_mba_load(qproc
);
1585 dev_info(qproc
->dev
, "MBA booted with%s debug policy, loading mpss\n",
1586 qproc
->dp_size
? "" : "out");
1588 ret
= q6v5_mpss_load(qproc
);
1592 ret
= qcom_q6v5_wait_for_start(&qproc
->q6v5
, msecs_to_jiffies(5000));
1593 if (ret
== -ETIMEDOUT
) {
1594 dev_err(qproc
->dev
, "start timed out\n");
1598 xfermemop_ret
= q6v5_xfer_mem_ownership(qproc
, &qproc
->mba_perm
, true,
1599 false, qproc
->mba_phys
,
1603 "Failed to reclaim mba buffer system may become unstable\n");
1605 /* Reset Dump Segment Mask */
1606 qproc
->current_dump_size
= 0;
1611 q6v5_mba_reclaim(qproc
);
1612 q6v5_dump_mba_logs(qproc
);
1617 static int q6v5_stop(struct rproc
*rproc
)
1619 struct q6v5
*qproc
= rproc
->priv
;
1622 ret
= qcom_q6v5_request_stop(&qproc
->q6v5
, qproc
->sysmon
);
1623 if (ret
== -ETIMEDOUT
)
1624 dev_err(qproc
->dev
, "timed out on wait\n");
1626 q6v5_mba_reclaim(qproc
);
1631 static int qcom_q6v5_register_dump_segments(struct rproc
*rproc
,
1632 const struct firmware
*mba_fw
)
1634 const struct firmware
*fw
;
1635 const struct elf32_phdr
*phdrs
;
1636 const struct elf32_phdr
*phdr
;
1637 const struct elf32_hdr
*ehdr
;
1638 struct q6v5
*qproc
= rproc
->priv
;
1642 ret
= request_firmware(&fw
, qproc
->hexagon_mdt_image
, qproc
->dev
);
1644 dev_err(qproc
->dev
, "unable to load %s\n",
1645 qproc
->hexagon_mdt_image
);
1649 rproc_coredump_set_elf_info(rproc
, ELFCLASS32
, EM_NONE
);
1651 ehdr
= (struct elf32_hdr
*)fw
->data
;
1652 phdrs
= (struct elf32_phdr
*)(ehdr
+ 1);
1653 qproc
->total_dump_size
= 0;
1655 for (i
= 0; i
< ehdr
->e_phnum
; i
++) {
1658 if (!q6v5_phdr_valid(phdr
))
1661 ret
= rproc_coredump_add_custom_segment(rproc
, phdr
->p_paddr
,
1663 qcom_q6v5_dump_segment
,
1668 qproc
->total_dump_size
+= phdr
->p_memsz
;
1671 release_firmware(fw
);
1675 static unsigned long q6v5_panic(struct rproc
*rproc
)
1677 struct q6v5
*qproc
= rproc
->priv
;
1679 return qcom_q6v5_panic(&qproc
->q6v5
);
1682 static const struct rproc_ops q6v5_ops
= {
1683 .start
= q6v5_start
,
1685 .parse_fw
= qcom_q6v5_register_dump_segments
,
1687 .panic
= q6v5_panic
,
1690 static void qcom_msa_handover(struct qcom_q6v5
*q6v5
)
1692 struct q6v5
*qproc
= container_of(q6v5
, struct q6v5
, q6v5
);
1694 q6v5_clk_disable(qproc
->dev
, qproc
->proxy_clks
,
1695 qproc
->proxy_clk_count
);
1696 q6v5_regulator_disable(qproc
, qproc
->proxy_regs
,
1697 qproc
->proxy_reg_count
);
1698 q6v5_regulator_disable(qproc
, qproc
->fallback_proxy_regs
,
1699 qproc
->fallback_proxy_reg_count
);
1700 q6v5_pds_disable(qproc
, qproc
->proxy_pds
, qproc
->proxy_pd_count
);
1703 static int q6v5_init_mem(struct q6v5
*qproc
, struct platform_device
*pdev
)
1705 struct of_phandle_args args
;
1706 int halt_cell_cnt
= 3;
1709 qproc
->reg_base
= devm_platform_ioremap_resource_byname(pdev
, "qdsp6");
1710 if (IS_ERR(qproc
->reg_base
))
1711 return PTR_ERR(qproc
->reg_base
);
1713 qproc
->rmb_base
= devm_platform_ioremap_resource_byname(pdev
, "rmb");
1714 if (IS_ERR(qproc
->rmb_base
))
1715 return PTR_ERR(qproc
->rmb_base
);
1720 ret
= of_parse_phandle_with_fixed_args(pdev
->dev
.of_node
,
1721 "qcom,halt-regs", halt_cell_cnt
, 0, &args
);
1723 dev_err(&pdev
->dev
, "failed to parse qcom,halt-regs\n");
1727 qproc
->halt_map
= syscon_node_to_regmap(args
.np
);
1728 of_node_put(args
.np
);
1729 if (IS_ERR(qproc
->halt_map
))
1730 return PTR_ERR(qproc
->halt_map
);
1732 qproc
->halt_q6
= args
.args
[0];
1733 qproc
->halt_modem
= args
.args
[1];
1734 qproc
->halt_nc
= args
.args
[2];
1737 qproc
->halt_vq6
= args
.args
[3];
1739 if (qproc
->has_qaccept_regs
) {
1740 ret
= of_parse_phandle_with_fixed_args(pdev
->dev
.of_node
,
1741 "qcom,qaccept-regs",
1744 dev_err(&pdev
->dev
, "failed to parse qaccept-regs\n");
1748 qproc
->qaccept_mdm
= args
.args
[0];
1749 qproc
->qaccept_cx
= args
.args
[1];
1750 qproc
->qaccept_axi
= args
.args
[2];
1753 if (qproc
->has_ext_cntl_regs
) {
1754 ret
= of_parse_phandle_with_fixed_args(pdev
->dev
.of_node
,
1758 dev_err(&pdev
->dev
, "failed to parse ext-regs index 0\n");
1762 qproc
->conn_map
= syscon_node_to_regmap(args
.np
);
1763 of_node_put(args
.np
);
1764 if (IS_ERR(qproc
->conn_map
))
1765 return PTR_ERR(qproc
->conn_map
);
1767 qproc
->force_clk_on
= args
.args
[0];
1768 qproc
->rscc_disable
= args
.args
[1];
1770 ret
= of_parse_phandle_with_fixed_args(pdev
->dev
.of_node
,
1774 dev_err(&pdev
->dev
, "failed to parse ext-regs index 1\n");
1778 qproc
->axim1_clk_off
= args
.args
[0];
1779 qproc
->crypto_clk_off
= args
.args
[1];
1782 if (qproc
->has_spare_reg
) {
1783 ret
= of_parse_phandle_with_fixed_args(pdev
->dev
.of_node
,
1787 dev_err(&pdev
->dev
, "failed to parse spare-regs\n");
1791 qproc
->conn_map
= syscon_node_to_regmap(args
.np
);
1792 of_node_put(args
.np
);
1793 if (IS_ERR(qproc
->conn_map
))
1794 return PTR_ERR(qproc
->conn_map
);
1796 qproc
->conn_box
= args
.args
[0];
1802 static int q6v5_init_clocks(struct device
*dev
, struct clk
**clks
,
1810 for (i
= 0; clk_names
[i
]; i
++) {
1811 clks
[i
] = devm_clk_get(dev
, clk_names
[i
]);
1812 if (IS_ERR(clks
[i
]))
1813 return dev_err_probe(dev
, PTR_ERR(clks
[i
]),
1814 "Failed to get %s clock\n",
1821 static int q6v5_pds_attach(struct device
*dev
, struct device
**devs
,
1831 while (pd_names
[num_pds
])
1834 for (i
= 0; i
< num_pds
; i
++) {
1835 devs
[i
] = dev_pm_domain_attach_by_name(dev
, pd_names
[i
]);
1836 if (IS_ERR_OR_NULL(devs
[i
])) {
1837 ret
= PTR_ERR(devs
[i
]) ? : -ENODATA
;
1845 for (i
--; i
>= 0; i
--)
1846 dev_pm_domain_detach(devs
[i
], false);
1851 static void q6v5_pds_detach(struct q6v5
*qproc
, struct device
**pds
,
1856 for (i
= 0; i
< pd_count
; i
++)
1857 dev_pm_domain_detach(pds
[i
], false);
1860 static int q6v5_init_reset(struct q6v5
*qproc
)
1862 qproc
->mss_restart
= devm_reset_control_get_exclusive(qproc
->dev
,
1864 if (IS_ERR(qproc
->mss_restart
)) {
1865 dev_err(qproc
->dev
, "failed to acquire mss restart\n");
1866 return PTR_ERR(qproc
->mss_restart
);
1869 if (qproc
->has_alt_reset
|| qproc
->has_spare_reg
|| qproc
->has_ext_cntl_regs
) {
1870 qproc
->pdc_reset
= devm_reset_control_get_exclusive(qproc
->dev
,
1872 if (IS_ERR(qproc
->pdc_reset
)) {
1873 dev_err(qproc
->dev
, "failed to acquire pdc reset\n");
1874 return PTR_ERR(qproc
->pdc_reset
);
1881 static int q6v5_alloc_memory_region(struct q6v5
*qproc
)
1883 struct device_node
*child
;
1884 struct reserved_mem
*rmem
;
1885 struct device_node
*node
;
1888 * In the absence of mba/mpss sub-child, extract the mba and mpss
1889 * reserved memory regions from device's memory-region property.
1891 child
= of_get_child_by_name(qproc
->dev
->of_node
, "mba");
1893 node
= of_parse_phandle(qproc
->dev
->of_node
,
1894 "memory-region", 0);
1896 node
= of_parse_phandle(child
, "memory-region", 0);
1901 dev_err(qproc
->dev
, "no mba memory-region specified\n");
1905 rmem
= of_reserved_mem_lookup(node
);
1908 dev_err(qproc
->dev
, "unable to resolve mba region\n");
1912 qproc
->mba_phys
= rmem
->base
;
1913 qproc
->mba_size
= rmem
->size
;
1916 node
= of_parse_phandle(qproc
->dev
->of_node
,
1917 "memory-region", 1);
1919 child
= of_get_child_by_name(qproc
->dev
->of_node
, "mpss");
1920 node
= of_parse_phandle(child
, "memory-region", 0);
1925 dev_err(qproc
->dev
, "no mpss memory-region specified\n");
1929 rmem
= of_reserved_mem_lookup(node
);
1932 dev_err(qproc
->dev
, "unable to resolve mpss region\n");
1936 qproc
->mpss_phys
= qproc
->mpss_reloc
= rmem
->base
;
1937 qproc
->mpss_size
= rmem
->size
;
1940 node
= of_parse_phandle(qproc
->dev
->of_node
, "memory-region", 2);
1942 child
= of_get_child_by_name(qproc
->dev
->of_node
, "metadata");
1943 node
= of_parse_phandle(child
, "memory-region", 0);
1950 rmem
= of_reserved_mem_lookup(node
);
1952 dev_err(qproc
->dev
, "unable to resolve metadata region\n");
1956 qproc
->mdata_phys
= rmem
->base
;
1957 qproc
->mdata_size
= rmem
->size
;
1962 static int q6v5_probe(struct platform_device
*pdev
)
1964 const struct rproc_hexagon_res
*desc
;
1965 struct device_node
*node
;
1967 struct rproc
*rproc
;
1968 const char *mba_image
;
1971 desc
= of_device_get_match_data(&pdev
->dev
);
1975 if (desc
->need_mem_protection
&& !qcom_scm_is_available())
1976 return -EPROBE_DEFER
;
1978 mba_image
= desc
->hexagon_mba_image
;
1979 ret
= of_property_read_string_index(pdev
->dev
.of_node
, "firmware-name",
1981 if (ret
< 0 && ret
!= -EINVAL
) {
1982 dev_err(&pdev
->dev
, "unable to read mba firmware-name\n");
1986 rproc
= devm_rproc_alloc(&pdev
->dev
, pdev
->name
, &q6v5_ops
,
1987 mba_image
, sizeof(*qproc
));
1989 dev_err(&pdev
->dev
, "failed to allocate rproc\n");
1993 rproc
->auto_boot
= false;
1994 rproc_coredump_set_elf_info(rproc
, ELFCLASS32
, EM_NONE
);
1996 qproc
= rproc
->priv
;
1997 qproc
->dev
= &pdev
->dev
;
1998 qproc
->rproc
= rproc
;
1999 qproc
->hexagon_mdt_image
= "modem.mdt";
2000 ret
= of_property_read_string_index(pdev
->dev
.of_node
, "firmware-name",
2001 1, &qproc
->hexagon_mdt_image
);
2002 if (ret
< 0 && ret
!= -EINVAL
) {
2003 dev_err(&pdev
->dev
, "unable to read mpss firmware-name\n");
2007 platform_set_drvdata(pdev
, qproc
);
2009 qproc
->has_qaccept_regs
= desc
->has_qaccept_regs
;
2010 qproc
->has_ext_cntl_regs
= desc
->has_ext_cntl_regs
;
2011 qproc
->has_vq6
= desc
->has_vq6
;
2012 qproc
->has_spare_reg
= desc
->has_spare_reg
;
2013 ret
= q6v5_init_mem(qproc
, pdev
);
2017 ret
= q6v5_alloc_memory_region(qproc
);
2021 ret
= q6v5_init_clocks(&pdev
->dev
, qproc
->proxy_clks
,
2022 desc
->proxy_clk_names
);
2025 qproc
->proxy_clk_count
= ret
;
2027 ret
= q6v5_init_clocks(&pdev
->dev
, qproc
->reset_clks
,
2028 desc
->reset_clk_names
);
2031 qproc
->reset_clk_count
= ret
;
2033 ret
= q6v5_init_clocks(&pdev
->dev
, qproc
->active_clks
,
2034 desc
->active_clk_names
);
2037 qproc
->active_clk_count
= ret
;
2039 ret
= q6v5_regulator_init(&pdev
->dev
, qproc
->proxy_regs
,
2040 desc
->proxy_supply
);
2043 qproc
->proxy_reg_count
= ret
;
2045 ret
= q6v5_regulator_init(&pdev
->dev
, qproc
->active_regs
,
2046 desc
->active_supply
);
2049 qproc
->active_reg_count
= ret
;
2051 ret
= q6v5_pds_attach(&pdev
->dev
, qproc
->proxy_pds
,
2052 desc
->proxy_pd_names
);
2053 /* Fallback to regulators for old device trees */
2054 if (ret
== -ENODATA
&& desc
->fallback_proxy_supply
) {
2055 ret
= q6v5_regulator_init(&pdev
->dev
,
2056 qproc
->fallback_proxy_regs
,
2057 desc
->fallback_proxy_supply
);
2060 qproc
->fallback_proxy_reg_count
= ret
;
2061 } else if (ret
< 0) {
2062 dev_err(&pdev
->dev
, "Failed to init power domains\n");
2065 qproc
->proxy_pd_count
= ret
;
2068 qproc
->has_alt_reset
= desc
->has_alt_reset
;
2069 ret
= q6v5_init_reset(qproc
);
2071 goto detach_proxy_pds
;
2073 qproc
->version
= desc
->version
;
2074 qproc
->need_mem_protection
= desc
->need_mem_protection
;
2075 qproc
->has_mba_logs
= desc
->has_mba_logs
;
2077 ret
= qcom_q6v5_init(&qproc
->q6v5
, pdev
, rproc
, MPSS_CRASH_REASON_SMEM
, "modem",
2080 goto detach_proxy_pds
;
2082 qproc
->mpss_perm
= BIT(QCOM_SCM_VMID_HLOS
);
2083 qproc
->mba_perm
= BIT(QCOM_SCM_VMID_HLOS
);
2084 qcom_add_glink_subdev(rproc
, &qproc
->glink_subdev
, "mpss");
2085 qcom_add_smd_subdev(rproc
, &qproc
->smd_subdev
);
2086 qcom_add_pdm_subdev(rproc
, &qproc
->pdm_subdev
);
2087 qcom_add_ssr_subdev(rproc
, &qproc
->ssr_subdev
, "mpss");
2088 qproc
->sysmon
= qcom_add_sysmon_subdev(rproc
, "modem", 0x12);
2089 if (IS_ERR(qproc
->sysmon
)) {
2090 ret
= PTR_ERR(qproc
->sysmon
);
2091 goto remove_subdevs
;
2094 ret
= rproc_add(rproc
);
2096 goto remove_sysmon_subdev
;
2098 node
= of_get_compatible_child(pdev
->dev
.of_node
, "qcom,bam-dmux");
2099 qproc
->bam_dmux
= of_platform_device_create(node
, NULL
, &pdev
->dev
);
2104 remove_sysmon_subdev
:
2105 qcom_remove_sysmon_subdev(qproc
->sysmon
);
2107 qcom_remove_ssr_subdev(rproc
, &qproc
->ssr_subdev
);
2108 qcom_remove_smd_subdev(rproc
, &qproc
->smd_subdev
);
2109 qcom_remove_glink_subdev(rproc
, &qproc
->glink_subdev
);
2111 q6v5_pds_detach(qproc
, qproc
->proxy_pds
, qproc
->proxy_pd_count
);
2116 static void q6v5_remove(struct platform_device
*pdev
)
2118 struct q6v5
*qproc
= platform_get_drvdata(pdev
);
2119 struct rproc
*rproc
= qproc
->rproc
;
2121 if (qproc
->bam_dmux
)
2122 of_platform_device_destroy(&qproc
->bam_dmux
->dev
, NULL
);
2125 qcom_q6v5_deinit(&qproc
->q6v5
);
2126 qcom_remove_sysmon_subdev(qproc
->sysmon
);
2127 qcom_remove_ssr_subdev(rproc
, &qproc
->ssr_subdev
);
2128 qcom_remove_pdm_subdev(rproc
, &qproc
->pdm_subdev
);
2129 qcom_remove_smd_subdev(rproc
, &qproc
->smd_subdev
);
2130 qcom_remove_glink_subdev(rproc
, &qproc
->glink_subdev
);
2132 q6v5_pds_detach(qproc
, qproc
->proxy_pds
, qproc
->proxy_pd_count
);
2135 static const struct rproc_hexagon_res sc7180_mss
= {
2136 .hexagon_mba_image
= "mba.mbn",
2137 .proxy_clk_names
= (char*[]){
2141 .reset_clk_names
= (char*[]){
2147 .active_clk_names
= (char*[]){
2152 .proxy_pd_names
= (char*[]){
2158 .need_mem_protection
= true,
2159 .has_alt_reset
= false,
2160 .has_mba_logs
= true,
2161 .has_spare_reg
= true,
2162 .has_qaccept_regs
= false,
2163 .has_ext_cntl_regs
= false,
2165 .version
= MSS_SC7180
,
2168 static const struct rproc_hexagon_res sc7280_mss
= {
2169 .hexagon_mba_image
= "mba.mbn",
2170 .proxy_clk_names
= (char*[]){
2175 .active_clk_names
= (char*[]){
2181 .proxy_pd_names
= (char*[]){
2186 .need_mem_protection
= true,
2187 .has_alt_reset
= false,
2188 .has_mba_logs
= true,
2189 .has_spare_reg
= false,
2190 .has_qaccept_regs
= true,
2191 .has_ext_cntl_regs
= true,
2193 .version
= MSS_SC7280
,
2196 static const struct rproc_hexagon_res sdm660_mss
= {
2197 .hexagon_mba_image
= "mba.mbn",
2198 .proxy_clk_names
= (char*[]){
2204 .active_clk_names
= (char*[]){
2212 .proxy_pd_names
= (char*[]){
2217 .need_mem_protection
= true,
2218 .has_alt_reset
= false,
2219 .has_mba_logs
= false,
2220 .has_spare_reg
= false,
2221 .has_qaccept_regs
= false,
2222 .has_ext_cntl_regs
= false,
2224 .version
= MSS_SDM660
,
2227 static const struct rproc_hexagon_res sdm845_mss
= {
2228 .hexagon_mba_image
= "mba.mbn",
2229 .proxy_clk_names
= (char*[]){
2234 .reset_clk_names
= (char*[]){
2239 .active_clk_names
= (char*[]){
2246 .proxy_pd_names
= (char*[]){
2252 .need_mem_protection
= true,
2253 .has_alt_reset
= true,
2254 .has_mba_logs
= false,
2255 .has_spare_reg
= false,
2256 .has_qaccept_regs
= false,
2257 .has_ext_cntl_regs
= false,
2259 .version
= MSS_SDM845
,
2262 static const struct rproc_hexagon_res msm8998_mss
= {
2263 .hexagon_mba_image
= "mba.mbn",
2264 .proxy_clk_names
= (char*[]){
2270 .active_clk_names
= (char*[]){
2278 .proxy_pd_names
= (char*[]){
2283 .need_mem_protection
= true,
2284 .has_alt_reset
= false,
2285 .has_mba_logs
= false,
2286 .has_spare_reg
= false,
2287 .has_qaccept_regs
= false,
2288 .has_ext_cntl_regs
= false,
2290 .version
= MSS_MSM8998
,
2293 static const struct rproc_hexagon_res msm8996_mss
= {
2294 .hexagon_mba_image
= "mba.mbn",
2295 .proxy_supply
= (struct qcom_mss_reg_res
[]) {
2302 .proxy_clk_names
= (char*[]){
2307 .active_clk_names
= (char*[]){
2316 .proxy_pd_names
= (char*[]){
2321 .need_mem_protection
= true,
2322 .has_alt_reset
= false,
2323 .has_mba_logs
= false,
2324 .has_spare_reg
= false,
2325 .has_qaccept_regs
= false,
2326 .has_ext_cntl_regs
= false,
2328 .version
= MSS_MSM8996
,
2331 static const struct rproc_hexagon_res msm8909_mss
= {
2332 .hexagon_mba_image
= "mba.mbn",
2333 .proxy_supply
= (struct qcom_mss_reg_res
[]) {
2340 .proxy_clk_names
= (char*[]){
2344 .active_clk_names
= (char*[]){
2350 .proxy_pd_names
= (char*[]){
2355 .need_mem_protection
= false,
2356 .has_alt_reset
= false,
2357 .has_mba_logs
= false,
2358 .has_spare_reg
= false,
2359 .has_qaccept_regs
= false,
2360 .has_ext_cntl_regs
= false,
2362 .version
= MSS_MSM8909
,
2365 static const struct rproc_hexagon_res msm8916_mss
= {
2366 .hexagon_mba_image
= "mba.mbn",
2367 .proxy_supply
= (struct qcom_mss_reg_res
[]) {
2374 .fallback_proxy_supply
= (struct qcom_mss_reg_res
[]) {
2385 .proxy_clk_names
= (char*[]){
2389 .active_clk_names
= (char*[]){
2395 .proxy_pd_names
= (char*[]){
2400 .need_mem_protection
= false,
2401 .has_alt_reset
= false,
2402 .has_mba_logs
= false,
2403 .has_spare_reg
= false,
2404 .has_qaccept_regs
= false,
2405 .has_ext_cntl_regs
= false,
2407 .version
= MSS_MSM8916
,
2410 static const struct rproc_hexagon_res msm8953_mss
= {
2411 .hexagon_mba_image
= "mba.mbn",
2412 .proxy_supply
= (struct qcom_mss_reg_res
[]) {
2419 .proxy_clk_names
= (char*[]){
2423 .active_clk_names
= (char*[]){
2429 .proxy_pd_names
= (char*[]) {
2435 .need_mem_protection
= false,
2436 .has_alt_reset
= false,
2437 .has_mba_logs
= false,
2438 .has_spare_reg
= false,
2439 .has_qaccept_regs
= false,
2440 .has_ext_cntl_regs
= false,
2442 .version
= MSS_MSM8953
,
2445 static const struct rproc_hexagon_res msm8974_mss
= {
2446 .hexagon_mba_image
= "mba.b00",
2447 .proxy_supply
= (struct qcom_mss_reg_res
[]) {
2454 .fallback_proxy_supply
= (struct qcom_mss_reg_res
[]) {
2465 .active_supply
= (struct qcom_mss_reg_res
[]) {
2473 .proxy_clk_names
= (char*[]){
2477 .active_clk_names
= (char*[]){
2483 .proxy_pd_names
= (char*[]){
2488 .need_mem_protection
= false,
2489 .has_alt_reset
= false,
2490 .has_mba_logs
= false,
2491 .has_spare_reg
= false,
2492 .has_qaccept_regs
= false,
2493 .has_ext_cntl_regs
= false,
2495 .version
= MSS_MSM8974
,
2498 static const struct of_device_id q6v5_of_match
[] = {
2499 { .compatible
= "qcom,q6v5-pil", .data
= &msm8916_mss
},
2500 { .compatible
= "qcom,msm8909-mss-pil", .data
= &msm8909_mss
},
2501 { .compatible
= "qcom,msm8916-mss-pil", .data
= &msm8916_mss
},
2502 { .compatible
= "qcom,msm8953-mss-pil", .data
= &msm8953_mss
},
2503 { .compatible
= "qcom,msm8974-mss-pil", .data
= &msm8974_mss
},
2504 { .compatible
= "qcom,msm8996-mss-pil", .data
= &msm8996_mss
},
2505 { .compatible
= "qcom,msm8998-mss-pil", .data
= &msm8998_mss
},
2506 { .compatible
= "qcom,sc7180-mss-pil", .data
= &sc7180_mss
},
2507 { .compatible
= "qcom,sc7280-mss-pil", .data
= &sc7280_mss
},
2508 { .compatible
= "qcom,sdm660-mss-pil", .data
= &sdm660_mss
},
2509 { .compatible
= "qcom,sdm845-mss-pil", .data
= &sdm845_mss
},
2512 MODULE_DEVICE_TABLE(of
, q6v5_of_match
);
2514 static struct platform_driver q6v5_driver
= {
2515 .probe
= q6v5_probe
,
2516 .remove
= q6v5_remove
,
2518 .name
= "qcom-q6v5-mss",
2519 .of_match_table
= q6v5_of_match
,
2522 module_platform_driver(q6v5_driver
);
2524 MODULE_DESCRIPTION("Qualcomm Self-authenticating modem remoteproc driver");
2525 MODULE_LICENSE("GPL v2");