mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-17 10:04:26 +00:00
feat(stm32mp1): handle DDR power supplies
Modify the DDR driver to handle the DDR power supplies when a PMIC is present in the function stm32mp_board_ddr_power_init(), define in the platform file. This patch allows to easily modify the used DDR power supplies for customer boards, when they don't use STPMIC1 PMU or when the regulators are not connected as on the STMicroelectronics boards. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Change-Id: I93ee6295ef7032ac20f03608d22cd460f7d87ef5
This commit is contained in:
parent
1f6cf1e447
commit
47e62314b6
5 changed files with 140 additions and 134 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2022, STMicroelectronics - All Rights Reserved
|
||||
* Copyright (C) 2022-2024, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
@ -8,7 +8,6 @@
|
|||
#include <drivers/delay_timer.h>
|
||||
#include <drivers/st/stm32mp_ddr.h>
|
||||
#include <drivers/st/stm32mp_ddrctrl_regs.h>
|
||||
#include <drivers/st/stm32mp_pmic.h>
|
||||
#include <lib/mmio.h>
|
||||
|
||||
#include <platform_def.h>
|
||||
|
@ -95,12 +94,3 @@ void stm32mp_ddr_enable_axi_port(struct stm32mp_ddrctl *ctl)
|
|||
#endif
|
||||
|
||||
}
|
||||
|
||||
int stm32mp_board_ddr_power_init(enum ddr_type ddr_type)
|
||||
{
|
||||
if (dt_pmic_status() > 0) {
|
||||
return pmic_ddr_power_init(ddr_type);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2022, STMicroelectronics - All Rights Reserved
|
||||
* Copyright (c) 2017-2024, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
@ -216,120 +216,6 @@ void print_pmic_info_and_debug(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
int pmic_ddr_power_init(enum ddr_type ddr_type)
|
||||
{
|
||||
int status;
|
||||
uint16_t buck3_min_mv;
|
||||
struct rdev *buck2, *buck3, *vref;
|
||||
struct rdev *ldo3 __unused;
|
||||
|
||||
buck2 = regulator_get_by_name("buck2");
|
||||
if (buck2 == NULL) {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
#if STM32MP15
|
||||
ldo3 = regulator_get_by_name("ldo3");
|
||||
if (ldo3 == NULL) {
|
||||
return -ENOENT;
|
||||
}
|
||||
#endif
|
||||
|
||||
vref = regulator_get_by_name("vref_ddr");
|
||||
if (vref == NULL) {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
switch (ddr_type) {
|
||||
case STM32MP_DDR3:
|
||||
#if STM32MP15
|
||||
status = regulator_set_flag(ldo3, REGUL_SINK_SOURCE);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
status = regulator_set_min_voltage(buck2);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = regulator_enable(buck2);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = regulator_enable(vref);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
#if STM32MP15
|
||||
status = regulator_enable(ldo3);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case STM32MP_LPDDR2:
|
||||
case STM32MP_LPDDR3:
|
||||
/*
|
||||
* Set LDO3 to 1.8V
|
||||
* Set LDO3 to bypass mode if BUCK3 = 1.8V
|
||||
* Set LDO3 to normal mode if BUCK3 != 1.8V
|
||||
*/
|
||||
buck3 = regulator_get_by_name("buck3");
|
||||
if (buck3 == NULL) {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
regulator_get_range(buck3, &buck3_min_mv, NULL);
|
||||
|
||||
#if STM32MP15
|
||||
if (buck3_min_mv != 1800) {
|
||||
status = regulator_set_min_voltage(ldo3);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
} else {
|
||||
status = regulator_set_flag(ldo3, REGUL_ENABLE_BYPASS);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
status = regulator_set_min_voltage(buck2);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
#if STM32MP15
|
||||
status = regulator_enable(ldo3);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
status = regulator_enable(buck2);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = regulator_enable(vref);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pmic_voltages_init(void)
|
||||
{
|
||||
#if STM32MP13
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2022, STMicroelectronics - All Rights Reserved
|
||||
* Copyright (c) 2017-2024, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
@ -41,13 +41,6 @@ static inline void print_pmic_info_and_debug(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* pmic_ddr_power_init - Initialize regulators required for DDR
|
||||
*
|
||||
* Returns 0 on success, and negative values on errors
|
||||
*/
|
||||
int pmic_ddr_power_init(enum ddr_type ddr_type);
|
||||
|
||||
/*
|
||||
* pmic_voltages_init - Update voltages for platform init
|
||||
*
|
||||
|
|
135
plat/st/stm32mp1/plat_ddr.c
Normal file
135
plat/st/stm32mp1/plat_ddr.c
Normal file
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* Copyright (C) 2024, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <drivers/st/regulator.h>
|
||||
#include <drivers/st/stm32mp_ddr.h>
|
||||
#include <drivers/st/stm32mp_pmic.h>
|
||||
|
||||
/* configure the STPMIC1 regulators on STMicroelectronics boards */
|
||||
static int pmic_ddr_power_init(enum ddr_type ddr_type)
|
||||
{
|
||||
int status;
|
||||
uint16_t buck3_min_mv __maybe_unused;
|
||||
struct rdev *buck2, *buck3 __maybe_unused, *vref;
|
||||
struct rdev *ldo3 __maybe_unused;
|
||||
|
||||
buck2 = regulator_get_by_name("buck2");
|
||||
if (buck2 == NULL) {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
#if STM32MP15
|
||||
ldo3 = regulator_get_by_name("ldo3");
|
||||
if (ldo3 == NULL) {
|
||||
return -ENOENT;
|
||||
}
|
||||
#endif
|
||||
|
||||
vref = regulator_get_by_name("vref_ddr");
|
||||
if (vref == NULL) {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
switch (ddr_type) {
|
||||
case STM32MP_DDR3:
|
||||
#if STM32MP15
|
||||
status = regulator_set_flag(ldo3, REGUL_SINK_SOURCE);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
status = regulator_set_min_voltage(buck2);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = regulator_enable(buck2);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = regulator_enable(vref);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
#if STM32MP15
|
||||
status = regulator_enable(ldo3);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case STM32MP_LPDDR2:
|
||||
case STM32MP_LPDDR3:
|
||||
#if STM32MP15
|
||||
/*
|
||||
* Set LDO3 to 1.8V according BUCK3 voltage
|
||||
* => bypass mode if BUCK3 = 1.8V
|
||||
* => normal mode if BUCK3 != 1.8V
|
||||
*/
|
||||
buck3 = regulator_get_by_name("buck3");
|
||||
if (buck3 == NULL) {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
regulator_get_range(buck3, &buck3_min_mv, NULL);
|
||||
|
||||
if (buck3_min_mv != 1800) {
|
||||
status = regulator_set_min_voltage(ldo3);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
} else {
|
||||
status = regulator_set_flag(ldo3, REGUL_ENABLE_BYPASS);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
status = regulator_set_min_voltage(buck2);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
#if STM32MP15
|
||||
status = regulator_enable(ldo3);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
status = regulator_enable(buck2);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = regulator_enable(vref);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int stm32mp_board_ddr_power_init(enum ddr_type ddr_type)
|
||||
{
|
||||
if (dt_pmic_status() > 0) {
|
||||
return pmic_ddr_power_init(ddr_type);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -253,6 +253,8 @@ endif
|
|||
BL2_SOURCES += drivers/st/ddr/stm32mp1_ddr.c \
|
||||
drivers/st/ddr/stm32mp1_ram.c
|
||||
|
||||
BL2_SOURCES += plat/st/stm32mp1/plat_ddr.c
|
||||
|
||||
ifeq ($(AARCH32_SP),sp_min)
|
||||
# Create DTB file for BL32
|
||||
${BUILD_PLAT}/fdts/%-bl32.dts: fdts/%.dts fdts/${BL32_DTSI} | $$(@D)/
|
||||
|
|
Loading…
Add table
Reference in a new issue