mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Cercueil <paul@crapouillou.net>
To: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
Cc: mturquette@baylibre.com, sboyd@kernel.org, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, zhouyu@wanyeetech.com,
	linux-mips@vger.kernel.org, linux-clk@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/6] clk: ingenic: Make PLL clock enable_bit and stable_bit optional
Date: Thu, 27 Oct 2022 13:39:17 +0100	[thread overview]
Message-ID: <HHWEKR.W3ZGGGZ709H01@crapouillou.net> (raw)
In-Reply-To: <20221026194345.243007-3-aidanmacdonald.0x0@gmail.com>

Hi Aidan,

Le mer. 26 oct. 2022 à 20:43:41 +0100, Aidan MacDonald 
<aidanmacdonald.0x0@gmail.com> a écrit :
> When the enable bit is undefined, the clock is assumed to be always
> on and enable/disable is a no-op. When the stable bit is undefined,
> the PLL stable check is a no-op.
> 
> Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>

Reviewed-by: Paul Cercueil <paul@crapouillou.net>

Cheers,
-Paul

> ---
>  drivers/clk/ingenic/cgu.c | 14 +++++++++++++-
>  drivers/clk/ingenic/cgu.h | 10 ++++++----
>  2 files changed, 19 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/clk/ingenic/cgu.c b/drivers/clk/ingenic/cgu.c
> index 3481129114b1..aea01b6b2764 100644
> --- a/drivers/clk/ingenic/cgu.c
> +++ b/drivers/clk/ingenic/cgu.c
> @@ -189,6 +189,9 @@ static inline int ingenic_pll_check_stable(struct 
> ingenic_cgu *cgu,
>  {
>  	u32 ctl;
> 
> +	if (pll_info->stable_bit < 0)
> +		return 0;
> +
>  	return readl_poll_timeout(cgu->base + pll_info->reg, ctl,
>  				  ctl & BIT(pll_info->stable_bit),
>  				  0, 100 * USEC_PER_MSEC);
> @@ -230,7 +233,7 @@ ingenic_pll_set_rate(struct clk_hw *hw, unsigned 
> long req_rate,
>  	writel(ctl, cgu->base + pll_info->reg);
> 
>  	/* If the PLL is enabled, verify that it's stable */
> -	if (ctl & BIT(pll_info->enable_bit))
> +	if (pll_info->enable_bit >= 0 && (ctl & BIT(pll_info->enable_bit)))
>  		ret = ingenic_pll_check_stable(cgu, pll_info);
> 
>  	spin_unlock_irqrestore(&cgu->lock, flags);
> @@ -248,6 +251,9 @@ static int ingenic_pll_enable(struct clk_hw *hw)
>  	int ret;
>  	u32 ctl;
> 
> +	if (pll_info->enable_bit < 0)
> +		return 0;
> +
>  	spin_lock_irqsave(&cgu->lock, flags);
>  	if (pll_info->bypass_bit >= 0) {
>  		ctl = readl(cgu->base + pll_info->bypass_reg);
> @@ -278,6 +284,9 @@ static void ingenic_pll_disable(struct clk_hw *hw)
>  	unsigned long flags;
>  	u32 ctl;
> 
> +	if (pll_info->enable_bit < 0)
> +		return;
> +
>  	spin_lock_irqsave(&cgu->lock, flags);
>  	ctl = readl(cgu->base + pll_info->reg);
> 
> @@ -295,6 +304,9 @@ static int ingenic_pll_is_enabled(struct clk_hw 
> *hw)
>  	const struct ingenic_cgu_pll_info *pll_info = &clk_info->pll;
>  	u32 ctl;
> 
> +	if (pll_info->enable_bit < 0)
> +		return true;
> +
>  	ctl = readl(cgu->base + pll_info->reg);
> 
>  	return !!(ctl & BIT(pll_info->enable_bit));
> diff --git a/drivers/clk/ingenic/cgu.h b/drivers/clk/ingenic/cgu.h
> index 567142b584bb..a5e44ca7f969 100644
> --- a/drivers/clk/ingenic/cgu.h
> +++ b/drivers/clk/ingenic/cgu.h
> @@ -42,8 +42,10 @@
>   * @bypass_reg: the offset of the bypass control register within the 
> CGU
>   * @bypass_bit: the index of the bypass bit in the PLL control 
> register, or
>   *              -1 if there is no bypass bit
> - * @enable_bit: the index of the enable bit in the PLL control 
> register
> - * @stable_bit: the index of the stable bit in the PLL control 
> register
> + * @enable_bit: the index of the enable bit in the PLL control 
> register, or
> + *		-1 if there is no enable bit (ie, the PLL is always on)
> + * @stable_bit: the index of the stable bit in the PLL control 
> register, or
> + *		-1 if there is no stable bit
>   */
>  struct ingenic_cgu_pll_info {
>  	unsigned reg;
> @@ -54,8 +56,8 @@ struct ingenic_cgu_pll_info {
>  	u8 od_shift, od_bits, od_max;
>  	unsigned bypass_reg;
>  	s8 bypass_bit;
> -	u8 enable_bit;
> -	u8 stable_bit;
> +	s8 enable_bit;
> +	s8 stable_bit;
>  	void (*calc_m_n_od)(const struct ingenic_cgu_pll_info *pll_info,
>  			    unsigned long rate, unsigned long parent_rate,
>  			    unsigned int *m, unsigned int *n, unsigned int *od);
> --
> 2.38.1
> 



  reply	other threads:[~2022-10-27 12:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-26 19:43 [PATCH v2 0/6] Add support for X1000 audio clocks Aidan MacDonald
2022-10-26 19:43 ` [PATCH v2 1/6] clk: ingenic: Make PLL clock "od" field optional Aidan MacDonald
2022-10-27 12:38   ` Paul Cercueil
2022-10-27 21:40     ` Aidan MacDonald
2022-10-27 21:51       ` Stephen Boyd
2022-10-27 18:59   ` Stephen Boyd
2022-10-26 19:43 ` [PATCH v2 2/6] clk: ingenic: Make PLL clock enable_bit and stable_bit optional Aidan MacDonald
2022-10-27 12:39   ` Paul Cercueil [this message]
2022-10-27 18:59   ` Stephen Boyd
2022-10-26 19:43 ` [PATCH v2 3/6] clk: ingenic: Add .set_rate_hook() for PLL clocks Aidan MacDonald
2022-10-27 12:40   ` Paul Cercueil
2022-10-27 18:59   ` Stephen Boyd
2022-10-26 19:43 ` [PATCH v2 4/6] dt-bindings: ingenic,x1000-cgu: Add audio clocks Aidan MacDonald
2022-10-27 18:59   ` Stephen Boyd
2022-10-26 19:43 ` [PATCH v2 5/6] clk: ingenic: Add X1000 " Aidan MacDonald
2022-10-27 12:43   ` Paul Cercueil
2022-10-27 18:59   ` Stephen Boyd
2022-10-26 19:43 ` [PATCH v2 6/6] clk: ingenic: Minor cosmetic fixups for X1000 Aidan MacDonald
2022-10-27 12:44   ` Paul Cercueil
2022-10-27 19:00   ` Stephen Boyd

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=HHWEKR.W3ZGGGZ709H01@crapouillou.net \
    --to=paul@crapouillou.net \
    --cc=aidanmacdonald.0x0@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=zhouyu@wanyeetech.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

all inboxes | Powered by JetHome®