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 <erwan.gouriou@linaro.org>
This commit is contained in:
Erwan Gouriou 2019-07-01 14:27:08 +02:00 committed by Anas Nashif
commit 0914f1031d
2 changed files with 11 additions and 0 deletions

View file

@ -267,6 +267,11 @@ static int gpio_stm32_config(struct device *dev, int access_op,
return -ENOTSUP; 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 /* figure out if we can map the requested GPIO
* configuration * 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; return 0;
} }

View file

@ -21,6 +21,8 @@
#define LL_HSEM_ID_0 (0U) /* HW semaphore 0 */ #define LL_HSEM_ID_0 (0U) /* HW semaphore 0 */
#define LL_HSEM_MASK_0 (1 << LL_HSEM_ID_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 <stm32h7xx_ll_hsem.h> #include <stm32h7xx_ll_hsem.h>