From 4c349a1eafa02a1f520d7603464cdda1e0c62a7f Mon Sep 17 00:00:00 2001 From: Craig Hesling Date: Mon, 4 Nov 2019 17:09:25 -0800 Subject: stm32f4: Implement UNUSED pins This CL adds support for UNUSED pins to the STM32F4 family of chips. This places the unused/unconnected pins in the lowest power state. In this case, ST recommends that you configure the pin as analog-in to disable the schmitt trigger logic. This codified the work done in crrev.com/c/1883127 . The CL should have no functional change for boards that have not specified UNUSED pins in their gpio.inc. BRANCH=nocturne,hatch BUG=b:130561737 TEST=make buildall -j Change-Id: I444b868b277b016a896e410dccae84429b68839e Signed-off-by: Craig Hesling Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1894242 Reviewed-by: Daisuke Nojiri --- chip/stm32/gpio.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/chip/stm32/gpio.c b/chip/stm32/gpio.c index fe79ca5aad..bb45f0e388 100644 --- a/chip/stm32/gpio.c +++ b/chip/stm32/gpio.c @@ -23,6 +23,7 @@ static uint8_t exti_events[16]; void gpio_pre_init(void) { const struct gpio_info *g = gpio_list; + const struct unused_pin_info *u = unused_pin_list; int is_warm = system_is_reboot_warm(); int i; @@ -59,6 +60,19 @@ void gpio_pre_init(void) /* Set up GPIO based on flags */ gpio_set_flags_by_mask(g->port, g->mask, flags); } + + /* Configure optional unused pins for low power optimization. */ + for (i = 0; i < unused_pin_count; i++, u++) { + /* + * Configure unused pins as ANALOG INPUT to save power. + * For more info, please see + * "USING STM32F4 MCU POWER MODES WITH BEST DYNAMIC EFFICIENCY" + * ("AN4365") section 1.2.6 and section 7.3.12 of the STM32F412 + * reference manual. + */ + if (IS_ENABLED(CHIP_FAMILY_STM32F4)) + gpio_set_flags_by_mask(u->port, u->mask, GPIO_ANALOG); + } } test_mockable int gpio_get_level(enum gpio_signal signal) -- cgit v1.2.1