Skip to content
Snippets Groups Projects
Commit 3ff57fd2 authored by Lionel Debieve's avatar Lionel Debieve Committed by Sebastien Pasdeloup
Browse files

stm32mp: add function to retrieve VDD regulator


Add function to find from device tree the proper regulator
that controls the VDD domain. Rework the dt_get_cpu_regulator_name
to use the same generic function.

Signed-off-by: default avatarLionel Debieve <lionel.debieve@st.com>
Change-Id: I75f96d30a408f6d10182fc780bc40c3971b6095f
Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/tf-a/+/185334


Reviewed-by: default avatarCITOOLS <smet-aci-reviews@lists.codex.cro.st.com>
Reviewed-by: default avatarCIBUILD <smet-aci-builds@lists.codex.cro.st.com>
Reviewed-by: default avatarYann GAUTIER <yann.gautier@st.com>
parent 5c128587
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,7 @@ bool stm32mp_is_closed_device(void);
bool stm32mp_is_auth_supported(void);
const char *stm32mp_get_cpu_supply_name(void);
const char *stm32mp_get_vdd_supply_name(void);
/* Return the base address of the DDR controller */
uintptr_t stm32mp_ddrctrl_base(void);
......
/*
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
* Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
......@@ -44,6 +44,7 @@ int dt_get_max_opp_freqvolt(uint32_t *freq_khz, uint32_t *voltage_mv);
int dt_get_all_opp_freqvolt(uint32_t *count, uint32_t *freq_khz_array,
uint32_t *voltage_mv_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_board_model(void);
int fdt_get_gpio_bank_pin_count(unsigned int bank);
......
......@@ -167,6 +167,22 @@ const char *stm32mp_get_cpu_supply_name(void)
return supply;
}
/* Return VDD supply name */
const char *stm32mp_get_vdd_supply_name(void)
{
const char *supply = NULL;
if (dt_pmic_status() > 0) {
const char *regulator = dt_get_vdd_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;
......
......@@ -485,20 +485,17 @@ uint32_t dt_get_pwr_vdd_voltage(void)
}
/*******************************************************************************
* This function retrieves CPU regulator name from DT.
* Returns string taken from supply node, NULL otherwise.
* This function return the real regulator name from DT.
******************************************************************************/
const char *dt_get_cpu_regulator_name(void)
static const char *dt_get_regulator_name(int node, const char *regu_name)
{
int node;
const fdt32_t *cuint;
node = fdt_path_offset(fdt, "/cpus/cpu@0");
if (node < 0) {
if ((node < 0) || (regu_name == NULL)) {
return NULL;
}
cuint = fdt_getprop(fdt, node, "cpu-supply", NULL);
cuint = fdt_getprop(fdt, node, regu_name, NULL);
if (cuint == NULL) {
return NULL;
}
......@@ -511,6 +508,36 @@ const char *dt_get_cpu_regulator_name(void)
return (const char *)fdt_getprop(fdt, node, "regulator-name", NULL);
}
/*******************************************************************************
* This function retrieves VDD regulator name from DT.
* Returns string taken from supply node, NULL otherwise.
******************************************************************************/
const char *dt_get_vdd_regulator_name(void)
{
int node = fdt_node_offset_by_compatible(fdt, -1, DT_PWR_COMPAT);
if (node < 0) {
return NULL;
}
return dt_get_regulator_name(node, "vdd-supply");
}
/*******************************************************************************
* This function retrieves CPU regulator name from DT.
* Returns string taken from supply node, NULL otherwise.
******************************************************************************/
const char *dt_get_cpu_regulator_name(void)
{
int node = fdt_path_offset(fdt, "/cpus/cpu@0");
if (node < 0) {
return NULL;
}
return dt_get_regulator_name(node, "cpu-supply");
}
/*******************************************************************************
* This function retrieves board model from DT
* Returns string taken from model node, NULL otherwise
......
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