Lines Matching full:core

78  *   Single-Core mode : AM62x, AM62A SoCs
92 * @is_single_core: flag to denote if SoC/IP has only single core R5
106 * @core_transition: wait queue to sync core state changes
118 * struct k3_r5_core - K3 R5 core structure
121 * @rproc: rproc handle representing this core
133 * @released_from_reset: flag to signal when core is out of reset
160 * @core: cached pointer to r5 core structure being used
170 struct k3_r5_core *core; member
183 * and we let remoteproc core handle it.
197 /* Do not forward message from a detached core */ in k3_r5_rproc_mbox_callback()
236 /* Do not forward message to a detached core */ in k3_r5_rproc_kick()
247 static int k3_r5_split_reset(struct k3_r5_core *core) in k3_r5_split_reset() argument
251 ret = reset_control_assert(core->reset); in k3_r5_split_reset()
253 dev_err(core->dev, "local-reset assert failed, ret = %d\n", in k3_r5_split_reset()
258 ret = core->ti_sci->ops.dev_ops.put_device(core->ti_sci, in k3_r5_split_reset()
259 core->ti_sci_id); in k3_r5_split_reset()
261 dev_err(core->dev, "module-reset assert failed, ret = %d\n", in k3_r5_split_reset()
263 if (reset_control_deassert(core->reset)) in k3_r5_split_reset()
264 dev_warn(core->dev, "local-reset deassert back failed\n"); in k3_r5_split_reset()
270 static int k3_r5_split_release(struct k3_r5_core *core) in k3_r5_split_release() argument
274 ret = core->ti_sci->ops.dev_ops.get_device(core->ti_sci, in k3_r5_split_release()
275 core->ti_sci_id); in k3_r5_split_release()
277 dev_err(core->dev, "module-reset deassert failed, ret = %d\n", in k3_r5_split_release()
282 ret = reset_control_deassert(core->reset); in k3_r5_split_release()
284 dev_err(core->dev, "local-reset deassert failed, ret = %d\n", in k3_r5_split_release()
286 if (core->ti_sci->ops.dev_ops.put_device(core->ti_sci, in k3_r5_split_release()
287 core->ti_sci_id)) in k3_r5_split_release()
288 dev_warn(core->dev, "module-reset assert back failed\n"); in k3_r5_split_release()
296 struct k3_r5_core *core; in k3_r5_lockstep_reset() local
300 list_for_each_entry(core, &cluster->cores, elem) { in k3_r5_lockstep_reset()
301 ret = reset_control_assert(core->reset); in k3_r5_lockstep_reset()
303 dev_err(core->dev, "local-reset assert failed, ret = %d\n", in k3_r5_lockstep_reset()
305 core = list_prev_entry(core, elem); in k3_r5_lockstep_reset()
311 list_for_each_entry(core, &cluster->cores, elem) { in k3_r5_lockstep_reset()
312 ret = core->ti_sci->ops.dev_ops.put_device(core->ti_sci, in k3_r5_lockstep_reset()
313 core->ti_sci_id); in k3_r5_lockstep_reset()
315 dev_err(core->dev, "module-reset assert failed, ret = %d\n", in k3_r5_lockstep_reset()
324 list_for_each_entry_continue_reverse(core, &cluster->cores, elem) { in k3_r5_lockstep_reset()
325 if (core->ti_sci->ops.dev_ops.put_device(core->ti_sci, in k3_r5_lockstep_reset()
326 core->ti_sci_id)) in k3_r5_lockstep_reset()
327 dev_warn(core->dev, "module-reset assert back failed\n"); in k3_r5_lockstep_reset()
329 core = list_last_entry(&cluster->cores, struct k3_r5_core, elem); in k3_r5_lockstep_reset()
331 list_for_each_entry_from_reverse(core, &cluster->cores, elem) { in k3_r5_lockstep_reset()
332 if (reset_control_deassert(core->reset)) in k3_r5_lockstep_reset()
333 dev_warn(core->dev, "local-reset deassert back failed\n"); in k3_r5_lockstep_reset()
341 struct k3_r5_core *core; in k3_r5_lockstep_release() local
345 list_for_each_entry_reverse(core, &cluster->cores, elem) { in k3_r5_lockstep_release()
346 ret = core->ti_sci->ops.dev_ops.get_device(core->ti_sci, in k3_r5_lockstep_release()
347 core->ti_sci_id); in k3_r5_lockstep_release()
349 dev_err(core->dev, "module-reset deassert failed, ret = %d\n", in k3_r5_lockstep_release()
351 core = list_next_entry(core, elem); in k3_r5_lockstep_release()
357 list_for_each_entry_reverse(core, &cluster->cores, elem) { in k3_r5_lockstep_release()
358 ret = reset_control_deassert(core->reset); in k3_r5_lockstep_release()
360 dev_err(core->dev, "module-reset deassert failed, ret = %d\n", in k3_r5_lockstep_release()
369 list_for_each_entry_continue(core, &cluster->cores, elem) { in k3_r5_lockstep_release()
370 if (reset_control_assert(core->reset)) in k3_r5_lockstep_release()
371 dev_warn(core->dev, "local-reset assert back failed\n"); in k3_r5_lockstep_release()
373 core = list_first_entry(&cluster->cores, struct k3_r5_core, elem); in k3_r5_lockstep_release()
375 list_for_each_entry_from(core, &cluster->cores, elem) { in k3_r5_lockstep_release()
376 if (core->ti_sci->ops.dev_ops.put_device(core->ti_sci, in k3_r5_lockstep_release()
377 core->ti_sci_id)) in k3_r5_lockstep_release()
378 dev_warn(core->dev, "module-reset assert back failed\n"); in k3_r5_lockstep_release()
384 static inline int k3_r5_core_halt(struct k3_r5_core *core) in k3_r5_core_halt() argument
386 return ti_sci_proc_set_control(core->tsp, in k3_r5_core_halt()
390 static inline int k3_r5_core_run(struct k3_r5_core *core) in k3_r5_core_run() argument
392 return ti_sci_proc_set_control(core->tsp, in k3_r5_core_run()
436 * invoked by remoteproc core before any firmware loading, and is followed
442 * private to each core. Only Core0 needs to be unhalted for running the
451 struct k3_r5_core *core = kproc->core; in k3_r5_rproc_prepare() local
458 ret = ti_sci_proc_get_status(core->tsp, &boot_vec, &cfg, &ctrl, &stat); in k3_r5_rproc_prepare()
466 k3_r5_lockstep_release(cluster) : k3_r5_split_release(core); in k3_r5_rproc_prepare()
485 * Zero out both TCMs unconditionally (access from v8 Arm core is not in k3_r5_rproc_prepare()
490 memset(core->mem[0].cpu_addr, 0x00, core->mem[0].size); in k3_r5_rproc_prepare()
493 memset(core->mem[1].cpu_addr, 0x00, core->mem[1].size); in k3_r5_rproc_prepare()
504 * .unprepare() ops is invoked by the remoteproc core after the remoteproc is
518 struct k3_r5_core *core = kproc->core; in k3_r5_rproc_unprepare() local
525 k3_r5_lockstep_reset(cluster) : k3_r5_split_reset(core); in k3_r5_rproc_unprepare()
534 * 1. Configure the boot vector for R5F core(s)
535 * 2. Unhalt/Run the R5F core(s)
554 struct k3_r5_core *core0, *core; in k3_r5_rproc_start() local
560 dev_dbg(dev, "booting R5F core using boot addr = 0x%x\n", boot_addr); in k3_r5_rproc_start()
563 core = kproc->core; in k3_r5_rproc_start()
564 ret = ti_sci_proc_set_config(core->tsp, boot_addr, 0, 0); in k3_r5_rproc_start()
570 list_for_each_entry_reverse(core, &cluster->cores, elem) { in k3_r5_rproc_start()
571 ret = k3_r5_core_run(core); in k3_r5_rproc_start()
576 /* do not allow core 1 to start before core 0 */ in k3_r5_rproc_start()
579 if (core != core0 && core0->rproc->state == RPROC_OFFLINE) { in k3_r5_rproc_start()
580 dev_err(dev, "%s: can not start core 1 before core 0\n", in k3_r5_rproc_start()
585 ret = k3_r5_core_run(core); in k3_r5_rproc_start()
589 core->released_from_reset = true; in k3_r5_rproc_start()
596 list_for_each_entry_continue(core, &cluster->cores, elem) { in k3_r5_rproc_start()
597 if (k3_r5_core_halt(core)) in k3_r5_rproc_start()
598 dev_warn(core->dev, "core halt back failed\n"); in k3_r5_rproc_start()
605 * 1. Halt R5F core(s)
619 * core is running, but is needed to make sure the core won't run after
632 struct k3_r5_core *core1, *core = kproc->core; in k3_r5_rproc_stop() local
637 list_for_each_entry(core, &cluster->cores, elem) { in k3_r5_rproc_stop()
638 ret = k3_r5_core_halt(core); in k3_r5_rproc_stop()
640 core = list_prev_entry(core, elem); in k3_r5_rproc_stop()
645 /* do not allow core 0 to stop before core 1 */ in k3_r5_rproc_stop()
648 if (core != core1 && core1->rproc->state != RPROC_OFFLINE) { in k3_r5_rproc_stop()
649 dev_err(dev, "%s: can not stop core 0 before core 1\n", in k3_r5_rproc_stop()
655 ret = k3_r5_core_halt(core); in k3_r5_rproc_stop()
663 list_for_each_entry_from_reverse(core, &cluster->cores, elem) { in k3_r5_rproc_stop()
664 if (k3_r5_core_run(core)) in k3_r5_rproc_stop()
665 dev_warn(core->dev, "core run back failed\n"); in k3_r5_rproc_stop()
729 * either by the remoteproc core for loading, or by any rpmsg bus drivers.
734 struct k3_r5_core *core = kproc->core; in k3_r5_rproc_da_to_va() local
745 for (i = 0; i < core->num_mems; i++) { in k3_r5_rproc_da_to_va()
746 bus_addr = core->mem[i].bus_addr; in k3_r5_rproc_da_to_va()
747 dev_addr = core->mem[i].dev_addr; in k3_r5_rproc_da_to_va()
748 size = core->mem[i].size; in k3_r5_rproc_da_to_va()
753 va = core->mem[i].cpu_addr + offset; in k3_r5_rproc_da_to_va()
760 va = core->mem[i].cpu_addr + offset; in k3_r5_rproc_da_to_va()
766 for (i = 0; i < core->num_sram; i++) { in k3_r5_rproc_da_to_va()
767 dev_addr = core->sram[i].dev_addr; in k3_r5_rproc_da_to_va()
768 size = core->sram[i].size; in k3_r5_rproc_da_to_va()
772 va = core->sram[i].cpu_addr + offset; in k3_r5_rproc_da_to_va()
802 * Internal R5F Core configuration
807 * as an alternate for LockStep mode that exercises only a single R5F core
808 * called Single-CPU mode. Each R5F core has a number of settings to either
809 * enable/disable each of the TCMs, control which TCM appears at the R5F core's
811 * corresponding core are released. These settings are all protected and managed
814 * This function is used to pre-configure these settings for each R5F core, and
840 struct k3_r5_core *core0, *core, *temp; in k3_r5_rproc_configure() local
852 core = core0; in k3_r5_rproc_configure()
854 core = kproc->core; in k3_r5_rproc_configure()
857 ret = ti_sci_proc_get_status(core->tsp, &boot_vec, &cfg, &ctrl, in k3_r5_rproc_configure()
882 if (core == core0) { in k3_r5_rproc_configure()
905 if (core->atcm_enable) in k3_r5_rproc_configure()
910 if (core->btcm_enable) in k3_r5_rproc_configure()
915 if (core->loczrama) in k3_r5_rproc_configure()
931 if (temp != core) { in k3_r5_rproc_configure()
943 ret = ti_sci_proc_set_config(core->tsp, boot_vec, in k3_r5_rproc_configure()
946 ret = k3_r5_core_halt(core); in k3_r5_rproc_configure()
950 ret = ti_sci_proc_set_config(core->tsp, boot_vec, in k3_r5_rproc_configure()
1062 * Each R5F core within a typical R5FSS instance has a total of 64 KB of TCMs,
1077 struct k3_r5_core *core = kproc->core; in k3_r5_adjust_tcm_sizes() local
1078 struct device *cdev = core->dev; in k3_r5_adjust_tcm_sizes()
1088 if (core == core0) { in k3_r5_adjust_tcm_sizes()
1089 WARN_ON(core->mem[0].size != SZ_64K); in k3_r5_adjust_tcm_sizes()
1090 WARN_ON(core->mem[1].size != SZ_64K); in k3_r5_adjust_tcm_sizes()
1092 core->mem[0].size /= 2; in k3_r5_adjust_tcm_sizes()
1093 core->mem[1].size /= 2; in k3_r5_adjust_tcm_sizes()
1096 core->mem[0].size, core->mem[1].size); in k3_r5_adjust_tcm_sizes()
1101 * This function checks and configures a R5F core for IPC-only or remoteproc
1102 * mode. The driver is configured to be in IPC-only mode for a R5F core when
1103 * the core has been loaded and started by a bootloader. The IPC-only mode is
1105 * and ensuring that the core is running. Any incomplete steps at bootloader
1116 struct k3_r5_core *core = kproc->core; in k3_r5_rproc_configure_mode() local
1117 struct device *cdev = core->dev; in k3_r5_rproc_configure_mode()
1129 ret = core->ti_sci->ops.dev_ops.is_on(core->ti_sci, core->ti_sci_id, in k3_r5_rproc_configure_mode()
1137 …dev_warn(cdev, "R5F core may have been powered on by a different host, programmed state (%d) != ac… in k3_r5_rproc_configure_mode()
1141 reset_ctrl_status = reset_control_status(core->reset); in k3_r5_rproc_configure_mode()
1150 * core has already been booted by another entity. in k3_r5_rproc_configure_mode()
1152 core->released_from_reset = c_state; in k3_r5_rproc_configure_mode()
1154 ret = ti_sci_proc_get_status(core->tsp, &boot_vec, &cfg, &ctrl, in k3_r5_rproc_configure_mode()
1176 * be deasserted and R5F core to be unhalted. Local reset status is in k3_r5_rproc_configure_mode()
1204 /* fixup TCMs, cluster & core flags to actual values in IPC-only mode */ in k3_r5_rproc_configure_mode()
1206 if (core == core0) in k3_r5_rproc_configure_mode()
1208 core->atcm_enable = atcm_enable; in k3_r5_rproc_configure_mode()
1209 core->btcm_enable = btcm_enable; in k3_r5_rproc_configure_mode()
1210 core->loczrama = loczrama; in k3_r5_rproc_configure_mode()
1211 core->mem[0].dev_addr = loczrama ? 0 : K3_R5_TCM_DEV_ADDR; in k3_r5_rproc_configure_mode()
1212 core->mem[1].dev_addr = loczrama ? K3_R5_TCM_DEV_ADDR : 0; in k3_r5_rproc_configure_mode()
1223 struct k3_r5_core *core, *core1; in k3_r5_cluster_rproc_init() local
1230 list_for_each_entry(core, &cluster->cores, elem) { in k3_r5_cluster_rproc_init()
1231 cdev = core->dev; in k3_r5_cluster_rproc_init()
1253 kproc->core = core; in k3_r5_cluster_rproc_init()
1256 core->rproc = rproc; in k3_r5_cluster_rproc_init()
1292 * single core mode in k3_r5_cluster_rproc_init()
1302 * So, wait for current core to power up before proceeding in k3_r5_cluster_rproc_init()
1303 * to next core and put timeout of 2sec for each core. in k3_r5_cluster_rproc_init()
1310 core->released_from_reset, in k3_r5_cluster_rproc_init()
1314 "Timed out waiting for %s core to power up!\n", in k3_r5_cluster_rproc_init()
1338 if (cluster->mode == CLUSTER_MODE_SPLIT && core == core1) { in k3_r5_cluster_rproc_init()
1339 core = list_prev_entry(core, elem); in k3_r5_cluster_rproc_init()
1340 rproc = core->rproc; in k3_r5_cluster_rproc_init()
1351 struct k3_r5_core *core; in k3_r5_cluster_rproc_exit() local
1357 * with first core, whereas split-mode has two rprocs associated with in k3_r5_cluster_rproc_exit()
1358 * each core, and requires that core1 be powered down first in k3_r5_cluster_rproc_exit()
1360 core = (cluster->mode == CLUSTER_MODE_LOCKSTEP || in k3_r5_cluster_rproc_exit()
1365 list_for_each_entry_from_reverse(core, &cluster->cores, elem) { in k3_r5_cluster_rproc_exit()
1366 rproc = core->rproc; in k3_r5_cluster_rproc_exit()
1386 struct k3_r5_core *core) in k3_r5_core_of_get_internal_memories() argument
1395 core->mem = devm_kcalloc(dev, num_mems, sizeof(*core->mem), GFP_KERNEL); in k3_r5_core_of_get_internal_memories()
1396 if (!core->mem) in k3_r5_core_of_get_internal_memories()
1422 core->mem[i].cpu_addr = devm_ioremap_wc(dev, res->start, in k3_r5_core_of_get_internal_memories()
1424 if (!core->mem[i].cpu_addr) { in k3_r5_core_of_get_internal_memories()
1428 core->mem[i].bus_addr = res->start; in k3_r5_core_of_get_internal_memories()
1439 core->mem[i].dev_addr = core->loczrama ? in k3_r5_core_of_get_internal_memories()
1442 core->mem[i].dev_addr = core->loczrama ? in k3_r5_core_of_get_internal_memories()
1445 core->mem[i].size = resource_size(res); in k3_r5_core_of_get_internal_memories()
1448 mem_names[i], &core->mem[i].bus_addr, in k3_r5_core_of_get_internal_memories()
1449 core->mem[i].size, core->mem[i].cpu_addr, in k3_r5_core_of_get_internal_memories()
1450 core->mem[i].dev_addr); in k3_r5_core_of_get_internal_memories()
1452 core->num_mems = num_mems; in k3_r5_core_of_get_internal_memories()
1458 struct k3_r5_core *core) in k3_r5_core_of_get_sram_memories() argument
1474 core->sram = devm_kcalloc(dev, num_sram, sizeof(*core->sram), GFP_KERNEL); in k3_r5_core_of_get_sram_memories()
1475 if (!core->sram) in k3_r5_core_of_get_sram_memories()
1493 core->sram[i].bus_addr = res.start; in k3_r5_core_of_get_sram_memories()
1494 core->sram[i].dev_addr = res.start; in k3_r5_core_of_get_sram_memories()
1495 core->sram[i].size = resource_size(&res); in k3_r5_core_of_get_sram_memories()
1496 core->sram[i].cpu_addr = devm_ioremap_wc(dev, res.start, in k3_r5_core_of_get_sram_memories()
1498 if (!core->sram[i].cpu_addr) { in k3_r5_core_of_get_sram_memories()
1505 i, &core->sram[i].bus_addr, in k3_r5_core_of_get_sram_memories()
1506 core->sram[i].size, core->sram[i].cpu_addr, in k3_r5_core_of_get_sram_memories()
1507 core->sram[i].dev_addr); in k3_r5_core_of_get_sram_memories()
1509 core->num_sram = num_sram; in k3_r5_core_of_get_sram_memories()
1518 struct k3_r5_core *core; in k3_r5_core_of_init() local
1524 core = devm_kzalloc(dev, sizeof(*core), GFP_KERNEL); in k3_r5_core_of_init()
1525 if (!core) { in k3_r5_core_of_init()
1530 core->dev = dev; in k3_r5_core_of_init()
1535 core->atcm_enable = 0; in k3_r5_core_of_init()
1536 core->btcm_enable = 1; in k3_r5_core_of_init()
1537 core->loczrama = 1; in k3_r5_core_of_init()
1539 ret = of_property_read_u32(np, "ti,atcm-enable", &core->atcm_enable); in k3_r5_core_of_init()
1546 ret = of_property_read_u32(np, "ti,btcm-enable", &core->btcm_enable); in k3_r5_core_of_init()
1553 ret = of_property_read_u32(np, "ti,loczrama", &core->loczrama); in k3_r5_core_of_init()
1559 core->ti_sci = devm_ti_sci_get_by_phandle(dev, "ti,sci"); in k3_r5_core_of_init()
1560 if (IS_ERR(core->ti_sci)) { in k3_r5_core_of_init()
1561 ret = PTR_ERR(core->ti_sci); in k3_r5_core_of_init()
1566 core->ti_sci = NULL; in k3_r5_core_of_init()
1570 ret = of_property_read_u32(np, "ti,sci-dev-id", &core->ti_sci_id); in k3_r5_core_of_init()
1576 core->reset = devm_reset_control_get_exclusive(dev, NULL); in k3_r5_core_of_init()
1577 if (IS_ERR_OR_NULL(core->reset)) { in k3_r5_core_of_init()
1578 ret = PTR_ERR_OR_ZERO(core->reset); in k3_r5_core_of_init()
1588 core->tsp = ti_sci_proc_of_get_tsp(dev, core->ti_sci); in k3_r5_core_of_init()
1589 if (IS_ERR(core->tsp)) { in k3_r5_core_of_init()
1590 ret = PTR_ERR(core->tsp); in k3_r5_core_of_init()
1596 ret = k3_r5_core_of_get_internal_memories(pdev, core); in k3_r5_core_of_init()
1603 ret = k3_r5_core_of_get_sram_memories(pdev, core); in k3_r5_core_of_init()
1609 ret = ti_sci_proc_request(core->tsp); in k3_r5_core_of_init()
1615 platform_set_drvdata(pdev, core); in k3_r5_core_of_init()
1631 struct k3_r5_core *core = platform_get_drvdata(pdev); in k3_r5_core_of_exit() local
1635 ret = ti_sci_proc_release(core->tsp); in k3_r5_core_of_exit()
1647 struct k3_r5_core *core, *temp; in k3_r5_cluster_of_exit() local
1649 list_for_each_entry_safe_reverse(core, temp, &cluster->cores, elem) { in k3_r5_cluster_of_exit()
1650 list_del(&core->elem); in k3_r5_cluster_of_exit()
1651 cpdev = to_platform_device(core->dev); in k3_r5_cluster_of_exit()
1663 struct k3_r5_core *core; in k3_r5_cluster_of_init() local
1670 dev_err(dev, "could not get R5 core platform device\n"); in k3_r5_cluster_of_init()
1684 core = platform_get_drvdata(cpdev); in k3_r5_cluster_of_init()
1686 list_add_tail(&core->elem, &cluster->cores); in k3_r5_cluster_of_init()
1733 * Single core on AM62x in k3_r5_probe()
1757 dev_err(dev, "SoC supports only single core R5 but num_cores is set to %d\n", in k3_r5_probe()