Skip to contentSkip to conversation

stm32mp1: use OPP information for PLL1 settings in SPL

PATCH New Patrick Delaunay 2 participants 15 messages May 25, 2020 – Jul 3, 2020

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v2 cover stm32mp1: use OPP information for PLL1 settings in SPL

This serie allows to switch the CPU frequency to the max frequency supported in OPP device tree nodes and supported by STM32MP SOC (800MHz is supported by STM32MP15xD and STM32MP15xF).

Board also increases the VDDCore voltage to support this new operation point.

This V2 version of [1] is rebased on top of custodian stm32 and solve issue with dh_stm32mp1 (because spl.c was shared between stm32mp1 and dh_stm32mp1).

[1] http://patchwork.ozlabs.org/project/uboot/list/?series=171767&state=*

Changes in v2:
- add stpmic1_init function, called in board_early_init_f for dh_stm32mp1 board support (and no more use spl.c from stm32mp1)
- remove CONFIG_SPL_BOARD_INIT
- stmpic_buck1_set is a static function called in stpmic1_init (with new parameter for vddcore value)
- update also dh_stm32mp1 board
- update stm32mp15xx-dhcor and dhcom device tree
- NEW: merge spl.c and board.c to avoid a file with only one function

Patrick Delaunay (9):
arm: stm32mp: spl: add bsec driver in SPL
ARM: dts: stm32: add cpufreq support on stm32mp15x
board: st: create common file stpmic1.c
stm32mp1: clk: configure pll1 with OPP
arm: stm32mp: add weak function to save vddcore
board: st: stpmic1: add function stpmic1_init
board: stm32mp1: update vddcore in SPL
ARM: dts: stm32mp1: use OPP information for PLL1 settings in SPL
board: stm32mp1: move the function board_debug_uart_init in spl.c

 arch/arm/dts/stm32mp15-u-boot.dtsi            |  12 +-
 arch/arm/dts/stm32mp151.dtsi                  |  21 ++
 arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi      |   9 -
 arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi      |   9 -
 arch/arm/dts/stm32mp157c-ed1.dts              |   8 +
 arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi    |   9 -
 arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi    |   9 -
 arch/arm/dts/stm32mp15xx-dkx.dtsi             |   8 +
 arch/arm/mach-stm32mp/Kconfig                 |   1 -
 arch/arm/mach-stm32mp/Makefile                |   2 +-
 arch/arm/mach-stm32mp/bsec.c                  |  11 +-
 .../arm/mach-stm32mp/include/mach/sys_proto.h |   3 +
 board/dhelectronics/dh_stm32mp1/Makefile      |   6 +-
 board/dhelectronics/dh_stm32mp1/board.c       |  10 +
 board/st/common/Makefile                      |   1 +
 .../st/{stm32mp1/board.c => common/stpmic1.c} |  82 +++--
 board/st/common/stpmic1.h                     |   6 +
 board/st/stm32mp1/Makefile                    |   2 -
 board/st/stm32mp1/spl.c                       |  72 +++--
 board/st/stm32mp1/stm32mp1.c                  |   6 +
 configs/stm32mp15_basic_defconfig             |   1 +
 .../clock/st,stm32mp1.txt                     |   4 +
 drivers/clk/clk_stm32mp1.c                    | 295 ++++++++++++++++--
 23 files changed, 445 insertions(+), 142 deletions(-)
 rename board/st/{stm32mp1/board.c => common/stpmic1.c} (74%)
 create mode 100644 board/st/common/stpmic1.h
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/9 arm: stm32mp: spl: add bsec driver in SPL

Add the bsec driver in SPL, as it is needed by SOC part number detection to found the supported OPP.

---

Changes in v2: None

 arch/arm/dts/stm32mp15-u-boot.dtsi |  2 +-
 arch/arm/mach-stm32mp/Makefile     |  2 +-
 arch/arm/mach-stm32mp/bsec.c       | 11 ++++++-----
 3 files changed, 8 insertions(+), 7 deletions(-)
arch/arm/dts/stm32mp15-u-boot.dtsi +1 -1
index 1279589a56..a0d971ad88 100644
@@ -65,7 +65,7 @@
 };
 
 &bsec {
-	u-boot,dm-pre-proper;
+	u-boot,dm-pre-reloc;
 };
 
 &clk_csi {
arch/arm/mach-stm32mp/Makefile +1 -1
index 66bb8cf92f..c8aa24d489 100644
@@ -6,12 +6,12 @@
 obj-y += cpu.o
 obj-y += dram_init.o
 obj-y += syscon.o
+obj-y += bsec.o
 
 ifdef CONFIG_SPL_BUILD
 obj-y += spl.o
 else
 obj-$(CONFIG_CMD_STM32PROG) += cmd_stm32prog/
-obj-y += bsec.o
 obj-$(CONFIG_CMD_STM32KEY) += cmd_stm32key.o
 obj-$(CONFIG_ARMV7_PSCI) += psci.o
 obj-$(CONFIG_TFABOOT) += boot_params.o
arch/arm/mach-stm32mp/bsec.c +6 -5
index 0d5850b4a9..98a950c640 100644
@@ -473,20 +473,23 @@ static int stm32mp_bsec_ofdata_to_platdata(struct udevice *dev)
 	return 0;
 }
 
-#ifndef CONFIG_TFABOOT
 static int stm32mp_bsec_probe(struct udevice *dev)
 {
+#if !defined(CONFIG_TFABOOT) && !defined(CONFIG_SPL_BUILD)
 	int otp;
 	struct stm32mp_bsec_platdata *plat = dev_get_platdata(dev);
 
-	/* update unlocked shadow for OTP cleared by the rom code */
+	/*
+	 * update unlocked shadow for OTP cleared by the rom code
+	 * only executed in U-Boot proper when TF-A is not used
+	 */
 	for (otp = 57; otp <= BSEC_OTP_MAX_VALUE; otp++)
 		if (!bsec_read_SR_lock(plat->base, otp))
 			bsec_shadow_register(plat->base, otp);
+#endif
 
 	return 0;
 }
-#endif
 
 static const struct udevice_id stm32mp_bsec_ids[] = {
 	{ .compatible = "st,stm32mp15-bsec" },
@@ -500,7 +503,5 @@ U_BOOT_DRIVER(stm32mp_bsec) = {
 	.ofdata_to_platdata = stm32mp_bsec_ofdata_to_platdata,
 	.platdata_auto_alloc_size = sizeof(struct stm32mp_bsec_platdata),
 	.ops = &stm32mp_bsec_ops,
-#ifndef CONFIG_TFABOOT
 	.probe = stm32mp_bsec_probe,
-#endif
 };
Signature · 1 line
2.17.1
#2 lore raw

PATCH v2 1/9 arm: stm32mp: spl: add bsec driver in SPL

HI Patrick

Quoted 77 lines · Patrick Delaunay

Add the bsec driver in SPL, as it is needed by SOC part number detection to found the supported OPP.

---

Changes in v2: None

 arch/arm/dts/stm32mp15-u-boot.dtsi |  2 +-
 arch/arm/mach-stm32mp/Makefile     |  2 +-
 arch/arm/mach-stm32mp/bsec.c       | 11 ++++++-----
 3 files changed, 8 insertions(+), 7 deletions(-)
arch/arm/dts/stm32mp15-u-boot.dtsi +1 -1
index 1279589a56..a0d971ad88 100644
@@ -65,7 +65,7 @@
 };
 
 &bsec {
-	u-boot,dm-pre-proper;
+	u-boot,dm-pre-reloc;
 };
 
 &clk_csi {
arch/arm/mach-stm32mp/Makefile +1 -1
index 66bb8cf92f..c8aa24d489 100644
@@ -6,12 +6,12 @@
 obj-y += cpu.o
 obj-y += dram_init.o
 obj-y += syscon.o
+obj-y += bsec.o
 
 ifdef CONFIG_SPL_BUILD
 obj-y += spl.o
 else
 obj-$(CONFIG_CMD_STM32PROG) += cmd_stm32prog/
-obj-y += bsec.o
 obj-$(CONFIG_CMD_STM32KEY) += cmd_stm32key.o
 obj-$(CONFIG_ARMV7_PSCI) += psci.o
 obj-$(CONFIG_TFABOOT) += boot_params.o
arch/arm/mach-stm32mp/bsec.c +6 -3
index 0d5850b4a9..98a950c640 100644
@@ -473,20 +473,23 @@ static int stm32mp_bsec_ofdata_to_platdata(struct udevice *dev)
 	return 0;
 }
 
-#ifndef CONFIG_TFABOOT
 static int stm32mp_bsec_probe(struct udevice *dev)
 {
+#if !defined(CONFIG_TFABOOT) && !defined(CONFIG_SPL_BUILD)
 	int otp;
 	struct stm32mp_bsec_platdata *plat = dev_get_platdata(dev);
 
-	/* update unlocked shadow for OTP cleared by the rom code */
+	/*
+	 * update unlocked shadow for OTP cleared by the rom code
+	 * only executed in U-Boot proper when TF-A is not used
+	 */
 	for (otp = 57; otp <= BSEC_OTP_MAX_VALUE; otp++)
 		if (!bsec_read_SR_lock(plat->base, otp))
 			bsec_shadow_register(plat->base, otp);
+#endif
 
 	return 0;
 }
-#endif
 
 static const struct udevice_id stm32mp_bsec_ids[] = {
 	{ .compatible = "st,stm32mp15-bsec" },

arch/arm/mach-stm32mp/bsec.c U_BOOT_DRIVER(stm32mp_bsec) = { · line 507

Quoted 7 lines
arch/arm/mach-stm32mp/bsec.c +0 -2
@@ -500,7 +503,5 @@ U_BOOT_DRIVER(stm32mp_bsec) = {
 	.ofdata_to_platdata = stm32mp_bsec_ofdata_to_platdata,
 	.platdata_auto_alloc_size = sizeof(struct stm32mp_bsec_platdata),
 	.ops = &stm32mp_bsec_ops,
-#ifndef CONFIG_TFABOOT
 	.probe = stm32mp_bsec_probe,
-#endif
 };

Thanks

#3 lore raw

PATCH v2 2/9 ARM: dts: stm32: add cpufreq support on stm32mp15x

In reply to Patrick Delaunay

This commit adds cpufreq support on stm32mp15x SOC. STM32 cpufreq uses operating points V2 bindings (no legacy). Nvmem cells have to be used to know the chip version and then which OPPs are available. Note that STM32 cpufreq driver is mainly based on "cpufreq-dt" driver.

---

Changes in v2: None

 arch/arm/dts/stm32mp151.dtsi      | 21 +++++++++++++++++++++
 arch/arm/dts/stm32mp157c-ed1.dts  |  8 ++++++++
 arch/arm/dts/stm32mp15xx-dkx.dtsi |  8 ++++++++
 3 files changed, 37 insertions(+)
arch/arm/dts/stm32mp151.dtsi +21 -0
index 75d2c0d296..d5216a1831 100644
@@ -20,6 +20,24 @@
 			clock-frequency = <650000000>;
 			device_type = "cpu";
 			reg = <0>;
+			operating-points-v2 = <&cpu0_opp_table>;
+			nvmem-cells = <&part_number_otp>;
+			nvmem-cell-names = "part_number";
+		};
+	};
+
+	cpu0_opp_table: cpu0-opp-table {
+		compatible = "operating-points-v2";
+		opp-shared;
+		opp-650000000 {
+			opp-hz = /bits/ 64 <650000000>;
+			opp-microvolt = <1200000>;
+			opp-supported-hw = <0x1>;
+		};
+		opp-800000000 {
+			opp-hz = /bits/ 64 <800000000>;
+			opp-microvolt = <1350000>;
+			opp-supported-hw = <0x2>;
 		};
 	};
 
@@ -1522,6 +1540,9 @@
 			reg = <0x5c005000 0x400>;
 			#address-cells = <1>;
 			#size-cells = <1>;
+			part_number_otp: part_number_otp at 4 {
+				reg = <0x4 0x1>;
+			};
 			ts_cal1: calib at 5c {
 				reg = <0x5c 0x2>;
 			};
arch/arm/dts/stm32mp157c-ed1.dts +8 -0
index 4fb71100f5..9996704b59 100644
@@ -112,6 +112,14 @@
 	};
 };
 
+&cpu0{
+	cpu-supply = <&vddcore>;
+};
+
+&cpu1{
+	cpu-supply = <&vddcore>;
+};
+
 &dac {
 	pinctrl-names = "default";
 	pinctrl-0 = <&dac_ch1_pins_a &dac_ch2_pins_a>;
arch/arm/dts/stm32mp15xx-dkx.dtsi +8 -0
index 812e370ee4..906bd4282c 100644
@@ -121,6 +121,14 @@
 	status = "okay";
 };
 
+&cpu0{
+	cpu-supply = <&vddcore>;
+};
+
+&cpu1{
+	cpu-supply = <&vddcore>;
+};
+
 &ethernet0 {
 	status = "okay";
 	pinctrl-0 = <&ethernet0_rgmii_pins_a>;
Signature · 1 line
2.17.1
#4 lore raw

PATCH v2 3/9 board: st: create common file stpmic1.c

In reply to Patrick Delaunay

Move function board_ddr_power_init() in a new file stpmic1 in board/st/common to avoid duplicated code in each board using stpmic1

---

Changes in v2: None

 board/dhelectronics/dh_stm32mp1/Makefile |   2 +-
 board/st/common/Makefile                 |   1 +
 board/st/common/stpmic1.c                | 162 +++++++++++++++++++++++
 board/st/stm32mp1/board.c                | 158 ----------------------
 4 files changed, 164 insertions(+), 159 deletions(-)
 create mode 100644 board/st/common/stpmic1.c
board/dhelectronics/dh_stm32mp1/Makefile +1 -1
index e8f218da08..5758d9816b 100644
@@ -7,7 +7,7 @@ ifdef CONFIG_SPL_BUILD
 obj-y += ../../st/stm32mp1/spl.o
 endif
 
-obj-y += ../../st/stm32mp1/board.o board.o
+obj-y += ../../st/common/stpmic1.o board.o
 
 obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += ../../st/common/stm32mp_mtdparts.o
 obj-$(CONFIG_SET_DFU_ALT_INFO) += ../../st/common/stm32mp_dfu.o
board/st/common/Makefile +1 -0
index aa030bacd8..012bfbbe8e 100644
@@ -4,6 +4,7 @@
 #
 
 obj-$(CONFIG_CMD_STBOARD) += cmd_stboard.o
+obj-$(CONFIG_PMIC_STPMIC1) += stpmic1.o
 
 ifeq ($(CONFIG_ARCH_STM32MP),y)
 obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += stm32mp_mtdparts.o
board/st/common/stpmic1.c new file +162 -0

162 lines not on this page · raw message

board/st/stm32mp1/board.c +0 -158

168 lines not on this page · raw message

Signature · 1 line
2.17.1
#5 lore raw

PATCH v2 4/9 stm32mp1: clk: configure pll1 with OPP

In reply to Patrick Delaunay

The PLL1 node (st,pll1) is optional in device tree, the max supported frequency define in OPP node is used when the node is absent.

---

Changes in v2: None

 .../clock/st,stm32mp1.txt                     |   4 +
 drivers/clk/clk_stm32mp1.c                    | 290 ++++++++++++++++--
 2 files changed, 266 insertions(+), 28 deletions(-)
doc/device-tree-bindings/clock/st,stm32mp1.txt +4 -0
index a3d427911d..4d4136d2fc 100644
@@ -87,6 +87,10 @@ Optional Properties:
   are listed with associated reg 0 to 3.
   PLLx is off when the associated node is absent or deactivated.
 
+  For PLL1, when the node is absent, the frequency of the OPP node is used
+  to compute the PLL setting (see compatible "operating-points-v2" in
+  opp/opp.txt for details).
+
   Here are the available properties for each PLL node:
     - compatible: should be "st,stm32mp1-pll"
 
drivers/clk/clk_stm32mp1.c +262 -28

342 lines not on this page · raw message

Signature · 1 line
2.17.1
#6 lore raw

PATCH v2 5/9 arm: stm32mp: add weak function to save vddcore

In reply to Patrick Delaunay

Add a weak functions to save the vddcore voltage value provided in the OPP node when the clock tree is initialized.

---

Changes in v2: None

 arch/arm/mach-stm32mp/include/mach/sys_proto.h | 3 +++
 drivers/clk/clk_stm32mp1.c                     | 5 +++++
 2 files changed, 8 insertions(+)
arch/arm/mach-stm32mp/include/mach/sys_proto.h +3 -0
index 4b6c7b8bdd..4149d3a133 100644
@@ -48,3 +48,6 @@ void get_soc_name(char name[SOC_NAME_SIZE]);
 u32 get_bootmode(void);
 
 int setup_mac_address(void);
+
+/* board power management : configure vddcore according OPP */
+void board_vddcore_init(u32 voltage_mv);
drivers/clk/clk_stm32mp1.c +5 -0
index b48c835bc3..d1177fc3af 100644
@@ -1226,6 +1226,10 @@ bool stm32mp1_supports_opp(u32 opp_id, u32 cpu_type)
 	}
 }
 
+__weak void board_vddcore_init(u32 voltage_mv)
+{
+}
+
 /*
  * gets OPP parameters (frequency in KHz and voltage in mV) from
  * an OPP table subnode. Platform HW support capabilities are also checked.
@@ -1303,6 +1307,7 @@ int stm32mp1_get_max_opp_freq(struct stm32mp1_clk_priv *priv, u64 *freq_hz)
 		return -FDT_ERR_NOTFOUND;
 
 	*freq_hz = (u64)1000U * freq;
+	board_vddcore_init(voltage);
 
 	return 0;
 }
Signature · 1 line
2.17.1
#7 lore raw

PATCH v2 6/9 board: st: stpmic1: add function stpmic1_init

In reply to Patrick Delaunay

Add a function stmpic_init to early initialize the PMIC STPMIC1
- keep vdd on during the reset cycle (to avoid issue when backup battery is absent)
- Check if debug is enabled to program PMIC according to the bit

This patch allows to remove the compilation of spl.c file from stm32mp1 board in dh_stm32mp1.

CONFIG_SPL_BOARD_INIT is removed as the new function is called earlier in SPL, in the function board_early_init_f.

---

Changes in v2:
- add stpmic1_init function, called in board_early_init_f for dh_stm32mp1 board support (and no more use spl.c from stm32mp1)
- remove CONFIG_SPL_BOARD_INIT

 arch/arm/mach-stm32mp/Kconfig            |  1 -
 board/dhelectronics/dh_stm32mp1/Makefile |  4 ---
 board/dhelectronics/dh_stm32mp1/board.c  |  3 ++
 board/st/common/stpmic1.c                | 31 +++++++++++++++++++
 board/st/common/stpmic1.h                |  6 ++++
 board/st/stm32mp1/spl.c                  | 39 +++---------------------
 board/st/stm32mp1/stm32mp1.c             |  6 ++++
 configs/stm32mp15_basic_defconfig        |  1 +
 8 files changed, 52 insertions(+), 39 deletions(-)
 create mode 100644 board/st/common/stpmic1.h
arch/arm/mach-stm32mp/Kconfig +0 -1
index 6c995ed8d8..ea7d57477b 100644
@@ -1,7 +1,6 @@
 if ARCH_STM32MP
 
 config SPL
-	select SPL_BOARD_INIT
 	select SPL_CLK
 	select SPL_DM
 	select SPL_DM_SEQ_ALIAS
board/dhelectronics/dh_stm32mp1/Makefile +0 -4
index 5758d9816b..b368b396a4 100644
@@ -3,10 +3,6 @@
 # Copyright (C) 2018, STMicroelectronics - All Rights Reserved
 #
 
-ifdef CONFIG_SPL_BUILD
-obj-y += ../../st/stm32mp1/spl.o
-endif
-
 obj-y += ../../st/common/stpmic1.o board.o
 
 obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += ../../st/common/stm32mp_mtdparts.o
board/dhelectronics/dh_stm32mp1/board.c +3 -0
index 85d56f6082..df0810dbda 100644
@@ -37,6 +37,7 @@
 #include <usb.h>
 #include <usb/dwc2_udc.h>
 #include <watchdog.h>
+#include "../../st/common/stpmic1.h"
 
 /* SYSCFG registers */
 #define SYSCFG_BOOTR		0x00
@@ -194,6 +195,8 @@ int board_stm32mp1_ddr_config_name_match(struct udevice *dev,
 
 int board_early_init_f(void)
 {
+	if (IS_ENABLED(CONFIG_SPL_BUILD))
+		stpmic1_init();
 	board_get_coding_straps();
 
 	return 0;
board/st/common/stpmic1.c +31 -0
index ca10a2246b..64f24f1f6f 100644
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <asm/io.h>
 #include <asm/arch/ddr.h>
 #include <power/pmic.h>
 #include <power/stpmic1.h>
@@ -160,3 +161,33 @@ int board_ddr_power_init(enum ddr_type ddr_type)
 
 	return 0;
 }
+
+/* early init of PMIC */
+void stpmic1_init(void)
+{
+	struct udevice *dev;
+
+	if (uclass_get_device_by_driver(UCLASS_PMIC,
+					DM_GET_DRIVER(pmic_stpmic1), &dev))
+		return;
+
+	/* Keep vdd on during the reset cycle */
+	pmic_clrsetbits(dev,
+			STPMIC1_BUCKS_MRST_CR,
+			STPMIC1_MRST_BUCK(STPMIC1_BUCK3),
+			STPMIC1_MRST_BUCK(STPMIC1_BUCK3));
+
+	/* Check if debug is enabled to program PMIC according to the bit */
+	if (readl(TAMP_BOOT_CONTEXT) & TAMP_BOOT_DEBUG_ON) {
+		printf("Keep debug unit ON\n");
+
+		pmic_clrsetbits(dev, STPMIC1_BUCKS_MRST_CR,
+				STPMIC1_MRST_BUCK_DEBUG,
+				STPMIC1_MRST_BUCK_DEBUG);
+
+		if (STPMIC1_MRST_LDO_DEBUG)
+			pmic_clrsetbits(dev, STPMIC1_LDOS_MRST_CR,
+					STPMIC1_MRST_LDO_DEBUG,
+					STPMIC1_MRST_LDO_DEBUG);
+	}
+}
board/st/common/stpmic1.h new file +6 -0
new file mode 100644
index 0000000000..ecc3276697
@@ -0,0 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
+/*
+ * Copyright (C) 2020, STMicroelectronics - All Rights Reserved
+ */
+
+void stpmic1_init(void);
board/st/stm32mp1/spl.c +5 -34
index e65ff288ea..28efc5c0ae 100644
@@ -5,41 +5,12 @@
 
 #include <config.h>
 #include <common.h>
-#include <spl.h>
-#include <dm.h>
-#include <ram.h>
-#include <asm/io.h>
-#include <power/pmic.h>
-#include <power/stpmic1.h>
-#include <asm/arch/ddr.h>
+#include "../common/stpmic1.h"
 
-void spl_board_init(void)
+int board_early_init_f(void)
 {
-	/* Keep vdd on during the reset cycle */
-#if defined(CONFIG_PMIC_STPMIC1) && defined(CONFIG_SPL_POWER_SUPPORT)
-	struct udevice *dev;
-	int ret;
+	if (IS_ENABLED(CONFIG_PMIC_STPMIC1) && CONFIG_IS_ENABLED(POWER_SUPPORT))
+		stpmic1_init();
 
-	ret = uclass_get_device_by_driver(UCLASS_PMIC,
-					  DM_GET_DRIVER(pmic_stpmic1), &dev);
-	if (!ret)
-		pmic_clrsetbits(dev,
-				STPMIC1_BUCKS_MRST_CR,
-				STPMIC1_MRST_BUCK(STPMIC1_BUCK3),
-				STPMIC1_MRST_BUCK(STPMIC1_BUCK3));
-
-	/* Check if debug is enabled to program PMIC according to the bit */
-	if ((readl(TAMP_BOOT_CONTEXT) & TAMP_BOOT_DEBUG_ON) && !ret) {
-		printf("Keep debug unit ON\n");
-
-		pmic_clrsetbits(dev, STPMIC1_BUCKS_MRST_CR,
-				STPMIC1_MRST_BUCK_DEBUG,
-				STPMIC1_MRST_BUCK_DEBUG);
-
-		if (STPMIC1_MRST_LDO_DEBUG)
-			pmic_clrsetbits(dev, STPMIC1_LDOS_MRST_CR,
-					STPMIC1_MRST_LDO_DEBUG,
-					STPMIC1_MRST_LDO_DEBUG);
-	}
-#endif
+	return 0;
 }
board/st/stm32mp1/stm32mp1.c +6 -0
index 33cb7f6c4d..22ad2dba9a 100644
@@ -79,6 +79,12 @@ DECLARE_GLOBAL_DATA_PTR;
 #define USB_START_LOW_THRESHOLD_UV	1230000
 #define USB_START_HIGH_THRESHOLD_UV	2150000
 
+int board_early_init_f(void)
+{
+	/* nothing to do, only used in SPL */
+	return 0;
+}
+
 int checkboard(void)
 {
 	int ret;
configs/stm32mp15_basic_defconfig +1 -0
index c7dd2926c9..628cde6cda 100644
@@ -16,6 +16,7 @@ CONFIG_SPL_TEXT_BASE=0x2FFC2500
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
 CONFIG_BOOTCOMMAND="run bootcmd_stm32mp"
+CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=3
 CONFIG_SPL_I2C_SUPPORT=y
Signature · 1 line
2.17.1
#8 lore raw

PATCH v2 6/9 board: st: stpmic1: add function stpmic1_init

Hi Patrick

Quoted 209 lines · Patrick Delaunay

Add a function stmpic_init to early initialize the PMIC STPMIC1
- keep vdd on during the reset cycle (to avoid issue when backup battery is absent)
- Check if debug is enabled to program PMIC according to the bit

This patch allows to remove the compilation of spl.c file from stm32mp1 board in dh_stm32mp1.

CONFIG_SPL_BOARD_INIT is removed as the new function is called earlier in SPL, in the function board_early_init_f.

---

Changes in v2:
- add stpmic1_init function, called in board_early_init_f for dh_stm32mp1 board support (and no more use spl.c from stm32mp1)
- remove CONFIG_SPL_BOARD_INIT

 arch/arm/mach-stm32mp/Kconfig            |  1 -
 board/dhelectronics/dh_stm32mp1/Makefile |  4 ---
 board/dhelectronics/dh_stm32mp1/board.c  |  3 ++
 board/st/common/stpmic1.c                | 31 +++++++++++++++++++
 board/st/common/stpmic1.h                |  6 ++++
 board/st/stm32mp1/spl.c                  | 39 +++---------------------
 board/st/stm32mp1/stm32mp1.c             |  6 ++++
 configs/stm32mp15_basic_defconfig        |  1 +
 8 files changed, 52 insertions(+), 39 deletions(-)
 create mode 100644 board/st/common/stpmic1.h
arch/arm/mach-stm32mp/Kconfig +0 -1
index 6c995ed8d8..ea7d57477b 100644
@@ -1,7 +1,6 @@
 if ARCH_STM32MP
 
 config SPL
-	select SPL_BOARD_INIT
 	select SPL_CLK
 	select SPL_DM
 	select SPL_DM_SEQ_ALIAS
board/dhelectronics/dh_stm32mp1/Makefile +0 -4
index 5758d9816b..b368b396a4 100644
@@ -3,10 +3,6 @@
 # Copyright (C) 2018, STMicroelectronics - All Rights Reserved
 #
 
-ifdef CONFIG_SPL_BUILD
-obj-y += ../../st/stm32mp1/spl.o
-endif
-
 obj-y += ../../st/common/stpmic1.o board.o
 
 obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += ../../st/common/stm32mp_mtdparts.o
board/dhelectronics/dh_stm32mp1/board.c +3 -0
index 85d56f6082..df0810dbda 100644
@@ -37,6 +37,7 @@
 #include <usb.h>
 #include <usb/dwc2_udc.h>
 #include <watchdog.h>
+#include "../../st/common/stpmic1.h"
 
 /* SYSCFG registers */
 #define SYSCFG_BOOTR		0x00
@@ -194,6 +195,8 @@ int board_stm32mp1_ddr_config_name_match(struct udevice *dev,
 
 int board_early_init_f(void)
 {
+	if (IS_ENABLED(CONFIG_SPL_BUILD))
+		stpmic1_init();
 	board_get_coding_straps();
 
 	return 0;
board/st/common/stpmic1.c +31 -0
index ca10a2246b..64f24f1f6f 100644
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <asm/io.h>
 #include <asm/arch/ddr.h>
 #include <power/pmic.h>
 #include <power/stpmic1.h>
@@ -160,3 +161,33 @@ int board_ddr_power_init(enum ddr_type ddr_type)
 
 	return 0;
 }
+
+/* early init of PMIC */
+void stpmic1_init(void)
+{
+	struct udevice *dev;
+
+	if (uclass_get_device_by_driver(UCLASS_PMIC,
+					DM_GET_DRIVER(pmic_stpmic1), &dev))
+		return;
+
+	/* Keep vdd on during the reset cycle */
+	pmic_clrsetbits(dev,
+			STPMIC1_BUCKS_MRST_CR,
+			STPMIC1_MRST_BUCK(STPMIC1_BUCK3),
+			STPMIC1_MRST_BUCK(STPMIC1_BUCK3));
+
+	/* Check if debug is enabled to program PMIC according to the bit */
+	if (readl(TAMP_BOOT_CONTEXT) & TAMP_BOOT_DEBUG_ON) {
+		printf("Keep debug unit ON\n");
+
+		pmic_clrsetbits(dev, STPMIC1_BUCKS_MRST_CR,
+				STPMIC1_MRST_BUCK_DEBUG,
+				STPMIC1_MRST_BUCK_DEBUG);
+
+		if (STPMIC1_MRST_LDO_DEBUG)
+			pmic_clrsetbits(dev, STPMIC1_LDOS_MRST_CR,
+					STPMIC1_MRST_LDO_DEBUG,
+					STPMIC1_MRST_LDO_DEBUG);
+	}
+}
board/st/common/stpmic1.h new file +6 -0
new file mode 100644
index 0000000000..ecc3276697
@@ -0,0 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
+/*
+ * Copyright (C) 2020, STMicroelectronics - All Rights Reserved
+ */
+
+void stpmic1_init(void);
board/st/stm32mp1/spl.c +5 -34
index e65ff288ea..28efc5c0ae 100644
@@ -5,41 +5,12 @@
 
 #include <config.h>
 #include <common.h>
-#include <spl.h>
-#include <dm.h>
-#include <ram.h>
-#include <asm/io.h>
-#include <power/pmic.h>
-#include <power/stpmic1.h>
-#include <asm/arch/ddr.h>
+#include "../common/stpmic1.h"
 
-void spl_board_init(void)
+int board_early_init_f(void)
 {
-	/* Keep vdd on during the reset cycle */
-#if defined(CONFIG_PMIC_STPMIC1) && defined(CONFIG_SPL_POWER_SUPPORT)
-	struct udevice *dev;
-	int ret;
+	if (IS_ENABLED(CONFIG_PMIC_STPMIC1) && CONFIG_IS_ENABLED(POWER_SUPPORT))
+		stpmic1_init();
 
-	ret = uclass_get_device_by_driver(UCLASS_PMIC,
-					  DM_GET_DRIVER(pmic_stpmic1), &dev);
-	if (!ret)
-		pmic_clrsetbits(dev,
-				STPMIC1_BUCKS_MRST_CR,
-				STPMIC1_MRST_BUCK(STPMIC1_BUCK3),
-				STPMIC1_MRST_BUCK(STPMIC1_BUCK3));
-
-	/* Check if debug is enabled to program PMIC according to the bit */
-	if ((readl(TAMP_BOOT_CONTEXT) & TAMP_BOOT_DEBUG_ON) && !ret) {
-		printf("Keep debug unit ON\n");
-
-		pmic_clrsetbits(dev, STPMIC1_BUCKS_MRST_CR,
-				STPMIC1_MRST_BUCK_DEBUG,
-				STPMIC1_MRST_BUCK_DEBUG);
-
-		if (STPMIC1_MRST_LDO_DEBUG)
-			pmic_clrsetbits(dev, STPMIC1_LDOS_MRST_CR,
-					STPMIC1_MRST_LDO_DEBUG,
-					STPMIC1_MRST_LDO_DEBUG);
-	}
-#endif
+	return 0;
 }
board/st/stm32mp1/stm32mp1.c +6 -0
index 33cb7f6c4d..22ad2dba9a 100644
@@ -79,6 +79,12 @@ DECLARE_GLOBAL_DATA_PTR;
 #define USB_START_LOW_THRESHOLD_UV	1230000
 #define USB_START_HIGH_THRESHOLD_UV	2150000
 
+int board_early_init_f(void)
+{
+	/* nothing to do, only used in SPL */
+	return 0;
+}
+
 int checkboard(void)
 {
 	int ret;
configs/stm32mp15_basic_defconfig +0 -0
index c7dd2926c9..628cde6cda 100644

configs/stm32mp15_basic_defconfig CONFIG_SPL_TEXT_BASE=0x2FFC2500 · line 22

Quoted 7 lines
configs/stm32mp15_basic_defconfig +1 -0
@@ -16,6 +16,7 @@ CONFIG_SPL_TEXT_BASE=0x2FFC2500
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
 CONFIG_BOOTCOMMAND="run bootcmd_stm32mp"
+CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=3
 CONFIG_SPL_I2C_SUPPORT=y

Thanks

#9 lore raw

PATCH v2 7/9 board: stm32mp1: update vddcore in SPL

In reply to Patrick Delaunay

For board using STPMIC1, the vddcore is provided by BUCK1 of STPMIC1 and need to be updated for 800MHz support and only after the clock tree initialization.

The VDDCORE voltage value is provided by clock driver, saved in global variable opp_voltage_mv and udpated in SPL board_early_init_f(), just after clock tree initialization.

---

Changes in v2:
- stmpic_buck1_set is a static function called in stpmic1_init (with new parameter for vddcore value)
- update also dh_stm32mp1 board

 board/dhelectronics/dh_stm32mp1/board.c |  9 ++++++++-
 board/st/common/stpmic1.c               | 23 ++++++++++++++++++++++-
 board/st/common/stpmic1.h               |  2 +-
 board/st/stm32mp1/spl.c                 | 11 ++++++++++-
 4 files changed, 41 insertions(+), 4 deletions(-)
board/dhelectronics/dh_stm32mp1/board.c +8 -1
index df0810dbda..2ae97f677b 100644
@@ -136,6 +136,7 @@ int checkboard(void)
 static u8 brdcode __section("data");
 static u8 ddr3code __section("data");
 static u8 somcode __section("data");
+static u32 opp_voltage_mv __section(".data");
 
 static void board_get_coding_straps(void)
 {
@@ -193,10 +194,16 @@ int board_stm32mp1_ddr_config_name_match(struct udevice *dev,
 	return -EINVAL;
 }
 
+void board_vddcore_init(u32 voltage_mv)
+{
+	if (IS_ENABLED(CONFIG_SPL_BUILD))
+		opp_voltage_mv = voltage_mv;
+}
+
 int board_early_init_f(void)
 {
 	if (IS_ENABLED(CONFIG_SPL_BUILD))
-		stpmic1_init();
+		stpmic1_init(opp_voltage_mv);
 	board_get_coding_straps();
 
 	return 0;
board/st/common/stpmic1.c +22 -1
index 64f24f1f6f..47f9d95c29 100644
@@ -162,8 +162,25 @@ int board_ddr_power_init(enum ddr_type ddr_type)
 	return 0;
 }
 
+static int stmpic_buck1_set(struct udevice *dev, u32 voltage_mv)
+{
+	u32 value;
+
+	/* VDDCORE= STMPCI1 BUCK1 ramp=+25mV, 5 => 725mV, 36 => 1500mV */
+	value = ((voltage_mv - 725) / 25) + 5;
+	if (value < 5)
+		value = 5;
+	if (value > 36)
+		value = 36;
+
+	return pmic_clrsetbits(dev,
+			       STPMIC1_BUCKX_MAIN_CR(STPMIC1_BUCK1),
+			       STPMIC1_BUCK_VOUT_MASK,
+			       STPMIC1_BUCK_VOUT(value));
+}
+
 /* early init of PMIC */
-void stpmic1_init(void)
+void stpmic1_init(u32 voltage_mv)
 {
 	struct udevice *dev;
 
@@ -171,6 +188,10 @@ void stpmic1_init(void)
 					DM_GET_DRIVER(pmic_stpmic1), &dev))
 		return;
 
+	/* update VDDCORE = BUCK1 */
+	if (voltage_mv)
+		stmpic_buck1_set(dev, voltage_mv);
+
 	/* Keep vdd on during the reset cycle */
 	pmic_clrsetbits(dev,
 			STPMIC1_BUCKS_MRST_CR,
board/st/common/stpmic1.h +1 -1
index ecc3276697..b17d6f1633 100644
@@ -3,4 +3,4 @@
  * Copyright (C) 2020, STMicroelectronics - All Rights Reserved
  */
 
-void stpmic1_init(void);
+void stpmic1_init(u32 voltage_mv);
board/st/stm32mp1/spl.c +10 -1
index 28efc5c0ae..96ab671169 100644
@@ -7,10 +7,19 @@
 #include <common.h>
 #include "../common/stpmic1.h"
 
+/* board early initialisation in board_f: need to use global variable */
+static u32 opp_voltage_mv __section(".data");
+
+void board_vddcore_init(u32 voltage_mv)
+{
+	if (IS_ENABLED(CONFIG_PMIC_STPMIC1) && CONFIG_IS_ENABLED(POWER_SUPPORT))
+		opp_voltage_mv = voltage_mv;
+}
+
 int board_early_init_f(void)
 {
 	if (IS_ENABLED(CONFIG_PMIC_STPMIC1) && CONFIG_IS_ENABLED(POWER_SUPPORT))
-		stpmic1_init();
+		stpmic1_init(opp_voltage_mv);
 
 	return 0;
 }
Signature · 1 line
2.17.1
#10 lore raw

PATCH v2 7/9 board: stm32mp1: update vddcore in SPL

Hi Patrick

Quoted 119 lines · Patrick Delaunay

For board using STPMIC1, the vddcore is provided by BUCK1 of STPMIC1 and need to be updated for 800MHz support and only after the clock tree initialization.

The VDDCORE voltage value is provided by clock driver, saved in global variable opp_voltage_mv and udpated in SPL board_early_init_f(), just after clock tree initialization.

---

Changes in v2:
- stmpic_buck1_set is a static function called in stpmic1_init (with new parameter for vddcore value)
- update also dh_stm32mp1 board

 board/dhelectronics/dh_stm32mp1/board.c |  9 ++++++++-
 board/st/common/stpmic1.c               | 23 ++++++++++++++++++++++-
 board/st/common/stpmic1.h               |  2 +-
 board/st/stm32mp1/spl.c                 | 11 ++++++++++-
 4 files changed, 41 insertions(+), 4 deletions(-)
board/dhelectronics/dh_stm32mp1/board.c +8 -1
index df0810dbda..2ae97f677b 100644
@@ -136,6 +136,7 @@ int checkboard(void)
 static u8 brdcode __section("data");
 static u8 ddr3code __section("data");
 static u8 somcode __section("data");
+static u32 opp_voltage_mv __section(".data");
 
 static void board_get_coding_straps(void)
 {
@@ -193,10 +194,16 @@ int board_stm32mp1_ddr_config_name_match(struct udevice *dev,
 	return -EINVAL;
 }
 
+void board_vddcore_init(u32 voltage_mv)
+{
+	if (IS_ENABLED(CONFIG_SPL_BUILD))
+		opp_voltage_mv = voltage_mv;
+}
+
 int board_early_init_f(void)
 {
 	if (IS_ENABLED(CONFIG_SPL_BUILD))
-		stpmic1_init();
+		stpmic1_init(opp_voltage_mv);
 	board_get_coding_straps();
 
 	return 0;
board/st/common/stpmic1.c +22 -1
index 64f24f1f6f..47f9d95c29 100644
@@ -162,8 +162,25 @@ int board_ddr_power_init(enum ddr_type ddr_type)
 	return 0;
 }
 
+static int stmpic_buck1_set(struct udevice *dev, u32 voltage_mv)
+{
+	u32 value;
+
+	/* VDDCORE= STMPCI1 BUCK1 ramp=+25mV, 5 => 725mV, 36 => 1500mV */
+	value = ((voltage_mv - 725) / 25) + 5;
+	if (value < 5)
+		value = 5;
+	if (value > 36)
+		value = 36;
+
+	return pmic_clrsetbits(dev,
+			       STPMIC1_BUCKX_MAIN_CR(STPMIC1_BUCK1),
+			       STPMIC1_BUCK_VOUT_MASK,
+			       STPMIC1_BUCK_VOUT(value));
+}
+
 /* early init of PMIC */
-void stpmic1_init(void)
+void stpmic1_init(u32 voltage_mv)
 {
 	struct udevice *dev;
 
@@ -171,6 +188,10 @@ void stpmic1_init(void)
 					DM_GET_DRIVER(pmic_stpmic1), &dev))
 		return;
 
+	/* update VDDCORE = BUCK1 */
+	if (voltage_mv)
+		stmpic_buck1_set(dev, voltage_mv);
+
 	/* Keep vdd on during the reset cycle */
 	pmic_clrsetbits(dev,
 			STPMIC1_BUCKS_MRST_CR,
board/st/common/stpmic1.h +1 -1
index ecc3276697..b17d6f1633 100644
@@ -3,4 +3,4 @@
  * Copyright (C) 2020, STMicroelectronics - All Rights Reserved
  */
 
-void stpmic1_init(void);
+void stpmic1_init(u32 voltage_mv);
board/st/stm32mp1/spl.c +7 -0
index 28efc5c0ae..96ab671169 100644
@@ -7,10 +7,19 @@
 #include <common.h>
 #include "../common/stpmic1.h"
 
+/* board early initialisation in board_f: need to use global variable */
+static u32 opp_voltage_mv __section(".data");
+
+void board_vddcore_init(u32 voltage_mv)
+{
+	if (IS_ENABLED(CONFIG_PMIC_STPMIC1) && CONFIG_IS_ENABLED(POWER_SUPPORT))
+		opp_voltage_mv = voltage_mv;

board/st/stm32mp1/spl.c line 25

Quoted 10 lines
board/st/stm32mp1/spl.c +3 -1
+}
+
 int board_early_init_f(void)
 {
 	if (IS_ENABLED(CONFIG_PMIC_STPMIC1) && CONFIG_IS_ENABLED(POWER_SUPPORT))
-		stpmic1_init();
+		stpmic1_init(opp_voltage_mv);
 
 	return 0;
 }

Thanks

#11 lore raw

PATCH v2 8/9 ARM: dts: stm32mp1: use OPP information for PLL1 settings in SPL

In reply to Patrick Delaunay

This patch allows to switch the CPU frequency to 800MHz on the ST Microelectronics board (DK1/DK2 and EV1) or dh electronics SOM using the STM32MP15x SOC and when it is supported by the HW (for STM32MP15xD and STM32MP15xF).

---

Changes in v2:
- update stm32mp15xx-dhcor and dhcom device tree

 arch/arm/dts/stm32mp15-u-boot.dtsi         | 10 ++++++++++
 arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi   |  9 ---------
 arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi   |  9 ---------
 arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi |  9 ---------
 arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi |  9 ---------
 5 files changed, 10 insertions(+), 36 deletions(-)
arch/arm/dts/stm32mp15-u-boot.dtsi +10 -0
index a0d971ad88..66be7df9ae 100644
@@ -88,6 +88,16 @@
 	u-boot,dm-pre-reloc;
 };
 
+&cpu0_opp_table {
+	u-boot,dm-spl;
+	opp-650000000 {
+		u-boot,dm-spl;
+	};
+	opp-800000000 {
+		u-boot,dm-spl;
+	};
+};
+
 &gpioa {
 	u-boot,dm-pre-reloc;
 };
arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi +0 -9
index c52abeb1e7..69cdae6685 100644
@@ -118,15 +118,6 @@
 		CLK_LPTIM45_LSE
 	>;
 
-	/* VCO = 1300.0 MHz => P = 650 (CPU) */
-	pll1: st,pll at 0 {
-		compatible = "st,stm32mp1-pll";
-		reg = <0>;
-		cfg = < 2 80 0 0 0 PQR(1,0,0) >;
-		frac = < 0x800 >;
-		u-boot,dm-pre-reloc;
-	};
-
 	/* VCO = 1066.0 MHz => P = 266 (AXI), Q = 533 (GPU), R = 533 (DDR) */
 	pll2: st,pll at 1 {
 		compatible = "st,stm32mp1-pll";
arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi +0 -9
index 84af7fa47b..3f716306be 100644
@@ -115,15 +115,6 @@
 		CLK_LPTIM45_LSE
 	>;
 
-	/* VCO = 1300.0 MHz => P = 650 (CPU) */
-	pll1: st,pll at 0 {
-		compatible = "st,stm32mp1-pll";
-		reg = <0>;
-		cfg = < 2 80 0 0 0 PQR(1,0,0) >;
-		frac = < 0x800 >;
-		u-boot,dm-pre-reloc;
-	};
-
 	/* VCO = 1066.0 MHz => P = 266 (AXI), Q = 533 (GPU), R = 533 (DDR) */
 	pll2: st,pll at 1 {
 		compatible = "st,stm32mp1-pll";
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +0 -9
index 75d75266e8..f96de9e7a3 100644
@@ -235,15 +235,6 @@
 		CLK_LPTIM45_LSE
 	>;
 
-	/* VCO = 1300.0 MHz => P = 650 (CPU) */
-	pll1: st,pll at 0 {
-		compatible = "st,stm32mp1-pll";
-		reg = <0>;
-		cfg = < 2 80 0 0 0 PQR(1,0,0) >;
-		frac = < 0x800 >;
-		u-boot,dm-pre-reloc;
-	};
-
 	/* VCO = 1066.0 MHz => P = 266 (AXI), Q = 533 (GPU), R = 533 (DDR) */
 	pll2: st,pll at 1 {
 		compatible = "st,stm32mp1-pll";
arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi +0 -9
index ef730a8322..4059dabf1d 100644
@@ -105,15 +105,6 @@
 		CLK_LPTIM45_LSE
 	>;
 
-	/* VCO = 1300.0 MHz => P = 650 (CPU) */
-	pll1: st,pll at 0 {
-		compatible = "st,stm32mp1-pll";
-		reg = <0>;
-		cfg = < 2 80 0 0 0 PQR(1,0,0) >;
-		frac = < 0x800 >;
-		u-boot,dm-pre-reloc;
-	};
-
 	/* VCO = 1066.0 MHz => P = 266 (AXI), Q = 533 (GPU), R = 533 (DDR) */
 	pll2: st,pll at 1 {
 		compatible = "st,stm32mp1-pll";
Signature · 1 line
2.17.1
#12 lore raw

PATCH v2 8/9 ARM: dts: stm32mp1: use OPP information for PLL1 settings in SPL

HI Patrick

Quoted 109 lines · Patrick Delaunay

This patch allows to switch the CPU frequency to 800MHz on the ST Microelectronics board (DK1/DK2 and EV1) or dh electronics SOM using the STM32MP15x SOC and when it is supported by the HW (for STM32MP15xD and STM32MP15xF).

---

Changes in v2:
- update stm32mp15xx-dhcor and dhcom device tree

 arch/arm/dts/stm32mp15-u-boot.dtsi         | 10 ++++++++++
 arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi   |  9 ---------
 arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi   |  9 ---------
 arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi |  9 ---------
 arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi |  9 ---------
 5 files changed, 10 insertions(+), 36 deletions(-)
arch/arm/dts/stm32mp15-u-boot.dtsi +10 -0
index a0d971ad88..66be7df9ae 100644
@@ -88,6 +88,16 @@
 	u-boot,dm-pre-reloc;
 };
 
+&cpu0_opp_table {
+	u-boot,dm-spl;
+	opp-650000000 {
+		u-boot,dm-spl;
+	};
+	opp-800000000 {
+		u-boot,dm-spl;
+	};
+};
+
 &gpioa {
 	u-boot,dm-pre-reloc;
 };
arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi +0 -9
index c52abeb1e7..69cdae6685 100644
@@ -118,15 +118,6 @@
 		CLK_LPTIM45_LSE
 	>;
 
-	/* VCO = 1300.0 MHz => P = 650 (CPU) */
-	pll1: st,pll at 0 {
-		compatible = "st,stm32mp1-pll";
-		reg = <0>;
-		cfg = < 2 80 0 0 0 PQR(1,0,0) >;
-		frac = < 0x800 >;
-		u-boot,dm-pre-reloc;
-	};
-
 	/* VCO = 1066.0 MHz => P = 266 (AXI), Q = 533 (GPU), R = 533 (DDR) */
 	pll2: st,pll at 1 {
 		compatible = "st,stm32mp1-pll";
arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi +0 -9
index 84af7fa47b..3f716306be 100644
@@ -115,15 +115,6 @@
 		CLK_LPTIM45_LSE
 	>;
 
-	/* VCO = 1300.0 MHz => P = 650 (CPU) */
-	pll1: st,pll at 0 {
-		compatible = "st,stm32mp1-pll";
-		reg = <0>;
-		cfg = < 2 80 0 0 0 PQR(1,0,0) >;
-		frac = < 0x800 >;
-		u-boot,dm-pre-reloc;
-	};
-
 	/* VCO = 1066.0 MHz => P = 266 (AXI), Q = 533 (GPU), R = 533 (DDR) */
 	pll2: st,pll at 1 {
 		compatible = "st,stm32mp1-pll";
arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi +0 -9
index 75d75266e8..f96de9e7a3 100644
@@ -235,15 +235,6 @@
 		CLK_LPTIM45_LSE
 	>;
 
-	/* VCO = 1300.0 MHz => P = 650 (CPU) */
-	pll1: st,pll at 0 {
-		compatible = "st,stm32mp1-pll";
-		reg = <0>;
-		cfg = < 2 80 0 0 0 PQR(1,0,0) >;
-		frac = < 0x800 >;
-		u-boot,dm-pre-reloc;
-	};
-
 	/* VCO = 1066.0 MHz => P = 266 (AXI), Q = 533 (GPU), R = 533 (DDR) */
 	pll2: st,pll at 1 {
 		compatible = "st,stm32mp1-pll";
arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi +0 -2
index ef730a8322..4059dabf1d 100644
@@ -105,15 +105,6 @@
 		CLK_LPTIM45_LSE
 	>;
 
-	/* VCO = 1300.0 MHz => P = 650 (CPU) */
-	pll1: st,pll at 0 {

arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi line 110

Quoted 10 lines
arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi +0 -7
-		compatible = "st,stm32mp1-pll";
-		reg = <0>;
-		cfg = < 2 80 0 0 0 PQR(1,0,0) >;
-		frac = < 0x800 >;
-		u-boot,dm-pre-reloc;
-	};
-
 	/* VCO = 1066.0 MHz => P = 266 (AXI), Q = 533 (GPU), R = 533 (DDR) */
 	pll2: st,pll at 1 {
 		compatible = "st,stm32mp1-pll";

Thanks

#13 lore raw

PATCH v2 9/9 board: stm32mp1: move the function board_debug_uart_init in spl.c

In reply to Patrick Delaunay

Move the debug function board_debug_uart_init in spl.c as the debug_uart_init() function is called in arch_cpu_init() only for SPL and remove the board.c file.

For TFABOOT, the UART TX pin configuration is done in TF-A.

---

Changes in v2:
- NEW: merge spl.c and board.c to avoid a file with only one function

 board/st/stm32mp1/Makefile |  2 --
 board/st/stm32mp1/board.c  | 34 ----------------------------------
 board/st/stm32mp1/spl.c    | 26 ++++++++++++++++++++++++++
 3 files changed, 26 insertions(+), 36 deletions(-)
 delete mode 100644 board/st/stm32mp1/board.c
board/st/stm32mp1/Makefile +0 -2
index 8188075b1a..65560df290 100644
@@ -8,5 +8,3 @@ obj-y += spl.o
 else
 obj-y += stm32mp1.o
 endif
-
-obj-y += board.o
board/st/stm32mp1/board.c deleted +0 -34
deleted file mode 100644
index 1887941e57..0000000000
@@ -1,34 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
-/*
- * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
- */
-
-#include <common.h>
-#include <asm/io.h>
-
-#ifdef CONFIG_DEBUG_UART_BOARD_INIT
-void board_debug_uart_init(void)
-{
-#if (CONFIG_DEBUG_UART_BASE == STM32_UART4_BASE)
-
-#define RCC_MP_APB1ENSETR (STM32_RCC_BASE + 0x0A00)
-#define RCC_MP_AHB4ENSETR (STM32_RCC_BASE + 0x0A28)
-
-	/* UART4 clock enable */
-	setbits_le32(RCC_MP_APB1ENSETR, BIT(16));
-
-#define GPIOG_BASE 0x50008000
-	/* GPIOG clock enable */
-	writel(BIT(6), RCC_MP_AHB4ENSETR);
-	/* GPIO configuration for EVAL board
-	 * => Uart4 TX = G11
-	 */
-	writel(0xffbfffff, GPIOG_BASE + 0x00);
-	writel(0x00006000, GPIOG_BASE + 0x24);
-#else
-
-#error("CONFIG_DEBUG_UART_BASE: not supported value")
-
-#endif
-}
-#endif
board/st/stm32mp1/spl.c +26 -0
index 96ab671169..977703f58a 100644
@@ -5,6 +5,7 @@
 
 #include <config.h>
 #include <common.h>
+#include <asm/io.h>
 #include "../common/stpmic1.h"
 
 /* board early initialisation in board_f: need to use global variable */
@@ -23,3 +24,28 @@ int board_early_init_f(void)
 
 	return 0;
 }
+
+#ifdef CONFIG_DEBUG_UART_BOARD_INIT
+void board_debug_uart_init(void)
+{
+#if (CONFIG_DEBUG_UART_BASE == STM32_UART4_BASE)
+
+#define RCC_MP_APB1ENSETR (STM32_RCC_BASE + 0x0A00)
+#define RCC_MP_AHB4ENSETR (STM32_RCC_BASE + 0x0A28)
+
+	/* UART4 clock enable */
+	setbits_le32(RCC_MP_APB1ENSETR, BIT(16));
+
+#define GPIOG_BASE 0x50008000
+	/* GPIOG clock enable */
+	writel(BIT(6), RCC_MP_AHB4ENSETR);
+	/* GPIO configuration for ST boards: Uart4 TX = G11 */
+	writel(0xffbfffff, GPIOG_BASE + 0x00);
+	writel(0x00006000, GPIOG_BASE + 0x24);
+#else
+
+#error("CONFIG_DEBUG_UART_BASE: not supported value")
+
+#endif
+}
+#endif
Signature · 1 line
2.17.1
#14 lore raw

PATCH v2 9/9 board: stm32mp1: move the function board_debug_uart_init in spl.c

Hi Patrick

Quoted 99 lines · Patrick Delaunay

Move the debug function board_debug_uart_init in spl.c as the debug_uart_init() function is called in arch_cpu_init() only for SPL and remove the board.c file.

For TFABOOT, the UART TX pin configuration is done in TF-A.

---

Changes in v2:
- NEW: merge spl.c and board.c to avoid a file with only one function

 board/st/stm32mp1/Makefile |  2 --
 board/st/stm32mp1/board.c  | 34 ----------------------------------
 board/st/stm32mp1/spl.c    | 26 ++++++++++++++++++++++++++
 3 files changed, 26 insertions(+), 36 deletions(-)
 delete mode 100644 board/st/stm32mp1/board.c
board/st/stm32mp1/Makefile +0 -2
index 8188075b1a..65560df290 100644
@@ -8,5 +8,3 @@ obj-y += spl.o
 else
 obj-y += stm32mp1.o
 endif
-
-obj-y += board.o
board/st/stm32mp1/board.c deleted +0 -34
deleted file mode 100644
index 1887941e57..0000000000
@@ -1,34 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
-/*
- * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
- */
-
-#include <common.h>
-#include <asm/io.h>
-
-#ifdef CONFIG_DEBUG_UART_BOARD_INIT
-void board_debug_uart_init(void)
-{
-#if (CONFIG_DEBUG_UART_BASE == STM32_UART4_BASE)
-
-#define RCC_MP_APB1ENSETR (STM32_RCC_BASE + 0x0A00)
-#define RCC_MP_AHB4ENSETR (STM32_RCC_BASE + 0x0A28)
-
-	/* UART4 clock enable */
-	setbits_le32(RCC_MP_APB1ENSETR, BIT(16));
-
-#define GPIOG_BASE 0x50008000
-	/* GPIOG clock enable */
-	writel(BIT(6), RCC_MP_AHB4ENSETR);
-	/* GPIO configuration for EVAL board
-	 * => Uart4 TX = G11
-	 */
-	writel(0xffbfffff, GPIOG_BASE + 0x00);
-	writel(0x00006000, GPIOG_BASE + 0x24);
-#else
-
-#error("CONFIG_DEBUG_UART_BASE: not supported value")
-
-#endif
-}
-#endif
board/st/stm32mp1/spl.c +16 -0
index 96ab671169..977703f58a 100644
@@ -5,6 +5,7 @@
 
 #include <config.h>
 #include <common.h>
+#include <asm/io.h>
 #include "../common/stpmic1.h"
 
 /* board early initialisation in board_f: need to use global variable */
@@ -23,3 +24,28 @@ int board_early_init_f(void)
 
 	return 0;
 }
+
+#ifdef CONFIG_DEBUG_UART_BOARD_INIT
+void board_debug_uart_init(void)
+{
+#if (CONFIG_DEBUG_UART_BASE == STM32_UART4_BASE)
+
+#define RCC_MP_APB1ENSETR (STM32_RCC_BASE + 0x0A00)
+#define RCC_MP_AHB4ENSETR (STM32_RCC_BASE + 0x0A28)
+
+	/* UART4 clock enable */
+	setbits_le32(RCC_MP_APB1ENSETR, BIT(16));
+
+#define GPIOG_BASE 0x50008000
+	/* GPIOG clock enable */
+	writel(BIT(6), RCC_MP_AHB4ENSETR);

board/st/stm32mp1/spl.c int board_early_init_f(void) · line 51

Quoted 10 lines
board/st/stm32mp1/spl.c +10 -0
+	/* GPIO configuration for ST boards: Uart4 TX = G11 */
+	writel(0xffbfffff, GPIOG_BASE + 0x00);
+	writel(0x00006000, GPIOG_BASE + 0x24);
+#else
+
+#error("CONFIG_DEBUG_UART_BASE: not supported value")
+
+#endif
+}
+#endif

Thanks