diff options
author | Jett Rink <jettrink@chromium.org> | 2020-02-19 09:33:09 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-25 02:28:20 +0000 |
commit | 7a9b2d8a7c83c087e40ddd9461408490b80ae400 (patch) | |
tree | c0c5af68ca33228003bad59bb606d309dabb933c | |
parent | 6331dd76feaa4dfeb5f66635f8b570b884380cb7 (diff) | |
download | chrome-ec-7a9b2d8a7c83c087e40ddd9461408490b80ae400.tar.gz |
cleanup: move voltage rail detection to common
Single source the VDD rail sagging reset interrupt
Add VDD detection to C2D2 as well.
BRANCH=servo
BUG=none
TEST=builds
Change-Id: Iceac7d9fa7a9bde5a3c23c36e63b6d635d8812a3
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2064593
Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r-- | board/c2d2/board.h | 7 | ||||
-rw-r--r-- | board/servo_micro/board.c | 9 | ||||
-rw-r--r-- | board/servo_v4/board.c | 9 | ||||
-rw-r--r-- | chip/stm32/system.c | 20 |
4 files changed, 24 insertions, 21 deletions
diff --git a/board/c2d2/board.h b/board/c2d2/board.h index 0eac431345..817bc68bc1 100644 --- a/board/c2d2/board.h +++ b/board/c2d2/board.h @@ -83,6 +83,13 @@ /* Options features */ #define CONFIG_ADC +/* + * See 'Programmable voltage detector characteristics' in the STM32F072x8 + * Datasheet. PVD Threshold 1 corresponds to a falling voltage threshold of + * min:2.09V, max:2.27V. + */ +#define CONFIG_PVD +#define PVD_THRESHOLD 1 /* This is not actually an EC so disable some features. */ #undef CONFIG_WATCHDOG_HELP diff --git a/board/servo_micro/board.c b/board/servo_micro/board.c index f7a21a6d95..d778f021c2 100644 --- a/board/servo_micro/board.c +++ b/board/servo_micro/board.c @@ -386,15 +386,6 @@ const struct ite_dfu_config_t ite_dfu_config = { .sda = GPIO_MASTER_I2C_SDA, }; -void pvd_interrupt(void) { - /* Clear Pending Register */ - STM32_EXTI_PR = EXTI_PVD_EVENT; - /* Handle recovery by rebooting the system */ - system_reset(0); -} - -DECLARE_IRQ(STM32_IRQ_PVD, pvd_interrupt, HOOK_PRIO_FIRST); - /****************************************************************************** * Initialize board. */ diff --git a/board/servo_v4/board.c b/board/servo_v4/board.c index 7661cee20c..bf1c51e267 100644 --- a/board/servo_v4/board.c +++ b/board/servo_v4/board.c @@ -410,15 +410,6 @@ int board_get_version(void) return ver; } -void pvd_interrupt(void) { - /* Clear Pending Register */ - STM32_EXTI_PR = EXTI_PVD_EVENT; - /* Handle recovery by rebooting the system */ - system_reset(0); -} - -DECLARE_IRQ(STM32_IRQ_PVD, pvd_interrupt, HOOK_PRIO_FIRST); - static void board_init(void) { /* USB to serial queues */ diff --git a/chip/stm32/system.c b/chip/stm32/system.c index 559de04197..5056b7e219 100644 --- a/chip/stm32/system.c +++ b/chip/stm32/system.c @@ -11,9 +11,10 @@ #include "cpu.h" #include "flash.h" #include "gpio_chip.h" +#include "hooks.h" #include "host_command.h" -#include "registers.h" #include "panic.h" +#include "registers.h" #include "system.h" #include "task.h" #include "util.h" @@ -179,7 +180,10 @@ void chip_pre_init(void) } #ifdef CONFIG_PVD -/* Configures the programmable voltage detector to monitor for brown out conditions. */ +/****************************************************************************** + * Detects sagging Vdd voltage and resets the system via the programmable + * voltage detector interrupt. + */ static void configure_pvd(void) { /* Clear Interrupt Enable Mask Register. */ @@ -208,7 +212,17 @@ static void configure_pvd(void) /* Enable the PVD Output. */ STM32_PWR_CR |= STM32_PWR_PVDE; } -#endif + +void pvd_interrupt(void) +{ + /* Clear Pending Register */ + STM32_EXTI_PR = EXTI_PVD_EVENT; + /* Handle recovery by rebooting the system */ + system_reset(0); +} +DECLARE_IRQ(STM32_IRQ_PVD, pvd_interrupt, HOOK_PRIO_FIRST); + +#endif /* CONFIG_PVD */ void system_pre_init(void) { |