Skip to content

Commit c01fb97

Browse files
tinghan-shenmathieupoirier
authored andcommitted
remoteproc: mediatek: Setup MT8195 SCP core 1 SRAM offset
Because MT8195 SCP core 0 and core 1 both boot from head of SRAM and have the same viewpoint of SRAM, SCP has a "core 1 SRAM offset" configuration to control the access destination of SCP core 1 to boot core 1 from different SRAM location. The "core 1 SRAM offset" configuration is composed by a range and an offset. It works like a simple memory mapped mechanism. When SCP core 1 accesses a SRAM address located in the range, the SCP bus adds the configured offset to the address to shift the physical destination address on SCP SRAM. This shifting is transparent to the software running on SCP core 1. Signed-off-by: Tinghan Shen <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Tested-by: AngeloGioacchino Del Regno <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mathieu Poirier <[email protected]>
1 parent c6eda63 commit c01fb97

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

drivers/remoteproc/mtk_common.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@
6565
#define MT8195_CORE1_MEM_ATT_PREDEF 0x20008
6666
#define MT8195_CORE1_WDT_CFG 0x20034
6767

68+
#define MT8195_SEC_CTRL 0x85000
69+
#define MT8195_CORE_OFFSET_ENABLE_D BIT(13)
70+
#define MT8195_CORE_OFFSET_ENABLE_I BIT(12)
71+
#define MT8195_L2TCM_OFFSET_RANGE_0_LOW 0x850b0
72+
#define MT8195_L2TCM_OFFSET_RANGE_0_HIGH 0x850b4
73+
#define MT8195_L2TCM_OFFSET 0x850d0
74+
6875
#define SCP_FW_VER_LEN 32
6976
#define SCP_SHARE_BUFFER_SIZE 288
7077

drivers/remoteproc/mtk_scp.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,10 @@ static int mt8195_scp_before_load(struct mtk_scp *scp)
495495

496496
static int mt8195_scp_c1_before_load(struct mtk_scp *scp)
497497
{
498+
u32 sec_ctrl;
499+
struct mtk_scp *scp_c0;
500+
struct mtk_scp_of_cluster *scp_cluster = scp->cluster;
501+
498502
scp->data->scp_reset_assert(scp);
499503

500504
mt8195_scp_l2tcm_on(scp);
@@ -504,6 +508,30 @@ static int mt8195_scp_c1_before_load(struct mtk_scp *scp)
504508
/* enable MPU for all memory regions */
505509
writel(0xff, scp->cluster->reg_base + MT8195_CORE1_MEM_ATT_PREDEF);
506510

511+
/*
512+
* The L2TCM_OFFSET_RANGE and L2TCM_OFFSET shift the destination address
513+
* on SRAM when SCP core 1 accesses SRAM.
514+
*
515+
* This configuration solves booting the SCP core 0 and core 1 from
516+
* different SRAM address because core 0 and core 1 both boot from
517+
* the head of SRAM by default. this must be configured before boot SCP core 1.
518+
*
519+
* The value of L2TCM_OFFSET_RANGE is from the viewpoint of SCP core 1.
520+
* When SCP core 1 issues address within the range (L2TCM_OFFSET_RANGE),
521+
* the address will be added with a fixed offset (L2TCM_OFFSET) on the bus.
522+
* The shift action is tranparent to software.
523+
*/
524+
writel(0, scp->cluster->reg_base + MT8195_L2TCM_OFFSET_RANGE_0_LOW);
525+
writel(scp->sram_size, scp->cluster->reg_base + MT8195_L2TCM_OFFSET_RANGE_0_HIGH);
526+
527+
scp_c0 = list_first_entry(&scp_cluster->mtk_scp_list, struct mtk_scp, elem);
528+
writel(scp->sram_phys - scp_c0->sram_phys, scp->cluster->reg_base + MT8195_L2TCM_OFFSET);
529+
530+
/* enable SRAM offset when fetching instruction and data */
531+
sec_ctrl = readl(scp->cluster->reg_base + MT8195_SEC_CTRL);
532+
sec_ctrl |= MT8195_CORE_OFFSET_ENABLE_I | MT8195_CORE_OFFSET_ENABLE_D;
533+
writel(sec_ctrl, scp->cluster->reg_base + MT8195_SEC_CTRL);
534+
507535
return 0;
508536
}
509537

0 commit comments

Comments
 (0)