Skip to content
Snippets Groups Projects
Commit ddb0ae7f authored by Amelie Delaunay's avatar Amelie Delaunay Committed by Sebastien Pasdeloup
Browse files

stm32mp1: disable USB phy supply in sp_min

PMIC ldo4 (vdd_usb 3v3) regulator is enabled in PMIC NVM for boot from USB.
This regulator is used by the USB HS phy.
There is a requirement in AN5031 [1] regarding this regulator:
"VDD3V3_USBHS must not be present unless VDDA1V8_REG is present, otherwise
permanent STM32MP15x lines damage could occur. Must be ensured by PMIC
ranking order or with external component in case of discrete component
power supply implementation".
VDD3V3_USBHS is PMIC vdd_usb regulator, provided by LDO4.
VDDA1V8_REG is PWR reg18 regulator.
It means that vdd_usb must not be ON unless reg18 is ON.
To follow this requirement and ensure vdd_usb will not be ON while reg18
OFF, disable ldo4 regulator.

[1] https://www.st.com/resource/en/application_note/dm00389996-getting-started-with-stm32mp151-stm32mp153-and-stm32mp157-line-hardware-development-stmicroelectronics.pdf



Change-Id: I31adcba720cdee8f2737635821c2273c4835edfb
Signed-off-by: default avatarAmelie Delaunay <amelie.delaunay@foss.st.com>
Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/tf-a/+/192905


Reviewed-by: default avatarCITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: default avatarCIBUILD <MDG-smet-aci-builds@list.st.com>
Reviewed-by: default avatarLionel DEBIEVE <lionel.debieve@foss.st.com>
Reviewed-by: default avatarYann GAUTIER <yann.gautier@foss.st.com>
parent cffa7c27
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,6 @@
/delete-node/ spi@58003000;
/delete-node/ sdmmc@58005000;
/delete-node/ sdmmc@58007000;
/delete-node/ usbphyc@5a006000;
/delete-node/ spi@5c001000;
/delete-node/ stgen@5c008000;
/delete-node/ i2c@5c009000;
......
......@@ -26,6 +26,7 @@ bool stm32mp_is_auth_supported(void);
const char *stm32mp_get_cpu_supply_name(void);
const char *stm32mp_get_vdd_supply_name(void);
const char *stm32mp_get_usb_phy_supply_name(void);
/* Return the base address of the DDR controller */
uintptr_t stm32mp_ddrctrl_base(void);
......
......@@ -46,6 +46,7 @@ int dt_get_all_opp_freqvolt(uint32_t *count, uint32_t *freq_khz_array,
uint32_t dt_get_pwr_vdd_voltage(void);
const char *dt_get_vdd_regulator_name(void);
const char *dt_get_cpu_regulator_name(void);
const char *dt_get_usb_phy_regulator_name(void);
const char *dt_get_board_model(void);
int fdt_get_gpio_bank_pin_count(unsigned int bank);
......
......@@ -183,6 +183,22 @@ const char *stm32mp_get_vdd_supply_name(void)
return supply;
}
/* Return USB phy supply name */
const char *stm32mp_get_usb_phy_supply_name(void)
{
const char *supply = NULL;
if (dt_pmic_status() > 0) {
const char *regulator = dt_get_usb_phy_regulator_name();
if (regulator != NULL) {
dt_pmic_find_supply(&supply, regulator);
}
}
return supply;
}
#if TRUSTED_BOARD_BOOT && STM32MP_USE_STM32IMAGE
/* Save pointer to last loaded header */
static boot_api_image_header_t *latest_stm32_header;
......
......@@ -538,6 +538,30 @@ const char *dt_get_cpu_regulator_name(void)
return dt_get_regulator_name(node, "cpu-supply");
}
/*******************************************************************************
* This function retrieves USB phy regulator name from DT.
* Returns string taken from supply node, NULL otherwise.
******************************************************************************/
const char *dt_get_usb_phy_regulator_name(void)
{
int node = fdt_node_offset_by_compatible(fdt, -1, DT_USBPHYC_COMPAT);
int subnode;
const char *reg_name = NULL;
if (node < 0) {
return NULL;
}
fdt_for_each_subnode(subnode, fdt, node) {
reg_name = dt_get_regulator_name(subnode, "phy-supply");
if (reg_name != NULL) {
return reg_name;
}
}
return NULL;
}
/*******************************************************************************
* This function retrieves board model from DT
* Returns string taken from model node, NULL otherwise
......
......@@ -161,6 +161,23 @@ static void initialize_pll1_settings(void)
}
}
static void disable_usb_phy_regulator(void)
{
if (dt_pmic_status() > 0) {
const char *name = stm32mp_get_usb_phy_supply_name();
int ret;
if (name == NULL) {
return;
}
ret = stpmic1_regulator_disable(name);
if (ret < 0) {
WARN("USBPHYC phy-supply (%s) disable failed\n", name);
}
}
}
/*******************************************************************************
* Interrupt handler for FIQ (secure IRQ)
******************************************************************************/
......@@ -524,6 +541,8 @@ void sp_min_early_platform_setup2(u_register_t arg0, u_register_t arg1,
initialize_pmic();
}
disable_usb_phy_regulator();
initialize_pll1_settings();
stm32mp1_init_lp_states();
......
......@@ -653,6 +653,7 @@ static inline uint32_t tamp_bkpr(uint32_t idx)
#define DT_PWR_COMPAT "st,stm32mp1,pwr-reg"
#define DT_RCC_CLK_COMPAT "st,stm32mp1-rcc"
#define DT_RCC_SEC_CLK_COMPAT "st,stm32mp1-rcc-secure"
#define DT_USBPHYC_COMPAT "st,stm32mp1-usbphyc"
#define DT_PLL1_NODE_NAME "st,pll@0"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment