Lines Matching full:scp
27 * scp_get() - get a reference to SCP.
29 * @pdev: the platform device of the module requesting SCP platform
30 * device for using SCP API.
32 * Return: Return NULL if failed. otherwise reference to SCP.
40 scp_node = of_parse_phandle(dev->of_node, "mediatek,scp", 0); in scp_get()
42 dev_err(dev, "can't get SCP node\n"); in scp_get()
50 dev_err(dev, "SCP pdev failed\n"); in scp_get()
59 * scp_put() - "free" the SCP
61 * @scp: mtk_scp structure from scp_get().
63 void scp_put(struct mtk_scp *scp) in scp_put() argument
65 put_device(scp->dev); in scp_put()
69 static void scp_wdt_handler(struct mtk_scp *scp, u32 scp_to_host) in scp_wdt_handler() argument
71 dev_err(scp->dev, "SCP watchdog timeout! 0x%x", scp_to_host); in scp_wdt_handler()
72 rproc_report_crash(scp->rproc, RPROC_WATCHDOG); in scp_wdt_handler()
77 struct mtk_scp *scp = (struct mtk_scp *)priv; in scp_init_ipi_handler() local
80 scp->run.signaled = run->signaled; in scp_init_ipi_handler()
81 strscpy(scp->run.fw_ver, run->fw_ver, SCP_FW_VER_LEN); in scp_init_ipi_handler()
82 scp->run.dec_capability = run->dec_capability; in scp_init_ipi_handler()
83 scp->run.enc_capability = run->enc_capability; in scp_init_ipi_handler()
84 wake_up_interruptible(&scp->run.wq); in scp_init_ipi_handler()
87 static void scp_ipi_handler(struct mtk_scp *scp) in scp_ipi_handler() argument
89 struct mtk_share_obj __iomem *rcv_obj = scp->recv_buf; in scp_ipi_handler()
90 struct scp_ipi_desc *ipi_desc = scp->ipi_desc; in scp_ipi_handler()
97 dev_err(scp->dev, "ipi message too long (len %d, max %d)", len, in scp_ipi_handler()
102 dev_err(scp->dev, "No such ipi id = %d\n", id); in scp_ipi_handler()
106 scp_ipi_lock(scp, id); in scp_ipi_handler()
109 dev_err(scp->dev, "No such ipi id = %d\n", id); in scp_ipi_handler()
110 scp_ipi_unlock(scp, id); in scp_ipi_handler()
116 scp_ipi_unlock(scp, id); in scp_ipi_handler()
118 scp->ipi_id_ack[id] = true; in scp_ipi_handler()
119 wake_up(&scp->ack_wq); in scp_ipi_handler()
122 static int scp_elf_read_ipi_buf_addr(struct mtk_scp *scp,
126 static int scp_ipi_init(struct mtk_scp *scp, const struct firmware *fw) in scp_ipi_init() argument
132 ret = scp_elf_read_ipi_buf_addr(scp, fw, &offset); in scp_ipi_init()
135 offset = scp->data->ipi_buf_offset; in scp_ipi_init()
139 dev_info(scp->dev, "IPI buf addr %#010zx\n", offset); in scp_ipi_init()
141 scp->recv_buf = (struct mtk_share_obj __iomem *) in scp_ipi_init()
142 (scp->sram_base + offset); in scp_ipi_init()
143 scp->send_buf = (struct mtk_share_obj __iomem *) in scp_ipi_init()
144 (scp->sram_base + offset + sizeof(*scp->recv_buf)); in scp_ipi_init()
145 memset_io(scp->recv_buf, 0, sizeof(*scp->recv_buf)); in scp_ipi_init()
146 memset_io(scp->send_buf, 0, sizeof(*scp->send_buf)); in scp_ipi_init()
151 static void mt8183_scp_reset_assert(struct mtk_scp *scp) in mt8183_scp_reset_assert() argument
155 val = readl(scp->reg_base + MT8183_SW_RSTN); in mt8183_scp_reset_assert()
157 writel(val, scp->reg_base + MT8183_SW_RSTN); in mt8183_scp_reset_assert()
160 static void mt8183_scp_reset_deassert(struct mtk_scp *scp) in mt8183_scp_reset_deassert() argument
164 val = readl(scp->reg_base + MT8183_SW_RSTN); in mt8183_scp_reset_deassert()
166 writel(val, scp->reg_base + MT8183_SW_RSTN); in mt8183_scp_reset_deassert()
169 static void mt8192_scp_reset_assert(struct mtk_scp *scp) in mt8192_scp_reset_assert() argument
171 writel(1, scp->reg_base + MT8192_CORE0_SW_RSTN_SET); in mt8192_scp_reset_assert()
174 static void mt8192_scp_reset_deassert(struct mtk_scp *scp) in mt8192_scp_reset_deassert() argument
176 writel(1, scp->reg_base + MT8192_CORE0_SW_RSTN_CLR); in mt8192_scp_reset_deassert()
179 static void mt8183_scp_irq_handler(struct mtk_scp *scp) in mt8183_scp_irq_handler() argument
183 scp_to_host = readl(scp->reg_base + MT8183_SCP_TO_HOST); in mt8183_scp_irq_handler()
185 scp_ipi_handler(scp); in mt8183_scp_irq_handler()
187 scp_wdt_handler(scp, scp_to_host); in mt8183_scp_irq_handler()
189 /* SCP won't send another interrupt until we set SCP_TO_HOST to 0. */ in mt8183_scp_irq_handler()
191 scp->reg_base + MT8183_SCP_TO_HOST); in mt8183_scp_irq_handler()
194 static void mt8192_scp_irq_handler(struct mtk_scp *scp) in mt8192_scp_irq_handler() argument
198 scp_to_host = readl(scp->reg_base + MT8192_SCP2APMCU_IPC_SET); in mt8192_scp_irq_handler()
201 scp_ipi_handler(scp); in mt8192_scp_irq_handler()
204 * SCP won't send another interrupt until we clear in mt8192_scp_irq_handler()
208 scp->reg_base + MT8192_SCP2APMCU_IPC_CLR); in mt8192_scp_irq_handler()
210 scp_wdt_handler(scp, scp_to_host); in mt8192_scp_irq_handler()
211 writel(1, scp->reg_base + MT8192_CORE0_WDT_IRQ); in mt8192_scp_irq_handler()
217 struct mtk_scp *scp = priv; in scp_irq_handler() local
220 ret = clk_prepare_enable(scp->clk); in scp_irq_handler()
222 dev_err(scp->dev, "failed to enable clocks\n"); in scp_irq_handler()
226 scp->data->scp_irq_handler(scp); in scp_irq_handler()
228 clk_disable_unprepare(scp->clk); in scp_irq_handler()
289 static int scp_elf_read_ipi_buf_addr(struct mtk_scp *scp, in scp_elf_read_ipi_buf_addr() argument
315 static int mt8183_scp_clk_get(struct mtk_scp *scp) in mt8183_scp_clk_get() argument
317 struct device *dev = scp->dev; in mt8183_scp_clk_get()
320 scp->clk = devm_clk_get(dev, "main"); in mt8183_scp_clk_get()
321 if (IS_ERR(scp->clk)) { in mt8183_scp_clk_get()
323 ret = PTR_ERR(scp->clk); in mt8183_scp_clk_get()
329 static int mt8192_scp_clk_get(struct mtk_scp *scp) in mt8192_scp_clk_get() argument
331 return mt8183_scp_clk_get(scp); in mt8192_scp_clk_get()
334 static int mt8195_scp_clk_get(struct mtk_scp *scp) in mt8195_scp_clk_get() argument
336 scp->clk = NULL; in mt8195_scp_clk_get()
341 static int mt8183_scp_before_load(struct mtk_scp *scp) in mt8183_scp_before_load() argument
343 /* Clear SCP to host interrupt */ in mt8183_scp_before_load()
344 writel(MT8183_SCP_IPC_INT_BIT, scp->reg_base + MT8183_SCP_TO_HOST); in mt8183_scp_before_load()
347 writel(0x0, scp->reg_base + MT8183_SCP_CLK_SW_SEL); in mt8183_scp_before_load()
348 writel(0x0, scp->reg_base + MT8183_SCP_CLK_DIV_SEL); in mt8183_scp_before_load()
351 writel(0x0, scp->reg_base + MT8183_SCP_L1_SRAM_PD); in mt8183_scp_before_load()
352 writel(0x0, scp->reg_base + MT8183_SCP_TCM_TAIL_SRAM_PD); in mt8183_scp_before_load()
354 /* Turn on the power of SCP's SRAM before using it. */ in mt8183_scp_before_load()
355 writel(0x0, scp->reg_base + MT8183_SCP_SRAM_PDN); in mt8183_scp_before_load()
358 * Set I-cache and D-cache size before loading SCP FW. in mt8183_scp_before_load()
359 * SCP SRAM logical address may change when cache size setting differs. in mt8183_scp_before_load()
362 scp->reg_base + MT8183_SCP_CACHE_CON); in mt8183_scp_before_load()
363 writel(MT8183_SCP_CACHESIZE_8KB, scp->reg_base + MT8183_SCP_DCACHE_CON); in mt8183_scp_before_load()
386 static int mt8186_scp_before_load(struct mtk_scp *scp) in mt8186_scp_before_load() argument
388 /* Clear SCP to host interrupt */ in mt8186_scp_before_load()
389 writel(MT8183_SCP_IPC_INT_BIT, scp->reg_base + MT8183_SCP_TO_HOST); in mt8186_scp_before_load()
392 writel(0x0, scp->reg_base + MT8183_SCP_CLK_SW_SEL); in mt8186_scp_before_load()
393 writel(0x0, scp->reg_base + MT8183_SCP_CLK_DIV_SEL); in mt8186_scp_before_load()
395 /* Turn on the power of SCP's SRAM before using it. Enable 1 block per time*/ in mt8186_scp_before_load()
396 scp_sram_power_on(scp->reg_base + MT8183_SCP_SRAM_PDN, 0); in mt8186_scp_before_load()
399 writel(0x0, scp->reg_base + MT8183_SCP_L1_SRAM_PD); in mt8186_scp_before_load()
400 writel(0x0, scp->reg_base + MT8183_SCP_TCM_TAIL_SRAM_PD); in mt8186_scp_before_load()
401 writel(0x0, scp->reg_base + MT8186_SCP_L1_SRAM_PD_P1); in mt8186_scp_before_load()
402 writel(0x0, scp->reg_base + MT8186_SCP_L1_SRAM_PD_p2); in mt8186_scp_before_load()
405 * Set I-cache and D-cache size before loading SCP FW. in mt8186_scp_before_load()
406 * SCP SRAM logical address may change when cache size setting differs. in mt8186_scp_before_load()
409 scp->reg_base + MT8183_SCP_CACHE_CON); in mt8186_scp_before_load()
410 writel(MT8183_SCP_CACHESIZE_8KB, scp->reg_base + MT8183_SCP_DCACHE_CON); in mt8186_scp_before_load()
415 static int mt8192_scp_before_load(struct mtk_scp *scp) in mt8192_scp_before_load() argument
418 writel(0xff, scp->reg_base + MT8192_SCP2SPM_IPC_CLR); in mt8192_scp_before_load()
420 writel(1, scp->reg_base + MT8192_CORE0_SW_RSTN_SET); in mt8192_scp_before_load()
423 scp_sram_power_on(scp->reg_base + MT8192_L2TCM_SRAM_PD_0, 0); in mt8192_scp_before_load()
424 scp_sram_power_on(scp->reg_base + MT8192_L2TCM_SRAM_PD_1, 0); in mt8192_scp_before_load()
425 scp_sram_power_on(scp->reg_base + MT8192_L2TCM_SRAM_PD_2, 0); in mt8192_scp_before_load()
426 scp_sram_power_on(scp->reg_base + MT8192_L1TCM_SRAM_PDN, 0); in mt8192_scp_before_load()
427 scp_sram_power_on(scp->reg_base + MT8192_CPU0_SRAM_PD, 0); in mt8192_scp_before_load()
430 writel(0xff, scp->reg_base + MT8192_CORE0_MEM_ATT_PREDEF); in mt8192_scp_before_load()
435 static int mt8195_scp_before_load(struct mtk_scp *scp) in mt8195_scp_before_load() argument
438 writel(0xff, scp->reg_base + MT8192_SCP2SPM_IPC_CLR); in mt8195_scp_before_load()
440 writel(1, scp->reg_base + MT8192_CORE0_SW_RSTN_SET); in mt8195_scp_before_load()
443 scp_sram_power_on(scp->reg_base + MT8192_L2TCM_SRAM_PD_0, 0); in mt8195_scp_before_load()
444 scp_sram_power_on(scp->reg_base + MT8192_L2TCM_SRAM_PD_1, 0); in mt8195_scp_before_load()
445 scp_sram_power_on(scp->reg_base + MT8192_L2TCM_SRAM_PD_2, 0); in mt8195_scp_before_load()
446 scp_sram_power_on(scp->reg_base + MT8192_L1TCM_SRAM_PDN, in mt8195_scp_before_load()
448 scp_sram_power_on(scp->reg_base + MT8192_CPU0_SRAM_PD, 0); in mt8195_scp_before_load()
451 writel(0xff, scp->reg_base + MT8192_CORE0_MEM_ATT_PREDEF); in mt8195_scp_before_load()
458 struct mtk_scp *scp = rproc->priv; in scp_load() local
459 struct device *dev = scp->dev; in scp_load()
462 ret = clk_prepare_enable(scp->clk); in scp_load()
468 /* Hold SCP in reset while loading FW. */ in scp_load()
469 scp->data->scp_reset_assert(scp); in scp_load()
471 ret = scp->data->scp_before_load(scp); in scp_load()
477 clk_disable_unprepare(scp->clk); in scp_load()
484 struct mtk_scp *scp = rproc->priv; in scp_parse_fw() local
485 struct device *dev = scp->dev; in scp_parse_fw()
488 ret = clk_prepare_enable(scp->clk); in scp_parse_fw()
494 ret = scp_ipi_init(scp, fw); in scp_parse_fw()
495 clk_disable_unprepare(scp->clk); in scp_parse_fw()
501 struct mtk_scp *scp = (struct mtk_scp *)rproc->priv; in scp_start() local
502 struct device *dev = scp->dev; in scp_start()
503 struct scp_run *run = &scp->run; in scp_start()
506 ret = clk_prepare_enable(scp->clk); in scp_start()
514 scp->data->scp_reset_deassert(scp); in scp_start()
522 dev_err(dev, "wait SCP initialization timeout!\n"); in scp_start()
527 dev_err(dev, "wait SCP interrupted by a signal!\n"); in scp_start()
531 clk_disable_unprepare(scp->clk); in scp_start()
532 dev_info(dev, "SCP is ready. FW version %s\n", run->fw_ver); in scp_start()
537 scp->data->scp_reset_assert(scp); in scp_start()
538 clk_disable_unprepare(scp->clk); in scp_start()
542 static void *mt8183_scp_da_to_va(struct mtk_scp *scp, u64 da, size_t len) in mt8183_scp_da_to_va() argument
546 if (da < scp->sram_size) { in mt8183_scp_da_to_va()
548 if (offset >= 0 && (offset + len) <= scp->sram_size) in mt8183_scp_da_to_va()
549 return (void __force *)scp->sram_base + offset; in mt8183_scp_da_to_va()
550 } else if (scp->dram_size) { in mt8183_scp_da_to_va()
551 offset = da - scp->dma_addr; in mt8183_scp_da_to_va()
552 if (offset >= 0 && (offset + len) <= scp->dram_size) in mt8183_scp_da_to_va()
553 return scp->cpu_addr + offset; in mt8183_scp_da_to_va()
559 static void *mt8192_scp_da_to_va(struct mtk_scp *scp, u64 da, size_t len) in mt8192_scp_da_to_va() argument
563 if (da >= scp->sram_phys && in mt8192_scp_da_to_va()
564 (da + len) <= scp->sram_phys + scp->sram_size) { in mt8192_scp_da_to_va()
565 offset = da - scp->sram_phys; in mt8192_scp_da_to_va()
566 return (void __force *)scp->sram_base + offset; in mt8192_scp_da_to_va()
570 if (scp->l1tcm_size && in mt8192_scp_da_to_va()
571 da >= scp->l1tcm_phys && in mt8192_scp_da_to_va()
572 (da + len) <= scp->l1tcm_phys + scp->l1tcm_size) { in mt8192_scp_da_to_va()
573 offset = da - scp->l1tcm_phys; in mt8192_scp_da_to_va()
574 return (void __force *)scp->l1tcm_base + offset; in mt8192_scp_da_to_va()
578 if (scp->dram_size && in mt8192_scp_da_to_va()
579 da >= scp->dma_addr && in mt8192_scp_da_to_va()
580 (da + len) <= scp->dma_addr + scp->dram_size) { in mt8192_scp_da_to_va()
581 offset = da - scp->dma_addr; in mt8192_scp_da_to_va()
582 return scp->cpu_addr + offset; in mt8192_scp_da_to_va()
590 struct mtk_scp *scp = (struct mtk_scp *)rproc->priv; in scp_da_to_va() local
592 return scp->data->scp_da_to_va(scp, da, len); in scp_da_to_va()
595 static void mt8183_scp_stop(struct mtk_scp *scp) in mt8183_scp_stop() argument
597 /* Disable SCP watchdog */ in mt8183_scp_stop()
598 writel(0, scp->reg_base + MT8183_WDT_CFG); in mt8183_scp_stop()
601 static void mt8192_scp_stop(struct mtk_scp *scp) in mt8192_scp_stop() argument
604 scp_sram_power_off(scp->reg_base + MT8192_L2TCM_SRAM_PD_0, 0); in mt8192_scp_stop()
605 scp_sram_power_off(scp->reg_base + MT8192_L2TCM_SRAM_PD_1, 0); in mt8192_scp_stop()
606 scp_sram_power_off(scp->reg_base + MT8192_L2TCM_SRAM_PD_2, 0); in mt8192_scp_stop()
607 scp_sram_power_off(scp->reg_base + MT8192_L1TCM_SRAM_PDN, 0); in mt8192_scp_stop()
608 scp_sram_power_off(scp->reg_base + MT8192_CPU0_SRAM_PD, 0); in mt8192_scp_stop()
610 /* Disable SCP watchdog */ in mt8192_scp_stop()
611 writel(0, scp->reg_base + MT8192_CORE0_WDT_CFG); in mt8192_scp_stop()
614 static void mt8195_scp_stop(struct mtk_scp *scp) in mt8195_scp_stop() argument
617 scp_sram_power_off(scp->reg_base + MT8192_L2TCM_SRAM_PD_0, 0); in mt8195_scp_stop()
618 scp_sram_power_off(scp->reg_base + MT8192_L2TCM_SRAM_PD_1, 0); in mt8195_scp_stop()
619 scp_sram_power_off(scp->reg_base + MT8192_L2TCM_SRAM_PD_2, 0); in mt8195_scp_stop()
620 scp_sram_power_off(scp->reg_base + MT8192_L1TCM_SRAM_PDN, in mt8195_scp_stop()
622 scp_sram_power_off(scp->reg_base + MT8192_CPU0_SRAM_PD, 0); in mt8195_scp_stop()
624 /* Disable SCP watchdog */ in mt8195_scp_stop()
625 writel(0, scp->reg_base + MT8192_CORE0_WDT_CFG); in mt8195_scp_stop()
630 struct mtk_scp *scp = (struct mtk_scp *)rproc->priv; in scp_stop() local
633 ret = clk_prepare_enable(scp->clk); in scp_stop()
635 dev_err(scp->dev, "failed to enable clocks\n"); in scp_stop()
639 scp->data->scp_reset_assert(scp); in scp_stop()
640 scp->data->scp_stop(scp); in scp_stop()
641 clk_disable_unprepare(scp->clk); in scp_stop()
655 * scp_get_device() - get device struct of SCP
657 * @scp: mtk_scp structure
659 struct device *scp_get_device(struct mtk_scp *scp) in scp_get_device() argument
661 return scp->dev; in scp_get_device()
666 * scp_get_rproc() - get rproc struct of SCP
668 * @scp: mtk_scp structure
670 struct rproc *scp_get_rproc(struct mtk_scp *scp) in scp_get_rproc() argument
672 return scp->rproc; in scp_get_rproc()
679 * @scp: mtk_scp structure
683 unsigned int scp_get_vdec_hw_capa(struct mtk_scp *scp) in scp_get_vdec_hw_capa() argument
685 return scp->run.dec_capability; in scp_get_vdec_hw_capa()
692 * @scp: mtk_scp structure
696 unsigned int scp_get_venc_hw_capa(struct mtk_scp *scp) in scp_get_venc_hw_capa() argument
698 return scp->run.enc_capability; in scp_get_venc_hw_capa()
705 * @scp: mtk_scp structure
706 * @mem_addr: SCP views memory address
708 * Mapping the SCP's SRAM address /
716 void *scp_mapping_dm_addr(struct mtk_scp *scp, u32 mem_addr) in scp_mapping_dm_addr() argument
720 ptr = scp_da_to_va(scp->rproc, mem_addr, 0, NULL); in scp_mapping_dm_addr()
728 static int scp_map_memory_region(struct mtk_scp *scp) in scp_map_memory_region() argument
732 ret = of_reserved_mem_device_init(scp->dev); in scp_map_memory_region()
736 dev_info(scp->dev, "skipping reserved memory initialization."); in scp_map_memory_region()
741 dev_err(scp->dev, "failed to assign memory-region: %d\n", ret); in scp_map_memory_region()
745 /* Reserved SCP code size */ in scp_map_memory_region()
746 scp->dram_size = MAX_CODE_SIZE; in scp_map_memory_region()
747 scp->cpu_addr = dma_alloc_coherent(scp->dev, scp->dram_size, in scp_map_memory_region()
748 &scp->dma_addr, GFP_KERNEL); in scp_map_memory_region()
749 if (!scp->cpu_addr) in scp_map_memory_region()
755 static void scp_unmap_memory_region(struct mtk_scp *scp) in scp_unmap_memory_region() argument
757 if (scp->dram_size == 0) in scp_unmap_memory_region()
760 dma_free_coherent(scp->dev, scp->dram_size, scp->cpu_addr, in scp_unmap_memory_region()
761 scp->dma_addr); in scp_unmap_memory_region()
762 of_reserved_mem_device_release(scp->dev); in scp_unmap_memory_region()
768 struct mtk_scp *scp = platform_get_drvdata(pdev); in scp_register_ipi() local
770 return scp_ipi_register(scp, id, handler, priv); in scp_register_ipi()
775 struct mtk_scp *scp = platform_get_drvdata(pdev); in scp_unregister_ipi() local
777 scp_ipi_unregister(scp, id); in scp_unregister_ipi()
783 struct mtk_scp *scp = platform_get_drvdata(pdev); in scp_send_ipi() local
785 return scp_ipi_send(scp, id, buf, len, wait); in scp_send_ipi()
795 static void scp_add_rpmsg_subdev(struct mtk_scp *scp) in scp_add_rpmsg_subdev() argument
797 scp->rpmsg_subdev = in scp_add_rpmsg_subdev()
798 mtk_rpmsg_create_rproc_subdev(to_platform_device(scp->dev), in scp_add_rpmsg_subdev()
800 if (scp->rpmsg_subdev) in scp_add_rpmsg_subdev()
801 rproc_add_subdev(scp->rproc, scp->rpmsg_subdev); in scp_add_rpmsg_subdev()
804 static void scp_remove_rpmsg_subdev(struct mtk_scp *scp) in scp_remove_rpmsg_subdev() argument
806 if (scp->rpmsg_subdev) { in scp_remove_rpmsg_subdev()
807 rproc_remove_subdev(scp->rproc, scp->rpmsg_subdev); in scp_remove_rpmsg_subdev()
808 mtk_rpmsg_destroy_rproc_subdev(scp->rpmsg_subdev); in scp_remove_rpmsg_subdev()
809 scp->rpmsg_subdev = NULL; in scp_remove_rpmsg_subdev()
817 struct mtk_scp *scp; in scp_probe() local
820 const char *fw_name = "scp.img"; in scp_probe()
827 rproc = devm_rproc_alloc(dev, np->name, &scp_ops, fw_name, sizeof(*scp)); in scp_probe()
831 scp = (struct mtk_scp *)rproc->priv; in scp_probe()
832 scp->rproc = rproc; in scp_probe()
833 scp->dev = dev; in scp_probe()
834 scp->data = of_device_get_match_data(dev); in scp_probe()
835 platform_set_drvdata(pdev, scp); in scp_probe()
838 scp->sram_base = devm_ioremap_resource(dev, res); in scp_probe()
839 if (IS_ERR(scp->sram_base)) in scp_probe()
840 return dev_err_probe(dev, PTR_ERR(scp->sram_base), in scp_probe()
843 scp->sram_size = resource_size(res); in scp_probe()
844 scp->sram_phys = res->start; in scp_probe()
848 scp->l1tcm_base = devm_ioremap_resource(dev, res); in scp_probe()
849 if (IS_ERR(scp->l1tcm_base)) { in scp_probe()
850 ret = PTR_ERR(scp->l1tcm_base); in scp_probe()
855 scp->l1tcm_size = resource_size(res); in scp_probe()
856 scp->l1tcm_phys = res->start; in scp_probe()
859 scp->reg_base = devm_platform_ioremap_resource_byname(pdev, "cfg"); in scp_probe()
860 if (IS_ERR(scp->reg_base)) in scp_probe()
861 return dev_err_probe(dev, PTR_ERR(scp->reg_base), in scp_probe()
864 ret = scp->data->scp_clk_get(scp); in scp_probe()
868 ret = scp_map_memory_region(scp); in scp_probe()
872 mutex_init(&scp->send_lock); in scp_probe()
874 mutex_init(&scp->ipi_desc[i].lock); in scp_probe()
876 /* register SCP initialization IPI */ in scp_probe()
877 ret = scp_ipi_register(scp, SCP_IPI_INIT, scp_init_ipi_handler, scp); in scp_probe()
883 init_waitqueue_head(&scp->run.wq); in scp_probe()
884 init_waitqueue_head(&scp->ack_wq); in scp_probe()
886 scp_add_rpmsg_subdev(scp); in scp_probe()
890 pdev->name, scp); in scp_probe()
904 scp_remove_rpmsg_subdev(scp); in scp_probe()
905 scp_ipi_unregister(scp, SCP_IPI_INIT); in scp_probe()
907 scp_unmap_memory_region(scp); in scp_probe()
909 mutex_destroy(&scp->ipi_desc[i].lock); in scp_probe()
910 mutex_destroy(&scp->send_lock); in scp_probe()
917 struct mtk_scp *scp = platform_get_drvdata(pdev); in scp_remove() local
920 rproc_del(scp->rproc); in scp_remove()
921 scp_remove_rpmsg_subdev(scp); in scp_remove()
922 scp_ipi_unregister(scp, SCP_IPI_INIT); in scp_remove()
923 scp_unmap_memory_region(scp); in scp_remove()
925 mutex_destroy(&scp->ipi_desc[i].lock); in scp_remove()
926 mutex_destroy(&scp->send_lock); in scp_remove()
994 { .compatible = "mediatek,mt8183-scp", .data = &mt8183_of_data },
995 { .compatible = "mediatek,mt8186-scp", .data = &mt8186_of_data },
996 { .compatible = "mediatek,mt8188-scp", .data = &mt8188_of_data },
997 { .compatible = "mediatek,mt8192-scp", .data = &mt8192_of_data },
998 { .compatible = "mediatek,mt8195-scp", .data = &mt8195_of_data },
1007 .name = "mtk-scp",
1015 MODULE_DESCRIPTION("MediaTek SCP control driver");