{"id":2175663,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2175663/?format=json","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.0/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20251218-clk-mtk-improvements-v1-4-72db131ba148@baylibre.com>","date":"2025-12-18T17:17:02","name":"[4/8] clk: mediatek: organize infrasys functions","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"f5bb1286d97fcdb8772338213b8ed6bdbb938e6c","submitter":{"id":87228,"url":"http://patchwork.ozlabs.org/api/1.0/people/87228/?format=json","name":"David Lechner","email":"dlechner@baylibre.com"},"delegate":{"id":3651,"url":"http://patchwork.ozlabs.org/api/1.0/users/3651/?format=json","username":"trini","first_name":"Tom","last_name":"Rini","email":"trini@ti.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20251218-clk-mtk-improvements-v1-4-72db131ba148@baylibre.com/mbox/","series":[{"id":485889,"url":"http://patchwork.ozlabs.org/api/1.0/series/485889/?format=json","date":"2025-12-18T17:16:58","name":"clk: mediatek: implement of_xlate and dump","version":1,"mbox":"http://patchwork.ozlabs.org/series/485889/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2175663/checks/","tags":{},"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=baylibre-com.20230601.gappssmtp.com\n header.i=@baylibre-com.20230601.gappssmtp.com header.a=rsa-sha256\n header.s=20230601 header.b=MDSI696y;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)","phobos.denx.de;\n dmarc=none (p=none dis=none) header.from=baylibre.com","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=baylibre-com.20230601.gappssmtp.com\n header.i=@baylibre-com.20230601.gappssmtp.com header.b=\"MDSI696y\";\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=none (p=none dis=none) header.from=baylibre.com","phobos.denx.de;\n spf=pass smtp.mailfrom=dlechner@baylibre.com"],"Received":["from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4dXHVV1sTHz1xty\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 19 Dec 2025 04:20:18 +1100 (AEDT)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 83242839A8;\n\tThu, 18 Dec 2025 18:18:43 +0100 (CET)","by phobos.denx.de (Postfix, from userid 109)\n id 2F1258367F; Thu, 18 Dec 2025 18:18:16 +0100 (CET)","from mail-oo1-xc30.google.com (mail-oo1-xc30.google.com\n [IPv6:2607:f8b0:4864:20::c30])\n (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id C2D7180077\n for <u-boot@lists.denx.de>; Thu, 18 Dec 2025 18:18:08 +0100 (CET)","by mail-oo1-xc30.google.com with SMTP id\n 006d021491bc7-659848c994bso439879eaf.3\n for <u-boot@lists.denx.de>; Thu, 18 Dec 2025 09:18:08 -0800 (PST)","from [127.0.1.1] ([2600:8803:e7e4:500:e5ea:76dc:e589:2d5e])\n by smtp.gmail.com with ESMTPSA id\n 006d021491bc7-65cff214d66sm1316372eaf.9.2025.12.18.09.18.06\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 18 Dec 2025 09:18:07 -0800 (PST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham\n autolearn_force=no version=3.4.2","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1766078287;\n x=1766683087;\n darn=lists.denx.de;\n h=cc:to:in-reply-to:references:message-id:content-transfer-encoding\n :mime-version:subject:date:from:from:to:cc:subject:date:message-id\n :reply-to; bh=1g7Mf1akq7KTGjVZGl8MgTI8h2J5H+hHLZsBMzPd4s0=;\n b=MDSI696ykKHIZQh4vIuLkWzrYXVHN1Sy0T882gADE51Cj3OPi9gP3/PUnMXLp80bnN\n VmIxAmPCeL+SUcc3LZf3S6SCaoYJUKmDrcsUFC2BhwEbMflvpylEVMaOnsSf9BOwwgnx\n 7XIxH7G+pdap67FwyuuCuLsuzq7eCRyYxsC3WClYaqNVJz2MMlaOx9DKm39AsbTlvc4A\n oU2rk8iEZj0uwg0snzCH0s0citY14UgAuqFynzAZ+iZdzR+XBajIk5qHBN3ENxwRDcyZ\n Z/2youbHVw2X0oasRVC+qCJd/oqiCi7ADp8UNZMm8x93poDNGZk28rqPf9eQp61WDJNY\n kobg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1766078287; x=1766683087;\n h=cc:to:in-reply-to:references:message-id:content-transfer-encoding\n :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to\n :cc:subject:date:message-id:reply-to;\n bh=1g7Mf1akq7KTGjVZGl8MgTI8h2J5H+hHLZsBMzPd4s0=;\n b=W67zJiyu1npkUkVKUTtmjo0tjgiPdBrkENeEYOaD/jDfSPYcpnVd2hfQ+q0nxYc6s0\n d9s9WmqAZECzxNEpb6PsWwF9kvF/UWYq4PdHuj3Fxtq10F88ZDQWN9YABYDlCCJEmGO+\n dB6tJjKPoG41exTp+mjnsDgHkA7p69jAVqKLDPOmNktxWem1JeHDYB3CzRt7OOLElzL9\n QKTVwXuooNHP1NV4593oWlZjvtR+lUL79p3+Hm2TXhvODApQEH98l3lla8CXiKUSIgfi\n 7geA8wAnnclSjDaO+baHOzfFtb+DP112cnUM3xEFYAPqsSro5XJidkiWMxUbEfcJqh1G\n Zwog==","X-Forwarded-Encrypted":"i=1;\n AJvYcCXH2d3MZQfMK19Wm6L6oXD9jV0K6TxMWynoP76nIp/+rw/fNdhKizsndFRjz/nmhh56QSsFevA=@lists.denx.de","X-Gm-Message-State":"AOJu0YwQIZSeY5wzvIj7mhFR/Up5aWvz8ggKM2Uy3S8rVwzdpLoYO3b5\n c9LDqbaalyOMWZczQGmJMR9PbUw+cE6NHnt9tvUmViGVTWKRsexdBZblcOs8/4DgUBQ=","X-Gm-Gg":"AY/fxX77TpY+r5tytCTKf31f6ZWZ7BfKuU5yLB4EELZxALGAOwDUbYGKP4cM3XAHqZX\n mwKsLnCtZoouMEeXfGdfnDbG2WQSBQ/lEVU3sk8W35UjZjufmCshf0XTvGdFFIZtHeRtXwMzY6T\n maOcDOSELaZFnS++PCYEf6lQ0Pa8k0Ic1EPpSYAuW8+4oTz42Z1kZlnQm0t7LQS+q5iHxKNzKZA\n +LM3oUVmxa8PImb9KQBrugz1G0cq3DGUqAY/0l21mZL5lDctY8hTYr73Yy2BrKzG1Ph4arJp3oN\n 9y0cktHm55qQLqQKN+qGlqPffZbiWSVd4or9LQjWUouhSaiGsuUTs3yiRm6rvgMNRLuP026MvJJ\n gypcjMSWrRXL/eB6NvqMLhkY6wU8vn0VIOk1YYfp21bMtFefXeGuBWYwRCFyYvJv17zXLTiiqu5\n Fo0BAcgJacrsQCK6g=","X-Google-Smtp-Source":"\n AGHT+IEExEek4qo+w2Xrzm9Rtr+u5cyB0Sp8bhbMHtWNMU8dKmxeuzYW4XdHTlIlP1d0STIdm4yGzA==","X-Received":"by 2002:a05:6820:178:b0:659:9a49:8fe8 with SMTP id\n 006d021491bc7-65d0e9620c8mr88889eaf.21.1766078287438;\n Thu, 18 Dec 2025 09:18:07 -0800 (PST)","From":"David Lechner <dlechner@baylibre.com>","Date":"Thu, 18 Dec 2025 11:17:02 -0600","Subject":"[PATCH 4/8] clk: mediatek: organize infrasys functions","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","Message-Id":"<20251218-clk-mtk-improvements-v1-4-72db131ba148@baylibre.com>","References":"<20251218-clk-mtk-improvements-v1-0-72db131ba148@baylibre.com>","In-Reply-To":"<20251218-clk-mtk-improvements-v1-0-72db131ba148@baylibre.com>","To":"Lukasz Majewski <lukma@denx.de>, Ryder Lee <ryder.lee@mediatek.com>,\n Weijie Gao <weijie.gao@mediatek.com>,\n Chunfeng Yun <chunfeng.yun@mediatek.com>,\n Igor Belwon <igor.belwon@mentallysanemainliners.org>,\n GSS_MTK_Uboot_upstream <GSS_MTK_Uboot_upstream@mediatek.com>,\n Tom Rini <trini@konsulko.com>","Cc":"Julien Stephan <jstephan@baylibre.com>, u-boot@lists.denx.de,\n David Lechner <dlechner@baylibre.com>","X-Mailer":"b4 0.14.3","X-Developer-Signature":"v=1; a=openpgp-sha256; l=9172; i=dlechner@baylibre.com;\n h=from:subject:message-id;\n bh=TYRtyRMhClQZdqEY+bMNXpL6cr8A1jJOedj+qplCJ40=;\n b=owEBhAF7/pANAwAKAcLMIAH/AY/AAcsmYgBpRDcpLyqCg62VGWD0Qiq5lY9uvaHYy341900/G\n fuKDZ3gwxqJAUoEAAEKADQWIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaUQ3KRYcZGxlY2huZXJA\n YmF5bGlicmUuY29tAAoJEMLMIAH/AY/ACaUH/i3t73n2Nj27jot8Q0f82Rh+L54CI3ifZ7BVgpt\n e8AX+MD8PqPYcIdFhMI0BxstgzI9JEanauUjXWBSy5HQtttiXliot71nIV9L+LaqqvFGuoKJlvE\n LJ7eTpEykNXhYBOW1OYCWSdhWhxawoIzhT3kqNT/kLpY5hrRaTlUbK3ALxW1ypvQAGhAZzbshl6\n xJjEjjl+aOploGvwlOwRESSiqORzfUhUiz50ej/rzq3u/R/taZNpqlGzofK+S71+A8P4MFHKbST\n IJmOMaZ1YZGOZzSsDmvP3GGkcDwCdIeByuGCfB6D0TahdbzeAswFgmfo9wD7Yh49ZHR0R58DdIk\n DxY8=","X-Developer-Key":"i=dlechner@baylibre.com; a=openpgp;\n fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03","X-Mailman-Approved-At":"Thu, 18 Dec 2025 18:18:40 +0100","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.39","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<https://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>","X-Virus-Scanned":"clamav-milter 0.103.8 at phobos.denx.de","X-Virus-Status":"Clean"},"content":"Move all infrasys ops and related functions next to each other in the\nfile for better organization.\n\nGenerally all ops functions are grouped together like this for the other\nops types (apmixedsys, topckgen, etc). However the infrasys functions\nwere mixed in with the other sections making them harder to find. This\nwill also give a logical place to add any future infrasys-specific\nfunctions.\n\nSigned-off-by: David Lechner <dlechner@baylibre.com>\n---\nNote: the diff looks a bit strange because some functions were quite\nsimilar, but this is just cut and paste reordering of 5 functions\nwithout changing any code.\n---\n drivers/clk/mediatek/clk-mtk.c | 200 +++++++++++++++++++++--------------------\n 1 file changed, 101 insertions(+), 99 deletions(-)","diff":"diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c\nindex ffaecbfd306..6ed0f23f685 100644\n--- a/drivers/clk/mediatek/clk-mtk.c\n+++ b/drivers/clk/mediatek/clk-mtk.c\n@@ -424,27 +424,6 @@ static ulong mtk_topckgen_get_factor_rate(struct clk *clk, u32 off)\n \treturn mtk_factor_recalc_rate(fdiv, rate);\n }\n \n-static ulong mtk_infrasys_get_factor_rate(struct clk *clk, u32 off)\n-{\n-\tstruct mtk_clk_priv *priv = dev_get_priv(clk->dev);\n-\tconst struct mtk_fixed_factor *fdiv = &priv->tree->fdivs[off];\n-\tulong rate;\n-\n-\tswitch (fdiv->flags & CLK_PARENT_MASK) {\n-\tcase CLK_PARENT_TOPCKGEN:\n-\t\trate = mtk_clk_find_parent_rate(clk, fdiv->parent,\n-\t\t\t\t\t\tpriv->parent);\n-\t\tbreak;\n-\tcase CLK_PARENT_XTAL:\n-\t\trate = priv->tree->xtal_rate;\n-\t\tbreak;\n-\tdefault:\n-\t\trate = mtk_clk_find_parent_rate(clk, fdiv->parent, NULL);\n-\t}\n-\n-\treturn mtk_factor_recalc_rate(fdiv, rate);\n-}\n-\n static ulong mtk_topckgen_find_parent_rate(struct mtk_clk_priv *priv, struct clk *clk,\n \t\t\t\t\t   const int parent, u16 flags)\n {\n@@ -504,33 +483,6 @@ static ulong mtk_find_parent_rate(struct mtk_clk_priv *priv, struct clk *clk,\n \t}\n }\n \n-static ulong mtk_infrasys_get_mux_rate(struct clk *clk, u32 off)\n-{\n-\tstruct mtk_clk_priv *priv = dev_get_priv(clk->dev);\n-\tconst struct mtk_composite *mux = &priv->tree->muxes[off];\n-\tu32 index;\n-\n-\tindex = readl(priv->base + mux->mux_reg);\n-\tindex &= mux->mux_mask << mux->mux_shift;\n-\tindex = index >> mux->mux_shift;\n-\n-\t/*\n-\t * Parents can be either from TOPCKGEN or INFRACFG,\n-\t * inspect the mtk_parent struct to check the source\n-\t */\n-\tif (mux->flags & CLK_PARENT_MIXED) {\n-\t\tconst struct mtk_parent *parent = &mux->parent_flags[index];\n-\n-\t\treturn mtk_find_parent_rate(priv, clk, parent->id, parent->flags);\n-\t}\n-\n-\tif (mux->parent[index] == CLK_XTAL &&\n-\t    !(priv->tree->flags & CLK_BYPASS_XTAL))\n-\t\treturn priv->tree->xtal_rate;\n-\n-\treturn mtk_find_parent_rate(priv, clk, mux->parent[index], mux->flags);\n-}\n-\n static ulong mtk_topckgen_get_rate(struct clk *clk)\n {\n \tstruct mtk_clk_priv *priv = dev_get_priv(clk->dev);\n@@ -546,42 +498,6 @@ static ulong mtk_topckgen_get_rate(struct clk *clk)\n \t\t\t\t\t\t priv->tree->muxes_offs);\n }\n \n-static ulong mtk_infrasys_get_rate(struct clk *clk)\n-{\n-\tstruct mtk_clk_priv *priv = dev_get_priv(clk->dev);\n-\tint id = mtk_clk_get_id(clk);\n-\tulong rate;\n-\n-\tif (id < priv->tree->fdivs_offs) {\n-\t\trate = priv->tree->fclks[id].rate;\n-\t} else if (id < priv->tree->muxes_offs) {\n-\t\trate = mtk_infrasys_get_factor_rate(clk, id -\n-\t\t\t\t\t\t    priv->tree->fdivs_offs);\n-\t/* No gates defined or ID is a MUX */\n-\t} else if (!priv->tree->gates || id < priv->tree->gates_offs) {\n-\t\trate = mtk_infrasys_get_mux_rate(clk, id -\n-\t\t\t\t\t\t priv->tree->muxes_offs);\n-\t/* Only valid with muxes + gates implementation */\n-\t} else {\n-\t\tstruct udevice *parent = NULL;\n-\t\tconst struct mtk_gate *gate;\n-\n-\t\tgate = &priv->tree->gates[id - priv->tree->gates_offs];\n-\t\tif (gate->flags & CLK_PARENT_TOPCKGEN)\n-\t\t\tparent = priv->parent;\n-\t\t/*\n-\t\t * Assume xtal_rate to be declared if some gates have\n-\t\t * XTAL as parent\n-\t\t */\n-\t\telse if (gate->flags & CLK_PARENT_XTAL)\n-\t\t\treturn priv->tree->xtal_rate;\n-\n-\t\trate = mtk_clk_find_parent_rate(clk, gate->parent, parent);\n-\t}\n-\n-\treturn rate;\n-}\n-\n static int mtk_clk_mux_enable(struct clk *clk)\n {\n \tstruct mtk_clk_priv *priv = dev_get_priv(clk->dev);\n@@ -661,22 +577,23 @@ static int mtk_common_clk_set_parent(struct clk *clk, struct clk *parent)\n \t\t\t&priv->tree->muxes[id - priv->tree->muxes_offs]);\n }\n \n-/* CG functions */\n+/* infrasys functions */\n \n-static int mtk_clk_gate_enable(struct clk *clk)\n+static int mtk_clk_infrasys_enable(struct clk *clk)\n {\n \tstruct mtk_cg_priv *priv = dev_get_priv(clk->dev);\n \tint id = mtk_clk_get_id(clk);\n \tconst struct mtk_gate *gate;\n \n-\tif (id < priv->tree->gates_offs)\n-\t\treturn -EINVAL;\n+\t/* MUX handling */\n+\tif (!priv->tree->gates || id < priv->tree->gates_offs)\n+\t\treturn mtk_clk_mux_enable(clk);\n \n-\tgate = &priv->gates[id - priv->tree->gates_offs];\n+\tgate = &priv->tree->gates[id - priv->tree->gates_offs];\n \treturn mtk_gate_enable(priv->base, gate);\n }\n \n-static int mtk_clk_infrasys_enable(struct clk *clk)\n+static int mtk_clk_infrasys_disable(struct clk *clk)\n {\n \tstruct mtk_cg_priv *priv = dev_get_priv(clk->dev);\n \tint id = mtk_clk_get_id(clk);\n@@ -684,13 +601,99 @@ static int mtk_clk_infrasys_enable(struct clk *clk)\n \n \t/* MUX handling */\n \tif (!priv->tree->gates || id < priv->tree->gates_offs)\n-\t\treturn mtk_clk_mux_enable(clk);\n+\t\treturn mtk_clk_mux_disable(clk);\n \n \tgate = &priv->tree->gates[id - priv->tree->gates_offs];\n-\treturn mtk_gate_enable(priv->base, gate);\n+\treturn mtk_gate_disable(priv->base, gate);\n }\n \n-static int mtk_clk_gate_disable(struct clk *clk)\n+static ulong mtk_infrasys_get_factor_rate(struct clk *clk, u32 off)\n+{\n+\tstruct mtk_clk_priv *priv = dev_get_priv(clk->dev);\n+\tconst struct mtk_fixed_factor *fdiv = &priv->tree->fdivs[off];\n+\tulong rate;\n+\n+\tswitch (fdiv->flags & CLK_PARENT_MASK) {\n+\tcase CLK_PARENT_TOPCKGEN:\n+\t\trate = mtk_clk_find_parent_rate(clk, fdiv->parent,\n+\t\t\t\t\t\tpriv->parent);\n+\t\tbreak;\n+\tcase CLK_PARENT_XTAL:\n+\t\trate = priv->tree->xtal_rate;\n+\t\tbreak;\n+\tdefault:\n+\t\trate = mtk_clk_find_parent_rate(clk, fdiv->parent, NULL);\n+\t}\n+\n+\treturn mtk_factor_recalc_rate(fdiv, rate);\n+}\n+\n+static ulong mtk_infrasys_get_mux_rate(struct clk *clk, u32 off)\n+{\n+\tstruct mtk_clk_priv *priv = dev_get_priv(clk->dev);\n+\tconst struct mtk_composite *mux = &priv->tree->muxes[off];\n+\tu32 index;\n+\n+\tindex = readl(priv->base + mux->mux_reg);\n+\tindex &= mux->mux_mask << mux->mux_shift;\n+\tindex = index >> mux->mux_shift;\n+\n+\t/*\n+\t * Parents can be either from TOPCKGEN or INFRACFG,\n+\t * inspect the mtk_parent struct to check the source\n+\t */\n+\tif (mux->flags & CLK_PARENT_MIXED) {\n+\t\tconst struct mtk_parent *parent = &mux->parent_flags[index];\n+\n+\t\treturn mtk_find_parent_rate(priv, clk, parent->id, parent->flags);\n+\t}\n+\n+\tif (mux->parent[index] == CLK_XTAL &&\n+\t    !(priv->tree->flags & CLK_BYPASS_XTAL))\n+\t\treturn priv->tree->xtal_rate;\n+\n+\treturn mtk_find_parent_rate(priv, clk, mux->parent[index], mux->flags);\n+}\n+\n+static ulong mtk_infrasys_get_rate(struct clk *clk)\n+{\n+\tstruct mtk_clk_priv *priv = dev_get_priv(clk->dev);\n+\tint id = mtk_clk_get_id(clk);\n+\tulong rate;\n+\n+\tif (id < priv->tree->fdivs_offs) {\n+\t\trate = priv->tree->fclks[id].rate;\n+\t} else if (id < priv->tree->muxes_offs) {\n+\t\trate = mtk_infrasys_get_factor_rate(clk, id -\n+\t\t\t\t\t\t    priv->tree->fdivs_offs);\n+\t/* No gates defined or ID is a MUX */\n+\t} else if (!priv->tree->gates || id < priv->tree->gates_offs) {\n+\t\trate = mtk_infrasys_get_mux_rate(clk, id -\n+\t\t\t\t\t\t priv->tree->muxes_offs);\n+\t/* Only valid with muxes + gates implementation */\n+\t} else {\n+\t\tstruct udevice *parent = NULL;\n+\t\tconst struct mtk_gate *gate;\n+\n+\t\tgate = &priv->tree->gates[id - priv->tree->gates_offs];\n+\t\tif (gate->flags & CLK_PARENT_TOPCKGEN)\n+\t\t\tparent = priv->parent;\n+\t\t/*\n+\t\t * Assume xtal_rate to be declared if some gates have\n+\t\t * XTAL as parent\n+\t\t */\n+\t\telse if (gate->flags & CLK_PARENT_XTAL)\n+\t\t\treturn priv->tree->xtal_rate;\n+\n+\t\trate = mtk_clk_find_parent_rate(clk, gate->parent, parent);\n+\t}\n+\n+\treturn rate;\n+}\n+\n+/* CG functions */\n+\n+static int mtk_clk_gate_enable(struct clk *clk)\n {\n \tstruct mtk_cg_priv *priv = dev_get_priv(clk->dev);\n \tint id = mtk_clk_get_id(clk);\n@@ -700,20 +703,19 @@ static int mtk_clk_gate_disable(struct clk *clk)\n \t\treturn -EINVAL;\n \n \tgate = &priv->gates[id - priv->tree->gates_offs];\n-\treturn mtk_gate_disable(priv->base, gate);\n+\treturn mtk_gate_enable(priv->base, gate);\n }\n \n-static int mtk_clk_infrasys_disable(struct clk *clk)\n+static int mtk_clk_gate_disable(struct clk *clk)\n {\n \tstruct mtk_cg_priv *priv = dev_get_priv(clk->dev);\n \tint id = mtk_clk_get_id(clk);\n \tconst struct mtk_gate *gate;\n \n-\t/* MUX handling */\n-\tif (!priv->tree->gates || id < priv->tree->gates_offs)\n-\t\treturn mtk_clk_mux_disable(clk);\n+\tif (id < priv->tree->gates_offs)\n+\t\treturn -EINVAL;\n \n-\tgate = &priv->tree->gates[id - priv->tree->gates_offs];\n+\tgate = &priv->gates[id - priv->tree->gates_offs];\n \treturn mtk_gate_disable(priv->base, gate);\n }\n \n","prefixes":["4/8"]}