From patchwork Fri Jul 28 02:39: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: 127290 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp157388vqg; Thu, 27 Jul 2023 20:06:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlHZjF7vikrGcbM8X4UCdYxcVkflj4/od7/TGHeoWHiFdxpru6XphELBqTvl11jKasQKt1bg X-Received: by 2002:a05:6808:1693:b0:39b:a87f:91e8 with SMTP id bb19-20020a056808169300b0039ba87f91e8mr1422826oib.45.1690513588061; Thu, 27 Jul 2023 20:06:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690513588; cv=none; d=google.com; s=arc-20160816; b=kfAkbsnHoIx1L4HGqUnM2kBJ7BCF4RR7qhjUEE3jeWZXcbBCmo7g+FJ9V+j1lLgtQj 10Gth0ngPbuOTSiJH/mfhxwLeqQClc+HqhFbfSWMFVi/FDC8ECvzE5Iq+cytoL5WxSGl HgeMADilVSsTkWcWjCYfPEFDpAm9/jISjeyZ2rjsYPQsq6DfXjO6w7e6o8MaGaDK05zG Dh9Oj/IkdUZyQfT8syY0bzGYy5LtE3sxeJ8I5duEYPUxUuNJ5hdHVrQZSTxr27MXXDgx rhxoWkwXT4RBLFMjewaxKgzwQ8SoTl9yfhoffEk/AcZ2mFXYus5njEBRzK/SEb1b+W2y g0ZQ== 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=3pZFqE2y9D9PRaM6rQ4fkTK3Ruxj+t8ui38IWeqFk8Y=; fh=fiUFlTmdXAnPLHH0bIyIc4brKi/t2/OmtpRJQ8s00Ug=; b=P/EXgmV1iZRM8Zpo9MmjeN2bQhPcSp1apd/m1wadhg2BY0ZinpKPHOKLDTUEoKqHeg EL2d/QChGzZRaNQQL64J4lbdalANa6VY682Oet8g4kvZVhT9FH3ZSOmk+h12kggcx2yd tk/WlTiyej77GpMz8YN3ZcqT/SdW6kwdveM2snRtmLbZL7GbFChoC0XleJRjJ3hfLC4A vvFvIOvhmVTnnFBY69PbTMEdcFf0ENLkdU0BYFI9Tq7JjuZLoVXwIZCm1fS4Sr57v4Vo MsClTXyshjeIiRj61QWdVdnCGQFy/FDkSCIAeL8tdvKeHjoSoMkohz4wRSPIAA0rXh3E sg9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=FGv61PCu; 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 l11-20020a17090ac58b00b002630f1d7650si3771843pjt.46.2023.07.27.20.05.58; Thu, 27 Jul 2023 20:06:28 -0700 (PDT) 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=FGv61PCu; 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 S233057AbjG1Ckw (ORCPT + 99 others); Thu, 27 Jul 2023 22:40:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232761AbjG1CkQ (ORCPT ); Thu, 27 Jul 2023 22:40:16 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BD0D3580; Thu, 27 Jul 2023 19:40:14 -0700 (PDT) X-UUID: 0daaad6a2cf011eeb20a276fd37b9834-20230728 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=3pZFqE2y9D9PRaM6rQ4fkTK3Ruxj+t8ui38IWeqFk8Y=; b=FGv61PCu9JAI3s4l3Y2kWtXjoq1U/lUAGSIdwRhgZB2ubgijTurNAt8nvmRoj9WBPizvtezm98KppPkmYFfaIfqGcUtk7xqMwzg2EufBD8SjkSQekD7R/luvS55lXsYRjk2bcrmKnsHWCNMNgGfgYxaym8JIctEN9NSS9Qy3vX8=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.30,REQID:42bc4ecd-4bda-4a42-94fd-8288b20d8fb8,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:1fcc6f8,CLOUDID:2ff78a42-d291-4e62-b539-43d7d78362ba,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,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 0daaad6a2cf011eeb20a276fd37b9834-20230728 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 237579189; Fri, 28 Jul 2023 10:40:02 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) 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.1118.26; Fri, 28 Jul 2023 10:40:01 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 28 Jul 2023 10:40:01 +0800 From: Tinghan Shen To: Bjorn Andersson , Mathieu Poirier , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Tinghan Shen CC: , , , , , Subject: [PATCH v16 06/14] remoteproc: mediatek: Revise SCP rproc initialization flow for multi-core SCP Date: Fri, 28 Jul 2023 10:39:51 +0800 Message-ID: <20230728023959.12293-7-tinghan.shen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230728023959.12293-1-tinghan.shen@mediatek.com> References: <20230728023959.12293-1-tinghan.shen@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,RDNS_NONE,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=no 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: INBOX X-GMAIL-THRID: 1772631976220035739 X-GMAIL-MSGID: 1772631976220035739 This is the 2nd preliminary step for probing multi-core SCP. Initialization of configuration and L1TCM registers is extracted to only performed once on multi-core SCP. The rest of remoteproc initialization procedure is similar for both single and multi-core SCP and is applied to each core. Signed-off-by: Tinghan Shen --- drivers/remoteproc/mtk_scp.c | 63 ++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index f88e60e4bc21..7a2ba1e1e95a 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -854,21 +854,17 @@ 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_cluster *scp_cluster) { struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; struct mtk_scp *scp; - struct mtk_scp_of_cluster *scp_cluster; struct rproc *rproc; struct resource *res; const char *fw_name = "scp.img"; int ret, i; - scp_cluster = devm_kzalloc(dev, sizeof(*scp_cluster), GFP_KERNEL); - if (!scp_cluster) - return -ENOMEM; - ret = rproc_of_parse_firmware(dev, 0, &fw_name); if (ret < 0 && ret != -EINVAL) return ret; @@ -893,24 +889,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->cluster->l1tcm_base = devm_ioremap_resource(dev, res); - if (IS_ERR(scp->cluster->l1tcm_base)) { - ret = PTR_ERR(scp->cluster->l1tcm_base); - if (ret != -EINVAL) { - return dev_err_probe(dev, ret, "Failed to map l1tcm memory\n"); - } - } else { - scp->cluster->l1tcm_size = resource_size(res); - scp->cluster->l1tcm_phys = res->start; - } - - scp->cluster->reg_base = devm_platform_ioremap_resource_byname(pdev, "cfg"); - if (IS_ERR(scp->cluster->reg_base)) - return dev_err_probe(dev, PTR_ERR(scp->cluster->reg_base), - "Failed to parse and map cfg memory\n"); - ret = scp->data->scp_clk_get(scp); if (ret) return ret; @@ -962,6 +940,43 @@ static int scp_probe(struct platform_device *pdev) return ret; } +static int scp_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct mtk_scp_of_cluster *scp_cluster; + struct resource *res; + int ret; + + scp_cluster = devm_kzalloc(dev, sizeof(*scp_cluster), GFP_KERNEL); + if (!scp_cluster) + return -ENOMEM; + + scp_cluster->reg_base = devm_platform_ioremap_resource_byname(pdev, "cfg"); + if (IS_ERR(scp_cluster->reg_base)) + return dev_err_probe(dev, PTR_ERR(scp_cluster->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_cluster->l1tcm_base = devm_ioremap_resource(dev, res); + if (IS_ERR(scp_cluster->l1tcm_base)) { + ret = PTR_ERR(scp_cluster->l1tcm_base); + if (ret != -EINVAL) + return dev_err_probe(dev, ret, "Failed to map l1tcm memory\n"); + + scp_cluster->l1tcm_base = NULL; + } else { + scp_cluster->l1tcm_size = resource_size(res); + scp_cluster->l1tcm_phys = res->start; + } + + ret = scp_rproc_init(pdev, scp_cluster); + if (ret) + return ret; + + return 0; +} + static void scp_remove(struct platform_device *pdev) { struct mtk_scp *scp = platform_get_drvdata(pdev);