From patchwork Wed Feb 15 04:12:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 57356 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3359083wrn; Tue, 14 Feb 2023 20:15:11 -0800 (PST) X-Google-Smtp-Source: AK7set/Z5+cNKAc5U/iJybSC6NubvD8G8Ug/V1kL/HsH68841sBKdww9cnkTdWBSsp/o1zLO2yW3 X-Received: by 2002:a17:907:98e6:b0:88b:109e:fbd3 with SMTP id ke6-20020a17090798e600b0088b109efbd3mr813330ejc.24.1676434511423; Tue, 14 Feb 2023 20:15:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676434511; cv=none; d=google.com; s=arc-20160816; b=wlF9DuOTz8MbI4dmHX4v2Ax6JNLTSLHrP66yDON2VUDwiav+6/vHGZVYsTmuzZAb8o WwhUV+fW7C+nBW0NcCvTAvtfdaU3PCM9wVDpDt7Kw3xc9pQ0zacGqdzI5v5q55qJ0ttX Va5P5Oz5ITWOcxMXDui4YuHvhfrXYDCoVhNTOnnnevE3cczIDJl6A1mPPuWWrSuDdxOH Pa3yn4aEQ6lID0ycRtd2OoVN6+ROCQ7j0onCWKSfsedsIk+2QW/U2LLGMsxRgexKkCBn QaKb45Qu3ETk3fVU1OXI7Jyilmz9v7pD5I8e5/+kXaVVE4USn2qAOz5j/w6a1UkBQuK/ gWgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=mzCsW2cWM5Qj34kAnxo7LScswdN78aRPfGLwPzdj4eA=; b=EtiQ8UjRNk02WyE4IkyfuHadSH+fVRa8tXCSyad9r51e2vnoMPi9VtEqnDZKz0ZGpS TvFXTiuO4dgyNJVG2bggrIIdj1ZbHbX6G1sIGzA+2S0bOAEe/aToLLx7NStEeJ3uyjoU HKR9XYZXazsMXz3EUW7+gKnR5b8DSMd8bsAeyIe9jQYCUvkTZ4vpvNC+cAUW5j2/qFrV +HkC7eGw7/Az0qUKHVibtqrRNOOAPQuUGNMmPsmfwUeburv9HgOqPnaGCJCuhUOFhWBI TsjJHkBN3XxKq5EgOWf1NlqR14Jmk4noy3chRJFdfguXcHAVBmcC+MUCKWwj+dFRu3U7 o9gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=YlI5pRLN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d5-20020a50ea85000000b004aaa505ac5fsi22248581edo.76.2023.02.14.20.14.47; Tue, 14 Feb 2023 20:15:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=YlI5pRLN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232979AbjBOEN0 (ORCPT + 99 others); Tue, 14 Feb 2023 23:13:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230489AbjBOENK (ORCPT ); Tue, 14 Feb 2023 23:13:10 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3662A1024E; Tue, 14 Feb 2023 20:13:06 -0800 (PST) X-UUID: 0900e646ace711eda06fc9ecc4dadd91-20230215 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=mzCsW2cWM5Qj34kAnxo7LScswdN78aRPfGLwPzdj4eA=; b=YlI5pRLNnwbhP/rinSRGF/IjaAcoKudPLNlfeCbNcT+07ikFUJkIuaBk1xLsqZzxDZK0kcOo6foAxntSGkSoq80hZ8SjlddCIUkHclOjvKMBXAIRanwW78Sj58FYjfnhaUaa64LHT5s5vFnlBSoJB5vRxdv8c3WPplQaADOTjpM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.19,REQID:4d63087a-0e3e-4b5c-8455-d99a93f5e115,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:885ddb2,CLOUDID:3b7709f3-ddba-41c3-91d9-10eeade8eac7,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-UUID: 0900e646ace711eda06fc9ecc4dadd91-20230215 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1079482391; Wed, 15 Feb 2023 12:13:00 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Wed, 15 Feb 2023 12:12:59 +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.15 via Frontend Transport; Wed, 15 Feb 2023 12:12:59 +0800 From: Tinghan Shen To: Bjorn Andersson , Mathieu Poirier , Rob Herring , Krzysztof Kozlowski , Matthias Brugger , AngeloGioacchino Del Regno , Tinghan Shen CC: , , , , , Subject: [PATCH v7 06/12] remoteproc: mediatek: Extract remoteproc initialization flow Date: Wed, 15 Feb 2023 12:12:51 +0800 Message-ID: <20230215041257.14548-7-tinghan.shen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230215041257.14548-1-tinghan.shen@mediatek.com> References: <20230215041257.14548-1-tinghan.shen@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757868994195064109?= X-GMAIL-MSGID: =?utf-8?q?1757868994195064109?= This is the preparation for probing multi-core SCP. The remoteproc initialization flow is similar on cores and is reuesd to avoid redundant code. The registers of config and l1tcm are shared for multi-core SCP. Reuse the mapped addresses for all cores. Signed-off-by: Tinghan Shen Reviewed-by: AngeloGioacchino Del Regno --- drivers/remoteproc/mtk_scp.c | 62 ++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index b92274067522..6270c388727a 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -23,6 +23,13 @@ #define MAX_CODE_SIZE 0x500000 #define SECTION_NAME_IPI_BUFFER ".ipi_buffer" +struct mtk_scp_of_regs { + void __iomem *reg_base; + void __iomem *l1tcm_base; + size_t l1tcm_size; + phys_addr_t l1tcm_phys; +}; + /** * scp_get() - get a reference to SCP. * @@ -854,7 +861,8 @@ static void scp_remove_rpmsg_subdev(struct mtk_scp *scp) } } -static int scp_probe(struct platform_device *pdev) +static int scp_rproc_init(struct platform_device *pdev, + struct mtk_scp_of_regs *of_regs) { struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; @@ -878,6 +886,11 @@ static int scp_probe(struct platform_device *pdev) scp->data = of_device_get_match_data(dev); platform_set_drvdata(pdev, scp); + scp->reg_base = of_regs->reg_base; + scp->l1tcm_base = of_regs->l1tcm_base; + scp->l1tcm_size = of_regs->l1tcm_size; + scp->l1tcm_phys = of_regs->l1tcm_phys; + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sram"); scp->sram_base = devm_ioremap_resource(dev, res); if (IS_ERR(scp->sram_base)) @@ -887,24 +900,6 @@ static int scp_probe(struct platform_device *pdev) scp->sram_size = resource_size(res); scp->sram_phys = res->start; - /* l1tcm is an optional memory region */ - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "l1tcm"); - scp->l1tcm_base = devm_ioremap_resource(dev, res); - if (IS_ERR(scp->l1tcm_base)) { - ret = PTR_ERR(scp->l1tcm_base); - if (ret != -EINVAL) { - return dev_err_probe(dev, ret, "Failed to map l1tcm memory\n"); - } - } else { - scp->l1tcm_size = resource_size(res); - scp->l1tcm_phys = res->start; - } - - scp->reg_base = devm_platform_ioremap_resource_byname(pdev, "cfg"); - if (IS_ERR(scp->reg_base)) - return dev_err_probe(dev, PTR_ERR(scp->reg_base), - "Failed to parse and map cfg memory\n"); - ret = scp->data->scp_clk_get(scp); if (ret) return ret; @@ -932,7 +927,6 @@ static int scp_probe(struct platform_device *pdev) 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 remove_subdev; @@ -956,6 +950,34 @@ static int scp_probe(struct platform_device *pdev) return ret; } +static int scp_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct resource *res; + struct mtk_scp_of_regs scp_regs; + int ret; + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg"); + scp_regs.reg_base = devm_ioremap_resource(dev, res); + if (IS_ERR(scp_regs.reg_base)) + return dev_err_probe(dev, PTR_ERR(scp_regs.reg_base), + "Failed to parse and map cfg memory\n"); + + /* l1tcm is an optional memory region */ + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "l1tcm"); + scp_regs.l1tcm_base = devm_ioremap_resource(dev, res); + if (IS_ERR(scp_regs.l1tcm_base)) { + ret = PTR_ERR(scp_regs.l1tcm_base); + if (ret != -EINVAL) + return dev_err_probe(dev, ret, "Failed to map l1tcm memory\n"); + } else { + scp_regs.l1tcm_size = resource_size(res); + scp_regs.l1tcm_phys = res->start; + } + + return scp_rproc_init(pdev, &scp_regs); +} + static int scp_remove(struct platform_device *pdev) { struct mtk_scp *scp = platform_get_drvdata(pdev);