From 812daf916c9c977a4f6d7d745d22b90c8492fc71 Mon Sep 17 00:00:00 2001 From: Lionel Debieve Date: Tue, 15 Dec 2020 10:35:59 +0100 Subject: [PATCH] feat(st): update the security based on new compatible From the new binding, the RCC become secured based on the new compatible. This must be done only from the secure OS initialisation. Signed-off-by: Lionel Debieve Change-Id: I7f0a62f22bfcca638ddaefc9563df00f89f01653 --- drivers/st/clk/stm32mp1_clk.c | 11 ++++++----- drivers/st/clk/stm32mp_clkfunc.c | 12 +++++------- include/drivers/st/stm32mp_clkfunc.h | 2 +- plat/st/stm32mp1/stm32mp1_def.h | 1 + 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/st/clk/stm32mp1_clk.c b/drivers/st/clk/stm32mp1_clk.c index af8b71e32..f525741b6 100644 --- a/drivers/st/clk/stm32mp1_clk.c +++ b/drivers/st/clk/stm32mp1_clk.c @@ -1837,11 +1837,6 @@ int stm32mp1_clk_init(void) return -FDT_ERR_NOTFOUND; } - /* Check status field to disable security */ - if (!fdt_get_rcc_secure_status()) { - mmio_write_32(rcc_base + RCC_TZCR, 0); - } - ret = fdt_rcc_read_uint32_array("st,clksrc", (uint32_t)CLKSRC_NB, clksrc); if (ret < 0) { @@ -2358,6 +2353,12 @@ static const struct clk_ops stm32mp_clk_ops = { int stm32mp1_clk_probe(void) { +#if defined(IMAGE_BL32) + if (!fdt_get_rcc_secure_state()) { + mmio_write_32(stm32mp_rcc_base() + RCC_TZCR, 0U); + } +#endif + stm32mp1_osc_init(); sync_earlyboot_clocks_state(); diff --git a/drivers/st/clk/stm32mp_clkfunc.c b/drivers/st/clk/stm32mp_clkfunc.c index a013a82c0..80c2f4102 100644 --- a/drivers/st/clk/stm32mp_clkfunc.c +++ b/drivers/st/clk/stm32mp_clkfunc.c @@ -250,24 +250,22 @@ const fdt32_t *fdt_rcc_read_prop(const char *prop_name, int *lenp) } /* - * Get the secure status for rcc node in device tree. - * @return: true if rcc is available from secure world, false if not. + * Get the secure state for rcc node in device tree. + * @return: true if rcc is configured for secure world access, false if not. */ -bool fdt_get_rcc_secure_status(void) +bool fdt_get_rcc_secure_state(void) { - int node; void *fdt; if (fdt_get_address(&fdt) == 0) { return false; } - node = fdt_get_rcc_node(fdt); - if (node < 0) { + if (fdt_node_offset_by_compatible(fdt, -1, DT_RCC_SEC_CLK_COMPAT) < 0) { return false; } - return !!(fdt_get_status(node) & DT_SECURE); + return true; } /* diff --git a/include/drivers/st/stm32mp_clkfunc.h b/include/drivers/st/stm32mp_clkfunc.h index 9df38d685..61286b224 100644 --- a/include/drivers/st/stm32mp_clkfunc.h +++ b/include/drivers/st/stm32mp_clkfunc.h @@ -23,7 +23,7 @@ int fdt_rcc_read_uint32_array(const char *prop_name, uint32_t count, uint32_t *array); int fdt_rcc_subnode_offset(const char *name); const fdt32_t *fdt_rcc_read_prop(const char *prop_name, int *lenp); -bool fdt_get_rcc_secure_status(void); +bool fdt_get_rcc_secure_state(void); int fdt_get_clock_id(int node); unsigned long fdt_get_uart_clock_freq(uintptr_t instance); diff --git a/plat/st/stm32mp1/stm32mp1_def.h b/plat/st/stm32mp1/stm32mp1_def.h index 76f358569..fd1215992 100644 --- a/plat/st/stm32mp1/stm32mp1_def.h +++ b/plat/st/stm32mp1/stm32mp1_def.h @@ -492,5 +492,6 @@ static inline uint32_t tamp_bkpr(uint32_t idx) #define DT_NVMEM_LAYOUT_COMPAT "st,stm32-nvmem-layout" #define DT_PWR_COMPAT "st,stm32mp1,pwr-reg" #define DT_RCC_CLK_COMPAT "st,stm32mp1-rcc" +#define DT_RCC_SEC_CLK_COMPAT "st,stm32mp1-rcc-secure" #endif /* STM32MP1_DEF_H */