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 6B186ECAAD1 for ; Thu, 1 Sep 2022 00:27:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 64B8684223; Thu, 1 Sep 2022 02:27:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 7E0FB849F1; Thu, 1 Sep 2022 02:27:07 +0200 (CEST) Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B9C5E841B7 for ; Thu, 1 Sep 2022 02:27:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=daniel@makrotopia.org Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1oTY2w-0004EX-18; Thu, 01 Sep 2022 02:27:03 +0200 Date: Thu, 1 Sep 2022 01:26:59 +0100 From: Daniel Golle To: Weijie Gao Cc: u-boot@lists.denx.de, GSS_MTK_Uboot_upstream , Lukasz Majewski , Sean Anderson Subject: Re: [PATCH v2 22/32] clk: mediatek: add CLK_BYPASS_XTAL flag to allow bypassing searching clock parent of xtal clock Message-ID: References: <5d9486c122d37e8fb009c562a5def66add2d171e.1661941661.git.weijie.gao@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5d9486c122d37e8fb009c562a5def66add2d171e.1661941661.git.weijie.gao@mediatek.com> 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 Wed, Aug 31, 2022 at 07:04:59PM +0800, Weijie Gao wrote: > The mtk clock framework in u-boot uses array index for searching clock > parent (kernel uses strings for search), so we need to specify a special > clock with ID=0 for CLK_XTAL in u-boot. > > In the mt7622/mt7629 clock tree, the clocks with ID=0 never call > mtk_topckgen_get_mux_rate, adn return xtal clock directly. This what we > expected. > > However for newer chips, they may have some clocks with ID=0 not > representing the xtal clock and still needs mtk_topckgen_get_mux_rate be > called. Current logic will make entire clock driver not working. > > This patch adds a flag to indicate that whether a clock driver needs clocks > with ID=0 to call mtk_topckgen_get_mux_rate. Tested on Bananapi BPi-R3 (MT7986A). Tested-by: Daniel Golle > > Reviewed-by: Simon Glass > Signed-off-by: Weijie Gao > --- > v2 changes: > Add comment for flags > Fix the if condition of CLK_BYPASS_XTAL > --- > drivers/clk/mediatek/clk-mtk.c | 4 +++- > drivers/clk/mediatek/clk-mtk.h | 6 ++++++ > 2 files changed, 9 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c > index d43b8a0648..7d145f4975 100644 > --- a/drivers/clk/mediatek/clk-mtk.c > +++ b/drivers/clk/mediatek/clk-mtk.c > @@ -319,7 +319,9 @@ static ulong mtk_topckgen_get_mux_rate(struct clk *clk, u32 off) > index &= mux->mux_mask << mux->mux_shift; > index = index >> mux->mux_shift; > > - if (mux->parent[index]) > + if (mux->parent[index] > 0 || > + (mux->parent[index] == CLK_XTAL && > + priv->tree->flags & CLK_BYPASS_XTAL)) > return mtk_clk_find_parent_rate(clk, mux->parent[index], > NULL); > > diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h > index 95a23d14a8..e0c5550c80 100644 > --- a/drivers/clk/mediatek/clk-mtk.h > +++ b/drivers/clk/mediatek/clk-mtk.h > @@ -11,6 +11,11 @@ > #define CLK_XTAL 0 > #define MHZ (1000 * 1000) > > +/* flags in struct mtk_clk_tree */ > + > +/* clk id == 0 doesn't mean it's xtal clk */ > +#define CLK_BYPASS_XTAL BIT(0) > + > #define HAVE_RST_BAR BIT(0) > #define CLK_DOMAIN_SCPSYS BIT(0) > #define CLK_MUX_SETCLR_UPD BIT(1) > @@ -197,6 +202,7 @@ struct mtk_clk_tree { > const struct mtk_fixed_clk *fclks; > const struct mtk_fixed_factor *fdivs; > const struct mtk_composite *muxes; > + u32 flags; > }; > > struct mtk_clk_priv { > -- > 2.17.1 >