public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Daniel Golle <daniel@makrotopia.org>
To: Weijie Gao <weijie.gao@mediatek.com>
Cc: u-boot@lists.denx.de,
	GSS_MTK_Uboot_upstream <GSS_MTK_Uboot_upstream@mediatek.com>,
	Lukasz Majewski <lukma@denx.de>,
	Sean Anderson <seanga2@gmail.com>
Subject: Re: [PATCH v2 22/32] clk: mediatek: add CLK_BYPASS_XTAL flag to allow bypassing searching clock parent of xtal clock
Date: Thu, 1 Sep 2022 01:26:59 +0100	[thread overview]
Message-ID: <Yw/8U0JsSUYL32q3@makrotopia.org> (raw)
In-Reply-To: <5d9486c122d37e8fb009c562a5def66add2d171e.1661941661.git.weijie.gao@mediatek.com>

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 <daniel@makrotopia.org>

> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
> ---
> 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
> 

  reply	other threads:[~2022-09-01  0:27 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-31 11:00 [PATCH v2 00/32] Add support for MediaTek MT7981/MT7986 SoCs - v2 Weijie Gao
2022-08-31 11:00 ` [PATCH v2 01/32] arm: mediatek: add support for MediaTek MT7986 SoC Weijie Gao
2022-08-31 13:46   ` Simon Glass
2022-09-01  0:09   ` Daniel Golle
2022-08-31 11:00 ` [PATCH v2 02/32] arm: mediatek: add support for MediaTek MT7981 SoC Weijie Gao
2022-08-31 13:46   ` Simon Glass
2022-08-31 11:00 ` [PATCH v2 03/32] board: mediatek: add MT7986 reference boards Weijie Gao
2022-08-31 11:00 ` [PATCH v2 04/32] board: mediatek: add MT7981 " Weijie Gao
2022-08-31 13:46   ` Simon Glass
2022-08-31 11:04 ` [PATCH v2 05/32] mmc: mediatek: add support for MediaTek MT7891/MT7986 SoCs Weijie Gao
2022-09-01  0:10   ` Daniel Golle
2022-08-31 11:04 ` [PATCH v2 06/32] net: mediatek: use a struct to cover variations of all SoCs Weijie Gao
2022-09-01  0:20   ` Daniel Golle
2022-08-31 11:04 ` [PATCH v2 07/32] net: mediatek: stop using bitfileds for DMA descriptors Weijie Gao
2022-09-01  0:20   ` Daniel Golle
2022-08-31 11:04 ` [PATCH v2 08/32] net: mediatek: add support for PDMA v2 Weijie Gao
2022-09-01  0:22   ` Daniel Golle
2022-08-31 11:04 ` [PATCH v2 09/32] net: mediatek: add support for MediaTek MT7981/MT7986 Weijie Gao
2022-09-01  0:22   ` Daniel Golle
2022-08-31 11:04 ` [PATCH v2 10/32] serial: mtk: add support for using dynamic baud clock souce Weijie Gao
2022-09-01  0:22   ` Daniel Golle
2022-08-31 11:04 ` [PATCH v2 11/32] arm: dts: mt7622: force high-speed mode for uart Weijie Gao
2022-09-01  0:23   ` Daniel Golle
2022-08-31 11:04 ` [PATCH v2 12/32] pwm: mtk: add support for MediaTek MT7986 SoC Weijie Gao
2022-08-31 11:04 ` [PATCH v2 13/32] pwm: mtk: add support for MediaTek MT7981 SoC Weijie Gao
2022-08-31 11:04 ` [PATCH v2 14/32] timer: mtk: add support for MediaTek MT7981/MT7986 SoCs Weijie Gao
2022-09-01  0:24   ` Daniel Golle
2022-08-31 11:04 ` [PATCH v2 15/32] watchdog: mediatek: add support for MediaTek MT7986 SoC Weijie Gao
2022-09-01  0:25   ` Daniel Golle
2022-08-31 11:04 ` [PATCH v2 16/32] spi: add support for MediaTek spi-mem controller Weijie Gao
2022-09-01  0:25   ` Daniel Golle
2022-08-31 11:04 ` [PATCH v2 17/32] i2c: add support for MediaTek I2C interface Weijie Gao
2022-08-31 11:04 ` [PATCH v2 18/32] arm: dts: mt7622: add i2c support Weijie Gao
2022-08-31 11:04 ` [PATCH v2 19/32] dt-bindings: pinctrl: mediatek: add a header for common pinconf parameters Weijie Gao
2022-08-31 11:04 ` [PATCH v2 20/32] pinctrl: mediatek: add pinctrl driver for MT7981 SoC Weijie Gao
2022-08-31 11:04 ` [PATCH v2 21/32] pinctrl: mediatek: add pinctrl driver for MT7986 SoC Weijie Gao
2022-09-01  0:26   ` Daniel Golle
2022-08-31 11:04 ` [PATCH v2 22/32] clk: mediatek: add CLK_BYPASS_XTAL flag to allow bypassing searching clock parent of xtal clock Weijie Gao
2022-09-01  0:26   ` Daniel Golle [this message]
2022-08-31 11:05 ` [PATCH v2 23/32] clk: mediatek: add support to configure clock driver parent Weijie Gao
2022-09-01  0:27   ` Daniel Golle
2022-08-31 11:05 ` [PATCH v2 24/32] clk: mediatek: add infrasys clock mux support Weijie Gao
2022-09-01  0:27   ` Daniel Golle
2022-08-31 11:05 ` [PATCH v2 25/32] clk: mediatek: add CLK_XTAL support for clock driver Weijie Gao
2022-08-31 13:46   ` Simon Glass
2022-09-01  0:27   ` Daniel Golle
2022-08-31 11:05 ` [PATCH v2 26/32] clk: mediatek: add clock driver support for MediaTek MT7986 SoC Weijie Gao
2022-09-01  0:28   ` Daniel Golle
2022-08-31 11:05 ` [PATCH v2 27/32] clk: mediatek: add clock driver support for MediaTek MT7981 SoC Weijie Gao
2022-08-31 11:05 ` [PATCH v2 28/32] cpu: add basic cpu driver for MediaTek ARM chips Weijie Gao
2022-08-31 13:46   ` Simon Glass
2022-09-01  3:00     ` Weijie Gao
2022-09-01  0:28   ` Daniel Golle
2022-08-31 11:05 ` [PATCH v2 29/32] tools: mtk_image: split gfh header verification into a new function Weijie Gao
2022-09-01  0:31   ` Daniel Golle
2022-08-31 11:05 ` [PATCH v2 30/32] tools: mtk_image: split the code of generating NAND header into a new file Weijie Gao
2022-09-01  0:32   ` Daniel Golle
2022-08-31 11:05 ` [PATCH v2 31/32] tools: mtk_image: add support for nand headers used by newer chips Weijie Gao
2022-09-01  0:32   ` Daniel Golle
2022-08-31 11:05 ` [PATCH v2 32/32] MAINTAINERS: update maintainer for MediaTek ARM platform Weijie Gao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yw/8U0JsSUYL32q3@makrotopia.org \
    --to=daniel@makrotopia.org \
    --cc=GSS_MTK_Uboot_upstream@mediatek.com \
    --cc=lukma@denx.de \
    --cc=seanga2@gmail.com \
    --cc=u-boot@lists.denx.de \
    --cc=weijie.gao@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox