From patchwork Wed Jun 1 11:21:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 12866757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AAC4C433EF for ; Wed, 1 Jun 2022 11:22:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243117AbiFALWZ (ORCPT ); Wed, 1 Jun 2022 07:22:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350587AbiFALWR (ORCPT ); Wed, 1 Jun 2022 07:22:17 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C762443AD8; Wed, 1 Jun 2022 04:22:14 -0700 (PDT) X-UUID: 17bf1eb0c22d4f76a43a189dd38307f5-20220601 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:257e5b34-b647-44bb-bb9e-96140dbf0861,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,RULE:Release_Ham,ACT ION:release,TS:95 X-CID-INFO: VERSION:1.1.5,REQID:257e5b34-b647-44bb-bb9e-96140dbf0861,OB:0,LOB: 0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,RULE:Spam_GS981B3D,ACT ION:quarantine,TS:95 X-CID-META: VersionHash:2a19b09,CLOUDID:ae90268a-32d7-4fc0-b2ef-8776ac194f8f,C OID:cf170092d950,Recheck:0,SF:28|17|19|48,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,QS:0,BEC:nil X-UUID: 17bf1eb0c22d4f76a43a189dd38307f5-20220601 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 2088635505; Wed, 01 Jun 2022 19:22:06 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Wed, 1 Jun 2022 19:22:05 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.3 via Frontend Transport; Wed, 1 Jun 2022 19:22:05 +0800 From: Tinghan Shen To: Bjorn Andersson , Mathieu Poirier , Rob Herring , "Krzysztof Kozlowski" , Matthias Brugger , Lee Jones , Benson Leung , Guenter Roeck , Daisuke Nojiri , Sebastian Reichel , "Dustin L. Howett" , Tzung-Bi Shih , Tinghan Shen , "Gustavo A. R. Silva" , Prashant Malani , "Enric Balletbo i Serra" , Brian Norris CC: , , , , , , , Subject: [PATCH v1 07/15] remoteproc: mediatek: Add SCP core 1 reserved memory support Date: Wed, 1 Jun 2022 19:21:53 +0800 Message-ID: <20220601112201.15510-8-tinghan.shen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220601112201.15510-1-tinghan.shen@mediatek.com> References: <20220601112201.15510-1-tinghan.shen@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Reuse the SCP core 0 reserved memory API on SCP core 1. Signed-off-by: Tinghan Shen --- drivers/remoteproc/mtk_common.h | 2 ++ drivers/remoteproc/mtk_scp.c | 6 ++++-- drivers/remoteproc/mtk_scp_dual.c | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h index 2e46be605687..da3ea2243678 100644 --- a/drivers/remoteproc/mtk_common.h +++ b/drivers/remoteproc/mtk_common.h @@ -168,4 +168,6 @@ int scp_stop(struct rproc *rproc); int scp_load(struct rproc *rproc, const struct firmware *fw); void *scp_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem); int scp_parse_fw(struct rproc *rproc, const struct firmware *fw); +int scp_map_memory_region(struct mtk_scp *scp); +void scp_unmap_memory_region(struct mtk_scp *scp); #endif diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index 7b9d12ec2d4f..75d161da0f59 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -747,7 +747,7 @@ void *scp_mapping_dm_addr(struct mtk_scp *scp, u32 mem_addr) } EXPORT_SYMBOL_GPL(scp_mapping_dm_addr); -static int scp_map_memory_region(struct mtk_scp *scp) +int scp_map_memory_region(struct mtk_scp *scp) { int ret; @@ -773,8 +773,9 @@ static int scp_map_memory_region(struct mtk_scp *scp) return 0; } +EXPORT_SYMBOL_GPL(scp_map_memory_region); -static void scp_unmap_memory_region(struct mtk_scp *scp) +void scp_unmap_memory_region(struct mtk_scp *scp) { if (scp->dram_size == 0) return; @@ -783,6 +784,7 @@ static void scp_unmap_memory_region(struct mtk_scp *scp) scp->dma_addr); of_reserved_mem_device_release(scp->dev); } +EXPORT_SYMBOL_GPL(scp_unmap_memory_region); static int scp_register_ipi(struct platform_device *pdev, u32 id, ipi_handler_t handler, void *priv) diff --git a/drivers/remoteproc/mtk_scp_dual.c b/drivers/remoteproc/mtk_scp_dual.c index e4ada5696bd7..0f932d26f864 100644 --- a/drivers/remoteproc/mtk_scp_dual.c +++ b/drivers/remoteproc/mtk_scp_dual.c @@ -60,6 +60,10 @@ static int scp_dual_probe(struct platform_device *pdev) return dev_err_probe(dev, PTR_ERR(scp->reg_base), "Failed to parse and map cfg memory\n"); + ret = scp_map_memory_region(scp); + if (ret) + return ret; + mutex_init(&scp->send_lock); for (i = 0; i < SCP_IPI_MAX; i++) mutex_init(&scp->ipi_desc[i].lock); @@ -75,6 +79,7 @@ static int scp_dual_remove(struct platform_device *pdev) struct mtk_scp *scp = platform_get_drvdata(pdev); int i; + scp_unmap_memory_region(scp); for (i = 0; i < SCP_IPI_MAX; i++) mutex_destroy(&scp->ipi_desc[i].lock); mutex_destroy(&scp->send_lock);