Skip to content

Commit f376091

Browse files
soc: st: stm32: u5: replace Kconfig power supply configuration with DT
Replace the existing infrastructure to specify power supply configuration through Kconfig with Devicetree. Set the LDO as default to reduce out-of-tree breakage - most users were relying on LDO being the default and it is harmless to use LDO if board is designed for SMPS. (Existing SMPS users should break anyways since the Kconfig symbol no longer exists, but this ensures they actively set the power supply to SMPS in DT) Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
1 parent d9dd668 commit f376091

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

dts/arm/st/u5/stm32u5.dtsi

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,10 +888,17 @@
888888
};
889889

890890
pwr: power@46020800 {
891-
compatible = "st,stm32-pwr";
891+
compatible = "st,stm32-dualreg-pwr", "st,stm32-pwr";
892892
reg = <0x46020800 0x400>; /* PWR register bank */
893893
status = "disabled";
894894

895+
/*
896+
* After reset, the LDO regulator is selected as
897+
* it works in all hardware configurations; set
898+
* default in SoC DTSI to reduce churn in boards.
899+
*/
900+
power-supply = "ldo";
901+
895902
wkup-pins-nb = <8>; /* 8 system wake-up pins */
896903
wkup-pin-srcs = <3>; /* 3 gpio sources associated with each wkup pin */
897904
wkup-pins-pol;

soc/st/stm32/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ config STM32_WKUP_PINS
7878
choice POWER_SUPPLY_CHOICE
7979
prompt "STM32 power supply configuration"
8080
default POWER_SUPPLY_LDO
81-
depends on SOC_SERIES_STM32U5X || SOC_STM32WBA55XX || SOC_STM32WBA65XX
81+
depends on SOC_STM32WBA55XX || SOC_STM32WBA65XX
8282

8383
config POWER_SUPPLY_LDO
8484
bool "LDO supply"

soc/st/stm32/stm32u5x/soc.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@
2121
#define LOG_LEVEL CONFIG_SOC_LOG_LEVEL
2222
LOG_MODULE_REGISTER(soc);
2323

24+
#define PWR_NODE DT_INST(0, st_stm32_pwr)
25+
26+
/* Helper to simplify following #if chain */
27+
#define SELECTED_PSU(_x) DT_ENUM_HAS_VALUE(PWR_NODE, power_supply, _x)
28+
29+
#if SELECTED_PSU(ldo)
30+
#define SELECTED_POWER_SUPPLY LL_PWR_LDO_SUPPLY
31+
#elif SELECTED_PSU(smps)
32+
#define SELECTED_POWER_SUPPLY LL_PWR_SMPS_SUPPLY
33+
#endif
34+
2435
extern void stm32_power_init(void);
2536
/**
2637
* @brief Perform basic hardware initialization at boot.
@@ -50,13 +61,7 @@ void soc_early_init_hook(void)
5061
#endif
5162

5263
/* Power Configuration */
53-
#if defined(CONFIG_POWER_SUPPLY_DIRECT_SMPS)
54-
LL_PWR_SetRegulatorSupply(LL_PWR_SMPS_SUPPLY);
55-
#elif defined(CONFIG_POWER_SUPPLY_LDO)
56-
LL_PWR_SetRegulatorSupply(LL_PWR_LDO_SUPPLY);
57-
#else
58-
#error "Unsupported power configuration"
59-
#endif
64+
LL_PWR_SetRegulatorSupply(SELECTED_POWER_SUPPLY);
6065

6166
#if CONFIG_PM
6267
stm32_power_init();

0 commit comments

Comments
 (0)