blob: 3448f1df2e8774b1cae5ac4ad0c710583d16d288 [file] [log] [blame]
Bjorn Andersson051fb702016-06-20 14:28:41 -07001/*
Bjorn Anderssonef73c222018-09-24 16:45:26 -07002 * Qualcomm self-authenticating modem subsystem remoteproc driver
Bjorn Andersson051fb702016-06-20 14:28:41 -07003 *
4 * Copyright (C) 2016 Linaro Ltd.
5 * Copyright (C) 2014 Sony Mobile Communications AB
6 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
18#include <linux/clk.h>
19#include <linux/delay.h>
20#include <linux/dma-mapping.h>
21#include <linux/interrupt.h>
22#include <linux/kernel.h>
23#include <linux/mfd/syscon.h>
24#include <linux/module.h>
25#include <linux/of_address.h>
Avaneesh Kumar Dwivedi7a8ffe12016-12-30 19:24:00 +053026#include <linux/of_device.h>
Bjorn Andersson051fb702016-06-20 14:28:41 -070027#include <linux/platform_device.h>
28#include <linux/regmap.h>
29#include <linux/regulator/consumer.h>
30#include <linux/remoteproc.h>
31#include <linux/reset.h>
Bjorn Andersson2aad40d2017-01-27 03:12:57 -080032#include <linux/soc/qcom/mdt_loader.h>
Avaneesh Kumar Dwivedi9f058fa2017-10-24 21:22:27 +053033#include <linux/iopoll.h>
Bjorn Andersson051fb702016-06-20 14:28:41 -070034
35#include "remoteproc_internal.h"
Bjorn Anderssonbde440e2017-01-27 02:28:32 -080036#include "qcom_common.h"
Bjorn Andersson7d674732018-06-04 13:30:38 -070037#include "qcom_q6v5.h"
Bjorn Andersson051fb702016-06-20 14:28:41 -070038
39#include <linux/qcom_scm.h>
40
Bjorn Andersson051fb702016-06-20 14:28:41 -070041#define MPSS_CRASH_REASON_SMEM 421
42
43/* RMB Status Register Values */
44#define RMB_PBL_SUCCESS 0x1
45
46#define RMB_MBA_XPU_UNLOCKED 0x1
47#define RMB_MBA_XPU_UNLOCKED_SCRIBBLED 0x2
48#define RMB_MBA_META_DATA_AUTH_SUCCESS 0x3
49#define RMB_MBA_AUTH_COMPLETE 0x4
50
51/* PBL/MBA interface registers */
52#define RMB_MBA_IMAGE_REG 0x00
53#define RMB_PBL_STATUS_REG 0x04
54#define RMB_MBA_COMMAND_REG 0x08
55#define RMB_MBA_STATUS_REG 0x0C
56#define RMB_PMI_META_DATA_REG 0x10
57#define RMB_PMI_CODE_START_REG 0x14
58#define RMB_PMI_CODE_LENGTH_REG 0x18
Sibi Sankar231f67d2018-05-21 22:57:13 +053059#define RMB_MBA_MSS_STATUS 0x40
60#define RMB_MBA_ALT_RESET 0x44
Bjorn Andersson051fb702016-06-20 14:28:41 -070061
62#define RMB_CMD_META_DATA_READY 0x1
63#define RMB_CMD_LOAD_READY 0x2
64
65/* QDSP6SS Register Offsets */
66#define QDSP6SS_RESET_REG 0x014
67#define QDSP6SS_GFMUX_CTL_REG 0x020
68#define QDSP6SS_PWR_CTL_REG 0x030
Avaneesh Kumar Dwivedi9f058fa2017-10-24 21:22:27 +053069#define QDSP6SS_MEM_PWR_CTL 0x0B0
70#define QDSP6SS_STRAP_ACC 0x110
Bjorn Andersson051fb702016-06-20 14:28:41 -070071
72/* AXI Halt Register Offsets */
73#define AXI_HALTREQ_REG 0x0
74#define AXI_HALTACK_REG 0x4
75#define AXI_IDLE_REG 0x8
76
77#define HALT_ACK_TIMEOUT_MS 100
78
79/* QDSP6SS_RESET */
80#define Q6SS_STOP_CORE BIT(0)
81#define Q6SS_CORE_ARES BIT(1)
82#define Q6SS_BUS_ARES_ENABLE BIT(2)
83
84/* QDSP6SS_GFMUX_CTL */
85#define Q6SS_CLK_ENABLE BIT(1)
86
87/* QDSP6SS_PWR_CTL */
88#define Q6SS_L2DATA_SLP_NRET_N_0 BIT(0)
89#define Q6SS_L2DATA_SLP_NRET_N_1 BIT(1)
90#define Q6SS_L2DATA_SLP_NRET_N_2 BIT(2)
91#define Q6SS_L2TAG_SLP_NRET_N BIT(16)
92#define Q6SS_ETB_SLP_NRET_N BIT(17)
93#define Q6SS_L2DATA_STBY_N BIT(18)
94#define Q6SS_SLP_RET_N BIT(19)
95#define Q6SS_CLAMP_IO BIT(20)
96#define QDSS_BHS_ON BIT(21)
97#define QDSS_LDO_BYP BIT(22)
98
Avaneesh Kumar Dwivedi9f058fa2017-10-24 21:22:27 +053099/* QDSP6v56 parameters */
100#define QDSP6v56_LDO_BYP BIT(25)
101#define QDSP6v56_BHS_ON BIT(24)
102#define QDSP6v56_CLAMP_WL BIT(21)
103#define QDSP6v56_CLAMP_QMC_MEM BIT(22)
104#define HALT_CHECK_MAX_LOOPS 200
105#define QDSP6SS_XO_CBCR 0x0038
106#define QDSP6SS_ACC_OVERRIDE_VAL 0x20
107
Sibi Sankar231f67d2018-05-21 22:57:13 +0530108/* QDSP6v65 parameters */
109#define QDSP6SS_SLEEP 0x3C
110#define QDSP6SS_BOOT_CORE_START 0x400
111#define QDSP6SS_BOOT_CMD 0x404
112#define SLEEP_CHECK_MAX_LOOPS 200
113#define BOOT_FSM_TIMEOUT 10000
114
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530115struct reg_info {
116 struct regulator *reg;
117 int uV;
118 int uA;
119};
120
121struct qcom_mss_reg_res {
122 const char *supply;
123 int uV;
124 int uA;
125};
126
Avaneesh Kumar Dwivedi7a8ffe12016-12-30 19:24:00 +0530127struct rproc_hexagon_res {
128 const char *hexagon_mba_image;
Arnd Bergmannec671b52017-02-01 17:56:28 +0100129 struct qcom_mss_reg_res *proxy_supply;
130 struct qcom_mss_reg_res *active_supply;
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +0530131 char **proxy_clk_names;
Sibi Sankar231f67d2018-05-21 22:57:13 +0530132 char **reset_clk_names;
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +0530133 char **active_clk_names;
Avaneesh Kumar Dwivedi9f058fa2017-10-24 21:22:27 +0530134 int version;
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530135 bool need_mem_protection;
Sibi Sankar231f67d2018-05-21 22:57:13 +0530136 bool has_alt_reset;
Avaneesh Kumar Dwivedi7a8ffe12016-12-30 19:24:00 +0530137};
138
Bjorn Andersson051fb702016-06-20 14:28:41 -0700139struct q6v5 {
140 struct device *dev;
141 struct rproc *rproc;
142
143 void __iomem *reg_base;
144 void __iomem *rmb_base;
145
146 struct regmap *halt_map;
147 u32 halt_q6;
148 u32 halt_modem;
149 u32 halt_nc;
150
151 struct reset_control *mss_restart;
Sibi Sankar29a5f9a2018-08-30 00:42:15 +0530152 struct reset_control *pdc_reset;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700153
Bjorn Andersson7d674732018-06-04 13:30:38 -0700154 struct qcom_q6v5 q6v5;
Sibi Sankar663e9842018-05-21 22:57:09 +0530155
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +0530156 struct clk *active_clks[8];
Sibi Sankar231f67d2018-05-21 22:57:13 +0530157 struct clk *reset_clks[4];
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +0530158 struct clk *proxy_clks[4];
159 int active_clk_count;
Sibi Sankar231f67d2018-05-21 22:57:13 +0530160 int reset_clk_count;
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +0530161 int proxy_clk_count;
162
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530163 struct reg_info active_regs[1];
164 struct reg_info proxy_regs[3];
165 int active_reg_count;
166 int proxy_reg_count;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700167
Bjorn Andersson051fb702016-06-20 14:28:41 -0700168 bool running;
169
170 phys_addr_t mba_phys;
171 void *mba_region;
172 size_t mba_size;
173
174 phys_addr_t mpss_phys;
175 phys_addr_t mpss_reloc;
176 void *mpss_region;
177 size_t mpss_size;
Bjorn Andersson4b489212017-01-29 14:05:50 -0800178
Sibi Sankar47254962018-05-21 22:57:14 +0530179 struct qcom_rproc_glink glink_subdev;
Bjorn Andersson4b489212017-01-29 14:05:50 -0800180 struct qcom_rproc_subdev smd_subdev;
Bjorn Andersson1e140df2017-07-24 22:56:43 -0700181 struct qcom_rproc_ssr ssr_subdev;
Bjorn Andersson1fb82ee2017-08-27 21:51:38 -0700182 struct qcom_sysmon *sysmon;
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530183 bool need_mem_protection;
Sibi Sankar231f67d2018-05-21 22:57:13 +0530184 bool has_alt_reset;
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530185 int mpss_perm;
186 int mba_perm;
Avaneesh Kumar Dwivedi9f058fa2017-10-24 21:22:27 +0530187 int version;
188};
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530189
Avaneesh Kumar Dwivedi9f058fa2017-10-24 21:22:27 +0530190enum {
191 MSS_MSM8916,
192 MSS_MSM8974,
193 MSS_MSM8996,
Sibi Sankar231f67d2018-05-21 22:57:13 +0530194 MSS_SDM845,
Bjorn Andersson051fb702016-06-20 14:28:41 -0700195};
196
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530197static int q6v5_regulator_init(struct device *dev, struct reg_info *regs,
198 const struct qcom_mss_reg_res *reg_res)
Bjorn Andersson051fb702016-06-20 14:28:41 -0700199{
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530200 int rc;
201 int i;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700202
Bjorn Andersson2bb5d902017-01-30 03:20:27 -0800203 if (!reg_res)
204 return 0;
205
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530206 for (i = 0; reg_res[i].supply; i++) {
207 regs[i].reg = devm_regulator_get(dev, reg_res[i].supply);
208 if (IS_ERR(regs[i].reg)) {
209 rc = PTR_ERR(regs[i].reg);
210 if (rc != -EPROBE_DEFER)
211 dev_err(dev, "Failed to get %s\n regulator",
212 reg_res[i].supply);
213 return rc;
214 }
Bjorn Andersson051fb702016-06-20 14:28:41 -0700215
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530216 regs[i].uV = reg_res[i].uV;
217 regs[i].uA = reg_res[i].uA;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700218 }
219
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530220 return i;
221}
222
223static int q6v5_regulator_enable(struct q6v5 *qproc,
224 struct reg_info *regs, int count)
225{
226 int ret;
227 int i;
228
229 for (i = 0; i < count; i++) {
230 if (regs[i].uV > 0) {
231 ret = regulator_set_voltage(regs[i].reg,
232 regs[i].uV, INT_MAX);
233 if (ret) {
234 dev_err(qproc->dev,
235 "Failed to request voltage for %d.\n",
236 i);
237 goto err;
238 }
239 }
240
241 if (regs[i].uA > 0) {
242 ret = regulator_set_load(regs[i].reg,
243 regs[i].uA);
244 if (ret < 0) {
245 dev_err(qproc->dev,
246 "Failed to set regulator mode\n");
247 goto err;
248 }
249 }
250
251 ret = regulator_enable(regs[i].reg);
252 if (ret) {
253 dev_err(qproc->dev, "Regulator enable failed\n");
254 goto err;
255 }
256 }
Bjorn Andersson051fb702016-06-20 14:28:41 -0700257
258 return 0;
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530259err:
260 for (; i >= 0; i--) {
261 if (regs[i].uV > 0)
262 regulator_set_voltage(regs[i].reg, 0, INT_MAX);
263
264 if (regs[i].uA > 0)
265 regulator_set_load(regs[i].reg, 0);
266
267 regulator_disable(regs[i].reg);
268 }
269
270 return ret;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700271}
272
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530273static void q6v5_regulator_disable(struct q6v5 *qproc,
274 struct reg_info *regs, int count)
Bjorn Andersson051fb702016-06-20 14:28:41 -0700275{
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530276 int i;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700277
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530278 for (i = 0; i < count; i++) {
279 if (regs[i].uV > 0)
280 regulator_set_voltage(regs[i].reg, 0, INT_MAX);
Bjorn Andersson051fb702016-06-20 14:28:41 -0700281
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530282 if (regs[i].uA > 0)
283 regulator_set_load(regs[i].reg, 0);
Bjorn Andersson051fb702016-06-20 14:28:41 -0700284
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530285 regulator_disable(regs[i].reg);
286 }
Bjorn Andersson051fb702016-06-20 14:28:41 -0700287}
288
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +0530289static int q6v5_clk_enable(struct device *dev,
290 struct clk **clks, int count)
291{
292 int rc;
293 int i;
294
295 for (i = 0; i < count; i++) {
296 rc = clk_prepare_enable(clks[i]);
297 if (rc) {
298 dev_err(dev, "Clock enable failed\n");
299 goto err;
300 }
301 }
302
303 return 0;
304err:
305 for (i--; i >= 0; i--)
306 clk_disable_unprepare(clks[i]);
307
308 return rc;
309}
310
311static void q6v5_clk_disable(struct device *dev,
312 struct clk **clks, int count)
313{
314 int i;
315
316 for (i = 0; i < count; i++)
317 clk_disable_unprepare(clks[i]);
318}
319
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530320static int q6v5_xfer_mem_ownership(struct q6v5 *qproc, int *current_perm,
321 bool remote_owner, phys_addr_t addr,
322 size_t size)
323{
324 struct qcom_scm_vmperm next;
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530325
326 if (!qproc->need_mem_protection)
327 return 0;
328 if (remote_owner && *current_perm == BIT(QCOM_SCM_VMID_MSS_MSA))
329 return 0;
330 if (!remote_owner && *current_perm == BIT(QCOM_SCM_VMID_HLOS))
331 return 0;
332
333 next.vmid = remote_owner ? QCOM_SCM_VMID_MSS_MSA : QCOM_SCM_VMID_HLOS;
334 next.perm = remote_owner ? QCOM_SCM_PERM_RW : QCOM_SCM_PERM_RWX;
335
Bjorn Andersson9f2a4342017-11-06 22:26:41 -0800336 return qcom_scm_assign_mem(addr, ALIGN(size, SZ_4K),
337 current_perm, &next, 1);
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530338}
339
Bjorn Andersson051fb702016-06-20 14:28:41 -0700340static int q6v5_load(struct rproc *rproc, const struct firmware *fw)
341{
342 struct q6v5 *qproc = rproc->priv;
343
344 memcpy(qproc->mba_region, fw->data, fw->size);
345
346 return 0;
347}
348
Sibi Sankar9f135fa2018-05-21 22:57:12 +0530349static int q6v5_reset_assert(struct q6v5 *qproc)
350{
Sibi Sankar29a5f9a2018-08-30 00:42:15 +0530351 int ret;
352
353 if (qproc->has_alt_reset) {
354 reset_control_assert(qproc->pdc_reset);
355 ret = reset_control_reset(qproc->mss_restart);
356 reset_control_deassert(qproc->pdc_reset);
357 } else {
358 ret = reset_control_assert(qproc->mss_restart);
359 }
360
361 return ret;
Sibi Sankar9f135fa2018-05-21 22:57:12 +0530362}
363
364static int q6v5_reset_deassert(struct q6v5 *qproc)
365{
Sibi Sankar231f67d2018-05-21 22:57:13 +0530366 int ret;
367
368 if (qproc->has_alt_reset) {
Sibi Sankar29a5f9a2018-08-30 00:42:15 +0530369 reset_control_assert(qproc->pdc_reset);
Sibi Sankar231f67d2018-05-21 22:57:13 +0530370 writel(1, qproc->rmb_base + RMB_MBA_ALT_RESET);
371 ret = reset_control_reset(qproc->mss_restart);
372 writel(0, qproc->rmb_base + RMB_MBA_ALT_RESET);
Sibi Sankar29a5f9a2018-08-30 00:42:15 +0530373 reset_control_deassert(qproc->pdc_reset);
Sibi Sankar231f67d2018-05-21 22:57:13 +0530374 } else {
375 ret = reset_control_deassert(qproc->mss_restart);
376 }
377
378 return ret;
Sibi Sankar9f135fa2018-05-21 22:57:12 +0530379}
380
Bjorn Andersson051fb702016-06-20 14:28:41 -0700381static int q6v5_rmb_pbl_wait(struct q6v5 *qproc, int ms)
382{
383 unsigned long timeout;
384 s32 val;
385
386 timeout = jiffies + msecs_to_jiffies(ms);
387 for (;;) {
388 val = readl(qproc->rmb_base + RMB_PBL_STATUS_REG);
389 if (val)
390 break;
391
392 if (time_after(jiffies, timeout))
393 return -ETIMEDOUT;
394
395 msleep(1);
396 }
397
398 return val;
399}
400
401static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms)
402{
403
404 unsigned long timeout;
405 s32 val;
406
407 timeout = jiffies + msecs_to_jiffies(ms);
408 for (;;) {
409 val = readl(qproc->rmb_base + RMB_MBA_STATUS_REG);
410 if (val < 0)
411 break;
412
413 if (!status && val)
414 break;
415 else if (status && val == status)
416 break;
417
418 if (time_after(jiffies, timeout))
419 return -ETIMEDOUT;
420
421 msleep(1);
422 }
423
424 return val;
425}
426
427static int q6v5proc_reset(struct q6v5 *qproc)
428{
429 u32 val;
430 int ret;
Avaneesh Kumar Dwivedi9f058fa2017-10-24 21:22:27 +0530431 int i;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700432
Sibi Sankar231f67d2018-05-21 22:57:13 +0530433 if (qproc->version == MSS_SDM845) {
434 val = readl(qproc->reg_base + QDSP6SS_SLEEP);
435 val |= 0x1;
436 writel(val, qproc->reg_base + QDSP6SS_SLEEP);
Bjorn Andersson051fb702016-06-20 14:28:41 -0700437
Sibi Sankar231f67d2018-05-21 22:57:13 +0530438 ret = readl_poll_timeout(qproc->reg_base + QDSP6SS_SLEEP,
439 val, !(val & BIT(31)), 1,
440 SLEEP_CHECK_MAX_LOOPS);
441 if (ret) {
442 dev_err(qproc->dev, "QDSP6SS Sleep clock timed out\n");
443 return -ETIMEDOUT;
444 }
445
446 /* De-assert QDSP6 stop core */
447 writel(1, qproc->reg_base + QDSP6SS_BOOT_CORE_START);
448 /* Trigger boot FSM */
449 writel(1, qproc->reg_base + QDSP6SS_BOOT_CMD);
450
451 ret = readl_poll_timeout(qproc->rmb_base + RMB_MBA_MSS_STATUS,
452 val, (val & BIT(0)) != 0, 10, BOOT_FSM_TIMEOUT);
453 if (ret) {
454 dev_err(qproc->dev, "Boot FSM failed to complete.\n");
455 /* Reset the modem so that boot FSM is in reset state */
456 q6v5_reset_deassert(qproc);
457 return ret;
458 }
459
460 goto pbl_wait;
461 } else if (qproc->version == MSS_MSM8996) {
Avaneesh Kumar Dwivedi9f058fa2017-10-24 21:22:27 +0530462 /* Override the ACC value if required */
463 writel(QDSP6SS_ACC_OVERRIDE_VAL,
464 qproc->reg_base + QDSP6SS_STRAP_ACC);
Bjorn Andersson051fb702016-06-20 14:28:41 -0700465
Avaneesh Kumar Dwivedi9f058fa2017-10-24 21:22:27 +0530466 /* Assert resets, stop core */
467 val = readl(qproc->reg_base + QDSP6SS_RESET_REG);
468 val |= Q6SS_CORE_ARES | Q6SS_BUS_ARES_ENABLE | Q6SS_STOP_CORE;
469 writel(val, qproc->reg_base + QDSP6SS_RESET_REG);
Bjorn Andersson051fb702016-06-20 14:28:41 -0700470
Avaneesh Kumar Dwivedi9f058fa2017-10-24 21:22:27 +0530471 /* BHS require xo cbcr to be enabled */
472 val = readl(qproc->reg_base + QDSP6SS_XO_CBCR);
473 val |= 0x1;
474 writel(val, qproc->reg_base + QDSP6SS_XO_CBCR);
475
476 /* Read CLKOFF bit to go low indicating CLK is enabled */
477 ret = readl_poll_timeout(qproc->reg_base + QDSP6SS_XO_CBCR,
478 val, !(val & BIT(31)), 1,
479 HALT_CHECK_MAX_LOOPS);
480 if (ret) {
481 dev_err(qproc->dev,
482 "xo cbcr enabling timed out (rc:%d)\n", ret);
483 return ret;
484 }
485 /* Enable power block headswitch and wait for it to stabilize */
486 val = readl(qproc->reg_base + QDSP6SS_PWR_CTL_REG);
487 val |= QDSP6v56_BHS_ON;
488 writel(val, qproc->reg_base + QDSP6SS_PWR_CTL_REG);
489 val |= readl(qproc->reg_base + QDSP6SS_PWR_CTL_REG);
490 udelay(1);
491
492 /* Put LDO in bypass mode */
493 val |= QDSP6v56_LDO_BYP;
494 writel(val, qproc->reg_base + QDSP6SS_PWR_CTL_REG);
495
496 /* Deassert QDSP6 compiler memory clamp */
497 val = readl(qproc->reg_base + QDSP6SS_PWR_CTL_REG);
498 val &= ~QDSP6v56_CLAMP_QMC_MEM;
499 writel(val, qproc->reg_base + QDSP6SS_PWR_CTL_REG);
500
501 /* Deassert memory peripheral sleep and L2 memory standby */
502 val |= Q6SS_L2DATA_STBY_N | Q6SS_SLP_RET_N;
503 writel(val, qproc->reg_base + QDSP6SS_PWR_CTL_REG);
504
505 /* Turn on L1, L2, ETB and JU memories 1 at a time */
506 val = readl(qproc->reg_base + QDSP6SS_MEM_PWR_CTL);
507 for (i = 19; i >= 0; i--) {
508 val |= BIT(i);
509 writel(val, qproc->reg_base +
510 QDSP6SS_MEM_PWR_CTL);
511 /*
512 * Read back value to ensure the write is done then
513 * wait for 1us for both memory peripheral and data
514 * array to turn on.
515 */
516 val |= readl(qproc->reg_base + QDSP6SS_MEM_PWR_CTL);
517 udelay(1);
518 }
519 /* Remove word line clamp */
520 val = readl(qproc->reg_base + QDSP6SS_PWR_CTL_REG);
521 val &= ~QDSP6v56_CLAMP_WL;
522 writel(val, qproc->reg_base + QDSP6SS_PWR_CTL_REG);
523 } else {
524 /* Assert resets, stop core */
525 val = readl(qproc->reg_base + QDSP6SS_RESET_REG);
526 val |= Q6SS_CORE_ARES | Q6SS_BUS_ARES_ENABLE | Q6SS_STOP_CORE;
527 writel(val, qproc->reg_base + QDSP6SS_RESET_REG);
528
529 /* Enable power block headswitch and wait for it to stabilize */
530 val = readl(qproc->reg_base + QDSP6SS_PWR_CTL_REG);
531 val |= QDSS_BHS_ON | QDSS_LDO_BYP;
532 writel(val, qproc->reg_base + QDSP6SS_PWR_CTL_REG);
533 val |= readl(qproc->reg_base + QDSP6SS_PWR_CTL_REG);
534 udelay(1);
535 /*
536 * Turn on memories. L2 banks should be done individually
537 * to minimize inrush current.
538 */
539 val = readl(qproc->reg_base + QDSP6SS_PWR_CTL_REG);
540 val |= Q6SS_SLP_RET_N | Q6SS_L2TAG_SLP_NRET_N |
541 Q6SS_ETB_SLP_NRET_N | Q6SS_L2DATA_STBY_N;
542 writel(val, qproc->reg_base + QDSP6SS_PWR_CTL_REG);
543 val |= Q6SS_L2DATA_SLP_NRET_N_2;
544 writel(val, qproc->reg_base + QDSP6SS_PWR_CTL_REG);
545 val |= Q6SS_L2DATA_SLP_NRET_N_1;
546 writel(val, qproc->reg_base + QDSP6SS_PWR_CTL_REG);
547 val |= Q6SS_L2DATA_SLP_NRET_N_0;
548 writel(val, qproc->reg_base + QDSP6SS_PWR_CTL_REG);
549 }
Bjorn Andersson051fb702016-06-20 14:28:41 -0700550 /* Remove IO clamp */
551 val &= ~Q6SS_CLAMP_IO;
552 writel(val, qproc->reg_base + QDSP6SS_PWR_CTL_REG);
553
554 /* Bring core out of reset */
555 val = readl(qproc->reg_base + QDSP6SS_RESET_REG);
556 val &= ~Q6SS_CORE_ARES;
557 writel(val, qproc->reg_base + QDSP6SS_RESET_REG);
558
559 /* Turn on core clock */
560 val = readl(qproc->reg_base + QDSP6SS_GFMUX_CTL_REG);
561 val |= Q6SS_CLK_ENABLE;
562 writel(val, qproc->reg_base + QDSP6SS_GFMUX_CTL_REG);
563
564 /* Start core execution */
565 val = readl(qproc->reg_base + QDSP6SS_RESET_REG);
566 val &= ~Q6SS_STOP_CORE;
567 writel(val, qproc->reg_base + QDSP6SS_RESET_REG);
568
Sibi Sankar231f67d2018-05-21 22:57:13 +0530569pbl_wait:
Bjorn Andersson051fb702016-06-20 14:28:41 -0700570 /* Wait for PBL status */
571 ret = q6v5_rmb_pbl_wait(qproc, 1000);
572 if (ret == -ETIMEDOUT) {
573 dev_err(qproc->dev, "PBL boot timed out\n");
574 } else if (ret != RMB_PBL_SUCCESS) {
575 dev_err(qproc->dev, "PBL returned unexpected status %d\n", ret);
576 ret = -EINVAL;
577 } else {
578 ret = 0;
579 }
580
581 return ret;
582}
583
584static void q6v5proc_halt_axi_port(struct q6v5 *qproc,
585 struct regmap *halt_map,
586 u32 offset)
587{
588 unsigned long timeout;
589 unsigned int val;
590 int ret;
591
592 /* Check if we're already idle */
593 ret = regmap_read(halt_map, offset + AXI_IDLE_REG, &val);
594 if (!ret && val)
595 return;
596
597 /* Assert halt request */
598 regmap_write(halt_map, offset + AXI_HALTREQ_REG, 1);
599
600 /* Wait for halt */
601 timeout = jiffies + msecs_to_jiffies(HALT_ACK_TIMEOUT_MS);
602 for (;;) {
603 ret = regmap_read(halt_map, offset + AXI_HALTACK_REG, &val);
604 if (ret || val || time_after(jiffies, timeout))
605 break;
606
607 msleep(1);
608 }
609
610 ret = regmap_read(halt_map, offset + AXI_IDLE_REG, &val);
611 if (ret || !val)
612 dev_err(qproc->dev, "port failed halt\n");
613
614 /* Clear halt request (port will remain halted until reset) */
615 regmap_write(halt_map, offset + AXI_HALTREQ_REG, 0);
616}
617
618static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw)
619{
Krzysztof Kozlowski00085f12016-08-03 13:46:00 -0700620 unsigned long dma_attrs = DMA_ATTR_FORCE_CONTIGUOUS;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700621 dma_addr_t phys;
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530622 int mdata_perm;
623 int xferop_ret;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700624 void *ptr;
625 int ret;
626
Krzysztof Kozlowski00085f12016-08-03 13:46:00 -0700627 ptr = dma_alloc_attrs(qproc->dev, fw->size, &phys, GFP_KERNEL, dma_attrs);
Bjorn Andersson051fb702016-06-20 14:28:41 -0700628 if (!ptr) {
629 dev_err(qproc->dev, "failed to allocate mdt buffer\n");
630 return -ENOMEM;
631 }
632
633 memcpy(ptr, fw->data, fw->size);
634
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530635 /* Hypervisor mapping to access metadata by modem */
636 mdata_perm = BIT(QCOM_SCM_VMID_HLOS);
637 ret = q6v5_xfer_mem_ownership(qproc, &mdata_perm,
638 true, phys, fw->size);
Bjorn Andersson9f2a4342017-11-06 22:26:41 -0800639 if (ret) {
640 dev_err(qproc->dev,
641 "assigning Q6 access to metadata failed: %d\n", ret);
Christophe JAILLET1a5d5c52017-11-15 07:58:35 +0100642 ret = -EAGAIN;
643 goto free_dma_attrs;
Bjorn Andersson9f2a4342017-11-06 22:26:41 -0800644 }
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530645
Bjorn Andersson051fb702016-06-20 14:28:41 -0700646 writel(phys, qproc->rmb_base + RMB_PMI_META_DATA_REG);
647 writel(RMB_CMD_META_DATA_READY, qproc->rmb_base + RMB_MBA_COMMAND_REG);
648
649 ret = q6v5_rmb_mba_wait(qproc, RMB_MBA_META_DATA_AUTH_SUCCESS, 1000);
650 if (ret == -ETIMEDOUT)
651 dev_err(qproc->dev, "MPSS header authentication timed out\n");
652 else if (ret < 0)
653 dev_err(qproc->dev, "MPSS header authentication failed: %d\n", ret);
654
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530655 /* Metadata authentication done, remove modem access */
656 xferop_ret = q6v5_xfer_mem_ownership(qproc, &mdata_perm,
657 false, phys, fw->size);
658 if (xferop_ret)
659 dev_warn(qproc->dev,
660 "mdt buffer not reclaimed system may become unstable\n");
661
Christophe JAILLET1a5d5c52017-11-15 07:58:35 +0100662free_dma_attrs:
Krzysztof Kozlowski00085f12016-08-03 13:46:00 -0700663 dma_free_attrs(qproc->dev, fw->size, ptr, phys, dma_attrs);
Bjorn Andersson051fb702016-06-20 14:28:41 -0700664
665 return ret < 0 ? ret : 0;
666}
667
Bjorn Anderssone7fd2522017-01-26 13:58:35 -0800668static bool q6v5_phdr_valid(const struct elf32_phdr *phdr)
669{
670 if (phdr->p_type != PT_LOAD)
671 return false;
672
673 if ((phdr->p_flags & QCOM_MDT_TYPE_MASK) == QCOM_MDT_TYPE_HASH)
674 return false;
675
676 if (!phdr->p_memsz)
677 return false;
678
679 return true;
680}
681
682static int q6v5_mpss_load(struct q6v5 *qproc)
Bjorn Andersson051fb702016-06-20 14:28:41 -0700683{
684 const struct elf32_phdr *phdrs;
685 const struct elf32_phdr *phdr;
Bjorn Anderssone7fd2522017-01-26 13:58:35 -0800686 const struct firmware *seg_fw;
687 const struct firmware *fw;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700688 struct elf32_hdr *ehdr;
Bjorn Anderssone7fd2522017-01-26 13:58:35 -0800689 phys_addr_t mpss_reloc;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700690 phys_addr_t boot_addr;
Stefan Agnerd7dc8992018-06-14 15:28:02 -0700691 phys_addr_t min_addr = PHYS_ADDR_MAX;
Bjorn Anderssone7fd2522017-01-26 13:58:35 -0800692 phys_addr_t max_addr = 0;
693 bool relocate = false;
694 char seg_name[10];
Bjorn Andersson01625cc52017-02-15 14:00:41 -0800695 ssize_t offset;
Avaneesh Kumar Dwivedi94c90782017-10-24 21:22:25 +0530696 size_t size = 0;
Bjorn Anderssone7fd2522017-01-26 13:58:35 -0800697 void *ptr;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700698 int ret;
699 int i;
700
Bjorn Anderssone7fd2522017-01-26 13:58:35 -0800701 ret = request_firmware(&fw, "modem.mdt", qproc->dev);
702 if (ret < 0) {
703 dev_err(qproc->dev, "unable to load modem.mdt\n");
Bjorn Andersson051fb702016-06-20 14:28:41 -0700704 return ret;
705 }
706
Bjorn Anderssone7fd2522017-01-26 13:58:35 -0800707 /* Initialize the RMB validator */
708 writel(0, qproc->rmb_base + RMB_PMI_CODE_LENGTH_REG);
709
710 ret = q6v5_mpss_init_image(qproc, fw);
711 if (ret)
712 goto release_firmware;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700713
714 ehdr = (struct elf32_hdr *)fw->data;
715 phdrs = (struct elf32_phdr *)(ehdr + 1);
Bjorn Anderssone7fd2522017-01-26 13:58:35 -0800716
717 for (i = 0; i < ehdr->e_phnum; i++) {
Bjorn Andersson051fb702016-06-20 14:28:41 -0700718 phdr = &phdrs[i];
719
Bjorn Anderssone7fd2522017-01-26 13:58:35 -0800720 if (!q6v5_phdr_valid(phdr))
Bjorn Andersson051fb702016-06-20 14:28:41 -0700721 continue;
722
Bjorn Anderssone7fd2522017-01-26 13:58:35 -0800723 if (phdr->p_flags & QCOM_MDT_RELOCATABLE)
724 relocate = true;
725
726 if (phdr->p_paddr < min_addr)
727 min_addr = phdr->p_paddr;
728
729 if (phdr->p_paddr + phdr->p_memsz > max_addr)
730 max_addr = ALIGN(phdr->p_paddr + phdr->p_memsz, SZ_4K);
731 }
732
733 mpss_reloc = relocate ? min_addr : qproc->mpss_phys;
Sibi Sankar3bf62eb2018-07-27 20:50:03 +0530734 qproc->mpss_reloc = mpss_reloc;
Avaneesh Kumar Dwivedi94c90782017-10-24 21:22:25 +0530735 /* Load firmware segments */
Bjorn Anderssone7fd2522017-01-26 13:58:35 -0800736 for (i = 0; i < ehdr->e_phnum; i++) {
737 phdr = &phdrs[i];
738
739 if (!q6v5_phdr_valid(phdr))
Bjorn Andersson051fb702016-06-20 14:28:41 -0700740 continue;
741
Bjorn Anderssone7fd2522017-01-26 13:58:35 -0800742 offset = phdr->p_paddr - mpss_reloc;
743 if (offset < 0 || offset + phdr->p_memsz > qproc->mpss_size) {
744 dev_err(qproc->dev, "segment outside memory range\n");
745 ret = -EINVAL;
746 goto release_firmware;
747 }
748
749 ptr = qproc->mpss_region + offset;
750
751 if (phdr->p_filesz) {
752 snprintf(seg_name, sizeof(seg_name), "modem.b%02d", i);
753 ret = request_firmware(&seg_fw, seg_name, qproc->dev);
754 if (ret) {
755 dev_err(qproc->dev, "failed to load %s\n", seg_name);
756 goto release_firmware;
757 }
758
759 memcpy(ptr, seg_fw->data, seg_fw->size);
760
761 release_firmware(seg_fw);
762 }
763
764 if (phdr->p_memsz > phdr->p_filesz) {
765 memset(ptr + phdr->p_filesz, 0,
766 phdr->p_memsz - phdr->p_filesz);
767 }
Bjorn Andersson051fb702016-06-20 14:28:41 -0700768 size += phdr->p_memsz;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700769 }
770
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530771 /* Transfer ownership of modem ddr region to q6 */
772 ret = q6v5_xfer_mem_ownership(qproc, &qproc->mpss_perm, true,
773 qproc->mpss_phys, qproc->mpss_size);
Bjorn Andersson9f2a4342017-11-06 22:26:41 -0800774 if (ret) {
775 dev_err(qproc->dev,
776 "assigning Q6 access to mpss memory failed: %d\n", ret);
Christophe JAILLET1a5d5c52017-11-15 07:58:35 +0100777 ret = -EAGAIN;
778 goto release_firmware;
Bjorn Andersson9f2a4342017-11-06 22:26:41 -0800779 }
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530780
Avaneesh Kumar Dwivedi94c90782017-10-24 21:22:25 +0530781 boot_addr = relocate ? qproc->mpss_phys : min_addr;
782 writel(boot_addr, qproc->rmb_base + RMB_PMI_CODE_START_REG);
783 writel(RMB_CMD_LOAD_READY, qproc->rmb_base + RMB_MBA_COMMAND_REG);
784 writel(size, qproc->rmb_base + RMB_PMI_CODE_LENGTH_REG);
785
Bjorn Andersson72beb492016-07-12 17:15:45 -0700786 ret = q6v5_rmb_mba_wait(qproc, RMB_MBA_AUTH_COMPLETE, 10000);
787 if (ret == -ETIMEDOUT)
788 dev_err(qproc->dev, "MPSS authentication timed out\n");
789 else if (ret < 0)
790 dev_err(qproc->dev, "MPSS authentication failed: %d\n", ret);
791
Bjorn Andersson051fb702016-06-20 14:28:41 -0700792release_firmware:
793 release_firmware(fw);
794
795 return ret < 0 ? ret : 0;
796}
797
798static int q6v5_start(struct rproc *rproc)
799{
800 struct q6v5 *qproc = (struct q6v5 *)rproc->priv;
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530801 int xfermemop_ret;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700802 int ret;
803
Bjorn Andersson7d674732018-06-04 13:30:38 -0700804 qcom_q6v5_prepare(&qproc->q6v5);
Sibi Sankar663e9842018-05-21 22:57:09 +0530805
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530806 ret = q6v5_regulator_enable(qproc, qproc->proxy_regs,
807 qproc->proxy_reg_count);
Bjorn Andersson051fb702016-06-20 14:28:41 -0700808 if (ret) {
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530809 dev_err(qproc->dev, "failed to enable proxy supplies\n");
Sibi Sankar663e9842018-05-21 22:57:09 +0530810 goto disable_irqs;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700811 }
812
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +0530813 ret = q6v5_clk_enable(qproc->dev, qproc->proxy_clks,
814 qproc->proxy_clk_count);
815 if (ret) {
816 dev_err(qproc->dev, "failed to enable proxy clocks\n");
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530817 goto disable_proxy_reg;
818 }
819
820 ret = q6v5_regulator_enable(qproc, qproc->active_regs,
821 qproc->active_reg_count);
822 if (ret) {
823 dev_err(qproc->dev, "failed to enable supplies\n");
824 goto disable_proxy_clk;
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +0530825 }
Sibi Sankar231f67d2018-05-21 22:57:13 +0530826
827 ret = q6v5_clk_enable(qproc->dev, qproc->reset_clks,
828 qproc->reset_clk_count);
829 if (ret) {
830 dev_err(qproc->dev, "failed to enable reset clocks\n");
831 goto disable_vdd;
832 }
833
Sibi Sankar9f135fa2018-05-21 22:57:12 +0530834 ret = q6v5_reset_deassert(qproc);
Bjorn Andersson051fb702016-06-20 14:28:41 -0700835 if (ret) {
836 dev_err(qproc->dev, "failed to deassert mss restart\n");
Sibi Sankar231f67d2018-05-21 22:57:13 +0530837 goto disable_reset_clks;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700838 }
839
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +0530840 ret = q6v5_clk_enable(qproc->dev, qproc->active_clks,
841 qproc->active_clk_count);
842 if (ret) {
843 dev_err(qproc->dev, "failed to enable clocks\n");
Bjorn Andersson051fb702016-06-20 14:28:41 -0700844 goto assert_reset;
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +0530845 }
Bjorn Andersson051fb702016-06-20 14:28:41 -0700846
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530847 /* Assign MBA image access in DDR to q6 */
Sibi Sankar27248072018-04-18 01:14:15 +0530848 ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true,
849 qproc->mba_phys, qproc->mba_size);
850 if (ret) {
Bjorn Andersson9f2a4342017-11-06 22:26:41 -0800851 dev_err(qproc->dev,
Sibi Sankar27248072018-04-18 01:14:15 +0530852 "assigning Q6 access to mba memory failed: %d\n", ret);
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530853 goto disable_active_clks;
Bjorn Andersson9f2a4342017-11-06 22:26:41 -0800854 }
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530855
Bjorn Andersson051fb702016-06-20 14:28:41 -0700856 writel(qproc->mba_phys, qproc->rmb_base + RMB_MBA_IMAGE_REG);
857
858 ret = q6v5proc_reset(qproc);
859 if (ret)
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530860 goto reclaim_mba;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700861
862 ret = q6v5_rmb_mba_wait(qproc, 0, 5000);
863 if (ret == -ETIMEDOUT) {
864 dev_err(qproc->dev, "MBA boot timed out\n");
865 goto halt_axi_ports;
866 } else if (ret != RMB_MBA_XPU_UNLOCKED &&
867 ret != RMB_MBA_XPU_UNLOCKED_SCRIBBLED) {
868 dev_err(qproc->dev, "MBA returned unexpected status %d\n", ret);
869 ret = -EINVAL;
870 goto halt_axi_ports;
871 }
872
873 dev_info(qproc->dev, "MBA booted, loading mpss\n");
874
875 ret = q6v5_mpss_load(qproc);
876 if (ret)
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530877 goto reclaim_mpss;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700878
Bjorn Andersson7d674732018-06-04 13:30:38 -0700879 ret = qcom_q6v5_wait_for_start(&qproc->q6v5, msecs_to_jiffies(5000));
880 if (ret == -ETIMEDOUT) {
Bjorn Andersson051fb702016-06-20 14:28:41 -0700881 dev_err(qproc->dev, "start timed out\n");
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530882 goto reclaim_mpss;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700883 }
884
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530885 xfermemop_ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, false,
886 qproc->mba_phys,
887 qproc->mba_size);
888 if (xfermemop_ret)
889 dev_err(qproc->dev,
890 "Failed to reclaim mba buffer system may become unstable\n");
Bjorn Andersson051fb702016-06-20 14:28:41 -0700891 qproc->running = true;
892
Bjorn Andersson051fb702016-06-20 14:28:41 -0700893 return 0;
894
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530895reclaim_mpss:
896 xfermemop_ret = q6v5_xfer_mem_ownership(qproc, &qproc->mpss_perm,
897 false, qproc->mpss_phys,
898 qproc->mpss_size);
899 WARN_ON(xfermemop_ret);
900
Bjorn Andersson051fb702016-06-20 14:28:41 -0700901halt_axi_ports:
902 q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_q6);
903 q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_modem);
904 q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_nc);
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530905
906reclaim_mba:
907 xfermemop_ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, false,
908 qproc->mba_phys,
909 qproc->mba_size);
910 if (xfermemop_ret) {
911 dev_err(qproc->dev,
912 "Failed to reclaim mba buffer, system may become unstable\n");
913 }
914
915disable_active_clks:
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +0530916 q6v5_clk_disable(qproc->dev, qproc->active_clks,
917 qproc->active_clk_count);
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530918
Bjorn Andersson051fb702016-06-20 14:28:41 -0700919assert_reset:
Sibi Sankar9f135fa2018-05-21 22:57:12 +0530920 q6v5_reset_assert(qproc);
Sibi Sankar231f67d2018-05-21 22:57:13 +0530921disable_reset_clks:
922 q6v5_clk_disable(qproc->dev, qproc->reset_clks,
923 qproc->reset_clk_count);
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530924disable_vdd:
925 q6v5_regulator_disable(qproc, qproc->active_regs,
926 qproc->active_reg_count);
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +0530927disable_proxy_clk:
928 q6v5_clk_disable(qproc->dev, qproc->proxy_clks,
929 qproc->proxy_clk_count);
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530930disable_proxy_reg:
931 q6v5_regulator_disable(qproc, qproc->proxy_regs,
932 qproc->proxy_reg_count);
Bjorn Andersson051fb702016-06-20 14:28:41 -0700933
Sibi Sankar663e9842018-05-21 22:57:09 +0530934disable_irqs:
Bjorn Andersson7d674732018-06-04 13:30:38 -0700935 qcom_q6v5_unprepare(&qproc->q6v5);
Sibi Sankar663e9842018-05-21 22:57:09 +0530936
Bjorn Andersson051fb702016-06-20 14:28:41 -0700937 return ret;
938}
939
940static int q6v5_stop(struct rproc *rproc)
941{
942 struct q6v5 *qproc = (struct q6v5 *)rproc->priv;
943 int ret;
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530944 u32 val;
Bjorn Andersson051fb702016-06-20 14:28:41 -0700945
946 qproc->running = false;
947
Bjorn Andersson7d674732018-06-04 13:30:38 -0700948 ret = qcom_q6v5_request_stop(&qproc->q6v5);
949 if (ret == -ETIMEDOUT)
Bjorn Andersson051fb702016-06-20 14:28:41 -0700950 dev_err(qproc->dev, "timed out on wait\n");
951
Bjorn Andersson051fb702016-06-20 14:28:41 -0700952 q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_q6);
953 q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_modem);
954 q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_nc);
Avaneesh Kumar Dwivedi9f058fa2017-10-24 21:22:27 +0530955 if (qproc->version == MSS_MSM8996) {
956 /*
957 * To avoid high MX current during LPASS/MSS restart.
958 */
959 val = readl(qproc->reg_base + QDSP6SS_PWR_CTL_REG);
960 val |= Q6SS_CLAMP_IO | QDSP6v56_CLAMP_WL |
961 QDSP6v56_CLAMP_QMC_MEM;
962 writel(val, qproc->reg_base + QDSP6SS_PWR_CTL_REG);
963 }
964
Bjorn Andersson051fb702016-06-20 14:28:41 -0700965
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +0530966 ret = q6v5_xfer_mem_ownership(qproc, &qproc->mpss_perm, false,
967 qproc->mpss_phys, qproc->mpss_size);
968 WARN_ON(ret);
969
Sibi Sankar9f135fa2018-05-21 22:57:12 +0530970 q6v5_reset_assert(qproc);
Sibi Sankar663e9842018-05-21 22:57:09 +0530971
Bjorn Andersson7d674732018-06-04 13:30:38 -0700972 ret = qcom_q6v5_unprepare(&qproc->q6v5);
973 if (ret) {
Sibi Sankar663e9842018-05-21 22:57:09 +0530974 q6v5_clk_disable(qproc->dev, qproc->proxy_clks,
975 qproc->proxy_clk_count);
976 q6v5_regulator_disable(qproc, qproc->proxy_regs,
977 qproc->proxy_reg_count);
978 }
979
Sibi Sankar231f67d2018-05-21 22:57:13 +0530980 q6v5_clk_disable(qproc->dev, qproc->reset_clks,
981 qproc->reset_clk_count);
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +0530982 q6v5_clk_disable(qproc->dev, qproc->active_clks,
983 qproc->active_clk_count);
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +0530984 q6v5_regulator_disable(qproc, qproc->active_regs,
985 qproc->active_reg_count);
Bjorn Andersson051fb702016-06-20 14:28:41 -0700986
987 return 0;
988}
989
990static void *q6v5_da_to_va(struct rproc *rproc, u64 da, int len)
991{
992 struct q6v5 *qproc = rproc->priv;
993 int offset;
994
995 offset = da - qproc->mpss_reloc;
996 if (offset < 0 || offset + len > qproc->mpss_size)
997 return NULL;
998
999 return qproc->mpss_region + offset;
1000}
1001
1002static const struct rproc_ops q6v5_ops = {
1003 .start = q6v5_start,
1004 .stop = q6v5_stop,
1005 .da_to_va = q6v5_da_to_va,
Bjorn Andersson0f21f9c2018-01-05 15:58:01 -08001006 .load = q6v5_load,
Bjorn Andersson051fb702016-06-20 14:28:41 -07001007};
1008
Bjorn Andersson7d674732018-06-04 13:30:38 -07001009static void qcom_msa_handover(struct qcom_q6v5 *q6v5)
Bjorn Andersson051fb702016-06-20 14:28:41 -07001010{
Bjorn Andersson7d674732018-06-04 13:30:38 -07001011 struct q6v5 *qproc = container_of(q6v5, struct q6v5, q6v5);
Sibi Sankar663e9842018-05-21 22:57:09 +05301012
1013 q6v5_clk_disable(qproc->dev, qproc->proxy_clks,
1014 qproc->proxy_clk_count);
1015 q6v5_regulator_disable(qproc, qproc->proxy_regs,
1016 qproc->proxy_reg_count);
Bjorn Andersson051fb702016-06-20 14:28:41 -07001017}
1018
1019static int q6v5_init_mem(struct q6v5 *qproc, struct platform_device *pdev)
1020{
1021 struct of_phandle_args args;
1022 struct resource *res;
1023 int ret;
1024
1025 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "qdsp6");
1026 qproc->reg_base = devm_ioremap_resource(&pdev->dev, res);
Wei Yongjunb1653f22016-07-14 12:57:44 +00001027 if (IS_ERR(qproc->reg_base))
Bjorn Andersson051fb702016-06-20 14:28:41 -07001028 return PTR_ERR(qproc->reg_base);
Bjorn Andersson051fb702016-06-20 14:28:41 -07001029
1030 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rmb");
1031 qproc->rmb_base = devm_ioremap_resource(&pdev->dev, res);
Wei Yongjunb1653f22016-07-14 12:57:44 +00001032 if (IS_ERR(qproc->rmb_base))
Bjorn Andersson051fb702016-06-20 14:28:41 -07001033 return PTR_ERR(qproc->rmb_base);
Bjorn Andersson051fb702016-06-20 14:28:41 -07001034
1035 ret = of_parse_phandle_with_fixed_args(pdev->dev.of_node,
1036 "qcom,halt-regs", 3, 0, &args);
1037 if (ret < 0) {
1038 dev_err(&pdev->dev, "failed to parse qcom,halt-regs\n");
1039 return -EINVAL;
1040 }
1041
1042 qproc->halt_map = syscon_node_to_regmap(args.np);
1043 of_node_put(args.np);
1044 if (IS_ERR(qproc->halt_map))
1045 return PTR_ERR(qproc->halt_map);
1046
1047 qproc->halt_q6 = args.args[0];
1048 qproc->halt_modem = args.args[1];
1049 qproc->halt_nc = args.args[2];
1050
1051 return 0;
1052}
1053
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +05301054static int q6v5_init_clocks(struct device *dev, struct clk **clks,
1055 char **clk_names)
Bjorn Andersson051fb702016-06-20 14:28:41 -07001056{
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +05301057 int i;
1058
1059 if (!clk_names)
1060 return 0;
1061
1062 for (i = 0; clk_names[i]; i++) {
1063 clks[i] = devm_clk_get(dev, clk_names[i]);
1064 if (IS_ERR(clks[i])) {
1065 int rc = PTR_ERR(clks[i]);
1066
1067 if (rc != -EPROBE_DEFER)
1068 dev_err(dev, "Failed to get %s clock\n",
1069 clk_names[i]);
1070 return rc;
1071 }
Bjorn Andersson051fb702016-06-20 14:28:41 -07001072 }
1073
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +05301074 return i;
Bjorn Andersson051fb702016-06-20 14:28:41 -07001075}
1076
1077static int q6v5_init_reset(struct q6v5 *qproc)
1078{
Philipp Zabel5acbf7e2017-07-19 17:26:16 +02001079 qproc->mss_restart = devm_reset_control_get_exclusive(qproc->dev,
Sibi Sankar9e483ef2018-08-30 00:42:14 +05301080 "mss_restart");
Bjorn Andersson051fb702016-06-20 14:28:41 -07001081 if (IS_ERR(qproc->mss_restart)) {
1082 dev_err(qproc->dev, "failed to acquire mss restart\n");
1083 return PTR_ERR(qproc->mss_restart);
1084 }
1085
Sibi Sankar29a5f9a2018-08-30 00:42:15 +05301086 if (qproc->has_alt_reset) {
1087 qproc->pdc_reset = devm_reset_control_get_exclusive(qproc->dev,
1088 "pdc_reset");
1089 if (IS_ERR(qproc->pdc_reset)) {
1090 dev_err(qproc->dev, "failed to acquire pdc reset\n");
1091 return PTR_ERR(qproc->pdc_reset);
1092 }
1093 }
1094
Bjorn Andersson051fb702016-06-20 14:28:41 -07001095 return 0;
1096}
1097
Bjorn Andersson051fb702016-06-20 14:28:41 -07001098static int q6v5_alloc_memory_region(struct q6v5 *qproc)
1099{
1100 struct device_node *child;
1101 struct device_node *node;
1102 struct resource r;
1103 int ret;
1104
1105 child = of_get_child_by_name(qproc->dev->of_node, "mba");
1106 node = of_parse_phandle(child, "memory-region", 0);
1107 ret = of_address_to_resource(node, 0, &r);
1108 if (ret) {
1109 dev_err(qproc->dev, "unable to resolve mba region\n");
1110 return ret;
1111 }
Tobias Jordan278d7442018-02-15 16:12:55 +01001112 of_node_put(node);
Bjorn Andersson051fb702016-06-20 14:28:41 -07001113
1114 qproc->mba_phys = r.start;
1115 qproc->mba_size = resource_size(&r);
1116 qproc->mba_region = devm_ioremap_wc(qproc->dev, qproc->mba_phys, qproc->mba_size);
1117 if (!qproc->mba_region) {
1118 dev_err(qproc->dev, "unable to map memory region: %pa+%zx\n",
1119 &r.start, qproc->mba_size);
1120 return -EBUSY;
1121 }
1122
1123 child = of_get_child_by_name(qproc->dev->of_node, "mpss");
1124 node = of_parse_phandle(child, "memory-region", 0);
1125 ret = of_address_to_resource(node, 0, &r);
1126 if (ret) {
1127 dev_err(qproc->dev, "unable to resolve mpss region\n");
1128 return ret;
1129 }
Tobias Jordan278d7442018-02-15 16:12:55 +01001130 of_node_put(node);
Bjorn Andersson051fb702016-06-20 14:28:41 -07001131
1132 qproc->mpss_phys = qproc->mpss_reloc = r.start;
1133 qproc->mpss_size = resource_size(&r);
1134 qproc->mpss_region = devm_ioremap_wc(qproc->dev, qproc->mpss_phys, qproc->mpss_size);
1135 if (!qproc->mpss_region) {
1136 dev_err(qproc->dev, "unable to map memory region: %pa+%zx\n",
1137 &r.start, qproc->mpss_size);
1138 return -EBUSY;
1139 }
1140
1141 return 0;
1142}
1143
1144static int q6v5_probe(struct platform_device *pdev)
1145{
Avaneesh Kumar Dwivedi7a8ffe12016-12-30 19:24:00 +05301146 const struct rproc_hexagon_res *desc;
Bjorn Andersson051fb702016-06-20 14:28:41 -07001147 struct q6v5 *qproc;
1148 struct rproc *rproc;
1149 int ret;
1150
Avaneesh Kumar Dwivedi7a8ffe12016-12-30 19:24:00 +05301151 desc = of_device_get_match_data(&pdev->dev);
1152 if (!desc)
1153 return -EINVAL;
1154
Bjorn Andersson051fb702016-06-20 14:28:41 -07001155 rproc = rproc_alloc(&pdev->dev, pdev->name, &q6v5_ops,
Avaneesh Kumar Dwivedi7a8ffe12016-12-30 19:24:00 +05301156 desc->hexagon_mba_image, sizeof(*qproc));
Bjorn Andersson051fb702016-06-20 14:28:41 -07001157 if (!rproc) {
1158 dev_err(&pdev->dev, "failed to allocate rproc\n");
1159 return -ENOMEM;
1160 }
1161
Bjorn Andersson051fb702016-06-20 14:28:41 -07001162 qproc = (struct q6v5 *)rproc->priv;
1163 qproc->dev = &pdev->dev;
1164 qproc->rproc = rproc;
1165 platform_set_drvdata(pdev, qproc);
1166
Bjorn Andersson051fb702016-06-20 14:28:41 -07001167 ret = q6v5_init_mem(qproc, pdev);
1168 if (ret)
1169 goto free_rproc;
1170
1171 ret = q6v5_alloc_memory_region(qproc);
1172 if (ret)
1173 goto free_rproc;
1174
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +05301175 ret = q6v5_init_clocks(&pdev->dev, qproc->proxy_clks,
1176 desc->proxy_clk_names);
1177 if (ret < 0) {
1178 dev_err(&pdev->dev, "Failed to get proxy clocks.\n");
Bjorn Andersson051fb702016-06-20 14:28:41 -07001179 goto free_rproc;
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +05301180 }
1181 qproc->proxy_clk_count = ret;
1182
Sibi Sankar231f67d2018-05-21 22:57:13 +05301183 ret = q6v5_init_clocks(&pdev->dev, qproc->reset_clks,
1184 desc->reset_clk_names);
1185 if (ret < 0) {
1186 dev_err(&pdev->dev, "Failed to get reset clocks.\n");
1187 goto free_rproc;
1188 }
1189 qproc->reset_clk_count = ret;
1190
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +05301191 ret = q6v5_init_clocks(&pdev->dev, qproc->active_clks,
1192 desc->active_clk_names);
1193 if (ret < 0) {
1194 dev_err(&pdev->dev, "Failed to get active clocks.\n");
1195 goto free_rproc;
1196 }
1197 qproc->active_clk_count = ret;
Bjorn Andersson051fb702016-06-20 14:28:41 -07001198
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +05301199 ret = q6v5_regulator_init(&pdev->dev, qproc->proxy_regs,
1200 desc->proxy_supply);
1201 if (ret < 0) {
1202 dev_err(&pdev->dev, "Failed to get proxy regulators.\n");
Bjorn Andersson051fb702016-06-20 14:28:41 -07001203 goto free_rproc;
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +05301204 }
1205 qproc->proxy_reg_count = ret;
1206
1207 ret = q6v5_regulator_init(&pdev->dev, qproc->active_regs,
1208 desc->active_supply);
1209 if (ret < 0) {
1210 dev_err(&pdev->dev, "Failed to get active regulators.\n");
1211 goto free_rproc;
1212 }
1213 qproc->active_reg_count = ret;
Bjorn Andersson051fb702016-06-20 14:28:41 -07001214
Sibi Sankar29a5f9a2018-08-30 00:42:15 +05301215 qproc->has_alt_reset = desc->has_alt_reset;
Bjorn Andersson051fb702016-06-20 14:28:41 -07001216 ret = q6v5_init_reset(qproc);
1217 if (ret)
1218 goto free_rproc;
1219
Avaneesh Kumar Dwivedi9f058fa2017-10-24 21:22:27 +05301220 qproc->version = desc->version;
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +05301221 qproc->need_mem_protection = desc->need_mem_protection;
Bjorn Andersson7d674732018-06-04 13:30:38 -07001222
1223 ret = qcom_q6v5_init(&qproc->q6v5, pdev, rproc, MPSS_CRASH_REASON_SMEM,
1224 qcom_msa_handover);
1225 if (ret)
Bjorn Andersson051fb702016-06-20 14:28:41 -07001226 goto free_rproc;
1227
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +05301228 qproc->mpss_perm = BIT(QCOM_SCM_VMID_HLOS);
1229 qproc->mba_perm = BIT(QCOM_SCM_VMID_HLOS);
Sibi Sankar47254962018-05-21 22:57:14 +05301230 qcom_add_glink_subdev(rproc, &qproc->glink_subdev);
Bjorn Andersson4b489212017-01-29 14:05:50 -08001231 qcom_add_smd_subdev(rproc, &qproc->smd_subdev);
Bjorn Andersson1e140df2017-07-24 22:56:43 -07001232 qcom_add_ssr_subdev(rproc, &qproc->ssr_subdev, "mpss");
Bjorn Andersson1fb82ee2017-08-27 21:51:38 -07001233 qproc->sysmon = qcom_add_sysmon_subdev(rproc, "modem", 0x12);
Bjorn Andersson4b489212017-01-29 14:05:50 -08001234
Bjorn Andersson051fb702016-06-20 14:28:41 -07001235 ret = rproc_add(rproc);
1236 if (ret)
1237 goto free_rproc;
1238
1239 return 0;
1240
1241free_rproc:
Bjorn Andersson433c0e02016-10-02 17:46:38 -07001242 rproc_free(rproc);
Bjorn Andersson051fb702016-06-20 14:28:41 -07001243
1244 return ret;
1245}
1246
1247static int q6v5_remove(struct platform_device *pdev)
1248{
1249 struct q6v5 *qproc = platform_get_drvdata(pdev);
1250
1251 rproc_del(qproc->rproc);
Bjorn Andersson4b489212017-01-29 14:05:50 -08001252
Bjorn Andersson1fb82ee2017-08-27 21:51:38 -07001253 qcom_remove_sysmon_subdev(qproc->sysmon);
Sibi Sankar47254962018-05-21 22:57:14 +05301254 qcom_remove_glink_subdev(qproc->rproc, &qproc->glink_subdev);
Bjorn Andersson4b489212017-01-29 14:05:50 -08001255 qcom_remove_smd_subdev(qproc->rproc, &qproc->smd_subdev);
Bjorn Andersson1e140df2017-07-24 22:56:43 -07001256 qcom_remove_ssr_subdev(qproc->rproc, &qproc->ssr_subdev);
Bjorn Andersson433c0e02016-10-02 17:46:38 -07001257 rproc_free(qproc->rproc);
Bjorn Andersson051fb702016-06-20 14:28:41 -07001258
1259 return 0;
1260}
1261
Sibi Sankar231f67d2018-05-21 22:57:13 +05301262static const struct rproc_hexagon_res sdm845_mss = {
1263 .hexagon_mba_image = "mba.mbn",
1264 .proxy_clk_names = (char*[]){
1265 "xo",
Sibi Sankar231f67d2018-05-21 22:57:13 +05301266 "prng",
1267 NULL
1268 },
1269 .reset_clk_names = (char*[]){
1270 "iface",
1271 "snoc_axi",
1272 NULL
1273 },
1274 .active_clk_names = (char*[]){
1275 "bus",
1276 "mem",
1277 "gpll0_mss",
1278 "mnoc_axi",
1279 NULL
1280 },
1281 .need_mem_protection = true,
1282 .has_alt_reset = true,
1283 .version = MSS_SDM845,
1284};
1285
Avaneesh Kumar Dwivedi9f058fa2017-10-24 21:22:27 +05301286static const struct rproc_hexagon_res msm8996_mss = {
1287 .hexagon_mba_image = "mba.mbn",
1288 .proxy_clk_names = (char*[]){
1289 "xo",
1290 "pnoc",
1291 NULL
1292 },
1293 .active_clk_names = (char*[]){
1294 "iface",
1295 "bus",
1296 "mem",
1297 "gpll0_mss_clk",
1298 NULL
1299 },
1300 .need_mem_protection = true,
Sibi Sankar231f67d2018-05-21 22:57:13 +05301301 .has_alt_reset = false,
Avaneesh Kumar Dwivedi9f058fa2017-10-24 21:22:27 +05301302 .version = MSS_MSM8996,
1303};
1304
Avaneesh Kumar Dwivedi7a8ffe12016-12-30 19:24:00 +05301305static const struct rproc_hexagon_res msm8916_mss = {
1306 .hexagon_mba_image = "mba.mbn",
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +05301307 .proxy_supply = (struct qcom_mss_reg_res[]) {
1308 {
1309 .supply = "mx",
1310 .uV = 1050000,
1311 },
1312 {
1313 .supply = "cx",
1314 .uA = 100000,
1315 },
1316 {
1317 .supply = "pll",
1318 .uA = 100000,
1319 },
1320 {}
1321 },
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +05301322 .proxy_clk_names = (char*[]){
1323 "xo",
1324 NULL
1325 },
1326 .active_clk_names = (char*[]){
1327 "iface",
1328 "bus",
1329 "mem",
1330 NULL
1331 },
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +05301332 .need_mem_protection = false,
Sibi Sankar231f67d2018-05-21 22:57:13 +05301333 .has_alt_reset = false,
Avaneesh Kumar Dwivedi9f058fa2017-10-24 21:22:27 +05301334 .version = MSS_MSM8916,
Avaneesh Kumar Dwivedi7a8ffe12016-12-30 19:24:00 +05301335};
1336
1337static const struct rproc_hexagon_res msm8974_mss = {
1338 .hexagon_mba_image = "mba.b00",
Avaneesh Kumar Dwivedi19f902b2016-12-30 19:24:02 +05301339 .proxy_supply = (struct qcom_mss_reg_res[]) {
1340 {
1341 .supply = "mx",
1342 .uV = 1050000,
1343 },
1344 {
1345 .supply = "cx",
1346 .uA = 100000,
1347 },
1348 {
1349 .supply = "pll",
1350 .uA = 100000,
1351 },
1352 {}
1353 },
1354 .active_supply = (struct qcom_mss_reg_res[]) {
1355 {
1356 .supply = "mss",
1357 .uV = 1050000,
1358 .uA = 100000,
1359 },
1360 {}
1361 },
Avaneesh Kumar Dwivedi39b24102016-12-30 19:24:01 +05301362 .proxy_clk_names = (char*[]){
1363 "xo",
1364 NULL
1365 },
1366 .active_clk_names = (char*[]){
1367 "iface",
1368 "bus",
1369 "mem",
1370 NULL
1371 },
Avaneesh Kumar Dwivedi6c5a9dc2017-10-24 21:22:26 +05301372 .need_mem_protection = false,
Sibi Sankar231f67d2018-05-21 22:57:13 +05301373 .has_alt_reset = false,
Avaneesh Kumar Dwivedi9f058fa2017-10-24 21:22:27 +05301374 .version = MSS_MSM8974,
Avaneesh Kumar Dwivedi7a8ffe12016-12-30 19:24:00 +05301375};
1376
Bjorn Andersson051fb702016-06-20 14:28:41 -07001377static const struct of_device_id q6v5_of_match[] = {
Avaneesh Kumar Dwivedi7a8ffe12016-12-30 19:24:00 +05301378 { .compatible = "qcom,q6v5-pil", .data = &msm8916_mss},
1379 { .compatible = "qcom,msm8916-mss-pil", .data = &msm8916_mss},
1380 { .compatible = "qcom,msm8974-mss-pil", .data = &msm8974_mss},
Avaneesh Kumar Dwivedi9f058fa2017-10-24 21:22:27 +05301381 { .compatible = "qcom,msm8996-mss-pil", .data = &msm8996_mss},
Sibi Sankar231f67d2018-05-21 22:57:13 +05301382 { .compatible = "qcom,sdm845-mss-pil", .data = &sdm845_mss},
Bjorn Andersson051fb702016-06-20 14:28:41 -07001383 { },
1384};
Javier Martinez Canillas3227c872016-10-18 18:24:19 -03001385MODULE_DEVICE_TABLE(of, q6v5_of_match);
Bjorn Andersson051fb702016-06-20 14:28:41 -07001386
1387static struct platform_driver q6v5_driver = {
1388 .probe = q6v5_probe,
1389 .remove = q6v5_remove,
1390 .driver = {
Bjorn Anderssonef73c222018-09-24 16:45:26 -07001391 .name = "qcom-q6v5-mss",
Bjorn Andersson051fb702016-06-20 14:28:41 -07001392 .of_match_table = q6v5_of_match,
1393 },
1394};
1395module_platform_driver(q6v5_driver);
1396
Bjorn Anderssonef73c222018-09-24 16:45:26 -07001397MODULE_DESCRIPTION("Qualcomm Self-authenticating modem remoteproc driver");
Bjorn Andersson051fb702016-06-20 14:28:41 -07001398MODULE_LICENSE("GPL v2");