Support MT8188 SCP core 1
Subsystems (3)
v4 cover Support MT8188 SCP core 1
Change in v4:
Updating the description of PATCH v4 4/4.
Olivia Wen (4):
dt-bindings: remoteproc: mediatek: Support MT8188 dual-core SCP
remoteproc: mediatek: Support MT8188 SCP core 1
remoteproc: mediatek: Support setting DRAM and IPI shared buffer sizes
remoteproc: mediatek: Add IMGSYS IPI command
.../devicetree/bindings/remoteproc/mtk,scp.yaml | 2 + drivers/remoteproc/mtk_common.h | 11 +- drivers/remoteproc/mtk_scp.c | 230 +++++++++++++++++++-- drivers/remoteproc/mtk_scp_ipi.c | 7 +- include/linux/remoteproc/mtk_scp.h | 1 + 5 files changed, 225 insertions(+), 26 deletions(-)
Signature · 1 line
2.6.4
PATCH v4 1/4 dt-bindings: remoteproc: mediatek: Support MT8188 dual-core SCP
Under different applications, the MT8188 SCP can be used as single-core or dual-core.
--- Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +2 -0
@@ -19,6 +19,7 @@ properties: - mediatek,mt8183-scp - mediatek,mt8186-scp - mediatek,mt8188-scp + - mediatek,mt8188-scp-dual - mediatek,mt8192-scp - mediatek,mt8195-scp - mediatek,mt8195-scp-dual
@@ -194,6 +195,7 @@ allOf: properties: compatible: enum: + - mediatek,mt8188-scp-dual - mediatek,mt8195-scp-dual then: properties:
Signature · 1 line
2.6.4
PATCH v4 2/4 remoteproc: mediatek: Support MT8188 SCP core 1
In reply to Olivia WenMT8188 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.
--- drivers/remoteproc/mtk_scp.c | 146 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 143 insertions(+), 3 deletions(-)
drivers/remoteproc/mtk_scp.c +143 -3
@@ -471,6 +471,86 @@ static int mt8186_scp_before_load(struct mtk_scp *scp)return 0 ; } +static int mt8188_scp_l2tcm_on (struct mtk_scp *scp) +{ +struct mtk_scp_of_cluster *scp_cluster = scp->cluster; + +mutex_lock (&scp_cluster->cluster_lock); + +if (scp_cluster->l2tcm_refcnt ==0 ) { +/* clear SPM interrupt, SCP2SPM_IPC_CLR */ +writel (0xff , scp->cluster->reg_base +MT8192_SCP2SPM_IPC_CLR ); + +/* Power on L2TCM */ +scp_sram_power_on (scp->cluster->reg_base +MT8192_L2TCM_SRAM_PD_0 ,0 ); +scp_sram_power_on (scp->cluster->reg_base +MT8192_L2TCM_SRAM_PD_1 ,0 ); +scp_sram_power_on (scp->cluster->reg_base +MT8192_L2TCM_SRAM_PD_2 ,0 ); +scp_sram_power_on (scp->cluster->reg_base +MT8192_L1TCM_SRAM_PDN ,0 ); + } + + scp_cluster->l2tcm_refcnt +=1 ; + +mutex_unlock (&scp_cluster->cluster_lock); + +return 0 ; +} + +static int mt8188_scp_before_load (struct mtk_scp *scp) +{ +writel (1 , scp->cluster->reg_base +MT8192_CORE0_SW_RSTN_SET ); + +mt8188_scp_l2tcm_on (scp); + +scp_sram_power_on (scp->cluster->reg_base +MT8192_CPU0_SRAM_PD ,0 ); + +/* enable MPU for all memory regions */ +writel (0xff , scp->cluster->reg_base +MT8192_CORE0_MEM_ATT_PREDEF ); + +return 0 ; +} + +static int mt8188_scp_c1_before_load (struct mtk_scp *scp) +{ +u32 sec_ctrl; +struct mtk_scp *scp_c0; +struct mtk_scp_of_cluster *scp_cluster = scp->cluster; + + scp->data->scp_reset_assert (scp); + +mt8188_scp_l2tcm_on (scp); + +scp_sram_power_on (scp->cluster->reg_base +MT8195_CPU1_SRAM_PD ,0 ); + +/* enable MPU for all memory regions */ +writel (0xff , scp->cluster->reg_base +MT8195_CORE1_MEM_ATT_PREDEF ); + +/* +* The L2TCM_OFFSET_RANGE and L2TCM_OFFSET shift the destination address +* on SRAM when SCP core 1 accesses SRAM. +* +* This configuration solves booting the SCP core 0 and core 1 from +* different SRAM address because core 0 and core 1 both boot from +* the head of SRAM by default. this must be configured before boot SCP core 1. +* +* The value of L2TCM_OFFSET_RANGE is from the viewpoint of SCP core 1. +* When SCP core 1 issues address within the range (L2TCM_OFFSET_RANGE), +* the address will be added with a fixed offset (L2TCM_OFFSET) on the bus. +* The shift action is tranparent to software. +*/ +writel (0 , scp->cluster->reg_base +MT8195_L2TCM_OFFSET_RANGE_0_LOW ); +writel (scp->sram_size, scp->cluster->reg_base +MT8195_L2TCM_OFFSET_RANGE_0_HIGH ); + + scp_c0 = list_first_entry(&scp_cluster->mtk_scp_list, struct mtk_scp, elem); +writel (scp->sram_phys - scp_c0->sram_phys, scp->cluster->reg_base +MT8195_L2TCM_OFFSET ); + +/* enable SRAM offset when fetching instruction and data */ + sec_ctrl =readl (scp->cluster->reg_base +MT8195_SEC_CTRL ); + sec_ctrl |=MT8195_CORE_OFFSET_ENABLE_I |MT8195_CORE_OFFSET_ENABLE_D ; +writel (sec_ctrl, scp->cluster->reg_base +MT8195_SEC_CTRL ); + +return 0 ; +} +static int mt8192_scp_before_load (struct mtk_scp *scp) {/* clear SPM interrupt, SCP2SPM_IPC_CLR */
@@ -717,6 +797,47 @@ static void mt8183_scp_stop(struct mtk_scp *scp)writel (0 , scp->cluster->reg_base +MT8183_WDT_CFG ); } +static void mt8188_scp_l2tcm_off (struct mtk_scp *scp) +{ +struct mtk_scp_of_cluster *scp_cluster = scp->cluster; + +mutex_lock (&scp_cluster->cluster_lock); + +if (scp_cluster->l2tcm_refcnt >0 ) + scp_cluster->l2tcm_refcnt -=1 ; + +if (scp_cluster->l2tcm_refcnt ==0 ) { +/* Power off L2TCM */ +scp_sram_power_off (scp->cluster->reg_base +MT8192_L2TCM_SRAM_PD_0 ,0 ); +scp_sram_power_off (scp->cluster->reg_base +MT8192_L2TCM_SRAM_PD_1 ,0 ); +scp_sram_power_off (scp->cluster->reg_base +MT8192_L2TCM_SRAM_PD_2 ,0 ); +scp_sram_power_off (scp->cluster->reg_base +MT8192_L1TCM_SRAM_PDN ,0 ); + } + +mutex_unlock (&scp_cluster->cluster_lock); +} + +static void mt8188_scp_stop (struct mtk_scp *scp) +{ +mt8188_scp_l2tcm_off (scp); + +scp_sram_power_off (scp->cluster->reg_base +MT8192_CPU0_SRAM_PD ,0 ); + +/* Disable SCP watchdog */ +writel (0 , scp->cluster->reg_base +MT8192_CORE0_WDT_CFG ); +} + +static void mt8188_scp_c1_stop (struct mtk_scp *scp) +{ +mt8188_scp_l2tcm_off (scp); + +/* Power off CPU SRAM */ +scp_sram_power_off (scp->cluster->reg_base +MT8195_CPU1_SRAM_PD ,0 ); + +/* Disable SCP watchdog */ +writel (0 , scp->cluster->reg_base +MT8195_CORE1_WDT_CFG ); +} +static void mt8192_scp_stop (struct mtk_scp *scp) {/* Disable SRAM clock */
@@ -1264,16 +1385,28 @@ static const struct mtk_scp_of_data mt8186_of_data = {static const struct mtk_scp_of_data mt8188_of_data = { .scp_clk_get = mt8195_scp_clk_get, - .scp_before_load = mt8192_scp_before_load, - .scp_irq_handler = mt8192_scp_irq_handler, + .scp_before_load = mt8188_scp_before_load, + .scp_irq_handler = mt8195_scp_irq_handler, .scp_reset_assert = mt8192_scp_reset_assert, .scp_reset_deassert = mt8192_scp_reset_deassert, - .scp_stop = mt8192_scp_stop, + .scp_stop = mt8188_scp_stop, .scp_da_to_va = mt8192_scp_da_to_va, .host_to_scp_reg =MT8192_GIPC_IN_SET , .host_to_scp_int_bit =MT8192_HOST_IPC_INT_BIT , }; +static const struct mtk_scp_of_data mt8188_of_data_c1 = { + .scp_clk_get = mt8195_scp_clk_get, + .scp_before_load = mt8188_scp_c1_before_load, + .scp_irq_handler = mt8195_scp_c1_irq_handler, + .scp_reset_assert = mt8195_scp_c1_reset_assert, + .scp_reset_deassert = mt8195_scp_c1_reset_deassert, + .scp_stop = mt8188_scp_c1_stop, + .scp_da_to_va = mt8192_scp_da_to_va, + .host_to_scp_reg =MT8192_GIPC_IN_SET , + .host_to_scp_int_bit =MT8195_CORE1_HOST_IPC_INT_BIT , +}; +static const struct mtk_scp_of_data mt8192_of_data = { .scp_clk_get = mt8192_scp_clk_get, .scp_before_load = mt8192_scp_before_load,
@@ -1310,6 +1443,12 @@ static const struct mtk_scp_of_data mt8195_of_data_c1 = { .host_to_scp_int_bit = MT8195_CORE1_HOST_IPC_INT_BIT, }; +static const struct mtk_scp_of_data *mt8188_of_data_cores[] = { + &mt8188_of_data, + &mt8188_of_data_c1, +NULL +}; +static const struct mtk_scp_of_data *mt8195_of_data_cores[] = { &mt8195_of_data, &mt8195_of_data_c1,
@@ -1320,6 +1459,7 @@ static const struct of_device_id mtk_scp_of_match[] = { { .compatible = "mediatek,mt8183-scp", .data = &mt8183_of_data }, { .compatible = "mediatek,mt8186-scp", .data = &mt8186_of_data }, { .compatible = "mediatek,mt8188-scp", .data = &mt8188_of_data }, + { .compatible = "mediatek,mt8188-scp-dual", .data = &mt8188_of_data_cores }, { .compatible = "mediatek,mt8192-scp", .data = &mt8192_of_data }, { .compatible = "mediatek,mt8195-scp", .data = &mt8195_of_data }, { .compatible = "mediatek,mt8195-scp-dual", .data = &mt8195_of_data_cores },
Signature · 1 line
2.6.4
PATCH v4 3/4 remoteproc: mediatek: Support setting DRAM and IPI shared buffer sizes
In reply to Olivia WenThe SCP on different chips will require different DRAM sizes and IPI shared buffer sizes based on varying requirements.
--- drivers/remoteproc/mtk_common.h | 11 ++++-- drivers/remoteproc/mtk_scp.c | 84 +++++++++++++++++++++++++++++++--------- drivers/remoteproc/mtk_scp_ipi.c | 7 +++- 3 files changed, 79 insertions(+), 23 deletions(-)
drivers/remoteproc/mtk_common.h +8 -3
@@ -78,7 +78,6 @@#define MT8195_L2TCM_OFFSET 0x850d0#define SCP_FW_VER_LEN 32 -#define SCP_SHARE_BUFFER_SIZE 288struct scp_run {u32 signaled;
@@ -97,6 +96,11 @@ struct scp_ipi_desc {struct mtk_scp ; +struct mtk_scp_sizes_data { +size_t max_dram_size; +size_t ipi_share_buffer_size; +}; +struct mtk_scp_of_data {int (*scp_clk_get)(struct mtk_scp *scp);int (*scp_before_load)(struct mtk_scp *scp);
@@ -110,6 +114,7 @@ struct mtk_scp_of_data {u32 host_to_scp_int_bit;size_t ipi_buf_offset; +const struct mtk_scp_sizes_data *scp_sizes; };struct mtk_scp_of_cluster {
@@ -141,10 +146,10 @@ struct mtk_scp {struct scp_ipi_desc ipi_desc[SCP_IPI_MAX ];bool ipi_id_ack[SCP_IPI_MAX ];wait_queue_head_t ack_wq; +u8 *share_buf;void *cpu_addr;dma_addr_t dma_addr; -size_t dram_size;struct rproc_subdev *rpmsg_subdev;
@@ -162,7 +167,7 @@ struct mtk_scp {struct mtk_share_obj {u32 id;u32 len; -u8 share_buf[SCP_SHARE_BUFFER_SIZE ]; +u8 *share_buf; };void scp_memcpy_aligned (void __iomem *dst,const void *src,unsigned int len);
drivers/remoteproc/mtk_scp.c +66 -18
239 lines not on this page · raw message
drivers/remoteproc/mtk_scp_ipi.c +5 -2
@@ -162,10 +162,13 @@ int scp_ipi_send(struct mtk_scp *scp, u32 id, void *buf, unsigned int len,struct mtk_share_obj __iomem *send_obj = scp->send_buf;u32 val;int ret; +const struct mtk_scp_sizes_data *scp_sizes; + + scp_sizes = scp->data->scp_sizes;if (WARN_ON (id <=SCP_IPI_INIT ) ||WARN_ON (id >=SCP_IPI_MAX ) ||WARN_ON (id ==SCP_IPI_NS_SERVICE ) || -WARN_ON (len >sizeof (send_obj->share_buf)) ||WARN_ON (!buf)) +WARN_ON (len > scp_sizes->ipi_share_buffer_size) ||WARN_ON (!buf))return -EINVAL ; ret =clk_prepare_enable (scp->clk);
@@ -184,7 +187,7 @@ int scp_ipi_send(struct mtk_scp *scp, u32 id, void *buf, unsigned int len, goto unlock_mutex; } -scp_memcpy_aligned (send_obj->share_buf, buf, len); +scp_memcpy_aligned (&send_obj->share_buf, buf, len);writel (len, &send_obj->len);writel (id, &send_obj->id);
Signature · 1 line
2.6.4
PATCH v4 4/4 remoteproc: mediatek: Add IMGSYS IPI command
In reply to Olivia WenAdd an IPI command definition for communication with IMGSYS through SCP mailbox.
--- include/linux/remoteproc/mtk_scp.h | 1 + 1 file changed, 1 insertion(+)
include/linux/remoteproc/mtk_scp.h +1 -0
@@ -43,6 +43,7 @@ enum scp_ipi_id {SCP_IPI_CROS_HOST_CMD ,SCP_IPI_VDEC_LAT ,SCP_IPI_VDEC_CORE , +SCP_IPI_IMGSYS_CMD ,SCP_IPI_NS_SERVICE =0xFF , SCP_IPI_MAX = 0x100, };
Signature · 1 line
2.6.4
Re: [PATCH v4 4/4] remoteproc: mediatek: Add IMGSYS IPI command
Il 30/04/24 03:15, Olivia Wen ha scritto:
Quoted 4 lines
Add an IPI command definition for communication with IMGSYS through SCP mailbox.
Signed-off-by Olivia Wen <[email protected]>
Mathieu Poirier
maintainerQuoted 9 lines · Olivia Wen
Change in v4:
Updating the description of PATCH v4 4/4.Olivia Wen (4):
dt-bindings: remoteproc: mediatek: Support MT8188 dual-core SCP
remoteproc: mediatek: Support MT8188 SCP core 1
remoteproc: mediatek: Support setting DRAM and IPI shared buffer sizes
remoteproc: mediatek: Add IMGSYS IPI command
Quoted 6 lines
.../devicetree/bindings/remoteproc/mtk,scp.yaml | 2 + drivers/remoteproc/mtk_common.h | 11 +- drivers/remoteproc/mtk_scp.c | 230 +++++++++++++++++++-- drivers/remoteproc/mtk_scp_ipi.c | 7 +- include/linux/remoteproc/mtk_scp.h | 1 + 5 files changed, 225 insertions(+), 26 deletions(-)
I have applied this set.
Thanks,
Mathieu
Quoted 4 lines
Signature · 2 lines
-- 2.6.4