From 0914f1031d516f8164f9868068e15ac5979f9bd7 Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Mon, 1 Jul 2019 14:27:08 +0200 Subject: [PATCH] drivers/gpio: stm32: Add semaphore on gpio_configure Protect gpio_configure function in dual core context. This operation is not needed for other fuctions of the api: * init * read * write Protecting gpio_configure also protects access to interrupt_controller IP. Signed-off-by: Erwan Gouriou --- drivers/gpio/gpio_stm32.c | 9 +++++++++ soc/arm/st_stm32/stm32h7/soc.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/drivers/gpio/gpio_stm32.c b/drivers/gpio/gpio_stm32.c index 8c1cd8d2ee7..e5d9810bb2a 100644 --- a/drivers/gpio/gpio_stm32.c +++ b/drivers/gpio/gpio_stm32.c @@ -267,6 +267,11 @@ static int gpio_stm32_config(struct device *dev, int access_op, return -ENOTSUP; } +#if defined(CONFIG_STM32H7_DUAL_CORE) + while (LL_HSEM_1StepLock(HSEM, LL_HSEM_ID_1)) { + } +#endif /* CONFIG_STM32H7_DUAL_CORE */ + /* figure out if we can map the requested GPIO * configuration */ @@ -312,6 +317,10 @@ static int gpio_stm32_config(struct device *dev, int access_op, } +#if defined(CONFIG_STM32H7_DUAL_CORE) + LL_HSEM_ReleaseLock(HSEM, LL_HSEM_ID_1, HSEM_CR_COREID_CURRENT); +#endif /* CONFIG_STM32H7_DUAL_CORE */ + return 0; } diff --git a/soc/arm/st_stm32/stm32h7/soc.h b/soc/arm/st_stm32/stm32h7/soc.h index 505c6d1c088..e8407df0f3b 100644 --- a/soc/arm/st_stm32/stm32h7/soc.h +++ b/soc/arm/st_stm32/stm32h7/soc.h @@ -21,6 +21,8 @@ #define LL_HSEM_ID_0 (0U) /* HW semaphore 0 */ #define LL_HSEM_MASK_0 (1 << LL_HSEM_ID_0) +#define LL_HSEM_ID_1 (1U) /* HW semaphore 1 */ +#define LL_HSEM_MASK_1 (1 << LL_HSEM_ID_1) #include