drivers/gpio: stm32l4: PortG[15:2] requires dedicated VDDio2

On STM32L4, 14 pins (Port G[15:2]), require external power supply.
Activate this at port G init when PWR_CR2_IOSV is defined.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
Erwan Gouriou 2018-12-19 10:32:55 +01:00 committed by Kumar Gala
commit f5d48240e9
2 changed files with 19 additions and 0 deletions

View file

@ -197,6 +197,20 @@ static int gpio_stm32_init(struct device *device)
return -EIO;
}
#ifdef PWR_CR2_IOSV
if (cfg->port == STM32_PORTG) {
/* Port G[15:2] requires external power supply */
/* Cf: L4XX RM, §5.1 Power supplies */
if (LL_APB1_GRP1_IsEnabledClock(LL_APB1_GRP1_PERIPH_PWR)) {
LL_PWR_EnableVddIO2();
} else {
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
LL_PWR_EnableVddIO2();
LL_APB1_GRP1_DisableClock(LL_APB1_GRP1_PERIPH_PWR);
}
}
#endif /* PWR_CR2_IOSV */
return 0;
}

View file

@ -34,6 +34,11 @@
/* base address for where GPIO registers start */
#define GPIO_PORTS_BASE (GPIOA_BASE)
#ifdef CONFIG_GPIO_STM32
/* Required to enable VDDio2 for port G */
#include <stm32l4xx_ll_pwr.h>
#endif
#ifdef CONFIG_SERIAL_HAS_DRIVER
#include <stm32l4xx_ll_usart.h>
#include <stm32l4xx_ll_lpuart.h>