From patchwork Thu Feb 9 07:40:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 54791 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp193237wrn; Wed, 8 Feb 2023 23:44:34 -0800 (PST) X-Google-Smtp-Source: AK7set9vFncAX/ufYGWHdL7DwCZIS5Q7mq9oJ3r3VziFqohPlV+kIep3t9JGXACw9T8JTCZuhqoK X-Received: by 2002:a17:906:d156:b0:84d:3403:f4f2 with SMTP id br22-20020a170906d15600b0084d3403f4f2mr10705500ejb.62.1675928674409; Wed, 08 Feb 2023 23:44:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675928674; cv=none; d=google.com; s=arc-20160816; b=bkil9ucDHOPEkCcnwTmNpoVN8AuVYG+pHLP7RBeIsoP1WFFY+1G4TtfskT4wml89BC KmIBlaX04C7K+Gv5sE2sRLAxWRywDz2mUGyLOhQFt4pLWvjxW9FkZNOsUWDh6UIVmf8f 6fDkW6r8KnKP1xGjD7cY7crL1QfECxbzPgJHIlJNiOWBJiiJJNvgPGyG06sIE4sXz2kA iAY5KFhKptvrzqw1vuxAg6XlDzHJOuMxZauE5xgaJtCsHAsoHeB64coagHwyON5+g1wm 8AhIQVW+/J5PgD2vTD6TUpVsiBZaovbqGxTzOlpJ182ZSGwPwxtUzvfSs2WlP/l2wiPz q2fg== 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=xda0JVIXh8C9Mjuim9UwdcizVvNQcJThjFmpczizUw8=; b=JYvMeqwfGTimy3pFLHyznhn2ByHFNl2uhuhAzzdeyfN1RxMO+QjkN56gYxHTQh68DY VpifB2owp10ihyu82jTwCJyaiLqcCPohNdkuGpebK+hF1crWn69lBXH+3u+LXKfFXrcd eFkTW/tipPMELRy2U3yETsSJs9cCpA/PbJCKGjtTs5RJpFlz94LTItUuuULpFOSp3U1z JX73U45M/fjIGsi/Nq70jIoFcPshsovqnZmD0Aqju+OEnnle37ThXn8a7NAaOxxBzZjG 7Ua1hLccFhv8Q2zYmdXWEBuH/05pOdVM4rod9mz3BWckWPYmAwgPDWMS531uTrhoji0n K8RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=BjsXsBwU; 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 ms24-20020a170907621800b0087bd4039179si1591776ejc.92.2023.02.08.23.44.11; Wed, 08 Feb 2023 23:44:34 -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=BjsXsBwU; 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 S230108AbjBIHlr (ORCPT + 99 others); Thu, 9 Feb 2023 02:41:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229960AbjBIHlY (ORCPT ); Thu, 9 Feb 2023 02:41:24 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADE5E442F4; Wed, 8 Feb 2023 23:41:00 -0800 (PST) X-UUID: 12e6bcbaa84d11eda06fc9ecc4dadd91-20230209 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=xda0JVIXh8C9Mjuim9UwdcizVvNQcJThjFmpczizUw8=; b=BjsXsBwUyzi9mmEszCsboI3mLnI9oQRfF9egANU8MiT/rIlLu0gL/XdE9534/YeY9jp2lcfnMUIggRtO5WBnl6T/NprVZ/ZLmyoMUqI6eGjVDKTZhEmlL+PC2UTe9qJbj+hAG+QKp+TGdczMVbglSw7pTYQEFJG8bTqQozdtQe0=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.19,REQID:b569114f-9869-49b6-8191-8d765bfd7011,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:885ddb2,CLOUDID:4955c556-dd49-462e-a4be-2143a3ddc739,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: 12e6bcbaa84d11eda06fc9ecc4dadd91-20230209 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 547922252; Thu, 09 Feb 2023 15:40:50 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) 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; Thu, 9 Feb 2023 15:40:49 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 9 Feb 2023 15:40:49 +0800 From: Tinghan Shen To: Bjorn Andersson , Mathieu Poirier , Rob Herring , "Krzysztof Kozlowski" , Matthias Brugger , AngeloGioacchino Del Regno , Tinghan Shen CC: , , , , , Subject: [PATCH v4 06/12] remoteproc: mediatek: Extract remoteproc initialization flow Date: Thu, 9 Feb 2023 15:40:15 +0800 Message-ID: <20230209074021.13936-7-tinghan.shen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230209074021.13936-1-tinghan.shen@mediatek.com> References: <20230209074021.13936-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?1757338585825130840?= X-GMAIL-MSGID: =?utf-8?q?1757338585825130840?= 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 --- drivers/remoteproc/mtk_common.h | 7 +++++ drivers/remoteproc/mtk_scp.c | 55 +++++++++++++++++++++------------ 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h index 3778894c96f3..20c1a90be77d 100644 --- a/drivers/remoteproc/mtk_common.h +++ b/drivers/remoteproc/mtk_common.h @@ -112,6 +112,13 @@ struct mtk_scp_of_data { size_t ipi_buf_offset; }; +struct mtk_scp_of_regs { + void __iomem *reg_base; + void __iomem *l1tcm_base; + size_t l1tcm_size; + phys_addr_t l1tcm_phys; +}; + struct mtk_scp { struct device *dev; struct rproc *rproc; diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index b92274067522..feebcadd56cd 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -854,7 +854,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 +879,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 +893,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 +920,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 +943,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, of_device_get_match_data(dev), &scp_regs); +} + static int scp_remove(struct platform_device *pdev) { struct mtk_scp *scp = platform_get_drvdata(pdev);