Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp880102ybl; Wed, 21 Aug 2019 06:59:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxbcQ8Fhjmzw6vBy6Ayca+JfAf6eo2A3F8gy+3w4eHtnRWx2AYInGdT/PXNlNYz25OHDrAa X-Received: by 2002:aa7:8e18:: with SMTP id c24mr36056735pfr.24.1566395966428; Wed, 21 Aug 2019 06:59:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566395966; cv=none; d=google.com; s=arc-20160816; b=nl3MCgo++xX+Y0CPwlSFyQjXIoPAPOQt5ell/T+UQHufFTydsEY+TIYdrKttY6vXs7 wpnHKKoCKCoIsOg5C9bH9JrZkH0i039HuqrEOcFJ0MO65Zc1ir/RvROJBE/s3iPQnJjE 2Mre0a1ohk30kVFlbMIjsTqth6yOhNqjH6fsv1dckibK6d7oE+vZ1DETm1PrbcROzGPu ZCaCTwkbj6A47yNOtQKnkDv5vzD6gakmcff7+9uKQIqV2/h1oM9ClmB8P0iURjQ4H/jm BUe/eqnN4BFZisWs8HC/veJIACWNEXH7vRNDHfSbdoBQ7FlUyKvWCd4K6jd11ud3K8Ko XiPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Gii2UTg+mrQXuD7ZlqLBdabeqM2SEW/xcdT7jR74ioY=; b=MqwqvTkVD5rQufBLOyDaF5UpxLWX0BlS4SH+PV8M00qWkYR3bQTmtmkSOnix0oc7zV yGrNdSzpRxc3Bk901YFyfJOlw/6014MNoQOZEgGcVFJlZx8cPQu6EyzPlr9pHSLiSNfg DDiGaJkdBOLeWMnCRSNVww3PCDAKLOYfhswFBBua+JwPSi1FNhfY+t5CdMbClH5WryD4 EqAbghp18eV6602ZgxEaCjmp59web66k9sREL2MJzURlIZtkrnt/gncoQlu4sARyjBRz B34WcxWsNYlbK6s+dFvNkhvuT0b9SjGKFKZLWuoG/xMTgIGfsg4MuQnGW0CAc9jKDrk6 GDBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t145si11484275pfc.161.2019.08.21.06.59.10; Wed, 21 Aug 2019 06:59:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729349AbfHUN5Y (ORCPT + 99 others); Wed, 21 Aug 2019 09:57:24 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:16487 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729018AbfHUN5Y (ORCPT ); Wed, 21 Aug 2019 09:57:24 -0400 X-UUID: 5de715aff01144faaf41e401b86e37b7-20190821 X-UUID: 5de715aff01144faaf41e401b86e37b7-20190821 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0707 with TLS) with ESMTP id 1401716824; Wed, 21 Aug 2019 21:57:14 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 21 Aug 2019 21:57:13 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 21 Aug 2019 21:57:12 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Robin Murphy , Will Deacon CC: Rob Herring , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , Matthias Kaehlcke , , , Subject: [PATCH v10 20/23] memory: mtk-smi: Add bus_sel for mt8183 Date: Wed, 21 Aug 2019 21:53:23 +0800 Message-ID: <1566395606-7975-21-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1566395606-7975-1-git-send-email-yong.wu@mediatek.com> References: <1566395606-7975-1-git-send-email-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are 2 mmu cells in a M4U HW. we could adjust some larbs entering mmu0 or mmu1 to balance the bandwidth via the smi-common register SMI_BUS_SEL(0x220)(Each larb occupy 2 bits). In mt8183, For better performance, we switch larb1/2/5/7 to enter mmu1 while the others still keep enter mmu0. In mt8173 and mt2712, we don't get the performance issue, Keep its default value(0x0), that means all the larbs enter mmu0. Note: smi gen1(mt2701/mt7623) don't have this bus_sel. And, the base of smi-common is completely different with smi_ao_base of gen1, thus I add new variable for that. CC: Matthias Brugger Signed-off-by: Yong Wu Reviewed-by: Evan Green Reviewed-by: Matthias Brugger --- drivers/memory/mtk-smi.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c index 2bb55b86..289e595 100644 --- a/drivers/memory/mtk-smi.c +++ b/drivers/memory/mtk-smi.c @@ -41,6 +41,12 @@ #define SMI_LARB_NONSEC_CON(id) (0x380 + ((id) * 4)) #define F_MMU_EN BIT(0) +/* SMI COMMON */ +#define SMI_BUS_SEL 0x220 +#define SMI_BUS_LARB_SHIFT(larbid) ((larbid) << 1) +/* All are MMU0 defaultly. Only specialize mmu1 here. */ +#define F_MMU1_LARB(larbid) (0x1 << SMI_BUS_LARB_SHIFT(larbid)) + enum mtk_smi_gen { MTK_SMI_GEN1, MTK_SMI_GEN2 @@ -49,6 +55,7 @@ enum mtk_smi_gen { struct mtk_smi_common_plat { enum mtk_smi_gen gen; bool has_gals; + u32 bus_sel; /* Balance some larbs to enter mmu0 or mmu1 */ }; struct mtk_smi_larb_gen { @@ -64,8 +71,10 @@ struct mtk_smi { struct clk *clk_apb, *clk_smi; struct clk *clk_gals0, *clk_gals1; struct clk *clk_async; /*only needed by mt2701*/ - void __iomem *smi_ao_base; - + union { + void __iomem *smi_ao_base; /* only for gen1 */ + void __iomem *base; /* only for gen2 */ + }; const struct mtk_smi_common_plat *plat; }; @@ -402,6 +411,8 @@ static int __maybe_unused mtk_smi_larb_suspend(struct device *dev) static const struct mtk_smi_common_plat mtk_smi_common_mt8183 = { .gen = MTK_SMI_GEN2, .has_gals = true, + .bus_sel = F_MMU1_LARB(1) | F_MMU1_LARB(2) | F_MMU1_LARB(5) | + F_MMU1_LARB(7), }; static const struct of_device_id mtk_smi_common_of_ids[] = { @@ -474,6 +485,11 @@ static int mtk_smi_common_probe(struct platform_device *pdev) ret = clk_prepare_enable(common->clk_async); if (ret) return ret; + } else { + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + common->base = devm_ioremap_resource(dev, res); + if (IS_ERR(common->base)) + return PTR_ERR(common->base); } pm_runtime_enable(dev); platform_set_drvdata(pdev, common); @@ -489,6 +505,7 @@ static int mtk_smi_common_remove(struct platform_device *pdev) static int __maybe_unused mtk_smi_common_resume(struct device *dev) { struct mtk_smi *common = dev_get_drvdata(dev); + u32 bus_sel = common->plat->bus_sel; int ret; ret = mtk_smi_clk_enable(common); @@ -496,6 +513,9 @@ static int __maybe_unused mtk_smi_common_resume(struct device *dev) dev_err(common->dev, "Failed to enable clock(%d).\n", ret); return ret; } + + if (common->plat->gen == MTK_SMI_GEN2 && bus_sel) + writel(bus_sel, common->base + SMI_BUS_SEL); return 0; } -- 1.9.1