Commit f564d439 authored by Etienne Carriere's avatar Etienne Carriere
Browse files

drivers/stm32mp_pmic: register PMIC resources as secure or not



Register in the shared resources driver the secure or non-secure
state of the PMIC.

Change-Id: Ic1f172ba62785018f8e9bb321782d725e2d2f434
Signed-off-by: default avatarEtienne Carriere <etienne.carriere@st.com>
parent ec8f4212
...@@ -54,6 +54,15 @@ int dt_pmic_status(void) ...@@ -54,6 +54,15 @@ int dt_pmic_status(void)
return fdt_get_status(node); 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. * 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. * Return 0 on success, negative on error, 1 if no PMIC node is found.
...@@ -223,6 +232,19 @@ bool initialize_pmic_i2c(void) ...@@ -223,6 +232,19 @@ bool initialize_pmic_i2c(void)
return true; 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) void initialize_pmic(void)
{ {
unsigned long pmic_version; unsigned long pmic_version;
...@@ -232,6 +254,8 @@ void initialize_pmic(void) ...@@ -232,6 +254,8 @@ void initialize_pmic(void)
return; return;
} }
register_pmic_shared_peripherals();
if (stpmic1_get_version(&pmic_version) != 0) { if (stpmic1_get_version(&pmic_version) != 0) {
ERROR("Failed to access PMIC\n"); ERROR("Failed to access PMIC\n");
panic(); panic();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment