Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

remoteproc: mediatek: Support MT8188 SCP core 1

MT8188 SCP has two RISC-V cores which is similar to MT8195 but without
L1TCM. We've added MT8188-specific functions to configure L1TCM in
multicore setups.

Signed-off-by: Olivia Wen <olivia.wen@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20240430011534.9587-3-olivia.wen@mediatek.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>

authored by

Olivia Wen and committed by
Mathieu Poirier
928a55ab 91e0d560

+143 -3
+143 -3
drivers/remoteproc/mtk_scp.c
··· 471 471 return 0; 472 472 } 473 473 474 + static int mt8188_scp_l2tcm_on(struct mtk_scp *scp) 475 + { 476 + struct mtk_scp_of_cluster *scp_cluster = scp->cluster; 477 + 478 + mutex_lock(&scp_cluster->cluster_lock); 479 + 480 + if (scp_cluster->l2tcm_refcnt == 0) { 481 + /* clear SPM interrupt, SCP2SPM_IPC_CLR */ 482 + writel(0xff, scp->cluster->reg_base + MT8192_SCP2SPM_IPC_CLR); 483 + 484 + /* Power on L2TCM */ 485 + scp_sram_power_on(scp->cluster->reg_base + MT8192_L2TCM_SRAM_PD_0, 0); 486 + scp_sram_power_on(scp->cluster->reg_base + MT8192_L2TCM_SRAM_PD_1, 0); 487 + scp_sram_power_on(scp->cluster->reg_base + MT8192_L2TCM_SRAM_PD_2, 0); 488 + scp_sram_power_on(scp->cluster->reg_base + MT8192_L1TCM_SRAM_PDN, 0); 489 + } 490 + 491 + scp_cluster->l2tcm_refcnt += 1; 492 + 493 + mutex_unlock(&scp_cluster->cluster_lock); 494 + 495 + return 0; 496 + } 497 + 498 + static int mt8188_scp_before_load(struct mtk_scp *scp) 499 + { 500 + writel(1, scp->cluster->reg_base + MT8192_CORE0_SW_RSTN_SET); 501 + 502 + mt8188_scp_l2tcm_on(scp); 503 + 504 + scp_sram_power_on(scp->cluster->reg_base + MT8192_CPU0_SRAM_PD, 0); 505 + 506 + /* enable MPU for all memory regions */ 507 + writel(0xff, scp->cluster->reg_base + MT8192_CORE0_MEM_ATT_PREDEF); 508 + 509 + return 0; 510 + } 511 + 512 + static int mt8188_scp_c1_before_load(struct mtk_scp *scp) 513 + { 514 + u32 sec_ctrl; 515 + struct mtk_scp *scp_c0; 516 + struct mtk_scp_of_cluster *scp_cluster = scp->cluster; 517 + 518 + scp->data->scp_reset_assert(scp); 519 + 520 + mt8188_scp_l2tcm_on(scp); 521 + 522 + scp_sram_power_on(scp->cluster->reg_base + MT8195_CPU1_SRAM_PD, 0); 523 + 524 + /* enable MPU for all memory regions */ 525 + writel(0xff, scp->cluster->reg_base + MT8195_CORE1_MEM_ATT_PREDEF); 526 + 527 + /* 528 + * The L2TCM_OFFSET_RANGE and L2TCM_OFFSET shift the destination address 529 + * on SRAM when SCP core 1 accesses SRAM. 530 + * 531 + * This configuration solves booting the SCP core 0 and core 1 from 532 + * different SRAM address because core 0 and core 1 both boot from 533 + * the head of SRAM by default. this must be configured before boot SCP core 1. 534 + * 535 + * The value of L2TCM_OFFSET_RANGE is from the viewpoint of SCP core 1. 536 + * When SCP core 1 issues address within the range (L2TCM_OFFSET_RANGE), 537 + * the address will be added with a fixed offset (L2TCM_OFFSET) on the bus. 538 + * The shift action is tranparent to software. 539 + */ 540 + writel(0, scp->cluster->reg_base + MT8195_L2TCM_OFFSET_RANGE_0_LOW); 541 + writel(scp->sram_size, scp->cluster->reg_base + MT8195_L2TCM_OFFSET_RANGE_0_HIGH); 542 + 543 + scp_c0 = list_first_entry(&scp_cluster->mtk_scp_list, struct mtk_scp, elem); 544 + writel(scp->sram_phys - scp_c0->sram_phys, scp->cluster->reg_base + MT8195_L2TCM_OFFSET); 545 + 546 + /* enable SRAM offset when fetching instruction and data */ 547 + sec_ctrl = readl(scp->cluster->reg_base + MT8195_SEC_CTRL); 548 + sec_ctrl |= MT8195_CORE_OFFSET_ENABLE_I | MT8195_CORE_OFFSET_ENABLE_D; 549 + writel(sec_ctrl, scp->cluster->reg_base + MT8195_SEC_CTRL); 550 + 551 + return 0; 552 + } 553 + 474 554 static int mt8192_scp_before_load(struct mtk_scp *scp) 475 555 { 476 556 /* clear SPM interrupt, SCP2SPM_IPC_CLR */ ··· 795 715 { 796 716 /* Disable SCP watchdog */ 797 717 writel(0, scp->cluster->reg_base + MT8183_WDT_CFG); 718 + } 719 + 720 + static void mt8188_scp_l2tcm_off(struct mtk_scp *scp) 721 + { 722 + struct mtk_scp_of_cluster *scp_cluster = scp->cluster; 723 + 724 + mutex_lock(&scp_cluster->cluster_lock); 725 + 726 + if (scp_cluster->l2tcm_refcnt > 0) 727 + scp_cluster->l2tcm_refcnt -= 1; 728 + 729 + if (scp_cluster->l2tcm_refcnt == 0) { 730 + /* Power off L2TCM */ 731 + scp_sram_power_off(scp->cluster->reg_base + MT8192_L2TCM_SRAM_PD_0, 0); 732 + scp_sram_power_off(scp->cluster->reg_base + MT8192_L2TCM_SRAM_PD_1, 0); 733 + scp_sram_power_off(scp->cluster->reg_base + MT8192_L2TCM_SRAM_PD_2, 0); 734 + scp_sram_power_off(scp->cluster->reg_base + MT8192_L1TCM_SRAM_PDN, 0); 735 + } 736 + 737 + mutex_unlock(&scp_cluster->cluster_lock); 738 + } 739 + 740 + static void mt8188_scp_stop(struct mtk_scp *scp) 741 + { 742 + mt8188_scp_l2tcm_off(scp); 743 + 744 + scp_sram_power_off(scp->cluster->reg_base + MT8192_CPU0_SRAM_PD, 0); 745 + 746 + /* Disable SCP watchdog */ 747 + writel(0, scp->cluster->reg_base + MT8192_CORE0_WDT_CFG); 748 + } 749 + 750 + static void mt8188_scp_c1_stop(struct mtk_scp *scp) 751 + { 752 + mt8188_scp_l2tcm_off(scp); 753 + 754 + /* Power off CPU SRAM */ 755 + scp_sram_power_off(scp->cluster->reg_base + MT8195_CPU1_SRAM_PD, 0); 756 + 757 + /* Disable SCP watchdog */ 758 + writel(0, scp->cluster->reg_base + MT8195_CORE1_WDT_CFG); 798 759 } 799 760 800 761 static void mt8192_scp_stop(struct mtk_scp *scp) ··· 1385 1264 1386 1265 static const struct mtk_scp_of_data mt8188_of_data = { 1387 1266 .scp_clk_get = mt8195_scp_clk_get, 1388 - .scp_before_load = mt8192_scp_before_load, 1389 - .scp_irq_handler = mt8192_scp_irq_handler, 1267 + .scp_before_load = mt8188_scp_before_load, 1268 + .scp_irq_handler = mt8195_scp_irq_handler, 1390 1269 .scp_reset_assert = mt8192_scp_reset_assert, 1391 1270 .scp_reset_deassert = mt8192_scp_reset_deassert, 1392 - .scp_stop = mt8192_scp_stop, 1271 + .scp_stop = mt8188_scp_stop, 1393 1272 .scp_da_to_va = mt8192_scp_da_to_va, 1394 1273 .host_to_scp_reg = MT8192_GIPC_IN_SET, 1395 1274 .host_to_scp_int_bit = MT8192_HOST_IPC_INT_BIT, 1275 + }; 1276 + 1277 + static const struct mtk_scp_of_data mt8188_of_data_c1 = { 1278 + .scp_clk_get = mt8195_scp_clk_get, 1279 + .scp_before_load = mt8188_scp_c1_before_load, 1280 + .scp_irq_handler = mt8195_scp_c1_irq_handler, 1281 + .scp_reset_assert = mt8195_scp_c1_reset_assert, 1282 + .scp_reset_deassert = mt8195_scp_c1_reset_deassert, 1283 + .scp_stop = mt8188_scp_c1_stop, 1284 + .scp_da_to_va = mt8192_scp_da_to_va, 1285 + .host_to_scp_reg = MT8192_GIPC_IN_SET, 1286 + .host_to_scp_int_bit = MT8195_CORE1_HOST_IPC_INT_BIT, 1396 1287 }; 1397 1288 1398 1289 static const struct mtk_scp_of_data mt8192_of_data = { ··· 1443 1310 .host_to_scp_int_bit = MT8195_CORE1_HOST_IPC_INT_BIT, 1444 1311 }; 1445 1312 1313 + static const struct mtk_scp_of_data *mt8188_of_data_cores[] = { 1314 + &mt8188_of_data, 1315 + &mt8188_of_data_c1, 1316 + NULL 1317 + }; 1318 + 1446 1319 static const struct mtk_scp_of_data *mt8195_of_data_cores[] = { 1447 1320 &mt8195_of_data, 1448 1321 &mt8195_of_data_c1, ··· 1459 1320 { .compatible = "mediatek,mt8183-scp", .data = &mt8183_of_data }, 1460 1321 { .compatible = "mediatek,mt8186-scp", .data = &mt8186_of_data }, 1461 1322 { .compatible = "mediatek,mt8188-scp", .data = &mt8188_of_data }, 1323 + { .compatible = "mediatek,mt8188-scp-dual", .data = &mt8188_of_data_cores }, 1462 1324 { .compatible = "mediatek,mt8192-scp", .data = &mt8192_of_data }, 1463 1325 { .compatible = "mediatek,mt8195-scp", .data = &mt8195_of_data }, 1464 1326 { .compatible = "mediatek,mt8195-scp-dual", .data = &mt8195_of_data_cores },