Skip to content
Snippets Groups Projects
Commit 473f04d5 authored by Nicolas Le Bayon's avatar Nicolas Le Bayon Committed by Sebastien Pasdeloup
Browse files

stm32mp1: get CPU supply name


Replace hard-coded regulator names by stm32mp_get_cpu_supply_name()
platform service which gets CPU regulator name from DT and finds its
related supply name.

Change-Id: I8a0ed4cbb9c4df729ecda95220a24b9c2f429d0f
Signed-off-by: default avatarNicolas Le Bayon <nicolas.le.bayon@st.com>
parent 02c769bc
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,8 @@ bool stm32mp_is_single_core(void);
bool stm32mp_is_closed_device(void);
bool stm32mp_is_auth_supported(void);
const char *stm32mp_get_cpu_supply_name(void);
/* Return the base address of the DDR controller */
uintptr_t stm32mp_ddrctrl_base(void);
......
......@@ -12,6 +12,7 @@
#include <arch_helpers.h>
#include <common/debug.h>
#include <drivers/st/stm32mp_clkfunc.h>
#include <drivers/st/stm32mp_pmic.h>
#include <lib/spinlock.h>
#include <lib/xlat_tables/xlat_tables_v2.h>
#include <plat/common/platform.h>
......@@ -141,6 +142,26 @@ int stm32mp_check_header(boot_api_image_header_t *header, uintptr_t buffer)
return 0;
}
/* Return CPU supply name */
const char *stm32mp_get_cpu_supply_name(void)
{
const char *regulator;
const char *supply = NULL;
regulator = dt_get_cpu_regulator_name();
if (regulator == NULL) {
return NULL;
}
if (dt_pmic_status() > 0) {
if (dt_pmic_find_supply(&supply, regulator) != 0) {
return NULL;
}
}
return supply;
}
int stm32mp_map_ddr_non_cacheable(void)
{
return mmap_add_dynamic_region(STM32MP_DDR_BASE, STM32MP_DDR_BASE,
......
......@@ -244,9 +244,9 @@ static void initialize_clock(void)
/*
* If no pre-defined PLL1 settings in DT, find the highest frequency
* in the OPP table (in DT, compatible with plaform capabilities, or
* in structure restored in RAM), and set related VDDCORE voltage.
* If PLL1 settings found in DT, we consider VDDCORE voltage in DT is
* consistent with it.
* in structure restored in RAM), and set related CPU supply voltage.
* If PLL1 settings found in DT, we consider CPU supply voltage in DT
* is consistent with it.
*/
if ((ret == 0) && !fdt_is_pll1_predefined()) {
if (wakeup_standby) {
......@@ -262,7 +262,12 @@ static void initialize_clock(void)
if (dt_pmic_status() > 0) {
int read_voltage;
const char *name = "buck1";
const char *name;
name = stm32mp_get_cpu_supply_name();
if (name == NULL) {
panic();
}
read_voltage = stpmic1_regulator_voltage_get(name);
if (read_voltage < 0) {
......
......@@ -126,24 +126,29 @@ static void configure_wakeup_interrupt(void)
static void initialize_pll1_settings(void)
{
uint32_t vddcore_voltage = 0U;
uint32_t cpu_voltage = 0U;
if (stm32_are_pll1_settings_valid_in_context()) {
return;
}
if (dt_pmic_status() > 0) {
const char *name = stm32mp_get_cpu_supply_name();
int ret;
ret = stpmic1_regulator_voltage_get("buck1");
if (name == NULL) {
panic();
}
ret = stpmic1_regulator_voltage_get(name);
if (ret < 0) {
panic();
}
vddcore_voltage = (uint32_t)ret;
cpu_voltage = (uint32_t)ret;
}
if (stm32mp1_clk_compute_all_pll1_settings(vddcore_voltage) != 0) {
if (stm32mp1_clk_compute_all_pll1_settings(cpu_voltage) != 0) {
panic();
}
}
......
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