Skip to content

Commit 4ed2983

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 7f78c55 commit 4ed2983

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

board/hx20/board.c

+2
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ static void board_power_off_deferred(void)
421421
charger_psys_enable(0);
422422
charge_gate_onoff(0);
423423

424+
MCHP_VBAT_RAM(MCHP_IMAGETYPE_IDX) |= 0x80;
425+
424426
/* Disable interrupts */
425427
interrupt_disable();
426428
for (i = 0; i < MCHP_IRQ_MAX; ++i) {

chip/mchp/lfw/ec_lfw.c

+13-1
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,26 @@ 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+
/*
342+
* **HX20**: We can't hibernate the EC without also keeping
343+
* 5v3v ALW on, so we cut power entirely. Unfortunately,
344+
* that means that one of rst_sts or wdt_sts will always be
345+
* on... and that precludes the use of the RW firmware.
346+
* However, if we store a bit in IMAGETYPE to indicate that
347+
* we cut power to ourselves, we can use it at the next boot
348+
* to determine whether this poweroff was EC-origin or not.
349+
*/
350+
bool wacked = (MCHP_VBAT_RAM(MCHP_IMAGETYPE_IDX) & 0x80) != 0;
341351

342352
trace12(0, LFW, 0,
343353
"VBAT_STS = 0x%08x PCR_PWR_RST_STS = 0x%08x",
344354
wdt_sts, rst_sts);
345355

346-
if (rst_sts || wdt_sts)
356+
if ((rst_sts || wdt_sts) && !wacked)
347357
MCHP_VBAT_RAM(MCHP_IMAGETYPE_IDX)
348358
= EC_IMAGE_UNKNOWN;
359+
360+
MCHP_VBAT_RAM(MCHP_IMAGETYPE_IDX) &= 0x7F;
349361
}
350362

351363
enum ec_image system_get_image_copy(void)

0 commit comments

Comments
 (0)