summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDino Li <Dino.Li@ite.com.tw>2021-04-23 15:27:14 +0800
committerCommit Bot <commit-bot@chromium.org>2021-04-27 07:06:37 +0000
commit33aabcfa90d3d35e7f1365928609c544b47e8d28 (patch)
tree940b30ba329b761ed72a10d041ff075624de5e2d
parent50fcf2e93bad86cae14c4c1f5708273b1dab0255 (diff)
downloadchrome-ec-33aabcfa90d3d35e7f1365928609c544b47e8d28.tar.gz
it83xx/hwtimer: swap timer 7 and timer 8's application
This CL change watchdog warning timer to timer 8 (32bit) and change low power mode timer to timer 7 (24bit) The next step will be changing watchdog warning timer to timer 1 (16bit), so we will get a 32bit timer for future use. BUG=b:186028167 BRANCH=none TEST=console command "waitms" "waitms 1200", EC warning but no reset. "waitms 1600", EC warning and reset. No reset after EC waked-up from low power mode. Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Change-Id: Ibf1387ffe334a6e3e82d5b6a72cdb6e099d3a279 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2847671 Reviewed-by: Wai-Hong Tam <waihong@google.com> Reviewed-by: Sam Hurst <shurst@google.com>
-rw-r--r--chip/it83xx/clock.c4
-rw-r--r--chip/it83xx/hwtimer_chip.h16
2 files changed, 16 insertions, 4 deletions
diff --git a/chip/it83xx/clock.c b/chip/it83xx/clock.c
index 3927091eff..49f99a167b 100644
--- a/chip/it83xx/clock.c
+++ b/chip/it83xx/clock.c
@@ -571,9 +571,9 @@ defined(CONFIG_HOSTCMD_ESPI)
if (IT83XX_ECPM_PLLCTRL == EC_PLL_DEEP_DOZE) {
clock_ec_pll_ctrl(EC_PLL_DOZE);
-
/* update free running timer */
- c = 0xffffffff - IT83XX_ETWD_ETXCNTOR(LOW_POWER_EXT_TIMER);
+ c = LOW_POWER_TIMER_MASK -
+ IT83XX_ETWD_ETXCNTOR(LOW_POWER_EXT_TIMER);
st_us = TIMER_32P768K_CNT_TO_US(c);
sleep_mode_t1.val = sleep_mode_t0.val + st_us;
__hw_clock_source_set(sleep_mode_t1.le.lo);
diff --git a/chip/it83xx/hwtimer_chip.h b/chip/it83xx/hwtimer_chip.h
index ef53c4e871..2ccdce1d96 100644
--- a/chip/it83xx/hwtimer_chip.h
+++ b/chip/it83xx/hwtimer_chip.h
@@ -19,8 +19,20 @@
#define FREE_EXT_TIMER_H EXT_TIMER_4
#define FAN_CTRL_EXT_TIMER EXT_TIMER_5
#define EVENT_EXT_TIMER EXT_TIMER_6
-#define WDT_EXT_TIMER EXT_TIMER_7
-#define LOW_POWER_EXT_TIMER EXT_TIMER_8
+/*
+ * The low power timer is used to continue system time when EC goes into low
+ * power in idle task. Timer 7 is 24bit timer and configured at 32.768khz.
+ * The configuration is enough for continuing system time, because periodic
+ * tick event (interval is 500ms on it8xxx2) will wake EC up.
+ *
+ * IMPORTANT:
+ * If you change low power timer to a non-24bit timer, you also have to change
+ * mask of observation register in clock_sleep_mode_wakeup_isr() or EC will get
+ * wrong system time after resume.
+ */
+#define LOW_POWER_EXT_TIMER EXT_TIMER_7
+#define LOW_POWER_TIMER_MASK (BIT(24) - 1)
+#define WDT_EXT_TIMER EXT_TIMER_8
enum ext_timer_clock_source {
EXT_PSR_32P768K_HZ = 0,