stm32mp1: update clock driver
Remove useless private structure in function prototypes.
Add a reference counter on clocks.
Prepare for future secured/shared/non-secured clocks.
Change-Id: I3dbed81721da5ceff5e10b2c4155b1e340c036ee
Signed-off-by: Yann Gautier <yann.gautier@st.com>
Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
Signed-off-by: Nicolas LE BAYON <nicolas.le.bayon@st.com>
diff --git a/plat/st/stm32mp1/bl2_plat_setup.c b/plat/st/stm32mp1/bl2_plat_setup.c
index 5ab20845..c7bc39f 100644
--- a/plat/st/stm32mp1/bl2_plat_setup.c
+++ b/plat/st/stm32mp1/bl2_plat_setup.c
@@ -225,9 +225,7 @@
goto skip_console_init;
}
- if (stm32mp_clk_enable((unsigned long)dt_uart_info.clock) != 0) {
- goto skip_console_init;
- }
+ stm32mp_clk_enable((unsigned long)dt_uart_info.clock);
stm32mp_reset_assert((uint32_t)dt_uart_info.reset);
udelay(2);
diff --git a/plat/st/stm32mp1/stm32mp1_context.c b/plat/st/stm32mp1/stm32mp1_context.c
index c402c20..cf8a91e 100644
--- a/plat/st/stm32mp1/stm32mp1_context.c
+++ b/plat/st/stm32mp1/stm32mp1_context.c
@@ -20,26 +20,16 @@
int stm32_save_boot_interface(uint32_t interface, uint32_t instance)
{
- uint32_t tamp_clk_off = 0;
uint32_t bkpr_itf_idx = tamp_bkpr(TAMP_BOOT_ITF_BACKUP_REG_ID);
- if (!stm32mp_clk_is_enabled(RTCAPB)) {
- tamp_clk_off = 1;
- if (stm32mp_clk_enable(RTCAPB) != 0) {
- return -EINVAL;
- }
- }
+ stm32mp_clk_enable(RTCAPB);
mmio_clrsetbits_32(bkpr_itf_idx,
TAMP_BOOT_ITF_MASK,
((interface << 4) | (instance & 0xFU)) <<
TAMP_BOOT_ITF_SHIFT);
- if (tamp_clk_off != 0U) {
- if (stm32mp_clk_disable(RTCAPB) != 0) {
- return -EINVAL;
- }
- }
+ stm32mp_clk_disable(RTCAPB);
return 0;
}
diff --git a/plat/st/stm32mp1/stm32mp1_def.h b/plat/st/stm32mp1/stm32mp1_def.h
index 8d7cea3..f0dc575 100644
--- a/plat/st/stm32mp1/stm32mp1_def.h
+++ b/plat/st/stm32mp1/stm32mp1_def.h
@@ -20,6 +20,7 @@
#include <boot_api.h>
#include <stm32mp_common.h>
#include <stm32mp_dt.h>
+#include <stm32mp_shres_helpers.h>
#include <stm32mp1_private.h>
#endif
diff --git a/plat/st/stm32mp1/stm32mp1_pm.c b/plat/st/stm32mp1/stm32mp1_pm.c
index 3262607..cf9fa8e 100644
--- a/plat/st/stm32mp1/stm32mp1_pm.c
+++ b/plat/st/stm32mp1/stm32mp1_pm.c
@@ -59,7 +59,6 @@
static int stm32_pwr_domain_on(u_register_t mpidr)
{
unsigned long current_cpu_mpidr = read_mpidr_el1();
- uint32_t tamp_clk_off = 0;
uint32_t bkpr_core1_addr =
tamp_bkpr(BOOT_API_CORE1_BRANCH_ADDRESS_TAMP_BCK_REG_IDX);
uint32_t bkpr_core1_magic =
@@ -75,12 +74,7 @@
return PSCI_E_INVALID_ADDRESS;
}
- if (!stm32mp_clk_is_enabled(RTCAPB)) {
- tamp_clk_off = 1;
- if (stm32mp_clk_enable(RTCAPB) != 0) {
- panic();
- }
- }
+ stm32mp_clk_enable(RTCAPB);
cntfrq_core0 = read_cntfrq_el0();
@@ -90,11 +84,7 @@
/* Write magic number in backup register */
mmio_write_32(bkpr_core1_magic, BOOT_API_A7_CORE1_MAGIC_NUMBER);
- if (tamp_clk_off != 0U) {
- if (stm32mp_clk_disable(RTCAPB) != 0) {
- panic();
- }
- }
+ stm32mp_clk_disable(RTCAPB);
/* Generate an IT to core 1 */
gicv2_raise_sgi(ARM_IRQ_SEC_SGI_0, STM32MP_SECONDARY_CPU);
diff --git a/plat/st/stm32mp1/stm32mp1_security.c b/plat/st/stm32mp1/stm32mp1_security.c
index baa3916..ebf1587 100644
--- a/plat/st/stm32mp1/stm32mp1_security.c
+++ b/plat/st/stm32mp1/stm32mp1_security.c
@@ -61,14 +61,8 @@
******************************************************************************/
static void early_init_tzc400(void)
{
- if (stm32mp_clk_enable(TZC1) != 0) {
- ERROR("Cannot enable TZC1 clock\n");
- panic();
- }
- if (stm32mp_clk_enable(TZC2) != 0) {
- ERROR("Cannot enable TZC2 clock\n");
- panic();
- }
+ stm32mp_clk_enable(TZC1);
+ stm32mp_clk_enable(TZC2);
tzc400_init(STM32MP1_TZC_BASE);