Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1247376imj; Sun, 17 Feb 2019 01:15:17 -0800 (PST) X-Google-Smtp-Source: AHgI3IbQu5h4LJVuXz7SIv1nBKLGP7lToPLZS0vqcoRjJpFxgHtOJWxqMP2dHJZ63mq9KE9Rnd+m X-Received: by 2002:a63:c946:: with SMTP id y6mr13532651pgg.109.1550394917688; Sun, 17 Feb 2019 01:15:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550394917; cv=none; d=google.com; s=arc-20160816; b=oeDy/yEHMjkrmMcIAemHPLvEaPIwDLwJtz8FIoDdNNS4DvnLLGUnvnnUps4g9cUwkf 5NecyU80nnlAH6+AbkOKqfLt+oEx1r53fdvLPOuDBpDoVZ6ip3S2khCJBhIIxoCYKlaY nonte4kgCEnvHg+7ySQP0e4+wIBCCgZ657hpZ+G1iPx/dhoLsUIg57Ewcn4hNsaJIXWU tiYwUm3QeIn3RolxYDEPZUilErvh1GQtZyTq8dSDNN9NTaf0+/1fvyjjEZzAZgg4QN1S qtgMeV51lEdGhjOlcY5RetrqYn7EwBC0SHFkdEKdsgsod9jODir0x6hvGofO4srum4Bo xbOQ== 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=OGc/tj99Tg5R1PXTTDvk/JTjPdPSiaEvP3y29adeCvs=; b=Bc8vQZJ12t37Ldv+uh0jRhfdBqEmOsM8zM6gn2uipTCNWoxnwaE5q1EJU/wx0IiCQ8 9wGZv7XP+yRoHTavMDGSeVDxLt42hRN6pIe/0MbCCd9fCq1grgla/XrDO4xURvPthzY6 McP5K/KwZuCzu747S7tTeN62G2xgN3kss+kzwnUSxNRsLUDNKq3ND/bNoJfUHdNLm6oX YxdPGBJIp/wKBw8zoVPmWYfZH+u/CJzzg7QywbPFKQFEAweS7DcEsGEJdM4Oj1g7opR+ IcWbxa4PlarBaho2Yobxn2N6Lit5i/Ryn53XObLA6DHLLrltsnCT166efz5C1zIh2OSr B4YQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f34si10636741ple.279.2019.02.17.01.15.01; Sun, 17 Feb 2019 01:15:17 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727544AbfBQJIi (ORCPT + 99 others); Sun, 17 Feb 2019 04:08:38 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:45722 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726371AbfBQJIh (ORCPT ); Sun, 17 Feb 2019 04:08:37 -0500 X-UUID: b3eb5efb2b774a4c9afe1c8fbbe6f2d4-20190217 X-UUID: b3eb5efb2b774a4c9afe1c8fbbe6f2d4-20190217 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 694387630; Sun, 17 Feb 2019 17:08:31 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sun, 17 Feb 2019 17:08:30 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Sun, 17 Feb 2019 17:08:29 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Robin Murphy , Rob Herring CC: Evan Green , Tomasz Figa , Will Deacon , , , , , , , , , , Nicolas Boichat , , Matthias Kaehlcke Subject: [PATCH v6 12/22] memory: mtk-smi: Add gals support Date: Sun, 17 Feb 2019 17:04:50 +0800 Message-ID: <1550394300-17420-13-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1550394300-17420-1-git-send-email-yong.wu@mediatek.com> References: <1550394300-17420-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 In some SoCs like mt8183, SMI add GALS(Global Async Local Sync) module which can help synchronize for the modules in different clock frequency. It can be seen as a "asynchronous fifo". This is a example diagram: M4U | ---------- | | gals0-rx gals1-rx | | | | gals0-tx gals1-tx | | ------------ SMI Common ------------ | +-----+--------+-----+- ... | | | | | gals-rx gals-rx | | | | | | | | | | gals-tx gals-tx | | | | | larb1 larb2 larb3 larb4 GALS only help transfer the command/data while it doesn't have the configuring register, thus it has the special "smi" clock and doesn't have the "apb" clock. From the diagram above, we add "gals0" and "gals1" clocks for smi-common and add a "gals" clock for smi-larb. This patch adds gals clock supporting in the SMI. Note that some larbs may still don't have the "gals" clock like larb1 and larb4 above. This is also a preparing patch for mt8183 which has GALS. CC: Matthias Brugger Signed-off-by: Yong Wu Reviewed-by: Evan Green --- drivers/memory/mtk-smi.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c index 8a2f968..91634d7 100644 --- a/drivers/memory/mtk-smi.c +++ b/drivers/memory/mtk-smi.c @@ -56,6 +56,7 @@ enum mtk_smi_gen { struct mtk_smi_common_plat { enum mtk_smi_gen gen; + bool has_gals; }; struct mtk_smi_larb_gen { @@ -63,11 +64,13 @@ struct mtk_smi_larb_gen { int port_in_larb[MTK_LARB_NR_MAX + 1]; void (*config_port)(struct device *); unsigned int larb_direct_to_common_mask; + bool has_gals; }; struct mtk_smi { struct device *dev; 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; @@ -99,8 +102,20 @@ static int mtk_smi_enable(const struct mtk_smi *smi) if (ret) goto err_disable_apb; + ret = clk_prepare_enable(smi->clk_gals0); + if (ret) + goto err_disable_smi; + + ret = clk_prepare_enable(smi->clk_gals1); + if (ret) + goto err_disable_gals0; + return 0; +err_disable_gals0: + clk_disable_unprepare(smi->clk_gals0); +err_disable_smi: + clk_disable_unprepare(smi->clk_smi); err_disable_apb: clk_disable_unprepare(smi->clk_apb); err_put_pm: @@ -110,6 +125,8 @@ static int mtk_smi_enable(const struct mtk_smi *smi) static void mtk_smi_disable(const struct mtk_smi *smi) { + clk_disable_unprepare(smi->clk_gals1); + clk_disable_unprepare(smi->clk_gals0); clk_disable_unprepare(smi->clk_smi); clk_disable_unprepare(smi->clk_apb); pm_runtime_put_sync(smi->dev); @@ -310,6 +327,15 @@ static int mtk_smi_larb_probe(struct platform_device *pdev) larb->smi.clk_smi = devm_clk_get(dev, "smi"); if (IS_ERR(larb->smi.clk_smi)) return PTR_ERR(larb->smi.clk_smi); + + if (larb->larb_gen->has_gals) { + /* The larbs may still haven't gals even if the SoC support.*/ + larb->smi.clk_gals0 = devm_clk_get(dev, "gals"); + if (PTR_ERR(larb->smi.clk_gals0) == -ENOENT) + larb->smi.clk_gals0 = NULL; + else if (IS_ERR(larb->smi.clk_gals0)) + return PTR_ERR(larb->smi.clk_gals0); + } larb->smi.dev = dev; if (larb->larb_gen->need_larbid) { @@ -402,6 +428,16 @@ static int mtk_smi_common_probe(struct platform_device *pdev) if (IS_ERR(common->clk_smi)) return PTR_ERR(common->clk_smi); + if (common->plat->has_gals) { + common->clk_gals0 = devm_clk_get(dev, "gals0"); + if (IS_ERR(common->clk_gals0)) + return PTR_ERR(common->clk_gals0); + + common->clk_gals1 = devm_clk_get(dev, "gals1"); + if (IS_ERR(common->clk_gals1)) + return PTR_ERR(common->clk_gals1); + } + /* * for mtk smi gen 1, we need to get the ao(always on) base to config * m4u port, and we need to enable the aync clock for transform the smi -- 1.9.1