Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1 | /* |
Bjorn Andersson | ef73c22 | 2018-09-24 16:45:26 -0700 | [diff] [blame] | 2 | * Qualcomm self-authenticating modem subsystem remoteproc driver |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 3 | * |
| 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 Dwivedi | 7a8ffe1 | 2016-12-30 19:24:00 +0530 | [diff] [blame] | 26 | #include <linux/of_device.h> |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 27 | #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 Andersson | 2aad40d | 2017-01-27 03:12:57 -0800 | [diff] [blame] | 32 | #include <linux/soc/qcom/mdt_loader.h> |
Avaneesh Kumar Dwivedi | 9f058fa | 2017-10-24 21:22:27 +0530 | [diff] [blame] | 33 | #include <linux/iopoll.h> |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 34 | |
| 35 | #include "remoteproc_internal.h" |
Bjorn Andersson | bde440e | 2017-01-27 02:28:32 -0800 | [diff] [blame] | 36 | #include "qcom_common.h" |
Bjorn Andersson | 7d67473 | 2018-06-04 13:30:38 -0700 | [diff] [blame] | 37 | #include "qcom_q6v5.h" |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 38 | |
| 39 | #include <linux/qcom_scm.h> |
| 40 | |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 41 | #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 Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 59 | #define RMB_MBA_MSS_STATUS 0x40 |
| 60 | #define RMB_MBA_ALT_RESET 0x44 |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 61 | |
| 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 Dwivedi | 9f058fa | 2017-10-24 21:22:27 +0530 | [diff] [blame] | 69 | #define QDSP6SS_MEM_PWR_CTL 0x0B0 |
| 70 | #define QDSP6SS_STRAP_ACC 0x110 |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 71 | |
| 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 Dwivedi | 9f058fa | 2017-10-24 21:22:27 +0530 | [diff] [blame] | 99 | /* 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 Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 108 | /* 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 Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 115 | struct reg_info { |
| 116 | struct regulator *reg; |
| 117 | int uV; |
| 118 | int uA; |
| 119 | }; |
| 120 | |
| 121 | struct qcom_mss_reg_res { |
| 122 | const char *supply; |
| 123 | int uV; |
| 124 | int uA; |
| 125 | }; |
| 126 | |
Avaneesh Kumar Dwivedi | 7a8ffe1 | 2016-12-30 19:24:00 +0530 | [diff] [blame] | 127 | struct rproc_hexagon_res { |
| 128 | const char *hexagon_mba_image; |
Arnd Bergmann | ec671b5 | 2017-02-01 17:56:28 +0100 | [diff] [blame] | 129 | struct qcom_mss_reg_res *proxy_supply; |
| 130 | struct qcom_mss_reg_res *active_supply; |
Avaneesh Kumar Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 131 | char **proxy_clk_names; |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 132 | char **reset_clk_names; |
Avaneesh Kumar Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 133 | char **active_clk_names; |
Avaneesh Kumar Dwivedi | 9f058fa | 2017-10-24 21:22:27 +0530 | [diff] [blame] | 134 | int version; |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 135 | bool need_mem_protection; |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 136 | bool has_alt_reset; |
Avaneesh Kumar Dwivedi | 7a8ffe1 | 2016-12-30 19:24:00 +0530 | [diff] [blame] | 137 | }; |
| 138 | |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 139 | struct 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 Sankar | 29a5f9a | 2018-08-30 00:42:15 +0530 | [diff] [blame] | 152 | struct reset_control *pdc_reset; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 153 | |
Bjorn Andersson | 7d67473 | 2018-06-04 13:30:38 -0700 | [diff] [blame] | 154 | struct qcom_q6v5 q6v5; |
Sibi Sankar | 663e984 | 2018-05-21 22:57:09 +0530 | [diff] [blame] | 155 | |
Avaneesh Kumar Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 156 | struct clk *active_clks[8]; |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 157 | struct clk *reset_clks[4]; |
Avaneesh Kumar Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 158 | struct clk *proxy_clks[4]; |
| 159 | int active_clk_count; |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 160 | int reset_clk_count; |
Avaneesh Kumar Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 161 | int proxy_clk_count; |
| 162 | |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 163 | struct reg_info active_regs[1]; |
| 164 | struct reg_info proxy_regs[3]; |
| 165 | int active_reg_count; |
| 166 | int proxy_reg_count; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 167 | |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 168 | 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 Andersson | 4b48921 | 2017-01-29 14:05:50 -0800 | [diff] [blame] | 178 | |
Sibi Sankar | 4725496 | 2018-05-21 22:57:14 +0530 | [diff] [blame] | 179 | struct qcom_rproc_glink glink_subdev; |
Bjorn Andersson | 4b48921 | 2017-01-29 14:05:50 -0800 | [diff] [blame] | 180 | struct qcom_rproc_subdev smd_subdev; |
Bjorn Andersson | 1e140df | 2017-07-24 22:56:43 -0700 | [diff] [blame] | 181 | struct qcom_rproc_ssr ssr_subdev; |
Bjorn Andersson | 1fb82ee | 2017-08-27 21:51:38 -0700 | [diff] [blame] | 182 | struct qcom_sysmon *sysmon; |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 183 | bool need_mem_protection; |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 184 | bool has_alt_reset; |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 185 | int mpss_perm; |
| 186 | int mba_perm; |
Avaneesh Kumar Dwivedi | 9f058fa | 2017-10-24 21:22:27 +0530 | [diff] [blame] | 187 | int version; |
| 188 | }; |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 189 | |
Avaneesh Kumar Dwivedi | 9f058fa | 2017-10-24 21:22:27 +0530 | [diff] [blame] | 190 | enum { |
| 191 | MSS_MSM8916, |
| 192 | MSS_MSM8974, |
| 193 | MSS_MSM8996, |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 194 | MSS_SDM845, |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 195 | }; |
| 196 | |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 197 | static int q6v5_regulator_init(struct device *dev, struct reg_info *regs, |
| 198 | const struct qcom_mss_reg_res *reg_res) |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 199 | { |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 200 | int rc; |
| 201 | int i; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 202 | |
Bjorn Andersson | 2bb5d90 | 2017-01-30 03:20:27 -0800 | [diff] [blame] | 203 | if (!reg_res) |
| 204 | return 0; |
| 205 | |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 206 | 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 215 | |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 216 | regs[i].uV = reg_res[i].uV; |
| 217 | regs[i].uA = reg_res[i].uA; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 218 | } |
| 219 | |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 220 | return i; |
| 221 | } |
| 222 | |
| 223 | static 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 257 | |
| 258 | return 0; |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 259 | err: |
| 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 271 | } |
| 272 | |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 273 | static void q6v5_regulator_disable(struct q6v5 *qproc, |
| 274 | struct reg_info *regs, int count) |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 275 | { |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 276 | int i; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 277 | |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 278 | for (i = 0; i < count; i++) { |
| 279 | if (regs[i].uV > 0) |
| 280 | regulator_set_voltage(regs[i].reg, 0, INT_MAX); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 281 | |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 282 | if (regs[i].uA > 0) |
| 283 | regulator_set_load(regs[i].reg, 0); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 284 | |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 285 | regulator_disable(regs[i].reg); |
| 286 | } |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 287 | } |
| 288 | |
Avaneesh Kumar Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 289 | static 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; |
| 304 | err: |
| 305 | for (i--; i >= 0; i--) |
| 306 | clk_disable_unprepare(clks[i]); |
| 307 | |
| 308 | return rc; |
| 309 | } |
| 310 | |
| 311 | static 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 Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 320 | static 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 Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 325 | |
| 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 Andersson | 9f2a434 | 2017-11-06 22:26:41 -0800 | [diff] [blame] | 336 | return qcom_scm_assign_mem(addr, ALIGN(size, SZ_4K), |
| 337 | current_perm, &next, 1); |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 338 | } |
| 339 | |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 340 | static 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 Sankar | 9f135fa | 2018-05-21 22:57:12 +0530 | [diff] [blame] | 349 | static int q6v5_reset_assert(struct q6v5 *qproc) |
| 350 | { |
Sibi Sankar | 29a5f9a | 2018-08-30 00:42:15 +0530 | [diff] [blame] | 351 | 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 Sankar | 9f135fa | 2018-05-21 22:57:12 +0530 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | static int q6v5_reset_deassert(struct q6v5 *qproc) |
| 365 | { |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 366 | int ret; |
| 367 | |
| 368 | if (qproc->has_alt_reset) { |
Sibi Sankar | 29a5f9a | 2018-08-30 00:42:15 +0530 | [diff] [blame] | 369 | reset_control_assert(qproc->pdc_reset); |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 370 | 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 Sankar | 29a5f9a | 2018-08-30 00:42:15 +0530 | [diff] [blame] | 373 | reset_control_deassert(qproc->pdc_reset); |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 374 | } else { |
| 375 | ret = reset_control_deassert(qproc->mss_restart); |
| 376 | } |
| 377 | |
| 378 | return ret; |
Sibi Sankar | 9f135fa | 2018-05-21 22:57:12 +0530 | [diff] [blame] | 379 | } |
| 380 | |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 381 | static 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 | |
| 401 | static 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 | |
| 427 | static int q6v5proc_reset(struct q6v5 *qproc) |
| 428 | { |
| 429 | u32 val; |
| 430 | int ret; |
Avaneesh Kumar Dwivedi | 9f058fa | 2017-10-24 21:22:27 +0530 | [diff] [blame] | 431 | int i; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 432 | |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 433 | 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 437 | |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 438 | 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 Dwivedi | 9f058fa | 2017-10-24 21:22:27 +0530 | [diff] [blame] | 462 | /* Override the ACC value if required */ |
| 463 | writel(QDSP6SS_ACC_OVERRIDE_VAL, |
| 464 | qproc->reg_base + QDSP6SS_STRAP_ACC); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 465 | |
Avaneesh Kumar Dwivedi | 9f058fa | 2017-10-24 21:22:27 +0530 | [diff] [blame] | 466 | /* 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 470 | |
Avaneesh Kumar Dwivedi | 9f058fa | 2017-10-24 21:22:27 +0530 | [diff] [blame] | 471 | /* 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 550 | /* 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 Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 569 | pbl_wait: |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 570 | /* 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 | |
| 584 | static 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 | |
| 618 | static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw) |
| 619 | { |
Krzysztof Kozlowski | 00085f1 | 2016-08-03 13:46:00 -0700 | [diff] [blame] | 620 | unsigned long dma_attrs = DMA_ATTR_FORCE_CONTIGUOUS; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 621 | dma_addr_t phys; |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 622 | int mdata_perm; |
| 623 | int xferop_ret; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 624 | void *ptr; |
| 625 | int ret; |
| 626 | |
Krzysztof Kozlowski | 00085f1 | 2016-08-03 13:46:00 -0700 | [diff] [blame] | 627 | ptr = dma_alloc_attrs(qproc->dev, fw->size, &phys, GFP_KERNEL, dma_attrs); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 628 | 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 Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 635 | /* 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 Andersson | 9f2a434 | 2017-11-06 22:26:41 -0800 | [diff] [blame] | 639 | if (ret) { |
| 640 | dev_err(qproc->dev, |
| 641 | "assigning Q6 access to metadata failed: %d\n", ret); |
Christophe JAILLET | 1a5d5c5 | 2017-11-15 07:58:35 +0100 | [diff] [blame] | 642 | ret = -EAGAIN; |
| 643 | goto free_dma_attrs; |
Bjorn Andersson | 9f2a434 | 2017-11-06 22:26:41 -0800 | [diff] [blame] | 644 | } |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 645 | |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 646 | 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 Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 655 | /* 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 JAILLET | 1a5d5c5 | 2017-11-15 07:58:35 +0100 | [diff] [blame] | 662 | free_dma_attrs: |
Krzysztof Kozlowski | 00085f1 | 2016-08-03 13:46:00 -0700 | [diff] [blame] | 663 | dma_free_attrs(qproc->dev, fw->size, ptr, phys, dma_attrs); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 664 | |
| 665 | return ret < 0 ? ret : 0; |
| 666 | } |
| 667 | |
Bjorn Andersson | e7fd252 | 2017-01-26 13:58:35 -0800 | [diff] [blame] | 668 | static 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 | |
| 682 | static int q6v5_mpss_load(struct q6v5 *qproc) |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 683 | { |
| 684 | const struct elf32_phdr *phdrs; |
| 685 | const struct elf32_phdr *phdr; |
Bjorn Andersson | e7fd252 | 2017-01-26 13:58:35 -0800 | [diff] [blame] | 686 | const struct firmware *seg_fw; |
| 687 | const struct firmware *fw; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 688 | struct elf32_hdr *ehdr; |
Bjorn Andersson | e7fd252 | 2017-01-26 13:58:35 -0800 | [diff] [blame] | 689 | phys_addr_t mpss_reloc; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 690 | phys_addr_t boot_addr; |
Stefan Agner | d7dc899 | 2018-06-14 15:28:02 -0700 | [diff] [blame] | 691 | phys_addr_t min_addr = PHYS_ADDR_MAX; |
Bjorn Andersson | e7fd252 | 2017-01-26 13:58:35 -0800 | [diff] [blame] | 692 | phys_addr_t max_addr = 0; |
| 693 | bool relocate = false; |
| 694 | char seg_name[10]; |
Bjorn Andersson | 01625cc5 | 2017-02-15 14:00:41 -0800 | [diff] [blame] | 695 | ssize_t offset; |
Avaneesh Kumar Dwivedi | 94c9078 | 2017-10-24 21:22:25 +0530 | [diff] [blame] | 696 | size_t size = 0; |
Bjorn Andersson | e7fd252 | 2017-01-26 13:58:35 -0800 | [diff] [blame] | 697 | void *ptr; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 698 | int ret; |
| 699 | int i; |
| 700 | |
Bjorn Andersson | e7fd252 | 2017-01-26 13:58:35 -0800 | [diff] [blame] | 701 | ret = request_firmware(&fw, "modem.mdt", qproc->dev); |
| 702 | if (ret < 0) { |
| 703 | dev_err(qproc->dev, "unable to load modem.mdt\n"); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 704 | return ret; |
| 705 | } |
| 706 | |
Bjorn Andersson | e7fd252 | 2017-01-26 13:58:35 -0800 | [diff] [blame] | 707 | /* 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 713 | |
| 714 | ehdr = (struct elf32_hdr *)fw->data; |
| 715 | phdrs = (struct elf32_phdr *)(ehdr + 1); |
Bjorn Andersson | e7fd252 | 2017-01-26 13:58:35 -0800 | [diff] [blame] | 716 | |
| 717 | for (i = 0; i < ehdr->e_phnum; i++) { |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 718 | phdr = &phdrs[i]; |
| 719 | |
Bjorn Andersson | e7fd252 | 2017-01-26 13:58:35 -0800 | [diff] [blame] | 720 | if (!q6v5_phdr_valid(phdr)) |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 721 | continue; |
| 722 | |
Bjorn Andersson | e7fd252 | 2017-01-26 13:58:35 -0800 | [diff] [blame] | 723 | 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 Sankar | 3bf62eb | 2018-07-27 20:50:03 +0530 | [diff] [blame^] | 734 | qproc->mpss_reloc = mpss_reloc; |
Avaneesh Kumar Dwivedi | 94c9078 | 2017-10-24 21:22:25 +0530 | [diff] [blame] | 735 | /* Load firmware segments */ |
Bjorn Andersson | e7fd252 | 2017-01-26 13:58:35 -0800 | [diff] [blame] | 736 | for (i = 0; i < ehdr->e_phnum; i++) { |
| 737 | phdr = &phdrs[i]; |
| 738 | |
| 739 | if (!q6v5_phdr_valid(phdr)) |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 740 | continue; |
| 741 | |
Bjorn Andersson | e7fd252 | 2017-01-26 13:58:35 -0800 | [diff] [blame] | 742 | 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 768 | size += phdr->p_memsz; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 769 | } |
| 770 | |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 771 | /* 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 Andersson | 9f2a434 | 2017-11-06 22:26:41 -0800 | [diff] [blame] | 774 | if (ret) { |
| 775 | dev_err(qproc->dev, |
| 776 | "assigning Q6 access to mpss memory failed: %d\n", ret); |
Christophe JAILLET | 1a5d5c5 | 2017-11-15 07:58:35 +0100 | [diff] [blame] | 777 | ret = -EAGAIN; |
| 778 | goto release_firmware; |
Bjorn Andersson | 9f2a434 | 2017-11-06 22:26:41 -0800 | [diff] [blame] | 779 | } |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 780 | |
Avaneesh Kumar Dwivedi | 94c9078 | 2017-10-24 21:22:25 +0530 | [diff] [blame] | 781 | 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 Andersson | 72beb49 | 2016-07-12 17:15:45 -0700 | [diff] [blame] | 786 | 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 792 | release_firmware: |
| 793 | release_firmware(fw); |
| 794 | |
| 795 | return ret < 0 ? ret : 0; |
| 796 | } |
| 797 | |
| 798 | static int q6v5_start(struct rproc *rproc) |
| 799 | { |
| 800 | struct q6v5 *qproc = (struct q6v5 *)rproc->priv; |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 801 | int xfermemop_ret; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 802 | int ret; |
| 803 | |
Bjorn Andersson | 7d67473 | 2018-06-04 13:30:38 -0700 | [diff] [blame] | 804 | qcom_q6v5_prepare(&qproc->q6v5); |
Sibi Sankar | 663e984 | 2018-05-21 22:57:09 +0530 | [diff] [blame] | 805 | |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 806 | ret = q6v5_regulator_enable(qproc, qproc->proxy_regs, |
| 807 | qproc->proxy_reg_count); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 808 | if (ret) { |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 809 | dev_err(qproc->dev, "failed to enable proxy supplies\n"); |
Sibi Sankar | 663e984 | 2018-05-21 22:57:09 +0530 | [diff] [blame] | 810 | goto disable_irqs; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 811 | } |
| 812 | |
Avaneesh Kumar Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 813 | 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 Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 817 | 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 Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 825 | } |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 826 | |
| 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 Sankar | 9f135fa | 2018-05-21 22:57:12 +0530 | [diff] [blame] | 834 | ret = q6v5_reset_deassert(qproc); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 835 | if (ret) { |
| 836 | dev_err(qproc->dev, "failed to deassert mss restart\n"); |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 837 | goto disable_reset_clks; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 838 | } |
| 839 | |
Avaneesh Kumar Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 840 | 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 844 | goto assert_reset; |
Avaneesh Kumar Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 845 | } |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 846 | |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 847 | /* Assign MBA image access in DDR to q6 */ |
Sibi Sankar | 2724807 | 2018-04-18 01:14:15 +0530 | [diff] [blame] | 848 | ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true, |
| 849 | qproc->mba_phys, qproc->mba_size); |
| 850 | if (ret) { |
Bjorn Andersson | 9f2a434 | 2017-11-06 22:26:41 -0800 | [diff] [blame] | 851 | dev_err(qproc->dev, |
Sibi Sankar | 2724807 | 2018-04-18 01:14:15 +0530 | [diff] [blame] | 852 | "assigning Q6 access to mba memory failed: %d\n", ret); |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 853 | goto disable_active_clks; |
Bjorn Andersson | 9f2a434 | 2017-11-06 22:26:41 -0800 | [diff] [blame] | 854 | } |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 855 | |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 856 | writel(qproc->mba_phys, qproc->rmb_base + RMB_MBA_IMAGE_REG); |
| 857 | |
| 858 | ret = q6v5proc_reset(qproc); |
| 859 | if (ret) |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 860 | goto reclaim_mba; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 861 | |
| 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 Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 877 | goto reclaim_mpss; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 878 | |
Bjorn Andersson | 7d67473 | 2018-06-04 13:30:38 -0700 | [diff] [blame] | 879 | ret = qcom_q6v5_wait_for_start(&qproc->q6v5, msecs_to_jiffies(5000)); |
| 880 | if (ret == -ETIMEDOUT) { |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 881 | dev_err(qproc->dev, "start timed out\n"); |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 882 | goto reclaim_mpss; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 883 | } |
| 884 | |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 885 | 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 891 | qproc->running = true; |
| 892 | |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 893 | return 0; |
| 894 | |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 895 | reclaim_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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 901 | halt_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 Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 905 | |
| 906 | reclaim_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 | |
| 915 | disable_active_clks: |
Avaneesh Kumar Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 916 | q6v5_clk_disable(qproc->dev, qproc->active_clks, |
| 917 | qproc->active_clk_count); |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 918 | |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 919 | assert_reset: |
Sibi Sankar | 9f135fa | 2018-05-21 22:57:12 +0530 | [diff] [blame] | 920 | q6v5_reset_assert(qproc); |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 921 | disable_reset_clks: |
| 922 | q6v5_clk_disable(qproc->dev, qproc->reset_clks, |
| 923 | qproc->reset_clk_count); |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 924 | disable_vdd: |
| 925 | q6v5_regulator_disable(qproc, qproc->active_regs, |
| 926 | qproc->active_reg_count); |
Avaneesh Kumar Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 927 | disable_proxy_clk: |
| 928 | q6v5_clk_disable(qproc->dev, qproc->proxy_clks, |
| 929 | qproc->proxy_clk_count); |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 930 | disable_proxy_reg: |
| 931 | q6v5_regulator_disable(qproc, qproc->proxy_regs, |
| 932 | qproc->proxy_reg_count); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 933 | |
Sibi Sankar | 663e984 | 2018-05-21 22:57:09 +0530 | [diff] [blame] | 934 | disable_irqs: |
Bjorn Andersson | 7d67473 | 2018-06-04 13:30:38 -0700 | [diff] [blame] | 935 | qcom_q6v5_unprepare(&qproc->q6v5); |
Sibi Sankar | 663e984 | 2018-05-21 22:57:09 +0530 | [diff] [blame] | 936 | |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 937 | return ret; |
| 938 | } |
| 939 | |
| 940 | static int q6v5_stop(struct rproc *rproc) |
| 941 | { |
| 942 | struct q6v5 *qproc = (struct q6v5 *)rproc->priv; |
| 943 | int ret; |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 944 | u32 val; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 945 | |
| 946 | qproc->running = false; |
| 947 | |
Bjorn Andersson | 7d67473 | 2018-06-04 13:30:38 -0700 | [diff] [blame] | 948 | ret = qcom_q6v5_request_stop(&qproc->q6v5); |
| 949 | if (ret == -ETIMEDOUT) |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 950 | dev_err(qproc->dev, "timed out on wait\n"); |
| 951 | |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 952 | 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 Dwivedi | 9f058fa | 2017-10-24 21:22:27 +0530 | [diff] [blame] | 955 | 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 965 | |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 966 | ret = q6v5_xfer_mem_ownership(qproc, &qproc->mpss_perm, false, |
| 967 | qproc->mpss_phys, qproc->mpss_size); |
| 968 | WARN_ON(ret); |
| 969 | |
Sibi Sankar | 9f135fa | 2018-05-21 22:57:12 +0530 | [diff] [blame] | 970 | q6v5_reset_assert(qproc); |
Sibi Sankar | 663e984 | 2018-05-21 22:57:09 +0530 | [diff] [blame] | 971 | |
Bjorn Andersson | 7d67473 | 2018-06-04 13:30:38 -0700 | [diff] [blame] | 972 | ret = qcom_q6v5_unprepare(&qproc->q6v5); |
| 973 | if (ret) { |
Sibi Sankar | 663e984 | 2018-05-21 22:57:09 +0530 | [diff] [blame] | 974 | 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 Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 980 | q6v5_clk_disable(qproc->dev, qproc->reset_clks, |
| 981 | qproc->reset_clk_count); |
Avaneesh Kumar Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 982 | q6v5_clk_disable(qproc->dev, qproc->active_clks, |
| 983 | qproc->active_clk_count); |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 984 | q6v5_regulator_disable(qproc, qproc->active_regs, |
| 985 | qproc->active_reg_count); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 986 | |
| 987 | return 0; |
| 988 | } |
| 989 | |
| 990 | static 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 | |
| 1002 | static const struct rproc_ops q6v5_ops = { |
| 1003 | .start = q6v5_start, |
| 1004 | .stop = q6v5_stop, |
| 1005 | .da_to_va = q6v5_da_to_va, |
Bjorn Andersson | 0f21f9c | 2018-01-05 15:58:01 -0800 | [diff] [blame] | 1006 | .load = q6v5_load, |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1007 | }; |
| 1008 | |
Bjorn Andersson | 7d67473 | 2018-06-04 13:30:38 -0700 | [diff] [blame] | 1009 | static void qcom_msa_handover(struct qcom_q6v5 *q6v5) |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1010 | { |
Bjorn Andersson | 7d67473 | 2018-06-04 13:30:38 -0700 | [diff] [blame] | 1011 | struct q6v5 *qproc = container_of(q6v5, struct q6v5, q6v5); |
Sibi Sankar | 663e984 | 2018-05-21 22:57:09 +0530 | [diff] [blame] | 1012 | |
| 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1017 | } |
| 1018 | |
| 1019 | static 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 Yongjun | b1653f2 | 2016-07-14 12:57:44 +0000 | [diff] [blame] | 1027 | if (IS_ERR(qproc->reg_base)) |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1028 | return PTR_ERR(qproc->reg_base); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1029 | |
| 1030 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rmb"); |
| 1031 | qproc->rmb_base = devm_ioremap_resource(&pdev->dev, res); |
Wei Yongjun | b1653f2 | 2016-07-14 12:57:44 +0000 | [diff] [blame] | 1032 | if (IS_ERR(qproc->rmb_base)) |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1033 | return PTR_ERR(qproc->rmb_base); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1034 | |
| 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 Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 1054 | static int q6v5_init_clocks(struct device *dev, struct clk **clks, |
| 1055 | char **clk_names) |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1056 | { |
Avaneesh Kumar Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 1057 | 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1072 | } |
| 1073 | |
Avaneesh Kumar Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 1074 | return i; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1075 | } |
| 1076 | |
| 1077 | static int q6v5_init_reset(struct q6v5 *qproc) |
| 1078 | { |
Philipp Zabel | 5acbf7e | 2017-07-19 17:26:16 +0200 | [diff] [blame] | 1079 | qproc->mss_restart = devm_reset_control_get_exclusive(qproc->dev, |
Sibi Sankar | 9e483ef | 2018-08-30 00:42:14 +0530 | [diff] [blame] | 1080 | "mss_restart"); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1081 | 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 Sankar | 29a5f9a | 2018-08-30 00:42:15 +0530 | [diff] [blame] | 1086 | 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1095 | return 0; |
| 1096 | } |
| 1097 | |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1098 | static 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 Jordan | 278d744 | 2018-02-15 16:12:55 +0100 | [diff] [blame] | 1112 | of_node_put(node); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1113 | |
| 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 Jordan | 278d744 | 2018-02-15 16:12:55 +0100 | [diff] [blame] | 1130 | of_node_put(node); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1131 | |
| 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 | |
| 1144 | static int q6v5_probe(struct platform_device *pdev) |
| 1145 | { |
Avaneesh Kumar Dwivedi | 7a8ffe1 | 2016-12-30 19:24:00 +0530 | [diff] [blame] | 1146 | const struct rproc_hexagon_res *desc; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1147 | struct q6v5 *qproc; |
| 1148 | struct rproc *rproc; |
| 1149 | int ret; |
| 1150 | |
Avaneesh Kumar Dwivedi | 7a8ffe1 | 2016-12-30 19:24:00 +0530 | [diff] [blame] | 1151 | desc = of_device_get_match_data(&pdev->dev); |
| 1152 | if (!desc) |
| 1153 | return -EINVAL; |
| 1154 | |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1155 | rproc = rproc_alloc(&pdev->dev, pdev->name, &q6v5_ops, |
Avaneesh Kumar Dwivedi | 7a8ffe1 | 2016-12-30 19:24:00 +0530 | [diff] [blame] | 1156 | desc->hexagon_mba_image, sizeof(*qproc)); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1157 | if (!rproc) { |
| 1158 | dev_err(&pdev->dev, "failed to allocate rproc\n"); |
| 1159 | return -ENOMEM; |
| 1160 | } |
| 1161 | |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1162 | qproc = (struct q6v5 *)rproc->priv; |
| 1163 | qproc->dev = &pdev->dev; |
| 1164 | qproc->rproc = rproc; |
| 1165 | platform_set_drvdata(pdev, qproc); |
| 1166 | |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1167 | 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 Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 1175 | 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1179 | goto free_rproc; |
Avaneesh Kumar Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 1180 | } |
| 1181 | qproc->proxy_clk_count = ret; |
| 1182 | |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 1183 | 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 Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 1191 | 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1198 | |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 1199 | 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1203 | goto free_rproc; |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 1204 | } |
| 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 Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1214 | |
Sibi Sankar | 29a5f9a | 2018-08-30 00:42:15 +0530 | [diff] [blame] | 1215 | qproc->has_alt_reset = desc->has_alt_reset; |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1216 | ret = q6v5_init_reset(qproc); |
| 1217 | if (ret) |
| 1218 | goto free_rproc; |
| 1219 | |
Avaneesh Kumar Dwivedi | 9f058fa | 2017-10-24 21:22:27 +0530 | [diff] [blame] | 1220 | qproc->version = desc->version; |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 1221 | qproc->need_mem_protection = desc->need_mem_protection; |
Bjorn Andersson | 7d67473 | 2018-06-04 13:30:38 -0700 | [diff] [blame] | 1222 | |
| 1223 | ret = qcom_q6v5_init(&qproc->q6v5, pdev, rproc, MPSS_CRASH_REASON_SMEM, |
| 1224 | qcom_msa_handover); |
| 1225 | if (ret) |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1226 | goto free_rproc; |
| 1227 | |
Avaneesh Kumar Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 1228 | qproc->mpss_perm = BIT(QCOM_SCM_VMID_HLOS); |
| 1229 | qproc->mba_perm = BIT(QCOM_SCM_VMID_HLOS); |
Sibi Sankar | 4725496 | 2018-05-21 22:57:14 +0530 | [diff] [blame] | 1230 | qcom_add_glink_subdev(rproc, &qproc->glink_subdev); |
Bjorn Andersson | 4b48921 | 2017-01-29 14:05:50 -0800 | [diff] [blame] | 1231 | qcom_add_smd_subdev(rproc, &qproc->smd_subdev); |
Bjorn Andersson | 1e140df | 2017-07-24 22:56:43 -0700 | [diff] [blame] | 1232 | qcom_add_ssr_subdev(rproc, &qproc->ssr_subdev, "mpss"); |
Bjorn Andersson | 1fb82ee | 2017-08-27 21:51:38 -0700 | [diff] [blame] | 1233 | qproc->sysmon = qcom_add_sysmon_subdev(rproc, "modem", 0x12); |
Bjorn Andersson | 4b48921 | 2017-01-29 14:05:50 -0800 | [diff] [blame] | 1234 | |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1235 | ret = rproc_add(rproc); |
| 1236 | if (ret) |
| 1237 | goto free_rproc; |
| 1238 | |
| 1239 | return 0; |
| 1240 | |
| 1241 | free_rproc: |
Bjorn Andersson | 433c0e0 | 2016-10-02 17:46:38 -0700 | [diff] [blame] | 1242 | rproc_free(rproc); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1243 | |
| 1244 | return ret; |
| 1245 | } |
| 1246 | |
| 1247 | static int q6v5_remove(struct platform_device *pdev) |
| 1248 | { |
| 1249 | struct q6v5 *qproc = platform_get_drvdata(pdev); |
| 1250 | |
| 1251 | rproc_del(qproc->rproc); |
Bjorn Andersson | 4b48921 | 2017-01-29 14:05:50 -0800 | [diff] [blame] | 1252 | |
Bjorn Andersson | 1fb82ee | 2017-08-27 21:51:38 -0700 | [diff] [blame] | 1253 | qcom_remove_sysmon_subdev(qproc->sysmon); |
Sibi Sankar | 4725496 | 2018-05-21 22:57:14 +0530 | [diff] [blame] | 1254 | qcom_remove_glink_subdev(qproc->rproc, &qproc->glink_subdev); |
Bjorn Andersson | 4b48921 | 2017-01-29 14:05:50 -0800 | [diff] [blame] | 1255 | qcom_remove_smd_subdev(qproc->rproc, &qproc->smd_subdev); |
Bjorn Andersson | 1e140df | 2017-07-24 22:56:43 -0700 | [diff] [blame] | 1256 | qcom_remove_ssr_subdev(qproc->rproc, &qproc->ssr_subdev); |
Bjorn Andersson | 433c0e0 | 2016-10-02 17:46:38 -0700 | [diff] [blame] | 1257 | rproc_free(qproc->rproc); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1258 | |
| 1259 | return 0; |
| 1260 | } |
| 1261 | |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 1262 | static const struct rproc_hexagon_res sdm845_mss = { |
| 1263 | .hexagon_mba_image = "mba.mbn", |
| 1264 | .proxy_clk_names = (char*[]){ |
| 1265 | "xo", |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 1266 | "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 Dwivedi | 9f058fa | 2017-10-24 21:22:27 +0530 | [diff] [blame] | 1286 | static 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 Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 1301 | .has_alt_reset = false, |
Avaneesh Kumar Dwivedi | 9f058fa | 2017-10-24 21:22:27 +0530 | [diff] [blame] | 1302 | .version = MSS_MSM8996, |
| 1303 | }; |
| 1304 | |
Avaneesh Kumar Dwivedi | 7a8ffe1 | 2016-12-30 19:24:00 +0530 | [diff] [blame] | 1305 | static const struct rproc_hexagon_res msm8916_mss = { |
| 1306 | .hexagon_mba_image = "mba.mbn", |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 1307 | .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 Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 1322 | .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 Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 1332 | .need_mem_protection = false, |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 1333 | .has_alt_reset = false, |
Avaneesh Kumar Dwivedi | 9f058fa | 2017-10-24 21:22:27 +0530 | [diff] [blame] | 1334 | .version = MSS_MSM8916, |
Avaneesh Kumar Dwivedi | 7a8ffe1 | 2016-12-30 19:24:00 +0530 | [diff] [blame] | 1335 | }; |
| 1336 | |
| 1337 | static const struct rproc_hexagon_res msm8974_mss = { |
| 1338 | .hexagon_mba_image = "mba.b00", |
Avaneesh Kumar Dwivedi | 19f902b | 2016-12-30 19:24:02 +0530 | [diff] [blame] | 1339 | .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 Dwivedi | 39b2410 | 2016-12-30 19:24:01 +0530 | [diff] [blame] | 1362 | .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 Dwivedi | 6c5a9dc | 2017-10-24 21:22:26 +0530 | [diff] [blame] | 1372 | .need_mem_protection = false, |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 1373 | .has_alt_reset = false, |
Avaneesh Kumar Dwivedi | 9f058fa | 2017-10-24 21:22:27 +0530 | [diff] [blame] | 1374 | .version = MSS_MSM8974, |
Avaneesh Kumar Dwivedi | 7a8ffe1 | 2016-12-30 19:24:00 +0530 | [diff] [blame] | 1375 | }; |
| 1376 | |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1377 | static const struct of_device_id q6v5_of_match[] = { |
Avaneesh Kumar Dwivedi | 7a8ffe1 | 2016-12-30 19:24:00 +0530 | [diff] [blame] | 1378 | { .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 Dwivedi | 9f058fa | 2017-10-24 21:22:27 +0530 | [diff] [blame] | 1381 | { .compatible = "qcom,msm8996-mss-pil", .data = &msm8996_mss}, |
Sibi Sankar | 231f67d | 2018-05-21 22:57:13 +0530 | [diff] [blame] | 1382 | { .compatible = "qcom,sdm845-mss-pil", .data = &sdm845_mss}, |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1383 | { }, |
| 1384 | }; |
Javier Martinez Canillas | 3227c87 | 2016-10-18 18:24:19 -0300 | [diff] [blame] | 1385 | MODULE_DEVICE_TABLE(of, q6v5_of_match); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1386 | |
| 1387 | static struct platform_driver q6v5_driver = { |
| 1388 | .probe = q6v5_probe, |
| 1389 | .remove = q6v5_remove, |
| 1390 | .driver = { |
Bjorn Andersson | ef73c22 | 2018-09-24 16:45:26 -0700 | [diff] [blame] | 1391 | .name = "qcom-q6v5-mss", |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1392 | .of_match_table = q6v5_of_match, |
| 1393 | }, |
| 1394 | }; |
| 1395 | module_platform_driver(q6v5_driver); |
| 1396 | |
Bjorn Andersson | ef73c22 | 2018-09-24 16:45:26 -0700 | [diff] [blame] | 1397 | MODULE_DESCRIPTION("Qualcomm Self-authenticating modem remoteproc driver"); |
Bjorn Andersson | 051fb70 | 2016-06-20 14:28:41 -0700 | [diff] [blame] | 1398 | MODULE_LICENSE("GPL v2"); |