mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-20 19:44:23 +00:00
refactor(st): update CPU and VDD voltage get
Use regulator framework to get CPU and VDD power supplies. Change-Id: Ice745fb21ff10e71ef811e747165499c2e19253e Signed-off-by: Pascal Paillet <p.paillet@st.com> Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
This commit is contained in:
parent
67d95409ba
commit
c39c658e75
2 changed files with 36 additions and 26 deletions
|
@ -37,6 +37,8 @@ int dt_get_stdout_uart_info(struct dt_node_info *info);
|
||||||
int dt_match_instance_by_compatible(const char *compatible, uintptr_t address);
|
int dt_match_instance_by_compatible(const char *compatible, uintptr_t address);
|
||||||
uint32_t dt_get_ddr_size(void);
|
uint32_t dt_get_ddr_size(void);
|
||||||
uint32_t dt_get_pwr_vdd_voltage(void);
|
uint32_t dt_get_pwr_vdd_voltage(void);
|
||||||
|
struct rdev *dt_get_vdd_regulator(void);
|
||||||
|
struct rdev *dt_get_cpu_regulator(void);
|
||||||
const char *dt_get_board_model(void);
|
const char *dt_get_board_model(void);
|
||||||
int fdt_get_gpio_bank_pin_count(unsigned int bank);
|
int fdt_get_gpio_bank_pin_count(unsigned int bank);
|
||||||
|
|
||||||
|
|
|
@ -7,16 +7,15 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <libfdt.h>
|
|
||||||
|
|
||||||
#include <platform_def.h>
|
|
||||||
|
|
||||||
#include <common/debug.h>
|
#include <common/debug.h>
|
||||||
#include <common/fdt_wrappers.h>
|
#include <common/fdt_wrappers.h>
|
||||||
|
#include <drivers/st/regulator.h>
|
||||||
#include <drivers/st/stm32_gpio.h>
|
#include <drivers/st/stm32_gpio.h>
|
||||||
#include <drivers/st/stm32mp1_ddr.h>
|
#include <drivers/st/stm32mp1_ddr.h>
|
||||||
#include <drivers/st/stm32mp1_ram.h>
|
#include <drivers/st/stm32mp1_ram.h>
|
||||||
|
#include <libfdt.h>
|
||||||
|
|
||||||
|
#include <platform_def.h>
|
||||||
#include <stm32mp_dt.h>
|
#include <stm32mp_dt.h>
|
||||||
|
|
||||||
static void *fdt;
|
static void *fdt;
|
||||||
|
@ -262,37 +261,46 @@ uint32_t dt_get_ddr_size(void)
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
uint32_t dt_get_pwr_vdd_voltage(void)
|
uint32_t dt_get_pwr_vdd_voltage(void)
|
||||||
{
|
{
|
||||||
int node, pwr_regulators_node;
|
struct rdev *regul = dt_get_vdd_regulator();
|
||||||
const fdt32_t *cuint;
|
uint16_t min;
|
||||||
|
|
||||||
|
if (regul == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
regulator_get_range(regul, &min, NULL);
|
||||||
|
|
||||||
|
return (uint32_t)min * 1000U;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* This function retrieves VDD supply regulator from DT.
|
||||||
|
* Returns an rdev taken from supply node, NULL otherwise.
|
||||||
|
******************************************************************************/
|
||||||
|
struct rdev *dt_get_vdd_regulator(void)
|
||||||
|
{
|
||||||
|
int node = fdt_node_offset_by_compatible(fdt, -1, DT_PWR_COMPAT);
|
||||||
|
|
||||||
node = fdt_node_offset_by_compatible(fdt, -1, DT_PWR_COMPAT);
|
|
||||||
if (node < 0) {
|
if (node < 0) {
|
||||||
INFO("%s: Cannot read PWR node in DT\n", __func__);
|
return NULL;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pwr_regulators_node = fdt_subnode_offset(fdt, node, "pwr-regulators");
|
return regulator_get_by_supply_name(fdt, node, "vdd");
|
||||||
if (pwr_regulators_node < 0) {
|
|
||||||
INFO("%s: Cannot read pwr-regulators node in DT\n", __func__);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cuint = fdt_getprop(fdt, pwr_regulators_node, "vdd-supply", NULL);
|
/*******************************************************************************
|
||||||
if (cuint == NULL) {
|
* This function retrieves CPU supply regulator from DT.
|
||||||
return 0;
|
* Returns an rdev taken from supply node, NULL otherwise.
|
||||||
}
|
******************************************************************************/
|
||||||
|
struct rdev *dt_get_cpu_regulator(void)
|
||||||
|
{
|
||||||
|
int node = fdt_path_offset(fdt, "/cpus/cpu@0");
|
||||||
|
|
||||||
node = fdt_node_offset_by_phandle(fdt, fdt32_to_cpu(*cuint));
|
|
||||||
if (node < 0) {
|
if (node < 0) {
|
||||||
return 0;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cuint = fdt_getprop(fdt, node, "regulator-min-microvolt", NULL);
|
return regulator_get_by_supply_name(fdt, node, "cpu");
|
||||||
if (cuint == NULL) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fdt32_to_cpu(*cuint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
Loading…
Add table
Reference in a new issue