summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Hesling <hesling@chromium.org>2019-11-04 17:09:25 -0800
committerCommit Bot <commit-bot@chromium.org>2019-11-08 22:58:55 +0000
commit4c349a1eafa02a1f520d7603464cdda1e0c62a7f (patch)
tree867b77469aefefb254ec842bae1645e55444e3d6
parentfe21ab18622825f2a402b970cfec50e429cc14f5 (diff)
downloadchrome-ec-4c349a1eafa02a1f520d7603464cdda1e0c62a7f.tar.gz
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 <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1894242 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--chip/stm32/gpio.c14
1 files changed, 14 insertions, 0 deletions
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)