From patchwork Tue May 12 17:07:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 245675 List-Id: U-Boot discussion From: marex at denx.de (Marek Vasut) Date: Tue, 12 May 2020 19:07:06 +0200 Subject: [PATCH 1/2] [RFC] ARM: stm32: Make bsec available in SPL Message-ID: <20200512170707.367351-1-marex@denx.de> Make the bsec driver available both in SPL and in U-Boot proper to make it possible to read out the SoC type (A/C/D/F) and thus to determine the MPU PLL configuration (650/800 MHz). Signed-off-by: Marek Vasut Cc: Patrick Delaunay Cc: Patrice Chotard --- arch/arm/mach-stm32mp/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-stm32mp/Makefile b/arch/arm/mach-stm32mp/Makefile index eee39c27c3..42c0206249 100644 --- a/arch/arm/mach-stm32mp/Makefile +++ b/arch/arm/mach-stm32mp/Makefile @@ -3,6 +3,7 @@ # Copyright (C) 2018, STMicroelectronics - All Rights Reserved # +obj-y += bsec.o obj-y += cpu.o obj-y += dram_init.o obj-y += syscon.o @@ -10,7 +11,6 @@ obj-y += syscon.o ifdef CONFIG_SPL_BUILD obj-y += spl.o else -obj-y += bsec.o obj-$(CONFIG_CMD_STM32KEY) += cmd_stm32key.o obj-$(CONFIG_ARMV7_PSCI) += psci.o endif From patchwork Tue May 12 17:07:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 245676 List-Id: U-Boot discussion From: marex at denx.de (Marek Vasut) Date: Tue, 12 May 2020 19:07:07 +0200 Subject: [PATCH 2/2] [RFC] clk: stm32mp1: Handle SoC speed grade configs In-Reply-To: <20200512170707.367351-1-marex@denx.de> References: <20200512170707.367351-1-marex@denx.de> Message-ID: <20200512170707.367351-2-marex@denx.de> 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 Cc: Patrick Delaunay Cc: Patrice Chotard --- 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 +#include #include #include #include @@ -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) {