Skip to content
Permalink
Browse files

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>
  • Loading branch information...
erwango authored and nashif committed Jul 1, 2019
1 parent edd2b44 commit 0914f1031d516f8164f9868068e15ac5979f9bd7
Showing with 11 additions and 0 deletions.
  1. +9 −0 drivers/gpio/gpio_stm32.c
  2. +2 −0 soc/arm/st_stm32/stm32h7/soc.h
@@ -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;
}

@@ -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 <stm32h7xx_ll_hsem.h>

0 comments on commit 0914f10

Please sign in to comment.
You can’t perform that action at this time.