Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Texas Instruments' K3 DSP Remoteproc driver |
| 4 | * |
Nishanth Menon | eaa39c6 | 2023-11-01 15:56:03 -0500 | [diff] [blame] | 5 | * Copyright (C) 2018-2020 Texas Instruments Incorporated - https://www.ti.com/ |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 6 | * Lokesh Vutla <lokeshvutla@ti.com> |
Suman Anna | be7fa2d | 2020-03-10 16:05:56 -0500 | [diff] [blame] | 7 | * Suman Anna <s-anna@ti.com> |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <common.h> |
| 11 | #include <dm.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 12 | #include <log.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 13 | #include <malloc.h> |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 14 | #include <remoteproc.h> |
| 15 | #include <errno.h> |
| 16 | #include <clk.h> |
| 17 | #include <reset.h> |
| 18 | #include <asm/io.h> |
| 19 | #include <power-domain.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 20 | #include <dm/device_compat.h> |
Simon Glass | d66c5f7 | 2020-02-03 07:36:15 -0700 | [diff] [blame] | 21 | #include <linux/err.h> |
Suman Anna | e45fa38 | 2020-03-10 16:05:54 -0500 | [diff] [blame] | 22 | #include <linux/sizes.h> |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 23 | #include <linux/soc/ti/ti_sci_protocol.h> |
| 24 | #include "ti_sci_proc.h" |
| 25 | |
| 26 | #define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) |
| 27 | |
| 28 | /** |
| 29 | * struct k3_dsp_mem - internal memory structure |
| 30 | * @cpu_addr: MPU virtual address of the memory region |
| 31 | * @bus_addr: Bus address used to access the memory region |
| 32 | * @dev_addr: Device address from remoteproc view |
| 33 | * @size: Size of the memory region |
| 34 | */ |
| 35 | struct k3_dsp_mem { |
| 36 | void __iomem *cpu_addr; |
| 37 | phys_addr_t bus_addr; |
| 38 | phys_addr_t dev_addr; |
| 39 | size_t size; |
| 40 | }; |
| 41 | |
| 42 | /** |
Suman Anna | e45fa38 | 2020-03-10 16:05:54 -0500 | [diff] [blame] | 43 | * struct k3_dsp_boot_data - internal data structure used for boot |
| 44 | * @boot_align_addr: Boot vector address alignment granularity |
Suman Anna | be7fa2d | 2020-03-10 16:05:56 -0500 | [diff] [blame] | 45 | * @uses_lreset: Flag to denote the need for local reset management |
Suman Anna | e45fa38 | 2020-03-10 16:05:54 -0500 | [diff] [blame] | 46 | */ |
| 47 | struct k3_dsp_boot_data { |
| 48 | u32 boot_align_addr; |
Suman Anna | be7fa2d | 2020-03-10 16:05:56 -0500 | [diff] [blame] | 49 | bool uses_lreset; |
Suman Anna | e45fa38 | 2020-03-10 16:05:54 -0500 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | /** |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 53 | * struct k3_dsp_privdata - Structure representing Remote processor data. |
| 54 | * @rproc_rst: rproc reset control data |
| 55 | * @tsp: Pointer to TISCI proc contrl handle |
Suman Anna | e45fa38 | 2020-03-10 16:05:54 -0500 | [diff] [blame] | 56 | * @data: Pointer to DSP specific boot data structure |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 57 | * @mem: Array of available memories |
| 58 | * @num_mem: Number of available memories |
Udit Kumar | a962c2e | 2023-11-25 23:59:39 +0530 | [diff] [blame] | 59 | * @in_use: flag to tell if the core is already in use. |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 60 | */ |
| 61 | struct k3_dsp_privdata { |
| 62 | struct reset_ctl dsp_rst; |
| 63 | struct ti_sci_proc tsp; |
Suman Anna | e45fa38 | 2020-03-10 16:05:54 -0500 | [diff] [blame] | 64 | struct k3_dsp_boot_data *data; |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 65 | struct k3_dsp_mem *mem; |
| 66 | int num_mems; |
Udit Kumar | a962c2e | 2023-11-25 23:59:39 +0530 | [diff] [blame] | 67 | bool in_use; |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 68 | }; |
| 69 | |
Suman Anna | be7fa2d | 2020-03-10 16:05:56 -0500 | [diff] [blame] | 70 | /* |
| 71 | * The C66x DSP cores have a local reset that affects only the CPU, and a |
| 72 | * generic module reset that powers on the device and allows the DSP internal |
| 73 | * memories to be accessed while the local reset is asserted. This function is |
| 74 | * used to release the global reset on C66x DSPs to allow loading into the DSP |
| 75 | * internal RAMs. This helper function is invoked in k3_dsp_load() before any |
| 76 | * actual firmware loading and is undone only in k3_dsp_stop(). The local reset |
| 77 | * on C71x cores is a no-op and the global reset cannot be released on C71x |
| 78 | * cores until after the firmware images are loaded, so this function does |
| 79 | * nothing for C71x cores. |
| 80 | */ |
| 81 | static int k3_dsp_prepare(struct udevice *dev) |
| 82 | { |
| 83 | struct k3_dsp_privdata *dsp = dev_get_priv(dev); |
| 84 | struct k3_dsp_boot_data *data = dsp->data; |
| 85 | int ret; |
| 86 | |
| 87 | /* local reset is no-op on C71x processors */ |
| 88 | if (!data->uses_lreset) |
| 89 | return 0; |
| 90 | |
| 91 | ret = ti_sci_proc_power_domain_on(&dsp->tsp); |
| 92 | if (ret) |
| 93 | dev_err(dev, "cannot enable internal RAM loading, ret = %d\n", |
| 94 | ret); |
| 95 | |
| 96 | return ret; |
| 97 | } |
| 98 | |
| 99 | /* |
| 100 | * This function is the counterpart to k3_dsp_prepare() and is used to assert |
| 101 | * the global reset on C66x DSP cores (no-op for C71x DSP cores). This completes |
| 102 | * the second step of powering down the C66x DSP cores. The cores themselves |
| 103 | * are halted through the local reset in first step. This function is invoked |
| 104 | * in k3_dsp_stop() after the local reset is asserted. |
| 105 | */ |
| 106 | static int k3_dsp_unprepare(struct udevice *dev) |
| 107 | { |
| 108 | struct k3_dsp_privdata *dsp = dev_get_priv(dev); |
| 109 | struct k3_dsp_boot_data *data = dsp->data; |
| 110 | |
| 111 | /* local reset is no-op on C71x processors */ |
| 112 | if (!data->uses_lreset) |
| 113 | return 0; |
| 114 | |
| 115 | return ti_sci_proc_power_domain_off(&dsp->tsp); |
| 116 | } |
| 117 | |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 118 | /** |
| 119 | * k3_dsp_load() - Load up the Remote processor image |
| 120 | * @dev: rproc device pointer |
| 121 | * @addr: Address at which image is available |
| 122 | * @size: size of the image |
| 123 | * |
| 124 | * Return: 0 if all goes good, else appropriate error message. |
| 125 | */ |
| 126 | static int k3_dsp_load(struct udevice *dev, ulong addr, ulong size) |
| 127 | { |
| 128 | struct k3_dsp_privdata *dsp = dev_get_priv(dev); |
Suman Anna | e45fa38 | 2020-03-10 16:05:54 -0500 | [diff] [blame] | 129 | struct k3_dsp_boot_data *data = dsp->data; |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 130 | u32 boot_vector; |
| 131 | int ret; |
| 132 | |
Udit Kumar | a962c2e | 2023-11-25 23:59:39 +0530 | [diff] [blame] | 133 | if (dsp->in_use) { |
| 134 | dev_err(dev, |
| 135 | "Invalid op: Trying to load/start on already running core %d\n", |
| 136 | dsp->tsp.proc_id); |
| 137 | return -EINVAL; |
| 138 | } |
| 139 | |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 140 | dev_dbg(dev, "%s addr = 0x%lx, size = 0x%lx\n", __func__, addr, size); |
| 141 | ret = ti_sci_proc_request(&dsp->tsp); |
| 142 | if (ret) |
| 143 | return ret; |
| 144 | |
Suman Anna | be7fa2d | 2020-03-10 16:05:56 -0500 | [diff] [blame] | 145 | ret = k3_dsp_prepare(dev); |
| 146 | if (ret) { |
| 147 | dev_err(dev, "DSP prepare failed for core %d\n", |
| 148 | dsp->tsp.proc_id); |
| 149 | goto proc_release; |
| 150 | } |
| 151 | |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 152 | ret = rproc_elf_load_image(dev, addr, size); |
| 153 | if (ret < 0) { |
| 154 | dev_err(dev, "Loading elf failed %d\n", ret); |
Suman Anna | be7fa2d | 2020-03-10 16:05:56 -0500 | [diff] [blame] | 155 | goto unprepare; |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | boot_vector = rproc_elf_get_boot_addr(dev, addr); |
Suman Anna | e45fa38 | 2020-03-10 16:05:54 -0500 | [diff] [blame] | 159 | if (boot_vector & (data->boot_align_addr - 1)) { |
| 160 | ret = -EINVAL; |
| 161 | dev_err(dev, "Boot vector 0x%x not aligned on 0x%x boundary\n", |
| 162 | boot_vector, data->boot_align_addr); |
| 163 | goto proc_release; |
| 164 | } |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 165 | |
| 166 | dev_dbg(dev, "%s: Boot vector = 0x%x\n", __func__, boot_vector); |
| 167 | |
| 168 | ret = ti_sci_proc_set_config(&dsp->tsp, boot_vector, 0, 0); |
Suman Anna | be7fa2d | 2020-03-10 16:05:56 -0500 | [diff] [blame] | 169 | unprepare: |
| 170 | if (ret) |
| 171 | k3_dsp_unprepare(dev); |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 172 | proc_release: |
| 173 | ti_sci_proc_release(&dsp->tsp); |
| 174 | return ret; |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * k3_dsp_start() - Start the remote processor |
| 179 | * @dev: rproc device pointer |
| 180 | * |
| 181 | * Return: 0 if all went ok, else return appropriate error |
| 182 | */ |
| 183 | static int k3_dsp_start(struct udevice *dev) |
| 184 | { |
| 185 | struct k3_dsp_privdata *dsp = dev_get_priv(dev); |
Suman Anna | be7fa2d | 2020-03-10 16:05:56 -0500 | [diff] [blame] | 186 | struct k3_dsp_boot_data *data = dsp->data; |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 187 | int ret; |
| 188 | |
| 189 | dev_dbg(dev, "%s\n", __func__); |
| 190 | |
| 191 | ret = ti_sci_proc_request(&dsp->tsp); |
| 192 | if (ret) |
| 193 | return ret; |
Suman Anna | 83d8fab | 2020-03-10 16:05:53 -0500 | [diff] [blame] | 194 | |
Suman Anna | be7fa2d | 2020-03-10 16:05:56 -0500 | [diff] [blame] | 195 | if (!data->uses_lreset) { |
| 196 | ret = ti_sci_proc_power_domain_on(&dsp->tsp); |
| 197 | if (ret) |
| 198 | goto proc_release; |
| 199 | } |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 200 | |
| 201 | ret = reset_deassert(&dsp->dsp_rst); |
Suman Anna | be7fa2d | 2020-03-10 16:05:56 -0500 | [diff] [blame] | 202 | if (ret) { |
| 203 | if (!data->uses_lreset) |
| 204 | ti_sci_proc_power_domain_off(&dsp->tsp); |
| 205 | } |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 206 | |
Udit Kumar | a962c2e | 2023-11-25 23:59:39 +0530 | [diff] [blame] | 207 | dsp->in_use = true; |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 208 | proc_release: |
| 209 | ti_sci_proc_release(&dsp->tsp); |
| 210 | |
| 211 | return ret; |
| 212 | } |
| 213 | |
| 214 | static int k3_dsp_stop(struct udevice *dev) |
| 215 | { |
| 216 | struct k3_dsp_privdata *dsp = dev_get_priv(dev); |
| 217 | |
| 218 | dev_dbg(dev, "%s\n", __func__); |
| 219 | |
Udit Kumar | a962c2e | 2023-11-25 23:59:39 +0530 | [diff] [blame] | 220 | dsp->in_use = false; |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 221 | ti_sci_proc_request(&dsp->tsp); |
| 222 | reset_assert(&dsp->dsp_rst); |
| 223 | ti_sci_proc_power_domain_off(&dsp->tsp); |
| 224 | ti_sci_proc_release(&dsp->tsp); |
| 225 | |
| 226 | return 0; |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * k3_dsp_init() - Initialize the remote processor |
| 231 | * @dev: rproc device pointer |
| 232 | * |
| 233 | * Return: 0 if all went ok, else return appropriate error |
| 234 | */ |
| 235 | static int k3_dsp_init(struct udevice *dev) |
| 236 | { |
| 237 | dev_dbg(dev, "%s\n", __func__); |
| 238 | |
| 239 | return 0; |
| 240 | } |
| 241 | |
| 242 | static int k3_dsp_reset(struct udevice *dev) |
| 243 | { |
| 244 | dev_dbg(dev, "%s\n", __func__); |
| 245 | |
| 246 | return 0; |
| 247 | } |
| 248 | |
| 249 | static void *k3_dsp_da_to_va(struct udevice *dev, ulong da, ulong len) |
| 250 | { |
| 251 | struct k3_dsp_privdata *dsp = dev_get_priv(dev); |
| 252 | phys_addr_t bus_addr, dev_addr; |
| 253 | void __iomem *va = NULL; |
| 254 | size_t size; |
| 255 | u32 offset; |
| 256 | int i; |
| 257 | |
| 258 | dev_dbg(dev, "%s\n", __func__); |
| 259 | |
| 260 | if (len <= 0) |
| 261 | return NULL; |
| 262 | |
| 263 | for (i = 0; i < dsp->num_mems; i++) { |
| 264 | bus_addr = dsp->mem[i].bus_addr; |
| 265 | dev_addr = dsp->mem[i].dev_addr; |
| 266 | size = dsp->mem[i].size; |
| 267 | |
| 268 | if (da >= dev_addr && ((da + len) <= (dev_addr + size))) { |
| 269 | offset = da - dev_addr; |
| 270 | va = dsp->mem[i].cpu_addr + offset; |
| 271 | return (__force void *)va; |
| 272 | } |
| 273 | |
| 274 | if (da >= bus_addr && (da + len) <= (bus_addr + size)) { |
| 275 | offset = da - bus_addr; |
| 276 | va = dsp->mem[i].cpu_addr + offset; |
| 277 | return (__force void *)va; |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | /* Assume it is DDR region and return da */ |
| 282 | return map_physmem(da, len, MAP_NOCACHE); |
| 283 | } |
| 284 | |
| 285 | static const struct dm_rproc_ops k3_dsp_ops = { |
| 286 | .init = k3_dsp_init, |
| 287 | .load = k3_dsp_load, |
| 288 | .start = k3_dsp_start, |
| 289 | .stop = k3_dsp_stop, |
| 290 | .reset = k3_dsp_reset, |
| 291 | .device_to_virt = k3_dsp_da_to_va, |
| 292 | }; |
| 293 | |
| 294 | static int ti_sci_proc_of_to_priv(struct udevice *dev, struct ti_sci_proc *tsp) |
| 295 | { |
| 296 | u32 ids[2]; |
| 297 | int ret; |
| 298 | |
| 299 | dev_dbg(dev, "%s\n", __func__); |
| 300 | |
| 301 | tsp->sci = ti_sci_get_by_phandle(dev, "ti,sci"); |
| 302 | if (IS_ERR(tsp->sci)) { |
| 303 | dev_err(dev, "ti_sci get failed: %ld\n", PTR_ERR(tsp->sci)); |
| 304 | return PTR_ERR(tsp->sci); |
| 305 | } |
| 306 | |
| 307 | ret = dev_read_u32_array(dev, "ti,sci-proc-ids", ids, 2); |
| 308 | if (ret) { |
| 309 | dev_err(dev, "Proc IDs not populated %d\n", ret); |
| 310 | return ret; |
| 311 | } |
| 312 | |
| 313 | tsp->ops = &tsp->sci->ops.proc_ops; |
| 314 | tsp->proc_id = ids[0]; |
| 315 | tsp->host_id = ids[1]; |
| 316 | tsp->dev_id = dev_read_u32_default(dev, "ti,sci-dev-id", |
| 317 | TI_SCI_RESOURCE_NULL); |
| 318 | if (tsp->dev_id == TI_SCI_RESOURCE_NULL) { |
| 319 | dev_err(dev, "Device ID not populated %d\n", ret); |
| 320 | return -ENODEV; |
| 321 | } |
| 322 | |
| 323 | return 0; |
| 324 | } |
| 325 | |
| 326 | static int k3_dsp_of_get_memories(struct udevice *dev) |
| 327 | { |
| 328 | static const char * const mem_names[] = {"l2sram", "l1pram", "l1dram"}; |
| 329 | struct k3_dsp_privdata *dsp = dev_get_priv(dev); |
| 330 | int i; |
| 331 | |
| 332 | dev_dbg(dev, "%s\n", __func__); |
| 333 | |
| 334 | dsp->num_mems = ARRAY_SIZE(mem_names); |
| 335 | dsp->mem = calloc(dsp->num_mems, sizeof(*dsp->mem)); |
| 336 | if (!dsp->mem) |
| 337 | return -ENOMEM; |
| 338 | |
| 339 | for (i = 0; i < dsp->num_mems; i++) { |
| 340 | /* C71 cores only have a L1P Cache, there are no L1P SRAMs */ |
| 341 | if (device_is_compatible(dev, "ti,j721e-c71-dsp") && |
| 342 | !strcmp(mem_names[i], "l1pram")) { |
| 343 | dsp->mem[i].bus_addr = FDT_ADDR_T_NONE; |
| 344 | dsp->mem[i].dev_addr = FDT_ADDR_T_NONE; |
| 345 | dsp->mem[i].cpu_addr = NULL; |
| 346 | dsp->mem[i].size = 0; |
| 347 | continue; |
| 348 | } |
| 349 | |
| 350 | dsp->mem[i].bus_addr = dev_read_addr_size_name(dev, mem_names[i], |
| 351 | (fdt_addr_t *)&dsp->mem[i].size); |
| 352 | if (dsp->mem[i].bus_addr == FDT_ADDR_T_NONE) { |
| 353 | dev_err(dev, "%s bus address not found\n", mem_names[i]); |
| 354 | return -EINVAL; |
| 355 | } |
| 356 | dsp->mem[i].cpu_addr = map_physmem(dsp->mem[i].bus_addr, |
| 357 | dsp->mem[i].size, |
| 358 | MAP_NOCACHE); |
| 359 | dsp->mem[i].dev_addr = dsp->mem[i].bus_addr & |
| 360 | KEYSTONE_RPROC_LOCAL_ADDRESS_MASK; |
| 361 | |
| 362 | dev_dbg(dev, "memory %8s: bus addr %pa size 0x%zx va %p da %pa\n", |
| 363 | mem_names[i], &dsp->mem[i].bus_addr, |
| 364 | dsp->mem[i].size, dsp->mem[i].cpu_addr, |
| 365 | &dsp->mem[i].dev_addr); |
| 366 | } |
| 367 | |
| 368 | return 0; |
| 369 | } |
| 370 | |
| 371 | /** |
| 372 | * k3_of_to_priv() - generate private data from device tree |
| 373 | * @dev: corresponding k3 dsp processor device |
| 374 | * @dsp: pointer to driver specific private data |
| 375 | * |
| 376 | * Return: 0 if all goes good, else appropriate error message. |
| 377 | */ |
| 378 | static int k3_dsp_of_to_priv(struct udevice *dev, struct k3_dsp_privdata *dsp) |
| 379 | { |
| 380 | int ret; |
| 381 | |
| 382 | dev_dbg(dev, "%s\n", __func__); |
| 383 | |
| 384 | ret = reset_get_by_index(dev, 0, &dsp->dsp_rst); |
| 385 | if (ret) { |
| 386 | dev_err(dev, "reset_get() failed: %d\n", ret); |
| 387 | return ret; |
| 388 | } |
| 389 | |
| 390 | ret = ti_sci_proc_of_to_priv(dev, &dsp->tsp); |
| 391 | if (ret) |
| 392 | return ret; |
| 393 | |
| 394 | ret = k3_dsp_of_get_memories(dev); |
| 395 | if (ret) |
| 396 | return ret; |
| 397 | |
Suman Anna | e45fa38 | 2020-03-10 16:05:54 -0500 | [diff] [blame] | 398 | dsp->data = (struct k3_dsp_boot_data *)dev_get_driver_data(dev); |
| 399 | |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 400 | return 0; |
| 401 | } |
| 402 | |
| 403 | /** |
| 404 | * k3_dsp_probe() - Basic probe |
| 405 | * @dev: corresponding k3 remote processor device |
| 406 | * |
| 407 | * Return: 0 if all goes good, else appropriate error message. |
| 408 | */ |
| 409 | static int k3_dsp_probe(struct udevice *dev) |
| 410 | { |
| 411 | struct k3_dsp_privdata *dsp; |
| 412 | int ret; |
| 413 | |
| 414 | dev_dbg(dev, "%s\n", __func__); |
| 415 | |
| 416 | dsp = dev_get_priv(dev); |
| 417 | |
| 418 | ret = k3_dsp_of_to_priv(dev, dsp); |
| 419 | if (ret) { |
| 420 | dev_dbg(dev, "%s: Probe failed with error %d\n", __func__, ret); |
| 421 | return ret; |
| 422 | } |
| 423 | |
Suman Anna | be7fa2d | 2020-03-10 16:05:56 -0500 | [diff] [blame] | 424 | /* |
| 425 | * The DSP local resets are deasserted by default on Power-On-Reset. |
| 426 | * Assert the local resets to ensure the DSPs don't execute bogus code |
| 427 | * in .load() callback when the module reset is released to support |
| 428 | * internal memory loading. This is needed for C66x DSPs, and is a |
| 429 | * no-op on C71x DSPs. |
| 430 | */ |
| 431 | reset_assert(&dsp->dsp_rst); |
| 432 | |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 433 | dev_dbg(dev, "Remoteproc successfully probed\n"); |
| 434 | |
| 435 | return 0; |
| 436 | } |
| 437 | |
| 438 | static int k3_dsp_remove(struct udevice *dev) |
| 439 | { |
| 440 | struct k3_dsp_privdata *dsp = dev_get_priv(dev); |
| 441 | |
| 442 | free(dsp->mem); |
| 443 | |
| 444 | return 0; |
| 445 | } |
| 446 | |
Suman Anna | e45fa38 | 2020-03-10 16:05:54 -0500 | [diff] [blame] | 447 | static const struct k3_dsp_boot_data c66_data = { |
| 448 | .boot_align_addr = SZ_1K, |
Suman Anna | be7fa2d | 2020-03-10 16:05:56 -0500 | [diff] [blame] | 449 | .uses_lreset = true, |
Suman Anna | e45fa38 | 2020-03-10 16:05:54 -0500 | [diff] [blame] | 450 | }; |
| 451 | |
| 452 | static const struct k3_dsp_boot_data c71_data = { |
| 453 | .boot_align_addr = SZ_2M, |
Suman Anna | be7fa2d | 2020-03-10 16:05:56 -0500 | [diff] [blame] | 454 | .uses_lreset = false, |
Suman Anna | e45fa38 | 2020-03-10 16:05:54 -0500 | [diff] [blame] | 455 | }; |
| 456 | |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 457 | static const struct udevice_id k3_dsp_ids[] = { |
Suman Anna | e45fa38 | 2020-03-10 16:05:54 -0500 | [diff] [blame] | 458 | { .compatible = "ti,j721e-c66-dsp", .data = (ulong)&c66_data, }, |
| 459 | { .compatible = "ti,j721e-c71-dsp", .data = (ulong)&c71_data, }, |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 460 | {} |
| 461 | }; |
| 462 | |
| 463 | U_BOOT_DRIVER(k3_dsp) = { |
| 464 | .name = "k3_dsp", |
| 465 | .of_match = k3_dsp_ids, |
| 466 | .id = UCLASS_REMOTEPROC, |
| 467 | .ops = &k3_dsp_ops, |
| 468 | .probe = k3_dsp_probe, |
| 469 | .remove = k3_dsp_remove, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 470 | .priv_auto = sizeof(struct k3_dsp_privdata), |
Lokesh Vutla | 2c77185 | 2019-09-04 16:01:36 +0530 | [diff] [blame] | 471 | }; |