Thomas Gleixner | 1802d0b | 2019-05-27 08:55:21 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 2 | /* |
Avaneesh Kumar Dwivedi | 90a068e | 2017-01-30 20:33:08 +0530 | [diff] [blame] | 3 | * Qualcomm ADSP/SLPI Peripheral Image Loader for MSM8974 and MSM8996 |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 4 | * |
| 5 | * Copyright (C) 2016 Linaro Ltd |
| 6 | * Copyright (C) 2014 Sony Mobile Communications AB |
| 7 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 8 | */ |
| 9 | |
Sarangdhar Joshi | f33a735 | 2016-10-25 13:57:26 -0700 | [diff] [blame] | 10 | #include <linux/clk.h> |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 11 | #include <linux/firmware.h> |
| 12 | #include <linux/interrupt.h> |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/of_address.h> |
| 16 | #include <linux/of_device.h> |
| 17 | #include <linux/platform_device.h> |
| 18 | #include <linux/qcom_scm.h> |
| 19 | #include <linux/regulator/consumer.h> |
| 20 | #include <linux/remoteproc.h> |
Bjorn Andersson | 2aad40d | 2017-01-27 03:12:57 -0800 | [diff] [blame] | 21 | #include <linux/soc/qcom/mdt_loader.h> |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 22 | #include <linux/soc/qcom/smem.h> |
| 23 | #include <linux/soc/qcom/smem_state.h> |
| 24 | |
Bjorn Andersson | bde440e | 2017-01-27 02:28:32 -0800 | [diff] [blame] | 25 | #include "qcom_common.h" |
Bjorn Andersson | 6103b1a | 2018-06-04 13:30:37 -0700 | [diff] [blame] | 26 | #include "qcom_q6v5.h" |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 27 | #include "remoteproc_internal.h" |
| 28 | |
Avaneesh Kumar Dwivedi | c7715e4 | 2017-01-30 20:33:06 +0530 | [diff] [blame] | 29 | struct adsp_data { |
| 30 | int crash_reason_smem; |
| 31 | const char *firmware_name; |
| 32 | int pas_id; |
Avaneesh Kumar Dwivedi | e323fc0 | 2017-01-30 20:33:07 +0530 | [diff] [blame] | 33 | bool has_aggre2_clk; |
Bjorn Andersson | 1fb82ee | 2017-08-27 21:51:38 -0700 | [diff] [blame] | 34 | |
Bjorn Andersson | 1e140df | 2017-07-24 22:56:43 -0700 | [diff] [blame] | 35 | const char *ssr_name; |
Bjorn Andersson | 1fb82ee | 2017-08-27 21:51:38 -0700 | [diff] [blame] | 36 | const char *sysmon_name; |
| 37 | int ssctl_id; |
Avaneesh Kumar Dwivedi | c7715e4 | 2017-01-30 20:33:06 +0530 | [diff] [blame] | 38 | }; |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 39 | |
| 40 | struct qcom_adsp { |
| 41 | struct device *dev; |
| 42 | struct rproc *rproc; |
| 43 | |
Bjorn Andersson | 6103b1a | 2018-06-04 13:30:37 -0700 | [diff] [blame] | 44 | struct qcom_q6v5 q6v5; |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 45 | |
Sarangdhar Joshi | f33a735 | 2016-10-25 13:57:26 -0700 | [diff] [blame] | 46 | struct clk *xo; |
Avaneesh Kumar Dwivedi | e323fc0 | 2017-01-30 20:33:07 +0530 | [diff] [blame] | 47 | struct clk *aggre2_clk; |
Sarangdhar Joshi | f33a735 | 2016-10-25 13:57:26 -0700 | [diff] [blame] | 48 | |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 49 | struct regulator *cx_supply; |
Avaneesh Kumar Dwivedi | e323fc0 | 2017-01-30 20:33:07 +0530 | [diff] [blame] | 50 | struct regulator *px_supply; |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 51 | |
Avaneesh Kumar Dwivedi | c7715e4 | 2017-01-30 20:33:06 +0530 | [diff] [blame] | 52 | int pas_id; |
| 53 | int crash_reason_smem; |
Avaneesh Kumar Dwivedi | e323fc0 | 2017-01-30 20:33:07 +0530 | [diff] [blame] | 54 | bool has_aggre2_clk; |
Avaneesh Kumar Dwivedi | c7715e4 | 2017-01-30 20:33:06 +0530 | [diff] [blame] | 55 | |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 56 | struct completion start_done; |
| 57 | struct completion stop_done; |
| 58 | |
| 59 | phys_addr_t mem_phys; |
| 60 | phys_addr_t mem_reloc; |
| 61 | void *mem_region; |
| 62 | size_t mem_size; |
Bjorn Andersson | 4b48921 | 2017-01-29 14:05:50 -0800 | [diff] [blame] | 63 | |
Bjorn Andersson | eea0702 | 2017-08-29 16:13:35 -0700 | [diff] [blame] | 64 | struct qcom_rproc_glink glink_subdev; |
Bjorn Andersson | 4b48921 | 2017-01-29 14:05:50 -0800 | [diff] [blame] | 65 | struct qcom_rproc_subdev smd_subdev; |
Bjorn Andersson | 1e140df | 2017-07-24 22:56:43 -0700 | [diff] [blame] | 66 | struct qcom_rproc_ssr ssr_subdev; |
Bjorn Andersson | 1fb82ee | 2017-08-27 21:51:38 -0700 | [diff] [blame] | 67 | struct qcom_sysmon *sysmon; |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | static int adsp_load(struct rproc *rproc, const struct firmware *fw) |
| 71 | { |
| 72 | struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 73 | |
Bjorn Andersson | 7f0dd07 | 2017-01-27 02:17:23 -0800 | [diff] [blame] | 74 | return qcom_mdt_load(adsp->dev, fw, rproc->firmware, adsp->pas_id, |
Bjorn Andersson | 4dd27f5 | 2018-01-05 16:04:19 -0800 | [diff] [blame] | 75 | adsp->mem_region, adsp->mem_phys, adsp->mem_size, |
| 76 | &adsp->mem_reloc); |
| 77 | |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 80 | static int adsp_start(struct rproc *rproc) |
| 81 | { |
| 82 | struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; |
| 83 | int ret; |
| 84 | |
Bjorn Andersson | 6103b1a | 2018-06-04 13:30:37 -0700 | [diff] [blame] | 85 | qcom_q6v5_prepare(&adsp->q6v5); |
| 86 | |
Sarangdhar Joshi | f33a735 | 2016-10-25 13:57:26 -0700 | [diff] [blame] | 87 | ret = clk_prepare_enable(adsp->xo); |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 88 | if (ret) |
| 89 | return ret; |
| 90 | |
Avaneesh Kumar Dwivedi | e323fc0 | 2017-01-30 20:33:07 +0530 | [diff] [blame] | 91 | ret = clk_prepare_enable(adsp->aggre2_clk); |
| 92 | if (ret) |
| 93 | goto disable_xo_clk; |
| 94 | |
Sarangdhar Joshi | f33a735 | 2016-10-25 13:57:26 -0700 | [diff] [blame] | 95 | ret = regulator_enable(adsp->cx_supply); |
| 96 | if (ret) |
Avaneesh Kumar Dwivedi | e323fc0 | 2017-01-30 20:33:07 +0530 | [diff] [blame] | 97 | goto disable_aggre2_clk; |
| 98 | |
| 99 | ret = regulator_enable(adsp->px_supply); |
| 100 | if (ret) |
| 101 | goto disable_cx_supply; |
Sarangdhar Joshi | f33a735 | 2016-10-25 13:57:26 -0700 | [diff] [blame] | 102 | |
Avaneesh Kumar Dwivedi | c7715e4 | 2017-01-30 20:33:06 +0530 | [diff] [blame] | 103 | ret = qcom_scm_pas_auth_and_reset(adsp->pas_id); |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 104 | if (ret) { |
| 105 | dev_err(adsp->dev, |
| 106 | "failed to authenticate image and release reset\n"); |
Avaneesh Kumar Dwivedi | e323fc0 | 2017-01-30 20:33:07 +0530 | [diff] [blame] | 107 | goto disable_px_supply; |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 108 | } |
| 109 | |
Bjorn Andersson | 6103b1a | 2018-06-04 13:30:37 -0700 | [diff] [blame] | 110 | ret = qcom_q6v5_wait_for_start(&adsp->q6v5, msecs_to_jiffies(5000)); |
| 111 | if (ret == -ETIMEDOUT) { |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 112 | dev_err(adsp->dev, "start timed out\n"); |
Avaneesh Kumar Dwivedi | c7715e4 | 2017-01-30 20:33:06 +0530 | [diff] [blame] | 113 | qcom_scm_pas_shutdown(adsp->pas_id); |
Avaneesh Kumar Dwivedi | e323fc0 | 2017-01-30 20:33:07 +0530 | [diff] [blame] | 114 | goto disable_px_supply; |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 115 | } |
| 116 | |
Bjorn Andersson | 6103b1a | 2018-06-04 13:30:37 -0700 | [diff] [blame] | 117 | return 0; |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 118 | |
Avaneesh Kumar Dwivedi | e323fc0 | 2017-01-30 20:33:07 +0530 | [diff] [blame] | 119 | disable_px_supply: |
| 120 | regulator_disable(adsp->px_supply); |
| 121 | disable_cx_supply: |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 122 | regulator_disable(adsp->cx_supply); |
Avaneesh Kumar Dwivedi | e323fc0 | 2017-01-30 20:33:07 +0530 | [diff] [blame] | 123 | disable_aggre2_clk: |
| 124 | clk_disable_unprepare(adsp->aggre2_clk); |
| 125 | disable_xo_clk: |
Sarangdhar Joshi | f33a735 | 2016-10-25 13:57:26 -0700 | [diff] [blame] | 126 | clk_disable_unprepare(adsp->xo); |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 127 | |
| 128 | return ret; |
| 129 | } |
| 130 | |
Bjorn Andersson | 6103b1a | 2018-06-04 13:30:37 -0700 | [diff] [blame] | 131 | static void qcom_pas_handover(struct qcom_q6v5 *q6v5) |
| 132 | { |
| 133 | struct qcom_adsp *adsp = container_of(q6v5, struct qcom_adsp, q6v5); |
| 134 | |
| 135 | regulator_disable(adsp->px_supply); |
| 136 | regulator_disable(adsp->cx_supply); |
| 137 | clk_disable_unprepare(adsp->aggre2_clk); |
| 138 | clk_disable_unprepare(adsp->xo); |
| 139 | } |
| 140 | |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 141 | static int adsp_stop(struct rproc *rproc) |
| 142 | { |
| 143 | struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; |
Bjorn Andersson | 6103b1a | 2018-06-04 13:30:37 -0700 | [diff] [blame] | 144 | int handover; |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 145 | int ret; |
| 146 | |
Bjorn Andersson | 6103b1a | 2018-06-04 13:30:37 -0700 | [diff] [blame] | 147 | ret = qcom_q6v5_request_stop(&adsp->q6v5); |
| 148 | if (ret == -ETIMEDOUT) |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 149 | dev_err(adsp->dev, "timed out on wait\n"); |
| 150 | |
Avaneesh Kumar Dwivedi | c7715e4 | 2017-01-30 20:33:06 +0530 | [diff] [blame] | 151 | ret = qcom_scm_pas_shutdown(adsp->pas_id); |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 152 | if (ret) |
| 153 | dev_err(adsp->dev, "failed to shutdown: %d\n", ret); |
| 154 | |
Bjorn Andersson | 6103b1a | 2018-06-04 13:30:37 -0700 | [diff] [blame] | 155 | handover = qcom_q6v5_unprepare(&adsp->q6v5); |
| 156 | if (handover) |
| 157 | qcom_pas_handover(&adsp->q6v5); |
| 158 | |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 159 | return ret; |
| 160 | } |
| 161 | |
| 162 | static void *adsp_da_to_va(struct rproc *rproc, u64 da, int len) |
| 163 | { |
| 164 | struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; |
| 165 | int offset; |
| 166 | |
| 167 | offset = da - adsp->mem_reloc; |
| 168 | if (offset < 0 || offset + len > adsp->mem_size) |
| 169 | return NULL; |
| 170 | |
| 171 | return adsp->mem_region + offset; |
| 172 | } |
| 173 | |
| 174 | static const struct rproc_ops adsp_ops = { |
| 175 | .start = adsp_start, |
| 176 | .stop = adsp_stop, |
| 177 | .da_to_va = adsp_da_to_va, |
Sarangdhar Joshi | dcb57ed | 2018-01-05 16:04:20 -0800 | [diff] [blame] | 178 | .parse_fw = qcom_register_dump_segments, |
Bjorn Andersson | 0f21f9c | 2018-01-05 15:58:01 -0800 | [diff] [blame] | 179 | .load = adsp_load, |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 180 | }; |
| 181 | |
Sarangdhar Joshi | f33a735 | 2016-10-25 13:57:26 -0700 | [diff] [blame] | 182 | static int adsp_init_clock(struct qcom_adsp *adsp) |
| 183 | { |
| 184 | int ret; |
| 185 | |
| 186 | adsp->xo = devm_clk_get(adsp->dev, "xo"); |
| 187 | if (IS_ERR(adsp->xo)) { |
| 188 | ret = PTR_ERR(adsp->xo); |
| 189 | if (ret != -EPROBE_DEFER) |
| 190 | dev_err(adsp->dev, "failed to get xo clock"); |
| 191 | return ret; |
| 192 | } |
| 193 | |
Avaneesh Kumar Dwivedi | e323fc0 | 2017-01-30 20:33:07 +0530 | [diff] [blame] | 194 | if (adsp->has_aggre2_clk) { |
| 195 | adsp->aggre2_clk = devm_clk_get(adsp->dev, "aggre2"); |
| 196 | if (IS_ERR(adsp->aggre2_clk)) { |
| 197 | ret = PTR_ERR(adsp->aggre2_clk); |
| 198 | if (ret != -EPROBE_DEFER) |
| 199 | dev_err(adsp->dev, |
| 200 | "failed to get aggre2 clock"); |
| 201 | return ret; |
| 202 | } |
| 203 | } |
| 204 | |
Sarangdhar Joshi | f33a735 | 2016-10-25 13:57:26 -0700 | [diff] [blame] | 205 | return 0; |
| 206 | } |
| 207 | |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 208 | static int adsp_init_regulator(struct qcom_adsp *adsp) |
| 209 | { |
| 210 | adsp->cx_supply = devm_regulator_get(adsp->dev, "cx"); |
| 211 | if (IS_ERR(adsp->cx_supply)) |
| 212 | return PTR_ERR(adsp->cx_supply); |
| 213 | |
| 214 | regulator_set_load(adsp->cx_supply, 100000); |
| 215 | |
Avaneesh Kumar Dwivedi | e323fc0 | 2017-01-30 20:33:07 +0530 | [diff] [blame] | 216 | adsp->px_supply = devm_regulator_get(adsp->dev, "px"); |
Himanshu Jha | c76929b | 2017-08-29 19:13:18 +0530 | [diff] [blame] | 217 | return PTR_ERR_OR_ZERO(adsp->px_supply); |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 218 | } |
| 219 | |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 220 | static int adsp_alloc_memory_region(struct qcom_adsp *adsp) |
| 221 | { |
| 222 | struct device_node *node; |
| 223 | struct resource r; |
| 224 | int ret; |
| 225 | |
| 226 | node = of_parse_phandle(adsp->dev->of_node, "memory-region", 0); |
| 227 | if (!node) { |
| 228 | dev_err(adsp->dev, "no memory-region specified\n"); |
| 229 | return -EINVAL; |
| 230 | } |
| 231 | |
| 232 | ret = of_address_to_resource(node, 0, &r); |
| 233 | if (ret) |
| 234 | return ret; |
| 235 | |
| 236 | adsp->mem_phys = adsp->mem_reloc = r.start; |
| 237 | adsp->mem_size = resource_size(&r); |
| 238 | adsp->mem_region = devm_ioremap_wc(adsp->dev, adsp->mem_phys, adsp->mem_size); |
| 239 | if (!adsp->mem_region) { |
| 240 | dev_err(adsp->dev, "unable to map memory region: %pa+%zx\n", |
| 241 | &r.start, adsp->mem_size); |
| 242 | return -EBUSY; |
| 243 | } |
| 244 | |
| 245 | return 0; |
| 246 | } |
| 247 | |
| 248 | static int adsp_probe(struct platform_device *pdev) |
| 249 | { |
Avaneesh Kumar Dwivedi | c7715e4 | 2017-01-30 20:33:06 +0530 | [diff] [blame] | 250 | const struct adsp_data *desc; |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 251 | struct qcom_adsp *adsp; |
| 252 | struct rproc *rproc; |
Sibi Sankar | a5a4e02 | 2019-01-15 01:20:01 +0530 | [diff] [blame] | 253 | const char *fw_name; |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 254 | int ret; |
| 255 | |
Avaneesh Kumar Dwivedi | c7715e4 | 2017-01-30 20:33:06 +0530 | [diff] [blame] | 256 | desc = of_device_get_match_data(&pdev->dev); |
| 257 | if (!desc) |
| 258 | return -EINVAL; |
| 259 | |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 260 | if (!qcom_scm_is_available()) |
| 261 | return -EPROBE_DEFER; |
| 262 | |
Sibi Sankar | a5a4e02 | 2019-01-15 01:20:01 +0530 | [diff] [blame] | 263 | fw_name = desc->firmware_name; |
| 264 | ret = of_property_read_string(pdev->dev.of_node, "firmware-name", |
| 265 | &fw_name); |
| 266 | if (ret < 0 && ret != -EINVAL) |
| 267 | return ret; |
| 268 | |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 269 | rproc = rproc_alloc(&pdev->dev, pdev->name, &adsp_ops, |
Sibi Sankar | a5a4e02 | 2019-01-15 01:20:01 +0530 | [diff] [blame] | 270 | fw_name, sizeof(*adsp)); |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 271 | if (!rproc) { |
| 272 | dev_err(&pdev->dev, "unable to allocate remoteproc\n"); |
| 273 | return -ENOMEM; |
| 274 | } |
| 275 | |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 276 | adsp = (struct qcom_adsp *)rproc->priv; |
| 277 | adsp->dev = &pdev->dev; |
| 278 | adsp->rproc = rproc; |
Avaneesh Kumar Dwivedi | c7715e4 | 2017-01-30 20:33:06 +0530 | [diff] [blame] | 279 | adsp->pas_id = desc->pas_id; |
Avaneesh Kumar Dwivedi | e323fc0 | 2017-01-30 20:33:07 +0530 | [diff] [blame] | 280 | adsp->has_aggre2_clk = desc->has_aggre2_clk; |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 281 | platform_set_drvdata(pdev, adsp); |
| 282 | |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 283 | ret = adsp_alloc_memory_region(adsp); |
| 284 | if (ret) |
| 285 | goto free_rproc; |
| 286 | |
Sarangdhar Joshi | f33a735 | 2016-10-25 13:57:26 -0700 | [diff] [blame] | 287 | ret = adsp_init_clock(adsp); |
| 288 | if (ret) |
| 289 | goto free_rproc; |
| 290 | |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 291 | ret = adsp_init_regulator(adsp); |
| 292 | if (ret) |
| 293 | goto free_rproc; |
| 294 | |
Bjorn Andersson | 6103b1a | 2018-06-04 13:30:37 -0700 | [diff] [blame] | 295 | ret = qcom_q6v5_init(&adsp->q6v5, pdev, rproc, desc->crash_reason_smem, |
| 296 | qcom_pas_handover); |
| 297 | if (ret) |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 298 | goto free_rproc; |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 299 | |
Bjorn Andersson | eea0702 | 2017-08-29 16:13:35 -0700 | [diff] [blame] | 300 | qcom_add_glink_subdev(rproc, &adsp->glink_subdev); |
Bjorn Andersson | 4b48921 | 2017-01-29 14:05:50 -0800 | [diff] [blame] | 301 | qcom_add_smd_subdev(rproc, &adsp->smd_subdev); |
Bjorn Andersson | 1e140df | 2017-07-24 22:56:43 -0700 | [diff] [blame] | 302 | qcom_add_ssr_subdev(rproc, &adsp->ssr_subdev, desc->ssr_name); |
Bjorn Andersson | 1fb82ee | 2017-08-27 21:51:38 -0700 | [diff] [blame] | 303 | adsp->sysmon = qcom_add_sysmon_subdev(rproc, |
| 304 | desc->sysmon_name, |
| 305 | desc->ssctl_id); |
Sibi Sankar | 027045a | 2019-01-08 15:53:43 +0530 | [diff] [blame] | 306 | if (IS_ERR(adsp->sysmon)) { |
| 307 | ret = PTR_ERR(adsp->sysmon); |
| 308 | goto free_rproc; |
| 309 | } |
Bjorn Andersson | 4b48921 | 2017-01-29 14:05:50 -0800 | [diff] [blame] | 310 | |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 311 | ret = rproc_add(rproc); |
| 312 | if (ret) |
| 313 | goto free_rproc; |
| 314 | |
| 315 | return 0; |
| 316 | |
| 317 | free_rproc: |
Bjorn Andersson | 90a80d8 | 2016-11-19 22:42:55 -0800 | [diff] [blame] | 318 | rproc_free(rproc); |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 319 | |
| 320 | return ret; |
| 321 | } |
| 322 | |
| 323 | static int adsp_remove(struct platform_device *pdev) |
| 324 | { |
| 325 | struct qcom_adsp *adsp = platform_get_drvdata(pdev); |
| 326 | |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 327 | rproc_del(adsp->rproc); |
Bjorn Andersson | 4b48921 | 2017-01-29 14:05:50 -0800 | [diff] [blame] | 328 | |
Bjorn Andersson | eea0702 | 2017-08-29 16:13:35 -0700 | [diff] [blame] | 329 | qcom_remove_glink_subdev(adsp->rproc, &adsp->glink_subdev); |
Bjorn Andersson | 1fb82ee | 2017-08-27 21:51:38 -0700 | [diff] [blame] | 330 | qcom_remove_sysmon_subdev(adsp->sysmon); |
Bjorn Andersson | 4b48921 | 2017-01-29 14:05:50 -0800 | [diff] [blame] | 331 | qcom_remove_smd_subdev(adsp->rproc, &adsp->smd_subdev); |
Bjorn Andersson | 1e140df | 2017-07-24 22:56:43 -0700 | [diff] [blame] | 332 | qcom_remove_ssr_subdev(adsp->rproc, &adsp->ssr_subdev); |
Bjorn Andersson | 90a80d8 | 2016-11-19 22:42:55 -0800 | [diff] [blame] | 333 | rproc_free(adsp->rproc); |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 334 | |
| 335 | return 0; |
| 336 | } |
| 337 | |
Avaneesh Kumar Dwivedi | c7715e4 | 2017-01-30 20:33:06 +0530 | [diff] [blame] | 338 | static const struct adsp_data adsp_resource_init = { |
| 339 | .crash_reason_smem = 423, |
| 340 | .firmware_name = "adsp.mdt", |
| 341 | .pas_id = 1, |
Avaneesh Kumar Dwivedi | e323fc0 | 2017-01-30 20:33:07 +0530 | [diff] [blame] | 342 | .has_aggre2_clk = false, |
Bjorn Andersson | 1e140df | 2017-07-24 22:56:43 -0700 | [diff] [blame] | 343 | .ssr_name = "lpass", |
Bjorn Andersson | 1fb82ee | 2017-08-27 21:51:38 -0700 | [diff] [blame] | 344 | .sysmon_name = "adsp", |
| 345 | .ssctl_id = 0x14, |
Avaneesh Kumar Dwivedi | c7715e4 | 2017-01-30 20:33:06 +0530 | [diff] [blame] | 346 | }; |
| 347 | |
Bjorn Andersson | 3b0d1b6 | 2018-08-28 00:14:58 -0700 | [diff] [blame] | 348 | static const struct adsp_data cdsp_resource_init = { |
| 349 | .crash_reason_smem = 601, |
| 350 | .firmware_name = "cdsp.mdt", |
| 351 | .pas_id = 18, |
| 352 | .has_aggre2_clk = false, |
| 353 | .ssr_name = "cdsp", |
| 354 | .sysmon_name = "cdsp", |
| 355 | .ssctl_id = 0x17, |
| 356 | }; |
| 357 | |
Avaneesh Kumar Dwivedi | 90a068e | 2017-01-30 20:33:08 +0530 | [diff] [blame] | 358 | static const struct adsp_data slpi_resource_init = { |
| 359 | .crash_reason_smem = 424, |
| 360 | .firmware_name = "slpi.mdt", |
| 361 | .pas_id = 12, |
| 362 | .has_aggre2_clk = true, |
Bjorn Andersson | 1e140df | 2017-07-24 22:56:43 -0700 | [diff] [blame] | 363 | .ssr_name = "dsps", |
Bjorn Andersson | 1fb82ee | 2017-08-27 21:51:38 -0700 | [diff] [blame] | 364 | .sysmon_name = "slpi", |
| 365 | .ssctl_id = 0x16, |
Avaneesh Kumar Dwivedi | 90a068e | 2017-01-30 20:33:08 +0530 | [diff] [blame] | 366 | }; |
| 367 | |
Bjorn Andersson | 0af9368 | 2018-09-27 12:03:46 -0700 | [diff] [blame] | 368 | static const struct adsp_data wcss_resource_init = { |
| 369 | .crash_reason_smem = 421, |
| 370 | .firmware_name = "wcnss.mdt", |
| 371 | .pas_id = 6, |
| 372 | .ssr_name = "mpss", |
| 373 | .sysmon_name = "wcnss", |
| 374 | .ssctl_id = 0x12, |
| 375 | }; |
| 376 | |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 377 | static const struct of_device_id adsp_of_match[] = { |
Avaneesh Kumar Dwivedi | c7715e4 | 2017-01-30 20:33:06 +0530 | [diff] [blame] | 378 | { .compatible = "qcom,msm8974-adsp-pil", .data = &adsp_resource_init}, |
| 379 | { .compatible = "qcom,msm8996-adsp-pil", .data = &adsp_resource_init}, |
Avaneesh Kumar Dwivedi | 90a068e | 2017-01-30 20:33:08 +0530 | [diff] [blame] | 380 | { .compatible = "qcom,msm8996-slpi-pil", .data = &slpi_resource_init}, |
Bjorn Andersson | 0af9368 | 2018-09-27 12:03:46 -0700 | [diff] [blame] | 381 | { .compatible = "qcom,qcs404-adsp-pas", .data = &adsp_resource_init }, |
| 382 | { .compatible = "qcom,qcs404-cdsp-pas", .data = &cdsp_resource_init }, |
| 383 | { .compatible = "qcom,qcs404-wcss-pas", .data = &wcss_resource_init }, |
Bjorn Andersson | 3b0d1b6 | 2018-08-28 00:14:58 -0700 | [diff] [blame] | 384 | { .compatible = "qcom,sdm845-adsp-pas", .data = &adsp_resource_init}, |
| 385 | { .compatible = "qcom,sdm845-cdsp-pas", .data = &cdsp_resource_init}, |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 386 | { }, |
| 387 | }; |
Bjorn Andersson | 6242347 | 2016-11-19 22:41:56 -0800 | [diff] [blame] | 388 | MODULE_DEVICE_TABLE(of, adsp_of_match); |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 389 | |
| 390 | static struct platform_driver adsp_driver = { |
| 391 | .probe = adsp_probe, |
| 392 | .remove = adsp_remove, |
| 393 | .driver = { |
Bjorn Andersson | 9e004f9 | 2018-09-24 16:45:25 -0700 | [diff] [blame] | 394 | .name = "qcom_q6v5_pas", |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 395 | .of_match_table = adsp_of_match, |
| 396 | }, |
| 397 | }; |
| 398 | |
| 399 | module_platform_driver(adsp_driver); |
Bjorn Andersson | 9e004f9 | 2018-09-24 16:45:25 -0700 | [diff] [blame] | 400 | MODULE_DESCRIPTION("Qualcomm Hexagon v5 Peripheral Authentication Service driver"); |
Bjorn Andersson | b9e718e | 2016-08-22 22:57:44 -0700 | [diff] [blame] | 401 | MODULE_LICENSE("GPL v2"); |