Merge "drivers/stm32mp_pmic: register PMIC resources as secure or not" into integration

This commit is contained in:
Madhukar Pappireddy 2020-07-16 14:40:13 +00:00 committed by TrustedFirmware Code Review
commit f4d5b6a78a
1 changed files with 24 additions and 0 deletions

View File

@ -54,6 +54,15 @@ int dt_pmic_status(void)
return fdt_get_status(node);
}
static bool dt_pmic_is_secure(void)
{
int status = dt_pmic_status();
return (status >= 0) &&
(status == DT_SECURE) &&
(i2c_handle.dt_status == DT_SECURE);
}
/*
* Get PMIC and its I2C bus configuration from the device tree.
* Return 0 on success, negative on error, 1 if no PMIC node is found.
@ -223,6 +232,19 @@ bool initialize_pmic_i2c(void)
return true;
}
static void register_pmic_shared_peripherals(void)
{
uintptr_t i2c_base = i2c_handle.i2c_base_addr;
if (dt_pmic_is_secure()) {
stm32mp_register_secure_periph_iomem(i2c_base);
} else {
if (i2c_base != 0U) {
stm32mp_register_non_secure_periph_iomem(i2c_base);
}
}
}
void initialize_pmic(void)
{
unsigned long pmic_version;
@ -232,6 +254,8 @@ void initialize_pmic(void)
return;
}
register_pmic_shared_peripherals();
if (stpmic1_get_version(&pmic_version) != 0) {
ERROR("Failed to access PMIC\n");
panic();