From patchwork Wed Jun 1 11:21:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 12866830 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC8DEC433F5 for ; Wed, 1 Jun 2022 11:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=c72/mzYM7kF8kEoneGzqkPUjlEL1MTiHTl27FdXwQ2k=; b=K7wGTR+y41/5R0 JsffDl5YaD62g4KvgpM/p5+s08ROI5LKMHt05sY0OxTqI46gYp3gtHQtDBZ8/smIOYKQpFInfceXM xs2HUV7qqV3tT0y6pTSLUiNzVf5TwT7mEzh24SxFtI6zoC35wuguI8ojwSMUqppcG5u6sp1P3Bzr+ NRnqCRtJdwQ/qcmtnimVzaEQ/LGTmVhDTUNPM55OEGp3D0Ev44Dz+UVfYUVxzxo4YehkwLtAXIakq a0bd+Z9ufsJSWDLi5zi45W4vHK36/VTntsHhsTC991O8wClYOlOhYOVieyKckjqip5SSGLwcvS4tz sS/2lXfidfcQPrFvyNrQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMaO-00FdI4-Un; Wed, 01 Jun 2022 11:32:24 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMaC-00FdCS-4x; Wed, 01 Jun 2022 11:32:13 +0000 X-UUID: b403a2864c314edabd77c9caeb7e8e60-20220601 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:66aff93a-99cf-4c33-beb0-dba8ed553999,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:2a19b09,CLOUDID:99ac8f14-f88c-475e-badf-d9ee54230b8f,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:0,BEC:nil X-UUID: b403a2864c314edabd77c9caeb7e8e60-20220601 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 155659035; Wed, 01 Jun 2022 04:32:08 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 1 Jun 2022 04:22:06 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Wed, 1 Jun 2022 19:22:04 +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:04 +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 01/15] dt-binding: remoteproc: mediatek: Support dual-core SCP Date: Wed, 1 Jun 2022 19:21:47 +0800 Message-ID: <20220601112201.15510-2-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_043212_232859_AD4F2076 X-CRM114-Status: GOOD ( 12.16 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The SCP co-processor is a dual-core RISC-V MCU on MT8195. Add a new property to identify each core and helps to find drivers through device tree API to cooperate with each other, e.g. boot flow and watchdog timeout flow. Add a new compatile for the driver of SCP 2nd core. Signed-off-by: Tinghan Shen --- .../devicetree/bindings/remoteproc/mtk,scp.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml b/Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml index eec3b9c4c713..b181786d9575 100644 --- a/Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +++ b/Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml @@ -20,6 +20,7 @@ properties: - mediatek,mt8186-scp - mediatek,mt8192-scp - mediatek,mt8195-scp + - mediatek,mt8195-scp-dual reg: description: @@ -57,6 +58,16 @@ properties: memory-region: maxItems: 1 + mediatek,scp-core: + $ref: /schemas/types.yaml#/definitions/uint32-array + description: + The property value is a list with 2 items, a core id and a phandle + to the sibling SCP node. The core id represents the id of the dts node contains + this property. The valid values of core id are 0 and 1 for dual-core SCP. + The phandle of sibling SCP node is used to find the register settings, + trigger core dependent callback, and invoke rproc API. + maxItems: 1 + required: - compatible - reg @@ -115,6 +126,7 @@ examples: reg-names = "sram", "cfg", "l1tcm"; clocks = <&infracfg CLK_INFRA_SCPSYS>; clock-names = "main"; + mediatek,scp-core = <0 &scp_dual>; cros_ec { mediatek,rpmsg-name = "cros-ec-rpmsg"; From patchwork Wed Jun 1 11:21:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 12866786 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 251FCC4332F for ; Wed, 1 Jun 2022 11:22:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3YhfptMFxP6fELvhH9itTPqbufVeXtJ6/BkfiXD4PQQ=; b=zJrLmhUOA62TBb aP8C0+/3EypNnOqJrYmBKnc8grSNK5l34Yy4COa7bWdNiJMxaZ4hsWFHa69hx/74TgnJ7xbTzn/76 Y6Uz9lcoeDm6tue7rahu6jkKRsWv5sD3dTF9vNArFEvH1lHWMC3w5U0cSNcU+yRccaWPR0Bwp9xjw HLeYcqFLH0tfWimErdsNVZohcxxe5sUHiUKxVMrKo0nY/4Ml5goPO2qCaSynMRX3/VKtOZcXjG0YQ p4gANLw0yepYs2eA0sXpuQGZIir3raIdCdoL5oCvZv7aiRTlqBUvltWbzVebzxx+B75gHdsRWjPLL RfkMs8nj7hr6JLbbDBJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMQe-00FawE-Vj; Wed, 01 Jun 2022 11:22:21 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMQb-00FauH-59; Wed, 01 Jun 2022 11:22:19 +0000 X-UUID: e073f8a76a61499395d40d1f364fe8e5-20220601 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:c2c3e0fc-79b6-4b14-9680-6a54a1b9a08b,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACT ION:release,TS:-5 X-CID-META: VersionHash:2a19b09,CLOUDID:ef648f14-f88c-475e-badf-d9ee54230b8f,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:0,BEC:nil X-UUID: e073f8a76a61499395d40d1f364fe8e5-20220601 Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1779496492; Wed, 01 Jun 2022 04:22:07 -0700 Received: from mtkmbs10n2.mediatek.inc (172.21.101.183) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 1 Jun 2022 04:22:06 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Wed, 1 Jun 2022 19:22:04 +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:04 +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 02/15] remoteproc: Kconfig: Add mt8195 SCP dual core configuration Date: Wed, 1 Jun 2022 19:21:48 +0800 Message-ID: <20220601112201.15510-3-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_042217_246323_C12AC4E6 X-CRM114-Status: GOOD ( 11.23 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org MediaTek MT8195 SoC SCP is a dual-core subsystem. Add a remoteproc configuration to enable support of the 2nd core. Signed-off-by: Tinghan Shen --- drivers/remoteproc/Kconfig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index 166019786653..bb2960b4ffbd 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -64,6 +64,16 @@ config MTK_SCP It's safe to say N here. +config MTK_SCP_DUALCORE + tristate "MediaTek SCP dual-core support" + depends on ARCH_MEDIATEK || COMPILE_TEST + depends on MTK_SCP + help + Say y here to support bring up the 2nd core of the dual-core version of + MediaTek's SCP via the remote processor framework. + + It's safe to say N here. + config OMAP_REMOTEPROC tristate "OMAP remoteproc support" depends on ARCH_OMAP4 || SOC_OMAP5 || SOC_DRA7XX From patchwork Wed Jun 1 11:21:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 12866839 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F15B1C433EF for ; Wed, 1 Jun 2022 11:34:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Dygh+zXb2fRB7uYhpR2qSpsGHadGFJjcVZsJBSebrAE=; b=c4T2a7JRtCINxk EMtNWvPJiv3a6ImNy3dUisGBIegiGSX/uW8CMMJPsFr5bUt2orWJtdGX/Dk/dRGZNRPOD4EI1J/8v hpvdrmLM636Wug7D+yWyzxU7DZ6cg5CVMFrbm8DddEf+XKtIgTpvo/228kT/3D/1CqcL82kd7RCcD LgDynlyMMPWOvs2KkZeQyAewC2n2tCUcSrezMXOM160lRbqabLgJgbZfYKqHs9dQymSoL1Eo78RA5 bYnN/R89EXKU63Zj1VyzTVHwMbVoXzkSPqBhzhQTMMzIMsc+c9i6+GZwWGAO3Fw6u+fkBRkjLcd86 dLkJdH4zoUx6ghRIXs5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMcj-00Fed7-Fn; Wed, 01 Jun 2022 11:34:49 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMaJ-00FdEe-2k; Wed, 01 Jun 2022 11:32:22 +0000 X-UUID: abe1bc8f1a6848cd80b0cde82c1770ef-20220601 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:f8af8cb1-2885-461e-b8e5-ff4bade5b14c,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:2a19b09,CLOUDID:bfac8f14-f88c-475e-badf-d9ee54230b8f,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:0,BEC:nil X-UUID: abe1bc8f1a6848cd80b0cde82c1770ef-20220601 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1494678624; Wed, 01 Jun 2022 04:32:09 -0700 Received: from mtkmbs10n2.mediatek.inc (172.21.101.183) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 1 Jun 2022 04:22:07 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Wed, 1 Jun 2022 19:22:04 +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:04 +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 03/15] remoteproc: mediatek: Support hanlding scp core 1 wdt timeout Date: Wed, 1 Jun 2022 19:21:49 +0800 Message-ID: <20220601112201.15510-4-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_043219_270427_4A69806E X-CRM114-Status: GOOD ( 17.64 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org MT8195 SCP is a dual-core processor. The SCP core 1 watchdog timeout interrupt uses the same interrupt line of SCP core 0 watchdog timeout interrupt. Add support for handling SCP core 1 watchdog timeout interrupt in the SCP IRQ handler. Signed-off-by: Tinghan Shen --- drivers/remoteproc/mtk_common.h | 4 ++++ drivers/remoteproc/mtk_scp.c | 27 ++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h index ea6fa1100a00..73e8adf00de3 100644 --- a/drivers/remoteproc/mtk_common.h +++ b/drivers/remoteproc/mtk_common.h @@ -54,6 +54,10 @@ #define MT8192_CORE0_WDT_IRQ 0x10030 #define MT8192_CORE0_WDT_CFG 0x10034 +#define MT8195_SYS_STATUS 0x4004 +#define MT8195_CORE0_WDT BIT(16) +#define MT8195_CORE1_WDT BIT(17) + #define MT8195_L1TCM_SRAM_PDN_RESERVED_RSI_BITS GENMASK(7, 4) #define SCP_FW_VER_LEN 32 diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index 47b2a40e1b4a..3510c6d0bbc8 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -212,6 +212,31 @@ static void mt8192_scp_irq_handler(struct mtk_scp *scp) } } +static void mt8195_scp_irq_handler(struct mtk_scp *scp) +{ + u32 scp_to_host; + + scp_to_host = readl(scp->reg_base + MT8192_SCP2APMCU_IPC_SET); + + if (scp_to_host & MT8192_SCP_IPC_INT_BIT) { + scp_ipi_handler(scp); + + /* + * SCP won't send another interrupt until we clear + * MT8192_SCP2APMCU_IPC. + */ + writel(MT8192_SCP_IPC_INT_BIT, + scp->reg_base + MT8192_SCP2APMCU_IPC_CLR); + } else { + if (readl(scp->reg_base + MT8195_SYS_STATUS) & MT8195_CORE1_WDT) { + writel(1, scp->reg_base + MT8195_CORE1_WDT_IRQ); + } else { + writel(1, scp->reg_base + MT8192_CORE0_WDT_IRQ); + scp_wdt_handler(scp, scp_to_host); + } + } +} + static irqreturn_t scp_irq_handler(int irq, void *priv) { struct mtk_scp *scp = priv; @@ -961,7 +986,7 @@ static const struct mtk_scp_of_data mt8192_of_data = { static const struct mtk_scp_of_data mt8195_of_data = { .scp_clk_get = mt8195_scp_clk_get, .scp_before_load = mt8195_scp_before_load, - .scp_irq_handler = mt8192_scp_irq_handler, + .scp_irq_handler = mt8195_scp_irq_handler, .scp_reset_assert = mt8192_scp_reset_assert, .scp_reset_deassert = mt8192_scp_reset_deassert, .scp_stop = mt8195_scp_stop, From patchwork Wed Jun 1 11:21:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 12866788 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E7B2AC433EF for ; Wed, 1 Jun 2022 11:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=O+agU/rqkrbE8c8Ji3O8Bleg3vpv3D+elU7DWgzLy+k=; b=EQvPzqvy1T2mXc 0wH2IQWWXnSskh1Ikppj7hhp0mezLc7t8qHMgQxxJdWAmuQprLJfF14w5XZITiR92VDqpVei2NAuL gRYpJvY7BTY5AiBtB9OHrrYNwRDIE9TK70U3zLh14JrpOprb0hr6XsZDEP4t9bS69kc4ubQP+METB JdM91L3yolL+zfKsyQqdjdzWl3kaWwEm0rqRJhB12q9lnw0M1MjzzjBezH+JCYnQuOPRX2s8xwy5p EftgE+6NWmJDnKM7Am/Rdfgg2iw9S8MjYo+ZK4f22bGPOoGyb9SV7sIlwnDnapbjlOWzMbck3h766 k19HKmqRSezF9Yfd2/0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMQx-00Fb2e-ES; Wed, 01 Jun 2022 11:22:39 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMQb-00FauE-PZ; Wed, 01 Jun 2022 11:22:21 +0000 X-UUID: eaac30aae64944ce85f608de17868700-20220601 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:2ea7de22-9a70-4376-a921-1457bd8f25e0,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACT ION:release,TS:-5 X-CID-META: VersionHash:2a19b09,CLOUDID:fd90268a-32d7-4fc0-b2ef-8776ac194f8f,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:0,BEC:nil X-UUID: eaac30aae64944ce85f608de17868700-20220601 Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 140173781; Wed, 01 Jun 2022 04:22:07 -0700 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 1 Jun 2022 04:22:06 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Wed, 1 Jun 2022 19:22:04 +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:04 +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 04/15] remoteproc: mediatek: Add SCP core 1 register definitions Date: Wed, 1 Jun 2022 19:21:50 +0800 Message-ID: <20220601112201.15510-5-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_042217_868312_E777D78D X-CRM114-Status: UNSURE ( 9.52 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Add MT8195 SCP core 1 related register definitions. Signed-off-by: Tinghan Shen --- drivers/remoteproc/mtk_common.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h index 73e8adf00de3..2eadb0e696a1 100644 --- a/drivers/remoteproc/mtk_common.h +++ b/drivers/remoteproc/mtk_common.h @@ -47,6 +47,7 @@ #define MT8192_SCP2SPM_IPC_CLR 0x4094 #define MT8192_GIPC_IN_SET 0x4098 #define MT8192_HOST_IPC_INT_BIT BIT(0) +#define MT8195_HOST_IPC_INT_BIT BIT(4) #define MT8192_CORE0_SW_RSTN_CLR 0x10000 #define MT8192_CORE0_SW_RSTN_SET 0x10004 @@ -60,6 +61,26 @@ #define MT8195_L1TCM_SRAM_PDN_RESERVED_RSI_BITS GENMASK(7, 4) +#define MT8195_CPU1_SRAM_PD 0x1084 +#define MT8195_SSHUB2APMCU_IPC_SET 0x4088 +#define MT8195_SSHUB2APMCU_IPC_CLR 0x408C +#define MT8195_CORE1_SW_RSTN_CLR 0x20000 +#define MT8195_CORE1_SW_RSTN_SET 0x20004 +#define MT8195_CORE1_MEM_ATT_PREDEF 0x20008 +#define MT8195_CORE1_WDT_IRQ 0x20030 +#define MT8195_CORE1_WDT_CFG 0x20034 + +#define MT8195_SEC_CTRL 0x85000 +#define MT8195_CORE_OFFSET_ENABLE_D BIT(13) +#define MT8195_CORE_OFFSET_ENABLE_I BIT(12) +#define MT8195_L2TCM_OFFSET_RANGE_0_LOW 0x850b0 +#define MT8195_L2TCM_OFFSET_RANGE_0_HIGH 0x850b4 +#define MT8195_L2TCM_OFFSET 0x850d0 +#define SCP_SRAM_REMAP_LOW 0 +#define SCP_SRAM_REMAP_HIGH 1 +#define SCP_SRAM_REMAP_OFFSET 2 +#define SCP_SRAM_REMAP_SIZE 3 + #define SCP_FW_VER_LEN 32 #define SCP_SHARE_BUFFER_SIZE 288 From patchwork Wed Jun 1 11:21:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 12866837 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D60D2C433FE for ; Wed, 1 Jun 2022 11:34:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Sgq+2V2cePP/3l647Cp9K9TNVY0STgjzNE3ZAYRvOzg=; b=OPMfBrmSOhqYjE L+NZGSPIg0CuIL1G0ACEO68jn+g+SpJOAGmLP+KCVHk0dN+JdgG6HM0BXsqhRxqd8fRpqCTjrENbK VL8tFyYPRX0Y5Am0dMO0kcxROh2lmCqh0rvfUID6Aa3Bq3HoHBvhbqW4dQUboqAo3QVRV1RkLnSJy Wt8jqPpaUOyQHMc3mjDmLzuhTL39kVlPzp91klUwjxTyKUSISy60JtY37MMijZmKuxEb2Abt6Gw1M ZoMNF1Mry5HDfXbKUolmeRI3Tr1JJZ9f5Seh5z2g/XJnLKvY0aXC0JhK3UyDSf9BFxgjmunj56t8Y zmPB+N4mVOOzYvhhlCgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMbw-00Fe7W-DJ; Wed, 01 Jun 2022 11:34:00 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMaJ-00FdFA-2e; Wed, 01 Jun 2022 11:32:20 +0000 X-UUID: cf823a8fea4b4d3ea567ca7dfb78801e-20220601 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:37d7062b-bd72-48b5-ab75-694428d97f7e,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACT ION:release,TS:-5 X-CID-META: VersionHash:2a19b09,CLOUDID:c1ac8f14-f88c-475e-badf-d9ee54230b8f,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:0,BEC:nil X-UUID: cf823a8fea4b4d3ea567ca7dfb78801e-20220601 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1791369835; Wed, 01 Jun 2022 04:32:09 -0700 Received: from mtkmbs10n2.mediatek.inc (172.21.101.183) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 1 Jun 2022 04:22:07 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Wed, 1 Jun 2022 19:22:04 +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:04 +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 05/15] remoteproc: mediatek: Add SCP core 1 driver for dual-core scp Date: Wed, 1 Jun 2022 19:21:51 +0800 Message-ID: <20220601112201.15510-6-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_043219_187682_041B5049 X-CRM114-Status: GOOD ( 23.94 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org MT8195 SCP is a dual-core processor. The mtk_scp.c driver only controls SCP core 0. This patch adds a basic driver to control the another core. Core 1 and core 0 of the SCP are housed in the same subsys.They see registers and memory in the same way. Core 1 of the SCP features its own set of core configuration registers, interrupt controller, timers, and DMAs. The rest of the peripherals in this subsystem are shared by core 0 and core 1. As for memory, core 1 has its own cache memory, and the SCP SRAM is shared by core 0 and core 1. Signed-off-by: Tinghan Shen --- drivers/remoteproc/Makefile | 1 + drivers/remoteproc/mtk_scp_dual.c | 97 +++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 drivers/remoteproc/mtk_scp_dual.c diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile index 5478c7cb9e07..84cb687d28da 100644 --- a/drivers/remoteproc/Makefile +++ b/drivers/remoteproc/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_IMX_REMOTEPROC) += imx_rproc.o obj-$(CONFIG_IMX_DSP_REMOTEPROC) += imx_dsp_rproc.o obj-$(CONFIG_INGENIC_VPU_RPROC) += ingenic_rproc.o obj-$(CONFIG_MTK_SCP) += mtk_scp.o mtk_scp_ipi.o +obj-$(CONFIG_MTK_SCP_DUALCORE) += mtk_scp_dual.o obj-$(CONFIG_OMAP_REMOTEPROC) += omap_remoteproc.o obj-$(CONFIG_WKUP_M3_RPROC) += wkup_m3_rproc.o obj-$(CONFIG_DA8XX_REMOTEPROC) += da8xx_remoteproc.o diff --git a/drivers/remoteproc/mtk_scp_dual.c b/drivers/remoteproc/mtk_scp_dual.c new file mode 100644 index 000000000000..7bc08d26f208 --- /dev/null +++ b/drivers/remoteproc/mtk_scp_dual.c @@ -0,0 +1,97 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (c) 2022 MediaTek Inc. + +#include +#include +#include +#include +#include +#include + +#include "mtk_common.h" +#include "remoteproc_internal.h" + +static const struct rproc_ops scp_ops; + +static int scp_dual_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct mtk_scp *scp; + struct rproc *rproc; + const char *fw_name = "scp-dual.img"; + int ret, i; + struct resource *res; + + ret = rproc_of_parse_firmware(dev, 0, &fw_name); + if (ret < 0 && ret != -EINVAL) + return ret; + + rproc = devm_rproc_alloc(dev, np->name, &scp_ops, fw_name, sizeof(*scp)); + if (!rproc) { + dev_err(dev, "unable to allocate remoteproc\n"); + return -ENOMEM; + } + + scp = (struct mtk_scp *)rproc->priv; + scp->rproc = rproc; + scp->dev = dev; + platform_set_drvdata(pdev, scp); + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sram"); + scp->sram_base = devm_ioremap(dev, res->start, resource_size(res)); + if (IS_ERR(scp->sram_base)) + return dev_err_probe(dev, PTR_ERR(scp->sram_base), + "Failed to parse and map sram memory\n"); + + scp->sram_size = resource_size(res); + scp->sram_phys = res->start; + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg"); + scp->reg_base = devm_ioremap(dev, res->start, resource_size(res)); + if (IS_ERR(scp->reg_base)) + return dev_err_probe(dev, PTR_ERR(scp->reg_base), + "Failed to parse and map cfg memory\n"); + + mutex_init(&scp->send_lock); + for (i = 0; i < SCP_IPI_MAX; i++) + mutex_init(&scp->ipi_desc[i].lock); + + init_waitqueue_head(&scp->run.wq); + init_waitqueue_head(&scp->ack_wq); + + return 0; +} + +static int scp_dual_remove(struct platform_device *pdev) +{ + struct mtk_scp *scp = platform_get_drvdata(pdev); + int i; + + for (i = 0; i < SCP_IPI_MAX; i++) + mutex_destroy(&scp->ipi_desc[i].lock); + mutex_destroy(&scp->send_lock); + + return 0; +} + +static const struct of_device_id mtk_scp_dual_of_match[] = { + { .compatible = "mediatek,mt8195-scp-dual" }, + {}, +}; +MODULE_DEVICE_TABLE(of, mtk_scp_dual_of_match); + +static struct platform_driver mtk_scp_dual_driver = { + .probe = scp_dual_probe, + .remove = scp_dual_remove, + .driver = { + .name = "mtk-scp-dual", + .of_match_table = mtk_scp_dual_of_match, + }, +}; + +module_platform_driver(mtk_scp_dual_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("MediaTek SCP dualcore control driver"); From patchwork Wed Jun 1 11:21:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 12866832 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 52608C433F5 for ; Wed, 1 Jun 2022 11:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zaVXN4hy2PjakNDFURWx2UogKU/l72cddlhHzHOKxOE=; b=CcYEutECAVPO6F wvBX7wptbYRGU2750UKsMo6ktfuq7Lc1SxADG40A3T0VXeQmkYkvMg4Gm9sD7+unPNBk+j+D5OzII lMvGj9j175wSGDL+f/JXwsrqC/v5P7oDx+KzEJHOMosL4NCFf0F+6LJaqK6mh3HGgo0lP+lIabNdU YQ/g/DzJQET4hYTv78uw2ntK/eIs8NE/8uSwopvWK+E4SjxJQZn9bV7V16j25v8g75qeQp538UWs/ bYZc1msOJuzSS4fHJo96uTL5lWu/LIgSbTXBsiKAfP4VnYql+V7PRgXV3j1Y4RjtzOIwhvgb4AcJj DObQpE2ifhSD//v37oZg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMah-00FdNJ-LF; Wed, 01 Jun 2022 11:32:43 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMaD-00FdCS-HO; Wed, 01 Jun 2022 11:32:15 +0000 X-UUID: 0f13f2113551422fa5aa1822f25fe364-20220601 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:7423b860-d1ba-41fb-bd24-293973935159,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACT ION:release,TS:-5 X-CID-META: VersionHash:2a19b09,CLOUDID:3ed9268a-32d7-4fc0-b2ef-8776ac194f8f,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:0,BEC:nil X-UUID: 0f13f2113551422fa5aa1822f25fe364-20220601 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 110150701; Wed, 01 Jun 2022 04:32:08 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 1 Jun 2022 04:22:06 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; 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 06/15] remoteproc: mediatek: Add SCP core 1 rproc operations Date: Wed, 1 Jun 2022 19:21:52 +0800 Message-ID: <20220601112201.15510-7-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_043213_610780_20E9A614 X-CRM114-Status: GOOD ( 16.00 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The firmware load and boot flow of SCP core 1 is almost the same as the SCP core 0 except the accessed registers. Reuse the core 0 rproc operations to load and boot SCP core 1. Signed-off-by: Tinghan Shen --- drivers/remoteproc/mtk_common.h | 5 +++++ drivers/remoteproc/mtk_scp.c | 15 ++++++++++----- drivers/remoteproc/mtk_scp_dual.c | 8 +++++++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h index 2eadb0e696a1..2e46be605687 100644 --- a/drivers/remoteproc/mtk_common.h +++ b/drivers/remoteproc/mtk_common.h @@ -163,4 +163,9 @@ void scp_memcpy_aligned(void __iomem *dst, const void *src, unsigned int len); void scp_ipi_lock(struct mtk_scp *scp, u32 id); void scp_ipi_unlock(struct mtk_scp *scp, u32 id); +int scp_start(struct rproc *rproc); +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); #endif diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index 3510c6d0bbc8..7b9d12ec2d4f 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -470,7 +470,7 @@ static int mt8195_scp_before_load(struct mtk_scp *scp) return 0; } -static int scp_load(struct rproc *rproc, const struct firmware *fw) +int scp_load(struct rproc *rproc, const struct firmware *fw) { struct mtk_scp *scp = rproc->priv; struct device *dev = scp->dev; @@ -495,8 +495,9 @@ static int scp_load(struct rproc *rproc, const struct firmware *fw) return ret; } +EXPORT_SYMBOL_GPL(scp_load); -static int scp_parse_fw(struct rproc *rproc, const struct firmware *fw) +int scp_parse_fw(struct rproc *rproc, const struct firmware *fw) { struct mtk_scp *scp = rproc->priv; struct device *dev = scp->dev; @@ -512,8 +513,9 @@ static int scp_parse_fw(struct rproc *rproc, const struct firmware *fw) clk_disable_unprepare(scp->clk); return ret; } +EXPORT_SYMBOL_GPL(scp_parse_fw); -static int scp_start(struct rproc *rproc) +int scp_start(struct rproc *rproc) { struct mtk_scp *scp = (struct mtk_scp *)rproc->priv; struct device *dev = scp->dev; @@ -555,6 +557,7 @@ static int scp_start(struct rproc *rproc) clk_disable_unprepare(scp->clk); return ret; } +EXPORT_SYMBOL_GPL(scp_start); static void *mt8183_scp_da_to_va(struct mtk_scp *scp, u64 da, size_t len) { @@ -602,12 +605,13 @@ static void *mt8192_scp_da_to_va(struct mtk_scp *scp, u64 da, size_t len) return NULL; } -static void *scp_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem) +void *scp_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem) { struct mtk_scp *scp = (struct mtk_scp *)rproc->priv; return scp->data->scp_da_to_va(scp, da, len); } +EXPORT_SYMBOL_GPL(scp_da_to_va); static void mt8183_scp_stop(struct mtk_scp *scp) { @@ -642,7 +646,7 @@ static void mt8195_scp_stop(struct mtk_scp *scp) writel(0, scp->reg_base + MT8192_CORE0_WDT_CFG); } -static int scp_stop(struct rproc *rproc) +int scp_stop(struct rproc *rproc) { struct mtk_scp *scp = (struct mtk_scp *)rproc->priv; int ret; @@ -659,6 +663,7 @@ static int scp_stop(struct rproc *rproc) return 0; } +EXPORT_SYMBOL_GPL(scp_stop); static const struct rproc_ops scp_ops = { .start = scp_start, diff --git a/drivers/remoteproc/mtk_scp_dual.c b/drivers/remoteproc/mtk_scp_dual.c index 7bc08d26f208..e4ada5696bd7 100644 --- a/drivers/remoteproc/mtk_scp_dual.c +++ b/drivers/remoteproc/mtk_scp_dual.c @@ -12,7 +12,13 @@ #include "mtk_common.h" #include "remoteproc_internal.h" -static const struct rproc_ops scp_ops; +static const struct rproc_ops scp_ops = { + .start = scp_start, + .stop = scp_stop, + .load = scp_load, + .da_to_va = scp_da_to_va, + .parse_fw = scp_parse_fw, +}; static int scp_dual_probe(struct platform_device *pdev) { 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: 12866787 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2856AC43219 for ; Wed, 1 Jun 2022 11:22:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vryjbgcUfXGsrNqdaOfzvzoRa8kuYa50n6AqfpJC5Lk=; b=Ubv3W7eX5gOEO5 sRFyyacWTv/vbxJhIIKJnU96xc5WbAtZhJA7J1gErds0mlZH5mTT2Ltdu0a2eOFK7Q3l5bZ3m+Ux2 VHRCfLb1qX8SQQyv7H4Jy9ZjMGgHXkRiCSPAuIBDCyWl0Shsv85JWp3jqKOCH1L4Zs5+CUMFPjAO7 e3u/7fzteuvJOx+yQT9yLKloiMhBsyhb/PtRhJm24Lp/x6Wr/oVOTVuwiZ8pIHIB+0OVLYbg9uPxc d5+xJFeB95mEBGBAWEyJwp4bkXDpqgHdCfayzSEEUMbjJjpbKtovQWxCbQmy+6aerMeXimwGdE5wk /jMHkZGoem1ndnKkycjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMQf-00Fawf-NM; Wed, 01 Jun 2022 11:22:21 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMQb-00FauJ-Ei; Wed, 01 Jun 2022 11:22:19 +0000 X-UUID: 94941786139b493dadd6464c5dbb5f16-20220601 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:c346ba6b-0754-45a5-9cbc-38b6648a776a,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:2a19b09,CLOUDID:eb648f14-f88c-475e-badf-d9ee54230b8f,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:0,BEC:nil X-UUID: 94941786139b493dadd6464c5dbb5f16-20220601 Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1270996758; Wed, 01 Jun 2022 04:22:07 -0700 Received: from mtkmbs10n1.mediatek.inc (172.21.101.34) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 1 Jun 2022 04:22:06 -0700 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_042217_535001_66ECF579 X-CRM114-Status: GOOD ( 14.91 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.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); From patchwork Wed Jun 1 11:21:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 12866838 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CD049C433F5 for ; Wed, 1 Jun 2022 11:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=k0/UAMxFCtFmFSaj2XEuJk4f1uHlmomHW1eUpIvvH6A=; b=zqAo8BAlTICogI XFECEARVvPbf2F9y+a1K4QCvP6HoclbkkysvRhLKkNbVeerCWNZzkQRKzth61Hk+8RJoyKuiu96A3 PQLRKYg8QFA/HYyDET9aaziBNdZd7fpUAHDghoGof0ekw2KFBydUPc0iSYm8UP5QW5XHZeLOT1swb n+t35dk3zKhzrK7Z5aGUwmErX57IGV/wmm4YigOTNsV5OhOmfPBlt+yGE1koWnfIukiIoU7pVR2kO 0gJCBb1eCAwYN4atyKma42oROC4uizA3nzPQo+nz/Ivpeun72wmA2WMY7+ONMQ70/WZ5YowO+9sRa pOWrWC3h66EZb17Dj4lg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMci-00FecU-9E; Wed, 01 Jun 2022 11:34:48 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMaJ-00FdFG-2f; Wed, 01 Jun 2022 11:32:22 +0000 X-UUID: ba67de36c3cf4ba388d15d4fe5b16e82-20220601 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:e42b1290-6368-4d23-9073-4a89c94bbd0e,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACT ION:release,TS:-5 X-CID-META: VersionHash:2a19b09,CLOUDID:c2ac8f14-f88c-475e-badf-d9ee54230b8f,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:0,BEC:nil X-UUID: ba67de36c3cf4ba388d15d4fe5b16e82-20220601 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1269172104; Wed, 01 Jun 2022 04:32:09 -0700 Received: from mtkmbs10n1.mediatek.inc (172.21.101.34) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 1 Jun 2022 04:22:07 -0700 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 08/15] remoteproc: mediatek: Add SCP core 1 interrupt support Date: Wed, 1 Jun 2022 19:21:54 +0800 Message-ID: <20220601112201.15510-9-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_043219_259293_B4BEB5C7 X-CRM114-Status: GOOD ( 17.53 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Reuse the interrupt handling API of SCP core 0 on SCP core 1. Signed-off-by: Tinghan Shen --- drivers/remoteproc/mtk_common.h | 1 + drivers/remoteproc/mtk_scp.c | 3 ++- drivers/remoteproc/mtk_scp_dual.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h index da3ea2243678..04f7ee590f96 100644 --- a/drivers/remoteproc/mtk_common.h +++ b/drivers/remoteproc/mtk_common.h @@ -170,4 +170,5 @@ 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); +irqreturn_t scp_irq_handler(int irq, void *priv); #endif diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index 75d161da0f59..c67883c28a43 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -237,7 +237,7 @@ static void mt8195_scp_irq_handler(struct mtk_scp *scp) } } -static irqreturn_t scp_irq_handler(int irq, void *priv) +irqreturn_t scp_irq_handler(int irq, void *priv) { struct mtk_scp *scp = priv; int ret; @@ -254,6 +254,7 @@ static irqreturn_t scp_irq_handler(int irq, void *priv) return IRQ_HANDLED; } +EXPORT_SYMBOL_GPL(scp_irq_handler); static int scp_elf_load_segments(struct rproc *rproc, const struct firmware *fw) { diff --git a/drivers/remoteproc/mtk_scp_dual.c b/drivers/remoteproc/mtk_scp_dual.c index 0f932d26f864..7bed39722bd5 100644 --- a/drivers/remoteproc/mtk_scp_dual.c +++ b/drivers/remoteproc/mtk_scp_dual.c @@ -71,7 +71,24 @@ static int scp_dual_probe(struct platform_device *pdev) init_waitqueue_head(&scp->run.wq); init_waitqueue_head(&scp->ack_wq); + ret = devm_request_threaded_irq(dev, platform_get_irq(pdev, 0), NULL, + scp_irq_handler, IRQF_ONESHOT, + pdev->name, scp); + + if (ret) { + dev_err(dev, "failed to request irq\n"); + goto release_dev_mem; + } + return 0; + +release_dev_mem: + 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); + + return ret; } static int scp_dual_remove(struct platform_device *pdev) From patchwork Wed Jun 1 11:21:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 12866829 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 596B1C433F5 for ; Wed, 1 Jun 2022 11:32:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=d9nwYmYpW/X095Eil2D0kq5wQvC2bno+1FTGd2LnGTE=; b=NExEb2CFtLai4K 3rHg7hWj/jYQ3zmtjezYMNA65Oglql8HJ7NTuLdVGQKMvdROkk+urTWEkkI4wZkCPcoCUiV+0XTRW /pg+X5sgu9Pb8RRHPUnX/EJ1Ws7Jdxjz/vLq7rhRHYnXMZ7yWd2L66nXS5Tu8BFj4bN9RbPvM++xy ZsE90b/Zzhn2qZdS3+VHKhpSVR/inVogn0G+syejPbsgID8Y9vh4EcjeQZxnMRPldvc+kU2a93HR7 yOjCriBjFs15zrD9LpPponqITTmO+OcVXLurZPsAZnpWX4VlRSbywz4kANs+Y6bMtntP+ubOQU38E NVR8qEh37AdH83msYqvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMaE-00FdEA-KU; Wed, 01 Jun 2022 11:32:14 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMaB-00FdCB-MV; Wed, 01 Jun 2022 11:32:13 +0000 X-UUID: c244a263fdc0416e9f940345a5b6acff-20220601 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:ad827442-2d9d-4ba3-83d0-ba2d65d240bd,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:2a19b09,CLOUDID:3ad9268a-32d7-4fc0-b2ef-8776ac194f8f,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:0,BEC:nil X-UUID: c244a263fdc0416e9f940345a5b6acff-20220601 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 334822013; Wed, 01 Jun 2022 04:32:08 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 1 Jun 2022 04:22:08 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; 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 09/15] remoteproc: mediatek: Register SCP core 1 initialization ipi Date: Wed, 1 Jun 2022 19:21:55 +0800 Message-ID: <20220601112201.15510-10-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_043211_782094_7FD8C9AA X-CRM114-Status: GOOD ( 16.14 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The SCP core 1 doesn't have vdec/venc functions like SCP core 0. Remove usage of venc/vdec parameters. Signed-off-by: Tinghan Shen --- drivers/remoteproc/mtk_scp_dual.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/mtk_scp_dual.c b/drivers/remoteproc/mtk_scp_dual.c index 7bed39722bd5..d4cc15e22640 100644 --- a/drivers/remoteproc/mtk_scp_dual.c +++ b/drivers/remoteproc/mtk_scp_dual.c @@ -20,6 +20,16 @@ static const struct rproc_ops scp_ops = { .parse_fw = scp_parse_fw, }; +static void scp_init_ipi_handler(void *data, unsigned int len, void *priv) +{ + struct mtk_scp *scp = (struct mtk_scp *)priv; + struct scp_run *run = (struct scp_run *)data; + + scp->run.signaled = run->signaled; + strscpy(scp->run.fw_ver, run->fw_ver, SCP_FW_VER_LEN); + wake_up_interruptible(&scp->run.wq); +} + static int scp_dual_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -68,6 +78,13 @@ static int scp_dual_probe(struct platform_device *pdev) for (i = 0; i < SCP_IPI_MAX; i++) mutex_init(&scp->ipi_desc[i].lock); + /* register SCP initialization IPI */ + ret = scp_ipi_register(scp, SCP_IPI_INIT, scp_init_ipi_handler, scp); + if (ret) { + dev_err(dev, "Failed to register IPI_SCP_INIT\n"); + goto release_dev_mem; + } + init_waitqueue_head(&scp->run.wq); init_waitqueue_head(&scp->ack_wq); @@ -77,11 +94,13 @@ static int scp_dual_probe(struct platform_device *pdev) if (ret) { dev_err(dev, "failed to request irq\n"); - goto release_dev_mem; + goto remove_ipi; } return 0; +remove_ipi: + scp_ipi_unregister(scp, SCP_IPI_INIT); release_dev_mem: scp_unmap_memory_region(scp); for (i = 0; i < SCP_IPI_MAX; i++) @@ -96,6 +115,7 @@ static int scp_dual_remove(struct platform_device *pdev) struct mtk_scp *scp = platform_get_drvdata(pdev); int i; + scp_ipi_unregister(scp, SCP_IPI_INIT); scp_unmap_memory_region(scp); for (i = 0; i < SCP_IPI_MAX; i++) mutex_destroy(&scp->ipi_desc[i].lock); From patchwork Wed Jun 1 11:21:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 12866834 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E0855C433F5 for ; Wed, 1 Jun 2022 11:33:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=z3CRWWjvqOdSH3+EYbhrV8u2/IvCv+EX+kuwenSTB14=; b=TWbWtm5VBSB1Mn uF3FUApVaMEtpZ/t9eYDfEj0VYQRbSNrrZP521lrCnLLE/aYffpnYcnK1xpPW5fsvwN8DMXH3o1GI lbhyqOrtOsRpPNiqAwSI6vj1wDD7xriaMIKG2HGOTcm0YaXstgnUMue4FwlcgYcT6gAhO+6yg2mya sKn7z7an6D9opfTO8GdeTvmnFx89EBzFKlmKa+45OtHka1zUzWef47ChRD+8tDXbvMdPJmIDy7+OI JkEu3YNk5QW+95wvs129ZFg9/M4adp0/OvgMBahXwG0zgUUSB5yGQ5Xzxj40+mlJi+dWgTgBPF5O5 IBGlvU8yeXjk4YWCKrcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMbG-00Fdg2-F5; Wed, 01 Jun 2022 11:33:18 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMaE-00FdDi-50; Wed, 01 Jun 2022 11:32:16 +0000 X-UUID: b675c96efa544aaf816e0c2e43999e09-20220601 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:4fa74643-13e2-4611-b7fa-7675b0418a73,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:2a19b09,CLOUDID:a0ac8f14-f88c-475e-badf-d9ee54230b8f,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:0,BEC:nil X-UUID: b675c96efa544aaf816e0c2e43999e09-20220601 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 217592412; Wed, 01 Jun 2022 04:32:08 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 1 Jun 2022 04:22:07 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; 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 10/15] remoteproc: mediatek: Add chip dependent operations for SCP core 1 Date: Wed, 1 Jun 2022 19:21:56 +0800 Message-ID: <20220601112201.15510-11-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_043214_234333_EF916B89 X-CRM114-Status: GOOD ( 20.71 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The SCP rproc operations has chip dependent callbacks. Implement a version of these callbacks for MT8195 SCP core 1. Signed-off-by: Tinghan Shen --- drivers/remoteproc/mtk_common.h | 1 + drivers/remoteproc/mtk_scp.c | 3 +- drivers/remoteproc/mtk_scp_dual.c | 121 +++++++++++++++++++++++++++++- 3 files changed, 123 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h index 04f7ee590f96..7b363411ec99 100644 --- a/drivers/remoteproc/mtk_common.h +++ b/drivers/remoteproc/mtk_common.h @@ -171,4 +171,5 @@ 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); irqreturn_t scp_irq_handler(int irq, void *priv); +void scp_ipi_handler(struct mtk_scp *scp); #endif diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index c67883c28a43..55bc4e9d1a6f 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -84,7 +84,7 @@ static void scp_init_ipi_handler(void *data, unsigned int len, void *priv) wake_up_interruptible(&scp->run.wq); } -static void scp_ipi_handler(struct mtk_scp *scp) +void scp_ipi_handler(struct mtk_scp *scp) { struct mtk_share_obj __iomem *rcv_obj = scp->recv_buf; struct scp_ipi_desc *ipi_desc = scp->ipi_desc; @@ -118,6 +118,7 @@ static void scp_ipi_handler(struct mtk_scp *scp) scp->ipi_id_ack[id] = true; wake_up(&scp->ack_wq); } +EXPORT_SYMBOL_GPL(scp_ipi_handler); static int scp_elf_read_ipi_buf_addr(struct mtk_scp *scp, const struct firmware *fw, diff --git a/drivers/remoteproc/mtk_scp_dual.c b/drivers/remoteproc/mtk_scp_dual.c index d4cc15e22640..16cf9d2628c8 100644 --- a/drivers/remoteproc/mtk_scp_dual.c +++ b/drivers/remoteproc/mtk_scp_dual.c @@ -12,6 +12,124 @@ #include "mtk_common.h" #include "remoteproc_internal.h" +static void mt8195_power_on_sram(void __iomem *addr) +{ + int i; + + for (i = 31; i >= 0; i--) + writel(GENMASK(i, 0), addr); + writel(0, addr); +} + +static void mt8195_power_off_sram(void __iomem *addr) +{ + int i; + + writel(0, addr); + for (i = 0; i < 32; i++) + writel(GENMASK(i, 0), addr); +} + +static int mt8195_scp_dual_before_load(struct mtk_scp *scp) +{ + u32 sec_ctrl; + + mt8195_power_on_sram(scp->reg_base + MT8195_CPU1_SRAM_PD); + + /* hold SCP in reset while loading FW. */ + scp->data->scp_reset_assert(scp); + + /* enable MPU for all memory regions */ + writel(0xff, scp->reg_base + MT8195_CORE1_MEM_ATT_PREDEF); + + return 0; +} + +static void mt8195_scp_dual_irq_handler(struct mtk_scp *scp) +{ + u32 scp_to_host; + + scp_to_host = readl(scp->reg_base + MT8195_SSHUB2APMCU_IPC_SET); + + if (scp_to_host & MT8192_SCP_IPC_INT_BIT) { + scp_ipi_handler(scp); + + /* + * SCP won't send another interrupt until we clear + * MT8195_SSHUB2APMCU_IPC_CLR. + */ + writel(MT8192_SCP_IPC_INT_BIT, + scp->reg_base + MT8195_SSHUB2APMCU_IPC_CLR); + } +} + +static void mt8195_scp_dual_reset_assert(struct mtk_scp *scp) +{ + writel(1, scp->reg_base + MT8195_CORE1_SW_RSTN_SET); +} + +static void mt8195_scp_dual_reset_deassert(struct mtk_scp *scp) +{ + writel(1, scp->reg_base + MT8195_CORE1_SW_RSTN_CLR); +} + +static void *mt8195_scp_dual_da_to_va(struct mtk_scp *scp, u64 da, size_t len) +{ + int offset; + + if (da >= scp->sram_phys && + (da + len) <= scp->sram_phys + scp->sram_size) { + offset = da - scp->sram_phys; + return (void __force *)scp->sram_base + offset; + } + + /* optional memory region */ + if (scp->l1tcm_size && + da >= scp->l1tcm_phys && + (da + len) <= scp->l1tcm_phys + scp->l1tcm_size) { + offset = da - scp->l1tcm_phys; + return (void __force *)scp->l1tcm_base + offset; + } + + /* optional memory region */ + if (scp->dram_size && + da >= scp->dma_addr && + (da + len) <= scp->dma_addr + scp->dram_size) { + offset = da - scp->dma_addr; + return scp->cpu_addr + offset; + } + + return NULL; +} + +static void mt8195_scp_dual_stop(struct mtk_scp *scp) +{ + /* Power off CPU SRAM */ + mt8195_power_off_sram(scp->reg_base + MT8195_CPU1_SRAM_PD); + + /* Disable SCP watchdog */ + writel(0, scp->reg_base + MT8195_CORE1_WDT_CFG); +} + +static int mt8195_scp_dual_clk_get(struct mtk_scp *scp) +{ + scp->clk = NULL; + + return 0; +} + +static const struct mtk_scp_of_data mt8195_scp_dual_of_data = { + .scp_clk_get = mt8195_scp_dual_clk_get, + .scp_before_load = mt8195_scp_dual_before_load, + .scp_irq_handler = mt8195_scp_dual_irq_handler, + .scp_reset_assert = mt8195_scp_dual_reset_assert, + .scp_reset_deassert = mt8195_scp_dual_reset_deassert, + .scp_stop = mt8195_scp_dual_stop, + .scp_da_to_va = mt8195_scp_dual_da_to_va, + .host_to_scp_reg = MT8192_GIPC_IN_SET, + .host_to_scp_int_bit = MT8195_HOST_IPC_INT_BIT, +}; + static const struct rproc_ops scp_ops = { .start = scp_start, .stop = scp_stop, @@ -53,6 +171,7 @@ static int scp_dual_probe(struct platform_device *pdev) scp = (struct mtk_scp *)rproc->priv; scp->rproc = rproc; scp->dev = dev; + scp->data = of_device_get_match_data(dev); platform_set_drvdata(pdev, scp); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sram"); @@ -125,7 +244,7 @@ static int scp_dual_remove(struct platform_device *pdev) } static const struct of_device_id mtk_scp_dual_of_match[] = { - { .compatible = "mediatek,mt8195-scp-dual" }, + { .compatible = "mediatek,mt8195-scp-dual", .data = &mt8195_scp_dual_of_data }, {}, }; MODULE_DEVICE_TABLE(of, mtk_scp_dual_of_match); From patchwork Wed Jun 1 11:21:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 12866833 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E5012C433EF for ; Wed, 1 Jun 2022 11:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=e8M/ZUPaLvIFBaNsU5iy0TFRUxi/d9UUIrlIYPkXzZI=; b=HBcYXhqGeOVKmY 68O1MK1zZAgnafZaLJriH5oRPXzVxPrfnwvvjBlDWA8bhs69Bkv3izXPguU0kbPem1RdwHv0B/Pqy ++D8ZHDqMqM6YBZF3bv6KPLOyYzIXWMa4df/aX7FwlO+Aikg44POYNvlTR/1qKcDJsvw8M6d/lOwD JTemVVTs6cC/oK8Zeb55I6TvAIP7TfzoAOMo32SMn3sm8TED7f9reXxB6bj076+JXkos9tpr/ei2t G+0xbTcZn08OvJwt/X3pvKf7zXRRiMX1/EEpjJGuwA31iRT7V0GwsZJ24GVMVEt7tKsO/mFCfgOVE Yy5q5e1n8z17TKyCl2ug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMag-00FdMz-Ve; Wed, 01 Jun 2022 11:32:42 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMaD-00FdCk-5A; Wed, 01 Jun 2022 11:32:14 +0000 X-UUID: 214625d9f3d347f39cae5c9295652e00-20220601 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:2d4bcb23-1d00-471d-8415-ac27da506f14,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:2a19b09,CLOUDID:3cd9268a-32d7-4fc0-b2ef-8776ac194f8f,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:0,BEC:nil X-UUID: 214625d9f3d347f39cae5c9295652e00-20220601 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1889018043; Wed, 01 Jun 2022 04:32:08 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 1 Jun 2022 04:22:09 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; 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 11/15] remoteproc: mediatek: Add SCP core 1 SRAM offset Date: Wed, 1 Jun 2022 19:21:57 +0800 Message-ID: <20220601112201.15510-12-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_043213_242100_7735D78D X-CRM114-Status: GOOD ( 19.02 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Because SCP core 0 and core 1 both boot from address 0 and have the same viewpoint of memory, HW has a set of registers, "SRAM offset", to add offset to accessed address for SCP core 1 to solve this problem. The "SRAM offset" configuration is composed by specifying a range and an offset. The value of range is from the viewpoint of SCP core 1. When SCP core 1 accessing addresses in the configured range, SCP bus adds an offset to shift the destination on SCP SRAM. This shift is transparent to the software running on SCP core 1. Signed-off-by: Tinghan Shen --- drivers/remoteproc/mtk_scp_dual.c | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/remoteproc/mtk_scp_dual.c b/drivers/remoteproc/mtk_scp_dual.c index 16cf9d2628c8..4e8d7f5cdad6 100644 --- a/drivers/remoteproc/mtk_scp_dual.c +++ b/drivers/remoteproc/mtk_scp_dual.c @@ -33,6 +33,27 @@ static void mt8195_power_off_sram(void __iomem *addr) static int mt8195_scp_dual_before_load(struct mtk_scp *scp) { u32 sec_ctrl; + struct device *dev = scp->dev; + struct device_node *main_np; + struct platform_device *main_pdev; + struct mtk_scp *scp_core0; + + /* Get sram start address from SCP core 0 */ + main_np = of_parse_phandle(dev->of_node, "mediatek,scp-core", 1); + if (!main_np) { + dev_warn(dev, "Invalid SCP main core phandle\n"); + return -EINVAL; + } + + main_pdev = of_find_device_by_node(main_np); + of_node_put(main_np); + + if (!main_pdev) { + dev_err(dev, "Cannot find SCP core 0 device\n"); + return -ENODEV; + } + scp_core0 = platform_get_drvdata(main_pdev); + put_device(&main_pdev->dev); mt8195_power_on_sram(scp->reg_base + MT8195_CPU1_SRAM_PD); @@ -42,6 +63,27 @@ static int mt8195_scp_dual_before_load(struct mtk_scp *scp) /* enable MPU for all memory regions */ writel(0xff, scp->reg_base + MT8195_CORE1_MEM_ATT_PREDEF); + /* The value of SRAM offset range is from the viewpoint of SCP core 1. + * This configuration adds an offset on SCP bus when SCP core 1 accesses SCP SRAM + * to solve the SCP core 0 and core 1 both fetch the 1st instruction from the same + * SRAM address. + * + * Because SCP core 0 and core 1 both boot from address 0, this must be configured + * before boot SCP core 1. + * + * Configure the range of SRAM addresses will be added offset. + */ + writel(0, scp->reg_base + MT8195_L2TCM_OFFSET_RANGE_0_LOW); + writel(scp->sram_size, scp->reg_base + MT8195_L2TCM_OFFSET_RANGE_0_HIGH); + + /* configure the offset value */ + writel(scp->sram_phys - scp_core0->sram_phys, scp->reg_base + MT8195_L2TCM_OFFSET); + + /* enable adding sram offset when fetching instruction and data */ + sec_ctrl = readl(scp->reg_base + MT8195_SEC_CTRL); + sec_ctrl |= MT8195_CORE_OFFSET_ENABLE_I | MT8195_CORE_OFFSET_ENABLE_D; + writel(sec_ctrl, scp->reg_base + MT8195_SEC_CTRL); + return 0; } From patchwork Wed Jun 1 11:21:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 12866835 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9DF8CC433F5 for ; Wed, 1 Jun 2022 11:33:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=B4U2yVirZlPUY4JSnDa9/g9eGeYV+d8Th1oxF5s9EPo=; b=ZPxoe68CvNz9/h LxR4inyiq5aozvWy5g739tGOuDUGuzKVlrgXA0CiOlMsglg7bKqzXq7hBDB8Y+Lf/9wRak/BO93LC 5PLXIBx078AMP+cqFpZj2H+vTufmINlZR9BixQykKhrHByU8ylG0t7itWfNBLVq0K7aFUBIJL4wac ehwRyuSdOhLjYSb+uCSo80XPb4FdrkHM15r2iD4U8kQBiQ5i6AgrHG9R0ZA41N123FQ+Jn8m78C59 SRT/kDCa1EjI3BiXJ3RDaFKc+C8v91WZUIh0PtahWBFMqd9HEcMPltURapGqMWO7P229CMrD+PU/q QbYAPXmV8iZRM0IxoZfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMbY-00Fdqf-LM; Wed, 01 Jun 2022 11:33:36 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMaE-00FdCB-Gd; Wed, 01 Jun 2022 11:32:16 +0000 X-UUID: 5d8642c37fd94775821333b786cbbe00-20220601 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:c3512885-2682-4038-944e-847a7ac2d61d,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:2a19b09,CLOUDID:9eac8f14-f88c-475e-badf-d9ee54230b8f,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:0,BEC:nil X-UUID: 5d8642c37fd94775821333b786cbbe00-20220601 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 653609552; Wed, 01 Jun 2022 04:32:08 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 1 Jun 2022 04:22:10 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Wed, 1 Jun 2022 19:22:06 +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:06 +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 12/15] remoteproc: mediatek: Add SCP core 1 as a rproc subdevice Date: Wed, 1 Jun 2022 19:21:58 +0800 Message-ID: <20220601112201.15510-13-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_043214_587366_0BD4F126 X-CRM114-Status: GOOD ( 23.94 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Because the clock and SRAM power is controlled by SCP core 0, SCP core 1 has to be boot after SCP core 0. We use the rproc subdev to achieve this purpose. The watchdog timeout handler of SCP core 1 is added as part of the rproc subdevice. This allows SCP core 0 to handle watchdog timeout coming from SCP core 1. Signed-off-by: Tinghan Shen --- drivers/remoteproc/Makefile | 2 +- drivers/remoteproc/mtk_common.h | 12 +++ drivers/remoteproc/mtk_scp.c | 32 +++++++ drivers/remoteproc/mtk_scp_dual.c | 8 ++ drivers/remoteproc/mtk_scp_subdev.c | 130 ++++++++++++++++++++++++++++ 5 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 drivers/remoteproc/mtk_scp_subdev.c diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile index 84cb687d28da..97f729f7c4ae 100644 --- a/drivers/remoteproc/Makefile +++ b/drivers/remoteproc/Makefile @@ -15,7 +15,7 @@ obj-$(CONFIG_IMX_REMOTEPROC) += imx_rproc.o obj-$(CONFIG_IMX_DSP_REMOTEPROC) += imx_dsp_rproc.o obj-$(CONFIG_INGENIC_VPU_RPROC) += ingenic_rproc.o obj-$(CONFIG_MTK_SCP) += mtk_scp.o mtk_scp_ipi.o -obj-$(CONFIG_MTK_SCP_DUALCORE) += mtk_scp_dual.o +obj-$(CONFIG_MTK_SCP_DUALCORE) += mtk_scp_dual.o mtk_scp_subdev.o obj-$(CONFIG_OMAP_REMOTEPROC) += omap_remoteproc.o obj-$(CONFIG_WKUP_M3_RPROC) += wkup_m3_rproc.o obj-$(CONFIG_DA8XX_REMOTEPROC) += da8xx_remoteproc.o diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h index 7b363411ec99..a5c26e56277d 100644 --- a/drivers/remoteproc/mtk_common.h +++ b/drivers/remoteproc/mtk_common.h @@ -99,6 +99,14 @@ struct scp_ipi_desc { void *priv; }; +struct scp_subdev_core { + struct rproc_subdev subdev; + struct mtk_scp *main_scp; + void (*scp_dual_wdt_timeout)(struct mtk_scp *scp, u32 scp_to_host); +}; + +#define to_subdev_core(d) container_of(d, struct scp_subdev_core, subdev) + struct mtk_scp; struct mtk_scp_of_data { @@ -144,6 +152,7 @@ struct mtk_scp { size_t dram_size; struct rproc_subdev *rpmsg_subdev; + struct rproc_subdev *dual_subdev; }; /** @@ -172,4 +181,7 @@ int scp_map_memory_region(struct mtk_scp *scp); void scp_unmap_memory_region(struct mtk_scp *scp); irqreturn_t scp_irq_handler(int irq, void *priv); void scp_ipi_handler(struct mtk_scp *scp); + +struct rproc_subdev *scp_dual_create_subdev(struct mtk_scp *scp); +void scp_dual_destroy_subdev(struct rproc_subdev *subdev); #endif diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index 55bc4e9d1a6f..c7bf0a44ba0d 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -231,6 +231,13 @@ static void mt8195_scp_irq_handler(struct mtk_scp *scp) } else { if (readl(scp->reg_base + MT8195_SYS_STATUS) & MT8195_CORE1_WDT) { writel(1, scp->reg_base + MT8195_CORE1_WDT_IRQ); + + if (scp->dual_subdev) { + struct scp_subdev_core *subdev_core; + + subdev_core = to_subdev_core(scp->dual_subdev); + subdev_core->scp_dual_wdt_timeout(scp, scp_to_host); + } } else { writel(1, scp->reg_base + MT8192_CORE0_WDT_IRQ); scp_wdt_handler(scp, scp_to_host); @@ -836,6 +843,27 @@ static void scp_remove_rpmsg_subdev(struct mtk_scp *scp) } } +static void scp_add_dual_subdev(struct mtk_scp *scp) +{ +#if IS_ENABLED(CONFIG_MTK_SCP_DUALCORE) + scp->dual_subdev = scp_dual_create_subdev(scp); + + if (scp->dual_subdev) + rproc_add_subdev(scp->rproc, scp->dual_subdev); +#endif +} + +static void scp_remove_dual_subdev(struct mtk_scp *scp) +{ +#if IS_ENABLED(CONFIG_MTK_SCP_DUALCORE) + if (scp->dual_subdev) { + rproc_remove_subdev(scp->rproc, scp->dual_subdev); + scp_dual_destroy_subdev(scp->dual_subdev); + scp->dual_subdev = NULL; + } +#endif +} + static int scp_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -911,6 +939,8 @@ static int scp_probe(struct platform_device *pdev) scp_add_rpmsg_subdev(scp); + scp_add_dual_subdev(scp); + ret = devm_request_threaded_irq(dev, platform_get_irq(pdev, 0), NULL, scp_irq_handler, IRQF_ONESHOT, pdev->name, scp); @@ -927,6 +957,7 @@ static int scp_probe(struct platform_device *pdev) return 0; remove_subdev: + scp_remove_dual_subdev(scp); scp_remove_rpmsg_subdev(scp); scp_ipi_unregister(scp, SCP_IPI_INIT); release_dev_mem: @@ -944,6 +975,7 @@ static int scp_remove(struct platform_device *pdev) int i; rproc_del(scp->rproc); + scp_remove_dual_subdev(scp); scp_remove_rpmsg_subdev(scp); scp_ipi_unregister(scp, SCP_IPI_INIT); scp_unmap_memory_region(scp); diff --git a/drivers/remoteproc/mtk_scp_dual.c b/drivers/remoteproc/mtk_scp_dual.c index 4e8d7f5cdad6..90c49716dd39 100644 --- a/drivers/remoteproc/mtk_scp_dual.c +++ b/drivers/remoteproc/mtk_scp_dual.c @@ -258,6 +258,14 @@ static int scp_dual_probe(struct platform_device *pdev) goto remove_ipi; } + /* disable auto boot before register rproc. + * it's booted as a subdevice of scp core 0. + */ + rproc->auto_boot = false; + ret = devm_rproc_add(dev, rproc); + if (ret) + goto remove_ipi; + return 0; remove_ipi: diff --git a/drivers/remoteproc/mtk_scp_subdev.c b/drivers/remoteproc/mtk_scp_subdev.c new file mode 100644 index 000000000000..197fb207c756 --- /dev/null +++ b/drivers/remoteproc/mtk_scp_subdev.c @@ -0,0 +1,130 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (c) 2022 MediaTek Inc. + +#include +#include +#include +#include +#include +#include + +#include "mtk_common.h" + +#define SCP_MAIN_CORE 0 +#define SCP_DTS_CORE_ID 0 +#define SCP_DTS_CORE_REF 1 + +static struct mtk_scp *scp_dual_get(struct mtk_scp *scp) +{ + struct device *dev = scp->dev; + struct device_node *np; + struct platform_device *dual_pdev; + + np = of_parse_phandle(dev->of_node, "mediatek,scp-core", SCP_DTS_CORE_REF); + dual_pdev = of_find_device_by_node(np); + of_node_put(np); + + if (!dual_pdev) { + dev_err(dev, "No scp-dual pdev\n"); + return NULL; + } + + return platform_get_drvdata(dual_pdev); +} + +static void scp_dual_put(struct mtk_scp *scp) +{ + put_device(scp->dev); +} + +static int scp_dual_rproc_start(struct rproc_subdev *subdev) +{ + struct scp_subdev_core *subdev_core = to_subdev_core(subdev); + struct mtk_scp *scp_dual; + + scp_dual = scp_dual_get(subdev_core->main_scp); + if (!scp_dual) + return -ENODEV; + + rproc_boot(scp_dual->rproc); + scp_dual_put(scp_dual); + + return 0; +} + +static void scp_dual_rproc_stop(struct rproc_subdev *subdev, bool crashed) +{ + struct scp_subdev_core *subdev_core = to_subdev_core(subdev); + struct mtk_scp *scp_dual; + + scp_dual = scp_dual_get(subdev_core->main_scp); + if (!scp_dual) + return; + + rproc_shutdown(scp_dual->rproc); + scp_dual_put(scp_dual); +} + +static void scp_dual_wdt_handler(struct mtk_scp *scp, u32 scp_to_host) +{ + struct mtk_scp *scp_dual; + + scp_dual = scp_dual_get(scp); + if (!scp_dual) + return; + + dev_err(scp_dual->dev, "SCP watchdog timeout! 0x%x\n", scp_to_host); + rproc_report_crash(scp_dual->rproc, RPROC_WATCHDOG); + scp_dual_put(scp_dual); +} + +struct rproc_subdev *scp_dual_create_subdev(struct mtk_scp *scp) +{ + struct device *dev = scp->dev; + struct scp_subdev_core *subdev_core; + struct device_node *np; + int ret, core_id; + + ret = of_property_read_u32_index(dev->of_node, "mediatek,scp-core", SCP_DTS_CORE_ID, + &core_id); + if (ret < 0) { + dev_warn(dev, "No SCP core id\n"); + return NULL; + } + + if (core_id != SCP_MAIN_CORE) { + dev_dbg(dev, "SCP core id %d\n", core_id); + return NULL; + } + + np = of_parse_phandle(dev->of_node, "mediatek,scp-core", SCP_DTS_CORE_REF); + if (!np) { + dev_err(dev, "Invalid mediatek,scp-core phandle\n"); + return NULL; + } + of_node_put(np); + + subdev_core = devm_kzalloc(dev, sizeof(*subdev_core), GFP_KERNEL); + if (!subdev_core) + return NULL; + + subdev_core->main_scp = scp; + subdev_core->scp_dual_wdt_timeout = scp_dual_wdt_handler; + subdev_core->subdev.start = scp_dual_rproc_start; + subdev_core->subdev.stop = scp_dual_rproc_stop; + + return &subdev_core->subdev; +} +EXPORT_SYMBOL_GPL(scp_dual_create_subdev); + +void scp_dual_destroy_subdev(struct rproc_subdev *subdev) +{ + struct scp_subdev_core *subdev_core = to_subdev_core(subdev); + + devm_kfree(subdev_core->main_scp->dev, subdev_core); +} +EXPORT_SYMBOL_GPL(scp_dual_destroy_subdev); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("MediaTek scp dual core subdev interface"); From patchwork Wed Jun 1 11:21:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 12866840 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A18AC433F5 for ; Wed, 1 Jun 2022 11:35:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dYnz9U7djP18qDa3IhFP0qcgiRReiAt3uvRt8/eEPcE=; b=im7X2P2t7+/a+G PO8IY2NxzH3owOEqEuiFov6quRmD369vzVq1Rsx8419a86Ipi+xAbIurC2FbCtgwTBybT23aweicl Uo6mqUf959kfbQmWEFlJBtc9U9O4uFjy0OdVpl1nKwXCH5ZWlQnUdojRRiL5OmZgRXswapxAy6M4m 2eFyoKiBgaieFFu1NLYkGys1BoUX66GrouDnYPezzXVzPY1SAuBk/VG008MAGXfHaRh0M64D2wqjN UlEUh6aSBSu/+IzMBa92X+oNX8KokhoS38KNy3vuaECpwrvXDmU7f5//+ssi9v4Sw5UgYtvVBWhB1 bKOEWWA/7ISb5H4F2B0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMdJ-00Feyz-SS; Wed, 01 Jun 2022 11:35:25 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMaJ-00FdEG-2k; Wed, 01 Jun 2022 11:32:22 +0000 X-UUID: ebecae47bf8b4092b833e6f2000b693a-20220601 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:2abdf3df-8d97-4b3b-b2e4-d768dc36e4c6,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:2a19b09,CLOUDID:68d9268a-32d7-4fc0-b2ef-8776ac194f8f,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:0,BEC:nil X-UUID: ebecae47bf8b4092b833e6f2000b693a-20220601 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 160539161; Wed, 01 Jun 2022 04:32:09 -0700 Received: from mtkmbs10n1.mediatek.inc (172.21.101.34) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 1 Jun 2022 04:22:08 -0700 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:06 +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:06 +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 13/15] remoteproc: mediatek: Wait SCP core 1 probe done Date: Wed, 1 Jun 2022 19:21:59 +0800 Message-ID: <20220601112201.15510-14-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_043219_261929_547F9546 X-CRM114-Status: GOOD ( 17.50 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org SCP core 1 driver probing must finish before start loading SCP core 1 image. Add a simple flag checking mechanism when preparing SCP core 1 subdevice. Signed-off-by: Tinghan Shen --- drivers/remoteproc/mtk_common.h | 1 + drivers/remoteproc/mtk_scp_dual.c | 2 ++ drivers/remoteproc/mtk_scp_subdev.c | 35 ++++++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h index a5c26e56277d..464d013ed6b2 100644 --- a/drivers/remoteproc/mtk_common.h +++ b/drivers/remoteproc/mtk_common.h @@ -153,6 +153,7 @@ struct mtk_scp { struct rproc_subdev *rpmsg_subdev; struct rproc_subdev *dual_subdev; + int dual_probe_done; }; /** diff --git a/drivers/remoteproc/mtk_scp_dual.c b/drivers/remoteproc/mtk_scp_dual.c index 90c49716dd39..ab62ab54175c 100644 --- a/drivers/remoteproc/mtk_scp_dual.c +++ b/drivers/remoteproc/mtk_scp_dual.c @@ -266,6 +266,8 @@ static int scp_dual_probe(struct platform_device *pdev) if (ret) goto remove_ipi; + scp->dual_probe_done = 1; + return 0; remove_ipi: diff --git a/drivers/remoteproc/mtk_scp_subdev.c b/drivers/remoteproc/mtk_scp_subdev.c index 197fb207c756..71dc6fcad61a 100644 --- a/drivers/remoteproc/mtk_scp_subdev.c +++ b/drivers/remoteproc/mtk_scp_subdev.c @@ -20,6 +20,7 @@ static struct mtk_scp *scp_dual_get(struct mtk_scp *scp) struct device *dev = scp->dev; struct device_node *np; struct platform_device *dual_pdev; + struct mtk_scp *scp_dual; np = of_parse_phandle(dev->of_node, "mediatek,scp-core", SCP_DTS_CORE_REF); dual_pdev = of_find_device_by_node(np); @@ -30,7 +31,11 @@ static struct mtk_scp *scp_dual_get(struct mtk_scp *scp) return NULL; } - return platform_get_drvdata(dual_pdev); + scp_dual = platform_get_drvdata(dual_pdev); + if (!scp_dual) + put_device(&dual_pdev->dev); + + return scp_dual; } static void scp_dual_put(struct mtk_scp *scp) @@ -38,6 +43,33 @@ static void scp_dual_put(struct mtk_scp *scp) put_device(scp->dev); } +static int scp_dual_rproc_prepare(struct rproc_subdev *subdev) +{ + struct scp_subdev_core *subdev_core = to_subdev_core(subdev); + struct mtk_scp *scp = subdev_core->main_scp; + unsigned long timeout; + + timeout = jiffies + msecs_to_jiffies(100); + while (1) { + struct mtk_scp *scp_dual = scp_dual_get(scp); + + if (scp_dual && scp_dual->dual_probe_done) { + scp_dual_put(scp_dual); + break; + } + + if (scp_dual && !scp_dual->dual_probe_done) + scp_dual_put(scp_dual); + + if (time_after(jiffies, timeout)) { + dev_err(scp->dev, "scp-dual probe timeout\n"); + return -ETIMEDOUT; + } + } + + return 0; +} + static int scp_dual_rproc_start(struct rproc_subdev *subdev) { struct scp_subdev_core *subdev_core = to_subdev_core(subdev); @@ -111,6 +143,7 @@ struct rproc_subdev *scp_dual_create_subdev(struct mtk_scp *scp) subdev_core->main_scp = scp; subdev_core->scp_dual_wdt_timeout = scp_dual_wdt_handler; + subdev_core->subdev.prepare = scp_dual_rproc_prepare; subdev_core->subdev.start = scp_dual_rproc_start; subdev_core->subdev.stop = scp_dual_rproc_stop; From patchwork Wed Jun 1 11:22:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 12866831 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4AB39C433EF for ; Wed, 1 Jun 2022 11:32:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=D+FjpHUioM7H8TSuKIVpl4wGWN+Ru2wL2Qkcxt0wgoc=; b=osnV2uQHErvCHL p0ftzVWq8LaW2ea4Y+85qebNcjk74/RmP1bRsQvdbaSd8zibVJpLIoT66Yw1FEdhrdHE++Y3Crogn MoOTF3AQ3ZqEAV53Py0BFuMKwvnev0OUGX3Roqk5puP5xU+T472NLxCrp5EyaaV934gPOK4uummNp zkMOv+lpnWBdnpXwS92KSUujO0M9VHEfDuuKtLo+rUY8Tdf/mwk9m9JN3q8dpMjoVznNl5+xKlMZg Fi+i+iAUnRNZmkZgamUB6c2hFgClFkUtRk8Uzfo5AdA7Nxhud4eoE5LZmpC9QOjrP4+gf6mU1c98+ N0UFF8ZgzVYoCezxMkkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMaX-00FdKM-SU; Wed, 01 Jun 2022 11:32:33 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMaD-00FdCB-3C; Wed, 01 Jun 2022 11:32:14 +0000 X-UUID: f6d62664d4ae476f89254e58b43d6185-20220601 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:48c3a6a7-c923-414e-8dc4-3212ccd43837,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:2a19b09,CLOUDID:98ac8f14-f88c-475e-badf-d9ee54230b8f,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:0,BEC:nil X-UUID: f6d62664d4ae476f89254e58b43d6185-20220601 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 2106799525; Wed, 01 Jun 2022 04:32:08 -0700 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 1 Jun 2022 04:22:08 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Wed, 1 Jun 2022 19:22:06 +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:06 +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 14/15] remoteproc: mediatek: Support rpmsg for SCP core 1 Date: Wed, 1 Jun 2022 19:22:00 +0800 Message-ID: <20220601112201.15510-15-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_043213_158425_1CC4167A X-CRM114-Status: GOOD ( 15.19 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Reuse the rpmsg subdevice flow of SCP core 0 on SCP core 1. Signed-off-by: Tinghan Shen --- drivers/remoteproc/mtk_common.h | 3 +++ drivers/remoteproc/mtk_scp.c | 6 ++++-- drivers/remoteproc/mtk_scp_dual.c | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h index 464d013ed6b2..89e2bec0a087 100644 --- a/drivers/remoteproc/mtk_common.h +++ b/drivers/remoteproc/mtk_common.h @@ -185,4 +185,7 @@ void scp_ipi_handler(struct mtk_scp *scp); struct rproc_subdev *scp_dual_create_subdev(struct mtk_scp *scp); void scp_dual_destroy_subdev(struct rproc_subdev *subdev); + +void scp_add_rpmsg_subdev(struct mtk_scp *scp); +void scp_remove_rpmsg_subdev(struct mtk_scp *scp); #endif diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index c7bf0a44ba0d..fbeaa81e914d 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -825,7 +825,7 @@ static struct mtk_rpmsg_info mtk_scp_rpmsg_info = { .ns_ipi_id = SCP_IPI_NS_SERVICE, }; -static void scp_add_rpmsg_subdev(struct mtk_scp *scp) +void scp_add_rpmsg_subdev(struct mtk_scp *scp) { scp->rpmsg_subdev = mtk_rpmsg_create_rproc_subdev(to_platform_device(scp->dev), @@ -833,8 +833,9 @@ static void scp_add_rpmsg_subdev(struct mtk_scp *scp) if (scp->rpmsg_subdev) rproc_add_subdev(scp->rproc, scp->rpmsg_subdev); } +EXPORT_SYMBOL_GPL(scp_add_rpmsg_subdev); -static void scp_remove_rpmsg_subdev(struct mtk_scp *scp) +void scp_remove_rpmsg_subdev(struct mtk_scp *scp) { if (scp->rpmsg_subdev) { rproc_remove_subdev(scp->rproc, scp->rpmsg_subdev); @@ -842,6 +843,7 @@ static void scp_remove_rpmsg_subdev(struct mtk_scp *scp) scp->rpmsg_subdev = NULL; } } +EXPORT_SYMBOL_GPL(scp_remove_rpmsg_subdev); static void scp_add_dual_subdev(struct mtk_scp *scp) { diff --git a/drivers/remoteproc/mtk_scp_dual.c b/drivers/remoteproc/mtk_scp_dual.c index ab62ab54175c..caa57516e083 100644 --- a/drivers/remoteproc/mtk_scp_dual.c +++ b/drivers/remoteproc/mtk_scp_dual.c @@ -249,6 +249,8 @@ static int scp_dual_probe(struct platform_device *pdev) init_waitqueue_head(&scp->run.wq); init_waitqueue_head(&scp->ack_wq); + scp_add_rpmsg_subdev(scp); + ret = devm_request_threaded_irq(dev, platform_get_irq(pdev, 0), NULL, scp_irq_handler, IRQF_ONESHOT, pdev->name, scp); @@ -271,6 +273,7 @@ static int scp_dual_probe(struct platform_device *pdev) return 0; remove_ipi: + scp_remove_rpmsg_subdev(scp); scp_ipi_unregister(scp, SCP_IPI_INIT); release_dev_mem: scp_unmap_memory_region(scp); @@ -286,6 +289,7 @@ static int scp_dual_remove(struct platform_device *pdev) struct mtk_scp *scp = platform_get_drvdata(pdev); int i; + scp_remove_rpmsg_subdev(scp); scp_ipi_unregister(scp, SCP_IPI_INIT); scp_unmap_memory_region(scp); for (i = 0; i < SCP_IPI_MAX; i++) From patchwork Wed Jun 1 11:22:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 12866836 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3DEB2C433F5 for ; Wed, 1 Jun 2022 11:34:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jzyK1yHqJxG84wIrGFZIhEqRjq4q0xU718rsBc0v2G8=; b=br1jSiRF65Fic8 EbREQCkxFsPUTtUcfSI1816iGdRu0atoZs0MU96Qa59Wqr7+mGeyHlExihFfSy8WakO7uwtbRRklJ o6wb+LHB4IUjGeHvBQo0kOXm/2Z22pGXLnX8uCwBa949inLVHTOST0KOaYTCbpWdrXDNQbmpFaTeP XuYZX5HpFqwKh9ZgrIk95JnE63fdHqmy4DaVSF9mTCNQoU7o/HOgiUVtGzLHBYfgqfVzxslnGNwrx 5J1mfbMTaR3ee5jtALcSR8DQextmuAmZHGECXdxBy5TInVR5A5lq3e9i0BwVLc+NzIO8KMYXZDG0S VHdgHyjzs7qlfvyHLPWQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMbu-00Fe6O-HQ; Wed, 01 Jun 2022 11:33:58 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwMaJ-00FdEx-2g; Wed, 01 Jun 2022 11:32:20 +0000 X-UUID: ebc538c82c124223bfed3000c7281501-20220601 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.5,REQID:d4d9192c-f3d2-4282-a2ab-15e252c00f7c,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:2a19b09,CLOUDID:67d9268a-32d7-4fc0-b2ef-8776ac194f8f,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:0,BEC:nil X-UUID: ebc538c82c124223bfed3000c7281501-20220601 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 113539524; Wed, 01 Jun 2022 04:32:09 -0700 Received: from mtkmbs10n1.mediatek.inc (172.21.101.34) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 1 Jun 2022 04:22:09 -0700 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:06 +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:06 +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 15/15] mfd: cros_ec: Add SCP core 1 as a new CrOS EC MCU Date: Wed, 1 Jun 2022 19:22:01 +0800 Message-ID: <20220601112201.15510-16-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220601_043219_246045_6A195335 X-CRM114-Status: GOOD ( 14.13 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org MT8195 System Companion Processors(SCP) is a dual-core RISC-V MCU. Add a new cros feature id to represent the SCP 2nd core. The 1st core is referred to as 'core 0', and the 2nd core is referred to as 'core 1'. Signed-off-by: Tinghan Shen --- drivers/mfd/cros_ec_dev.c | 5 +++++ include/linux/platform_data/cros_ec_commands.h | 2 ++ include/linux/platform_data/cros_ec_proto.h | 1 + 3 files changed, 8 insertions(+) diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index 596731caf407..07cc31d92edc 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c @@ -64,6 +64,11 @@ static const struct cros_feature_to_name cros_mcu_devices[] = { .name = CROS_EC_DEV_SCP_NAME, .desc = "System Control Processor", }, + { + .id = EC_FEATURE_SCP_C1, + .name = CROS_EC_DEV_SCP_C1_NAME, + .desc = "System Control Processor 2nd Core", + }, { .id = EC_FEATURE_TOUCHPAD, .name = CROS_EC_DEV_TP_NAME, diff --git a/include/linux/platform_data/cros_ec_commands.h b/include/linux/platform_data/cros_ec_commands.h index 8cfa8cfca77e..9fbf1c5eb8d3 100644 --- a/include/linux/platform_data/cros_ec_commands.h +++ b/include/linux/platform_data/cros_ec_commands.h @@ -1300,6 +1300,8 @@ enum ec_feature_code { * mux. */ EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK = 43, + /* The MCU is a System Companion Processor (SCP) 2nd Core. */ + EC_FEATURE_SCP_C1 = 45, }; #define EC_FEATURE_MASK_0(event_code) BIT(event_code % 32) diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h index 138fd912c808..da06dc7cf1cb 100644 --- a/include/linux/platform_data/cros_ec_proto.h +++ b/include/linux/platform_data/cros_ec_proto.h @@ -19,6 +19,7 @@ #define CROS_EC_DEV_ISH_NAME "cros_ish" #define CROS_EC_DEV_PD_NAME "cros_pd" #define CROS_EC_DEV_SCP_NAME "cros_scp" +#define CROS_EC_DEV_SCP_C1_NAME "cros_scp_c1" #define CROS_EC_DEV_TP_NAME "cros_tp" /*