Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp11478782imu; Mon, 31 Dec 2018 23:53:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN5zmz2EsPrNIRxVJMQ6ugBnsAk9xuWutLiLMC5agHOpSXazsN5qwsqpRKcICl5NuRymlrAt X-Received: by 2002:a63:990a:: with SMTP id d10mr9972601pge.279.1546329208834; Mon, 31 Dec 2018 23:53:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546329208; cv=none; d=google.com; s=arc-20160816; b=a/b1WNdYbczHd1DMj6nmD6icW9h8rxRhJm62R8Aht+XJ++XyizYDdhyvhzLEpsWOjc hZ1aRQClJ0qxYBo99I2dQj8Jmj+g/fJE0RHDcC9tebtHBxz2XYPeaosANbLyyhYp52ln jWin+ZXs6sAWjfHLl8PUEOUkoCfeaVeBRM0mXb0DXiQTvO0dUcgQ1JKgw9KbjdTLVPpW sNcVw6l4QkY0Cnx88CImY8XBG4+/simqtcA5c7ydE3GaJP5B4QjWzS491q/aevTcEHnO w6oeyxnECg8c8etDrfOko8LrjHePdjmcTOt5oVnPS5xjNXff8F5l7q6o3+wycwEVppKX RRVA== 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=btOUhmdw9xNssw7a7C68L/CDeAA+FRv7KIAS+asD4y4=; b=sL2i5uaJyrXjYKjPk27GKjHrFqt3Xr6bV1B3rciAfMwLJJKaD7zlvOT6F4UyAtCiCX SPECWiEPvRlbHUV2vdvjRhCOluHA4Hck3BtCUtgkfiZZnL/0bdwDB1Y5LSnMWNo8Iq33 QP4zjNQTPlvjRM4dJ92GOji5s3OF1qRb7TLy3ykVgfR/jShbK4578XkTVFpE2rw6wwUJ WBe4RpEJI1lZd9UXxRIa1p0pZpddzCYJfpL+2WOl1uu/CLaP4h7vFLLjEbCrqhi32TBf xY10qa6/hFZbucce88SioulLJYEcbwB33jCRhwSwedrvA8mxDs5ZSlRK8Thr7p1z7wb7 ZvyA== 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 k22si42638266pgl.29.2018.12.31.23.52.58; Mon, 31 Dec 2018 23:53:28 -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 S1728333AbfAAD6u (ORCPT + 99 others); Mon, 31 Dec 2018 22:58:50 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:17903 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727487AbfAAD6u (ORCPT ); Mon, 31 Dec 2018 22:58:50 -0500 X-UUID: ee5b9e9671a442a5bfb3973994337659-20190101 X-UUID: ee5b9e9671a442a5bfb3973994337659-20190101 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 863140756; Tue, 01 Jan 2019 11:58:44 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs03n2.mediatek.inc (172.21.101.182) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 1 Jan 2019 11:58:42 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 1 Jan 2019 11:58:42 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Robin Murphy , Rob Herring CC: Tomasz Figa , Will Deacon , , , , , , , , , , , Nicolas Boichat Subject: [PATCH v5 12/20] memory: mtk-smi: Add gals support Date: Tue, 1 Jan 2019 11:55:44 +0800 Message-ID: <1546314952-15990-13-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1546314952-15990-1-git-send-email-yong.wu@mediatek.com> References: <1546314952-15990-1-git-send-email-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 23B1376600F2A7E57E2F9D0C55B8013928A914DA847755D6D42A934CE7094B8D2000:8 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. Signed-off-by: Yong Wu --- 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