All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick DELAUNAY <patrick.delaunay@st.com>
To: u-boot@lists.denx.de
Subject: [PATCH 2/2] [RFC] clk: stm32mp1: Handle SoC speed grade configs
Date: Wed, 13 May 2020 09:12:33 +0000	[thread overview]
Message-ID: <85d6188d564244249824619d11d7a718@SFHDAG6NODE3.st.com> (raw)
In-Reply-To: <20200512170707.367351-2-marex@denx.de>

Dear Marek,

> From: Marek Vasut <marex@denx.de>
> Sent: mardi 12 mai 2020 19:07
> 
> There are two speed grades of the STM32MP1, the A/C and D/F, the former can
> run up to 650 MHz, the later at up to 800 MHz. Allow specifying PLL config for
> both in the DT, so that it is possible to cater for boards which can be populated
> with either SoC.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Patrick Delaunay <patrick.delaunay@st.com>
> Cc: Patrice Chotard <patrice.chotard@st.com>
> ---
>  drivers/clk/clk_stm32mp1.c | 30 ++++++++++++++++++++++++++----
>  1 file changed, 26 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/clk/clk_stm32mp1.c b/drivers/clk/clk_stm32mp1.c index
> 50df8425bf..cecc06638e 100644
> --- a/drivers/clk/clk_stm32mp1.c
> +++ b/drivers/clk/clk_stm32mp1.c
> @@ -4,6 +4,7 @@
>   */
> 
>  #include <common.h>
> +#include <asm/arch/sys_proto.h>
>  #include <clk-uclass.h>
>  #include <div64.h>
>  #include <dm.h>
> @@ -1464,6 +1465,12 @@ static void pll_csg(struct stm32mp1_clk_priv *priv, int
> pll_id, u32 *csg)
>  	setbits_le32(priv->base + pll[pll_id].pllxcr, RCC_PLLNCR_SSCG_CTRL);
> }
> 
> +static __maybe_unused int stm32mp1_is_df(void) {
> +	/* ID bit 7 is set on 15x{D,F}xx and not on 15x{A,C}xx */
> +	return get_cpu_type() & BIT(7);
> +}
> +
>  static  __maybe_unused int pll_set_rate(struct udevice *dev,
>  					int pll_id,
>  					int div_id,
> @@ -1491,8 +1498,13 @@ static  __maybe_unused int pll_set_rate(struct
> udevice *dev,
> 
>  	ret = ofnode_read_u32_array(plloff, "cfg",
>  				    pllcfg, PLLCFG_NB);
> -	if (ret < 0)
> -		return -FDT_ERR_NOTFOUND;
> +	if (ret < 0) {
> +		ret = ofnode_read_u32_array(plloff,
> +				stm32mp1_is_df() ? "cfg-df" : "cfg-ac",
> +				pllcfg, PLLCFG_NB);
> +		if (ret < 0)
> +			return -FDT_ERR_NOTFOUND;
> +	}
> 
>  	fck_ref = pll_get_fref_ck(priv, pll_id);
> 
> @@ -1687,8 +1699,13 @@ static int stm32mp1_clktree(struct udevice *dev)
>  		ret = ofnode_read_u32_array(plloff[i], "cfg",
>  					    pllcfg[i], PLLCFG_NB);
>  		if (ret < 0) {
> -			debug("field cfg invalid: error %d\n", ret);
> -			return -FDT_ERR_NOTFOUND;
> +			ret = ofnode_read_u32_array(plloff[i],
> +					stm32mp1_is_df() ? "cfg-df" : "cfg-ac",
> +					pllcfg[i], PLLCFG_NB);
> +			if (ret < 0) {
> +				debug("field cfg invalid: error %d\n", ret);
> +				return -FDT_ERR_NOTFOUND;
> +			}
>  		}
>  	}
> 
> @@ -1783,6 +1800,11 @@ static int stm32mp1_clktree(struct udevice *dev)
>  			continue;
> 
>  		fracv = ofnode_read_u32_default(plloff[i], "frac", 0);
> +		if (!fracv) {
> +			fracv = ofnode_read_u32_default(plloff[i],
> +					stm32mp1_is_df() ? "frac-df" : "frac-ac",
> +					0);
> +		}
>  		pll_config(priv, i, pllcfg[i], fracv);
>  		ret = ofnode_read_u32_array(plloff[i], "csg", csg, PLLCSG_NB);
>  		if (!ret) {
> --
> 2.25.1

The 2 speed grade will be supported with OPP information and HW support,present in kernel device tree (upstream in progress) 

I port this patch in U-Boot with:
http://patchwork.ozlabs.org/project/uboot/patch/20200421171123.2.Id3620aec4deb419f1c1a5876b865556e86d3aba1 at changeid/


Please check the full serie
stm32mp1: use OPP information for PLL1 settings in SPL
http://patchwork.ozlabs.org/project/uboot/list/?series=171767

PLL1 settings are now computed in SPL and no more read from DT.

Regards

Patrick

  reply	other threads:[~2020-05-13  9:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-12 17:07 [PATCH 1/2] [RFC] ARM: stm32: Make bsec available in SPL Marek Vasut
2020-05-12 17:07 ` [PATCH 2/2] [RFC] clk: stm32mp1: Handle SoC speed grade configs Marek Vasut
2020-05-13  9:12   ` Patrick DELAUNAY [this message]
2020-05-13 10:52     ` Marek Vasut
2020-05-13 12:23       ` Patrick DELAUNAY
2020-05-13 12:38         ` Marek Vasut
2020-06-14 15:23     ` Marek Vasut
2020-05-13  9:05 ` [PATCH 1/2] [RFC] ARM: stm32: Make bsec available in SPL Patrick DELAUNAY

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=85d6188d564244249824619d11d7a718@SFHDAG6NODE3.st.com \
    --to=patrick.delaunay@st.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.