Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3731174rwl; Mon, 27 Mar 2023 19:30:13 -0700 (PDT) X-Google-Smtp-Source: AKy350Zh5ffH0jl4R7L/xODMe53ce6Tkvvwy+oP62mhKBa3ZZ8dluRIJXZ6giL5ySyhhxRhe8deO X-Received: by 2002:a62:170c:0:b0:5dc:6dec:e992 with SMTP id 12-20020a62170c000000b005dc6dece992mr11996512pfx.1.1679970613380; Mon, 27 Mar 2023 19:30:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679970613; cv=none; d=google.com; s=arc-20160816; b=AW+4iehCp/S5fnN71A7J+pxrijVchJtIXWk+7rTQh/mMdd50fiEOpvFm157yzL75Go sUbBC5gGC3aZtqqzDiimUt8Zk3S5q9Z1aRZYJFRJ2FgS3LhBxJHMU/epuqYq2vhXDRQC uPY9o7aSd0iZKjKEy1lnpq0VFuz60t6FJQGSJtG1g4aJlcSUA1C6QnZcXcM5cyp/QfxD QoY8nd0w3DlTcKkONGAhRfwkSMOz6TAGbHUG6t34KMJidUtgYcRaQfJ7zPrVHtPYY8YH 4tx10rLm2R6QxH2tom91V/exuapbfzrfZyazfrqq3EXB6hguj3OKhzyCCgOwHj2jv2ol N3TQ== 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=reo26zyzbyWFM5kohN/Wkl/Jbo8+FV2cThy+TnnCN6I=; b=suHGQ0gkuJYKWVFWBF5cOgeJQ+QoopvJWpCoW8PkOoA/AtM/ioyyzqca/IDKXRQWnA t4SJd23fpcrfom5tOJ6vJcuSDugiGTdrX3ZZTxkiQ/j63yNBfeDj0WkcTe4oAgbKX/69 Nwy8rscDxN/EG6L/RfhUwNSYAY1/54YOT4VHCCNwjfAbEGtqjV6PKwhE4eZz4pRc21Id y9fvCwBYWzwL3PaS0mFTgnfEZy4xjAONYbYlXUYVHgL8tkQ6XQmv8e7DuArGELMz1UOp PA6Jv/pOy1TU82JzrLfrdnoRcp84gmVIEBbg5xawy4H6WoIjEu9IeeVGLqrUJE5EsrcV lnCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=oKVPNF7h; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p9-20020a056a0026c900b005a8d979fb49si27321516pfw.98.2023.03.27.19.30.01; Mon, 27 Mar 2023 19:30:13 -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=oKVPNF7h; 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 S232628AbjC1C2Z (ORCPT + 99 others); Mon, 27 Mar 2023 22:28:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232287AbjC1C2L (ORCPT ); Mon, 27 Mar 2023 22:28:11 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 951C619A8; Mon, 27 Mar 2023 19:28:07 -0700 (PDT) X-UUID: 266921dccd1011edb6b9f13eb10bd0fe-20230328 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=reo26zyzbyWFM5kohN/Wkl/Jbo8+FV2cThy+TnnCN6I=; b=oKVPNF7h3pzfHWQ9uWUWaag8PmXF73LBAvEWRvW01qiqkPrfAM6rgjiXqKZtu70ACcUhNNDpXnhtLKoiHXiNwuoJrk4zLunudAXWLmrlw2+2QuzlKYLgki+8XHpJR8yjZ0uqj4ccN9wqfXgYhRRYhVzJxt7LdSyt+Iq4ib/le6s=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:530aba23-ccbe-4e15-a845-3096944721bd,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:90 X-CID-INFO: VERSION:1.1.22,REQID:530aba23-ccbe-4e15-a845-3096944721bd,IP:0,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:90 X-CID-META: VersionHash:120426c,CLOUDID:6cc8ac29-564d-42d9-9875-7c868ee415ec,B ulkID:2303281027590T2S0TIG,BulkQuantity:0,Recheck:0,SF:38|29|28|17|19|48,T C:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: 266921dccd1011edb6b9f13eb10bd0fe-20230328 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 162280053; Tue, 28 Mar 2023 10:27:56 +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.25; Tue, 28 Mar 2023 10:27:55 +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.25 via Frontend Transport; Tue, 28 Mar 2023 10:27:55 +0800 From: Tinghan Shen To: Bjorn Andersson , Mathieu Poirier , Rob Herring , Krzysztof Kozlowski , Matthias Brugger , AngeloGioacchino Del Regno , Tinghan Shen CC: , , , , , Subject: [PATCH v9 05/11] remoteproc: mediatek: Extract remoteproc initialization flow Date: Tue, 28 Mar 2023 10:27:27 +0800 Message-ID: <20230328022733.29910-6-tinghan.shen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230328022733.29910-1-tinghan.shen@mediatek.com> References: <20230328022733.29910-1-tinghan.shen@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable 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 This is the preparation for probing multi-core SCP. The remoteproc initialization flow is similar on cores and is reused 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 | 64 +++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index a3b9bc158cd9..32ecd1450c6f 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. * @@ -855,7 +862,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; @@ -879,6 +887,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)) @@ -888,24 +901,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; @@ -957,6 +952,37 @@ 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_regs scp_regs; + struct resource *res; + 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"); + + scp_regs.l1tcm_size = 0; + scp_regs.l1tcm_phys = 0; + } 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); -- 2.18.0