From patchwork Fri Aug 11 09:56:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WW9uZyBXdSAo5ZC05YuHKQ==?= X-Patchwork-Id: 9895397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B4923602DA for ; Fri, 11 Aug 2017 10:00:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A434628B6A for ; Fri, 11 Aug 2017 10:00:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9901228B6E; Fri, 11 Aug 2017 10:00:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D4C6828C1F for ; Fri, 11 Aug 2017 10:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=d17+KUkTwKpgSCboUbhqDjqtDgGbtaouPyn4GGeI4Ps=; b=u6LPaT5FxW4i0p 0P5odzVlwanOON9Z+HrOgEh6CNpKKqWAE9mZy1Ev8Wob7rK7ktZ8vgVrCrHobfu/jigL/O2QzOhx+ TJU/ggr0FUveJlKrmL7bJ2wW27Ol2XeaPg2amrQunSa8XYYDEp4BPZxOCDQR7rFIJOP0M1XMn3rht a3PJZaDTVwnTqzypLRA6X4dxM3ruvWTocifHgiaFM9RhqYKJ/7rvk2E3v0P7Kt3mzlp8rwLubJZEJ xgnMbweryd2rxg2U2OajTOj1qKIZveXDNIC2evzMztNWXEVkOrsFCtbrR2PlLN7stagCcwoHu0aQS 2eFUZqzFQC2w/PUl4mgA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dg6k2-0003nU-P4; Fri, 11 Aug 2017 10:00:30 +0000 Received: from [210.61.82.183] (helo=mailgw01.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dg6hU-0000MA-Rh; Fri, 11 Aug 2017 09:58:21 +0000 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 191388913; Fri, 11 Aug 2017 17:57:29 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs03n2.mediatek.inc (172.21.101.182) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Fri, 11 Aug 2017 17:57:27 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Fri, 11 Aug 2017 17:57:26 +0800 From: Yong Wu To: Joerg Roedel , Rob Herring , Matthias Brugger , Robin Murphy Subject: [PATCH 7/8] memory: mtk-smi: Rearrange some function position alphabetically Date: Fri, 11 Aug 2017 17:56:16 +0800 Message-ID: <1502445377-26936-8-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502445377-26936-1-git-send-email-yong.wu@mediatek.com> References: <1502445377-26936-1-git-send-email-yong.wu@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170811_025754_047184_2F3F30B9 X-CRM114-Status: GOOD ( 18.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Arvind Yadav , arnd@arndb.de, srv_heupstream@mediatek.com, Catalin Marinas , youlin.pei@mediatek.com, Will Deacon , linux-kernel@vger.kernel.org, Tomasz Figa , iommu@lists.linux-foundation.org, Daniel Kurtz , yong.wu@mediatek.com, honghui.zhang@mediatek.com, cloud.chou@mediatek.com, linux-mediatek@lists.infradead.org, k.zhang@mediatek.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Only adjust some code position in Soc numerical order, from mt2701, mt2712 to mt8173. Besides, 3 minor changes: 1) fix a coding style issue: CHECK: Alignment should match open parenthesis + writel(reg_val, + common->smi_ao_base 2) change from readl to readl_relaxed in gen1_config_port. 3) change the type "larbid" from "int" to "unsigned int" to meet the requirement of of_property_read_u32. Signed-off-by: Yong Wu --- drivers/memory/mtk-smi.c | 105 +++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c index ec06d2b..ce27bdf 100644 --- a/drivers/memory/mtk-smi.c +++ b/drivers/memory/mtk-smi.c @@ -23,9 +23,6 @@ #include #include -/* mt8173 */ -#define SMI_LARB_MMU_EN 0xf00 - /* mt2701 */ #define REG_SMI_SECUR_CON_BASE 0x5c0 @@ -48,16 +45,19 @@ #define SMI_LARB_NONSEC_CON(id) (0x380 + (id * 4)) #define F_MMU_EN BIT(0) +/* mt8173 */ +#define SMI_LARB_MMU_EN 0xf00 + struct mtk_smi_larb_gen { - bool need_larbid; - int port_in_larb[MTK_LARB_NR_MAX + 1]; - void (*config_port)(struct device *); + bool need_larbid; + int port_in_larb[MTK_LARB_NR_MAX + 1];/* Only needed by smi gen1 */ + void (*config_port)(struct device *); }; struct mtk_smi { struct device *dev; struct clk *clk_apb, *clk_smi; - struct clk *clk_async; /*only needed by mt2701*/ + struct clk *clk_async; /*only needed by smi gen1*/ void __iomem *smi_ao_base; }; @@ -66,7 +66,7 @@ struct mtk_smi_larb { /* larb: local arbiter */ void __iomem *base; struct device *smi_common_dev; const struct mtk_smi_larb_gen *larb_gen; - int larbid; + unsigned int larbid; u32 *mmu; }; @@ -166,28 +166,16 @@ void mtk_smi_larb_put(struct device *larbdev) return -ENODEV; } -static void mtk_smi_larb_config_port_mt8173(struct device *dev) +static void +mtk_smi_larb_unbind(struct device *dev, struct device *master, void *data) { - struct mtk_smi_larb *larb = dev_get_drvdata(dev); - - writel(*larb->mmu, larb->base + SMI_LARB_MMU_EN); + /* Do nothing as the iommu is always enabled. */ } -static void mtk_smi_larb_config_port_mt2712(struct device *dev) -{ - struct mtk_smi_larb *larb = dev_get_drvdata(dev); - u32 reg; - int i; - - for (i = 0; i < 32; i++) { - if (*larb->mmu & BIT(i)) { - reg = readl_relaxed(larb->base + - SMI_LARB_NONSEC_CON(i)); - reg |= F_MMU_EN; - writel(reg, larb->base + SMI_LARB_NONSEC_CON(i)); - } - } -} +static const struct component_ops mtk_smi_larb_component_ops = { + .bind = mtk_smi_larb_bind, + .unbind = mtk_smi_larb_unbind, +}; static void mtk_smi_larb_config_port_gen1(struct device *dev) { @@ -209,36 +197,39 @@ static void mtk_smi_larb_config_port_gen1(struct device *dev) /* do not need to enable m4u for this port */ continue; } - reg_val = readl(common->smi_ao_base + reg_val = readl_relaxed(common->smi_ao_base + REG_SMI_SECUR_CON_ADDR(m4u_port_id)); reg_val &= SMI_SECUR_CON_VAL_MSK(m4u_port_id); reg_val |= sec_con_val; reg_val |= SMI_SECUR_CON_VAL_DOMAIN(m4u_port_id); writel(reg_val, - common->smi_ao_base - + REG_SMI_SECUR_CON_ADDR(m4u_port_id)); + common->smi_ao_base + + REG_SMI_SECUR_CON_ADDR(m4u_port_id)); } } -static void -mtk_smi_larb_unbind(struct device *dev, struct device *master, void *data) +static void mtk_smi_larb_config_port_mt2712(struct device *dev) { - /* Do nothing as the iommu is always enabled. */ -} + struct mtk_smi_larb *larb = dev_get_drvdata(dev); + u32 reg; + int i; -static const struct component_ops mtk_smi_larb_component_ops = { - .bind = mtk_smi_larb_bind, - .unbind = mtk_smi_larb_unbind, -}; + for (i = 0; i < 32; i++) { + if (*larb->mmu & BIT(i)) { + reg = readl_relaxed(larb->base + + SMI_LARB_NONSEC_CON(i)); + reg |= F_MMU_EN; + writel(reg, larb->base + SMI_LARB_NONSEC_CON(i)); + } + } +} -static const struct mtk_smi_larb_gen mtk_smi_larb_mt8173 = { - /* mt8173 do not need the port in larb */ - .config_port = mtk_smi_larb_config_port_mt8173, -}; +static void mtk_smi_larb_config_port_mt8173(struct device *dev) +{ + struct mtk_smi_larb *larb = dev_get_drvdata(dev); -static const struct mtk_smi_larb_gen mtk_smi_larb_mt2712 = { - .config_port = mtk_smi_larb_config_port_mt2712, -}; + writel(*larb->mmu, larb->base + SMI_LARB_MMU_EN); +} static const struct mtk_smi_larb_gen mtk_smi_larb_mt2701 = { .need_larbid = true, @@ -249,12 +240,16 @@ static void mtk_smi_larb_config_port_gen1(struct device *dev) .config_port = mtk_smi_larb_config_port_gen1, }; +static const struct mtk_smi_larb_gen mtk_smi_larb_mt2712 = { + .config_port = mtk_smi_larb_config_port_mt2712, +}; + +static const struct mtk_smi_larb_gen mtk_smi_larb_mt8173 = { + .config_port = mtk_smi_larb_config_port_mt8173, +}; + static const struct of_device_id mtk_smi_larb_of_ids[] = { { - .compatible = "mediatek,mt8173-smi-larb", - .data = &mtk_smi_larb_mt8173 - }, - { .compatible = "mediatek,mt2701-smi-larb", .data = &mtk_smi_larb_mt2701 }, @@ -262,6 +257,10 @@ static void mtk_smi_larb_config_port_gen1(struct device *dev) .compatible = "mediatek,mt2712-smi-larb", .data = &mtk_smi_larb_mt2712 }, + { + .compatible = "mediatek,mt8173-smi-larb", + .data = &mtk_smi_larb_mt8173 + }, {} }; @@ -341,10 +340,6 @@ static int mtk_smi_larb_remove(struct platform_device *pdev) static const struct of_device_id mtk_smi_common_of_ids[] = { { - .compatible = "mediatek,mt8173-smi-common", - .data = (void *)MTK_SMI_GEN2 - }, - { .compatible = "mediatek,mt2701-smi-common", .data = (void *)MTK_SMI_GEN1 }, @@ -352,6 +347,10 @@ static int mtk_smi_larb_remove(struct platform_device *pdev) .compatible = "mediatek,mt2712-smi-common", .data = (void *)MTK_SMI_GEN2 }, + { + .compatible = "mediatek,mt8173-smi-common", + .data = (void *)MTK_SMI_GEN2 + }, {} };