Skip to content

Commit 0f31593

Browse files
committed
Remember whether we cut power to ourselves, and re-check during boot
On the hx20 (and presumably hx30,) a design issue prevents us from hibernating the EC properly. Therefore, every time we bring the machine down we cut power instead of hibernating. That results in the next boot being a complete reset. There is code in lfw that checks whether the current boot is due to a watchdog reset or a power-on reset and if it is, clears the image type back to EC_IMAGE_UNKNOWN. Due to that design issue, the hx20 EC is *always* in POR/VTR or WDT on startup. By storing whether the last shutdown was graceful/intended and checking it before resetting the image type, we can work around this issue.
1 parent 787200e commit 0f31593

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

board/hx20/board.c

+2
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,8 @@ static void board_power_off_deferred(void)
403403
charger_psys_enable(0);
404404
charge_gate_onoff(0);
405405

406+
MCHP_VBAT_RAM(MCHP_IMAGETYPE_IDX) |= 0x80;
407+
406408
/* Disable interrupts */
407409
interrupt_disable();
408410
for (i = 0; i < MCHP_IRQ_MAX; ++i) {

chip/mchp/lfw/ec_lfw.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,24 @@ void system_init(void)
338338
uint32_t wdt_sts = MCHP_VBAT_STS & MCHP_VBAT_STS_ANY_RST;
339339
uint32_t rst_sts = MCHP_PCR_PWR_RST_STS &
340340
MCHP_PWR_RST_STS_VTR;
341+
// **HX20**: We can't hibernate the EC without also keeping
342+
// 5v3v ALW on, so we cut power entirely. Unfortunately,
343+
// that means that one of rst_sts or wdt_sts will always be
344+
// on... and that precludes the use of the RW firmware.
345+
// However, if we store a bit in IMAGETYPE to indicate that
346+
// we cut power to ourselves, we can use it at the next boot
347+
// to determine whether this poweroff was EC-origin or not.
348+
bool wacked = (MCHP_VBAT_RAM(MCHP_IMAGETYPE_IDX) & 0x80) != 0
341349

342350
trace12(0, LFW, 0,
343351
"VBAT_STS = 0x%08x PCR_PWR_RST_STS = 0x%08x",
344352
wdt_sts, rst_sts);
345353

346-
if (rst_sts || wdt_sts)
354+
if ((rst_sts || wdt_sts) && !wacked)
347355
MCHP_VBAT_RAM(MCHP_IMAGETYPE_IDX)
348356
= EC_IMAGE_UNKNOWN;
357+
358+
MCHP_VBAT_RAM(MCHP_IMAGETYPE_IDX) &= 0x7F;
349359
}
350360

351361
enum ec_image system_get_image_copy(void)

0 commit comments

Comments
 (0)