Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4D7B6C00140 for ; Mon, 8 Aug 2022 03:13:39 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 692F78498E; Mon, 8 Aug 2022 05:13:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=mediatek.com header.i=@mediatek.com header.b="Vr2c4kkV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EE889849A6; Mon, 8 Aug 2022 05:13:35 +0200 (CEST) Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9E66684978 for ; Mon, 8 Aug 2022 05:13:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=weijie.gao@mediatek.com X-UUID: b252f7efc3a9480794da79782428995a-20220808 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:MIME-Version:Content-Type:References:In-Reply-To:Date:CC:To:From:Subject:Message-ID; bh=6sp4lIc6oOHoDMeg2ZUsvzKpUae50DmElbwp5QWge2Y=; b=Vr2c4kkVdJ7+A5ZZryE5OIyWYbiBELUqk6zPC9a58aFHS1xlr25BE9PiGs9/oO1e+CZ9o5+DhEcXyHuuM+bXQyHL+vdQUk4qY68GZK0obeZdnZXMIWlY6xY+D/7Fq+erfylQQzVziv9l9RmSFSOOnrBD9ZNb1QKy9OLQZltTuyA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.8, REQID:3bff1e14-b5a5-41f7-8827-ae1204c6bb1c, OB:0, LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:0f94e32, CLOUDID:c8d7f848-f57f-4088-93dd-066979cdb4e6, C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:nil,BEC:nil,COL:0 X-UUID: b252f7efc3a9480794da79782428995a-20220808 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 95735041; Mon, 08 Aug 2022 11:13:24 +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.792.15; Mon, 8 Aug 2022 11:13:24 +0800 Received: from mcddlt001.gcn.mediatek.inc (10.19.240.15) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Mon, 8 Aug 2022 11:13:23 +0800 Message-ID: Subject: Re: [PATCH 26/31] clk: mediatek: add clock driver support for MediaTek MT7986 SoC From: Weijie Gao To: Simon Glass CC: U-Boot Mailing List , GSS_MTK_Uboot_upstream , Lukasz Majewski , Sean Anderson Date: Mon, 8 Aug 2022 11:13:23 +0800 In-Reply-To: References: <31add4a828b5f707d5616cee985df7a05fd004f2.1659581119.git.weijie.gao@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1-2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-MTK: N X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On Thu, 2022-08-04 at 07:57 -0600, Simon Glass wrote: > Hi Weijie, > > On Wed, 3 Aug 2022 at 21:40, Weijie Gao > wrote: > > > > This patch adds clock driver support for MediaTek MT7986 SoC > > > > Signed-off-by: Weijie Gao > > --- > > drivers/clk/mediatek/Makefile | 1 + > > drivers/clk/mediatek/clk-mt7986.c | 671 > > +++++++++++++++++++++++++ > > include/dt-bindings/clock/mt7986-clk.h | 249 +++++++++ > > 3 files changed, 921 insertions(+) > > create mode 100644 drivers/clk/mediatek/clk-mt7986.c > > create mode 100644 include/dt-bindings/clock/mt7986-clk.h > > > > Reviewed-by: Simon Glass > > [..] > > > new file mode 100644 > > index 0000000000..11c489cd50 > > --- /dev/null > > +++ b/drivers/clk/mediatek/clk-mt7986.c > > @@ -0,0 +1,671 @@ > > > [..] > > > +static int mt7986_topckgen_probe(struct udevice *dev) > > +{ > > + struct mtk_clk_priv *priv = dev_get_priv(dev); > > + > > + priv->base = dev_read_addr_ptr(dev); > > + writel(MT7986_CLK_PDN_EN_WRITE, priv->base + > > MT7986_CLK_PDN); > > blank line here OK. > > > + return mtk_common_clk_init(dev, &mt7986_topckgen_clk_tree); > > +} > > + > > +U_BOOT_DRIVER(mtk_clk_apmixedsys) = { > > + .name = "mt7986-clock-fixed-pll", > > + .id = UCLASS_CLK, > > + .of_match = mt7986_fixed_pll_compat, > > + .probe = mt7986_fixed_pll_probe, > > + .priv_auto = sizeof(struct mtk_clk_priv), > > + .ops = &mtk_clk_topckgen_ops, > > + .flags = DM_FLAG_PRE_RELOC, > > +}; > > + > > +U_BOOT_DRIVER(mtk_clk_topckgen) = { > > + .name = "mt7986-clock-topckgen", > > + .id = UCLASS_CLK, > > + .of_match = mt7986_topckgen_compat, > > + .probe = mt7986_topckgen_probe, > > + .priv_auto = sizeof(struct mtk_clk_priv), > > + .ops = &mtk_clk_topckgen_ops, > > + .flags = DM_FLAG_PRE_RELOC, > > +}; > > + > > +static const struct udevice_id mt7986_infracfg_compat[] = { > > + { .compatible = "mediatek,mt7986-infracfg" }, > > + {} > > +}; > > + > > +static const struct udevice_id mt7986_infracfg_ao_compat[] = { > > + { .compatible = "mediatek,mt7986-infracfg_ao" }, > > + {} > > +}; > > + > > +static int mt7986_infracfg_probe(struct udevice *dev) > > +{ > > + return mtk_common_clk_init(dev, &mt7986_infracfg_clk_tree); > > +} > > + > > +static int mt7986_infracfg_ao_probe(struct udevice *dev) > > +{ > > + return mtk_common_clk_gate_init(dev, > > &mt7986_infracfg_clk_tree, > > + infracfg_ao_gates); > > +} > > + > > +U_BOOT_DRIVER(mtk_clk_infracfg) = { > > + .name = "mt7986-clock-infracfg", > > + .id = UCLASS_CLK, > > + .of_match = mt7986_infracfg_compat, > > + .probe = mt7986_infracfg_probe, > > + .priv_auto = sizeof(struct mtk_clk_priv), > > + .ops = &mtk_clk_infrasys_ops, > > + .flags = DM_FLAG_PRE_RELOC, > > +}; > > + > > +U_BOOT_DRIVER(mtk_clk_infracfg_ao) = { > > + .name = "mt7986-clock-infracfg-ao", > > + .id = UCLASS_CLK, > > + .of_match = mt7986_infracfg_ao_compat, > > + .probe = mt7986_infracfg_ao_probe, > > + .priv_auto = sizeof(struct mtk_cg_priv), > > + .ops = &mtk_clk_gate_ops, > > + .flags = DM_FLAG_PRE_RELOC, > > +}; > > + > > +/* ethsys */ > > +static const struct mtk_gate_regs eth_cg_regs = { > > + .sta_ofs = 0x30, > > +}; > > + > > +#define GATE_ETH(_id, _name, _parent, _shift) > > \ > > + { > > \ > > + .id = _id, .parent = _parent, .regs = > > ð_cg_regs, \ > > + .shift = > > _shift, \ > > + .flags = CLK_GATE_NO_SETCLR_INV | > > CLK_PARENT_TOPCKGEN, \ > > + } > > + > > +static const struct mtk_gate eth_cgs[] = { > > + GATE_ETH(CK_ETH_FE_EN, "eth_fe_en", CK_TOP_NETSYS_2X, 7), > > + GATE_ETH(CK_ETH_GP2_EN, "eth_gp2_en", CK_TOP_SGM_325M, 8), > > + GATE_ETH(CK_ETH_GP1_EN, "eth_gp1_en", CK_TOP_SGM_325M, 8), > > + GATE_ETH(CK_ETH_WOCPU1_EN, "eth_wocpu1_en", > > CK_TOP_NETSYS_WED_MCU, 14), > > + GATE_ETH(CK_ETH_WOCPU0_EN, "eth_wocpu0_en", > > CK_TOP_NETSYS_WED_MCU, 15), > > +}; > > + > > +static int mt7986_ethsys_probe(struct udevice *dev) > > +{ > > + return mtk_common_clk_gate_init(dev, > > &mt7986_topckgen_clk_tree, > > + eth_cgs); > > +} > > + > > +static int mt7986_ethsys_bind(struct udevice *dev) > > +{ > > + int ret = 0; > > + > > +#if CONFIG_IS_ENABLED(RESET_MEDIATEK) > > if (CONFIG_IS_ENABLED()... OK. > > > + ret = mediatek_reset_bind(dev, ETHSYS_HIFSYS_RST_CTRL_OFS, > > 1); > > + if (ret) > > + debug("Warning: failed to bind reset > > controller\n"); > > +#endif > > + > > + return ret; > > +} > > + > > +static const struct udevice_id mt7986_ethsys_compat[] = { > > + { .compatible = "mediatek,mt7986-ethsys" }, > > + { } > > +}; > > + > > +U_BOOT_DRIVER(mtk_clk_ethsys) = { > > + .name = "mt7986-clock-ethsys", > > + .id = UCLASS_CLK, > > + .of_match = mt7986_ethsys_compat, > > + .probe = mt7986_ethsys_probe, > > + .bind = mt7986_ethsys_bind, > > + .priv_auto = sizeof(struct mtk_cg_priv), > > + .ops = &mtk_clk_gate_ops, > > +}; > > Regards, > Simon