From edd2b44a0fd7da85d2d4d1a5a84f63cb7246cee5 Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Fri, 14 Jun 2019 16:18:39 +0200 Subject: [PATCH] drivers/clock_control: stm32h7: Disable configuration for CM4 core On STM32H7, in Dual core configuration, we restrict configuration access to CM7 core. CM4 can access to API but not the init part of the driver. Signed-off-by: Erwan Gouriou --- drivers/clock_control/clock_stm32_ll_h7.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/clock_control/clock_stm32_ll_h7.c b/drivers/clock_control/clock_stm32_ll_h7.c index 4ed253587ca102..c58df7ec8a6d3c 100644 --- a/drivers/clock_control/clock_stm32_ll_h7.c +++ b/drivers/clock_control/clock_stm32_ll_h7.c @@ -32,6 +32,7 @@ /** * @brief fill in AHB/APB buses configuration structure */ +#if !defined(CONFIG_CPU_CORTEX_M4) static void config_bus_prescalers(void) { LL_RCC_SetSysPrescaler(sysclk_prescaler(CONFIG_CLOCK_STM32_D1CPRE)); @@ -41,6 +42,7 @@ static void config_bus_prescalers(void) LL_RCC_SetAPB3Prescaler(apb3_prescaler(CONFIG_CLOCK_STM32_D1PPRE)); LL_RCC_SetAPB4Prescaler(apb4_prescaler(CONFIG_CLOCK_STM32_D3PPRE)); } +#endif /* CONFIG_CPU_CORTEX_M4 */ static u32_t get_bus_clock(u32_t clock, u32_t prescaler) { @@ -54,6 +56,9 @@ static inline int stm32_clock_control_on(struct device *dev, ARG_UNUSED(dev); + /* Both cores can access bansk by following LL API */ + /* Using "_Cn_" LL API would restrict access to one or the other */ + switch (pclken->bus) { case STM32_CLOCK_BUS_AHB1: LL_AHB1_GRP1_EnableClock(pclken->enr); @@ -96,6 +101,9 @@ static inline int stm32_clock_control_off(struct device *dev, ARG_UNUSED(dev); + /* Both cores can access bansk by following LL API */ + /* Using "_Cn_" LL API would restrict access to one or the other */ + switch (pclken->bus) { case STM32_CLOCK_BUS_AHB1: LL_AHB1_GRP1_DisableClock(pclken->enr); @@ -194,6 +202,8 @@ static int stm32_clock_control_init(struct device *dev) { ARG_UNUSED(dev); +#if !defined(CONFIG_CPU_CORTEX_M4) + #ifdef CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL /* Power Configuration */ LL_PWR_ConfigSupply(LL_PWR_DIRECT_SMPS_SUPPLY); @@ -252,6 +262,8 @@ static int stm32_clock_control_init(struct device *dev) #error "CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL not selected" #endif /* CLOCK_STM32_SYSCLK_SRC_PLL */ +#endif /* CONFIG_CPU_CORTEX_M4 */ + /* Set systick to 1ms */ SysTick_Config(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC / 1000); /* Update CMSIS variable */