summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDino Li <Dino.Li@ite.com.tw>2021-01-13 17:46:47 +0800
committerCommit Bot <commit-bot@chromium.org>2021-01-15 05:43:52 +0000
commit6b59de88156fc1ff447b29a80d25feb0441bfc48 (patch)
treeee26b0a8a5917554a0c3ecb0ffe13614c205d0d7
parent9e422c3c05fdd324565049b09be27c446f9dc0ca (diff)
downloadchrome-ec-stabilize-13729.16.B-main.tar.gz
it83xx/gpg1 reset EC: handle case of watchdog resetstabilize-13729.16.B-main
This CL triggers GPG1 HW reset after a EC watchdog. So the EC_RST_ODL signal will be toggled after the reset. BUG=b:173075595 BRANCH=none TEST=trigger watchdog to reboot system and verified system is able to boot to kernel. Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Change-Id: I5d7a88dbb4bdb00977bc1fa02e5fa61e52347104 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2627536 Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
-rw-r--r--chip/it83xx/system.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/chip/it83xx/system.c b/chip/it83xx/system.c
index 6f92c134de..44f94258ec 100644
--- a/chip/it83xx/system.c
+++ b/chip/it83xx/system.c
@@ -49,6 +49,15 @@ static void clear_reset_flags(void)
}
DECLARE_HOOK(HOOK_INIT, clear_reset_flags, HOOK_PRIO_LAST);
+static void system_reset_ec_by_gpg1(void)
+{
+ /* Set GPG1 as output high and wait until EC reset. */
+ IT83XX_GPIO_CTRL(GPIO_G, 1) = GPCR_PORT_PIN_MODE_OUTPUT;
+ IT83XX_GPIO_DATA(GPIO_G) |= BIT(1);
+ while (1)
+ ;
+}
+
static void check_reset_cause(void)
{
uint32_t flags;
@@ -65,6 +74,18 @@ static void check_reset_cause(void)
/* Determine if watchdog reset or power on reset. */
if (raw_reset_cause & 0x02) {
flags |= EC_RESET_FLAG_WATCHDOG;
+ if (IS_ENABLED(CONFIG_IT83XX_HARD_RESET_BY_GPG1)) {
+ /*
+ * Save watchdog reset flag to BRAM so we can restore
+ * the flag on next reboot.
+ */
+ chip_save_reset_flags(EC_RESET_FLAG_WATCHDOG);
+ /*
+ * Assert GPG1 to reset EC and then EC_RST_ODL will be
+ * toggled.
+ */
+ system_reset_ec_by_gpg1();
+ }
} else if (raw_reset_cause & 0x01) {
flags |= EC_RESET_FLAG_POWER_ON;
} else {
@@ -277,11 +298,9 @@ void system_reset(int flags)
IT83XX_GCTRL_ETWDUARTCR |= ETWD_HW_RST_EN;
#endif
/* Set GPG1 as output high and wait until EC reset. */
- if (IS_ENABLED(CONFIG_IT83XX_HARD_RESET_BY_GPG1)) {
- IT83XX_GPIO_CTRL(GPIO_G, 1) = GPCR_PORT_PIN_MODE_OUTPUT;
- IT83XX_GPIO_DATA(GPIO_G) |= BIT(1);
- goto system_wait_until_reset;
- }
+ if (IS_ENABLED(CONFIG_IT83XX_HARD_RESET_BY_GPG1))
+ system_reset_ec_by_gpg1();
+
/*
* Writing invalid key to watchdog module triggers a soft or hardware
* reset. It depends on the setting of bit0 at ETWDUARTCR register.
@@ -289,7 +308,6 @@ void system_reset(int flags)
IT83XX_ETWD_ETWCFG |= 0x20;
IT83XX_ETWD_EWDKEYR = 0x00;
-system_wait_until_reset:
/* Spin and wait for reboot; should never return */
while (1)
;