From 4567f99015278deb0666c30c2cedf96344294324 Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Fri, 17 Feb 2023 13:50:43 -0700 Subject: [PATCH] peci: Clear status after command completion Per the flow charts for PECI programming guide, clear the status register after the command has completed. Ref: IT5570E V0.3.2 datasheet Signed-off-by: Tim Crawford --- src/board/system76/common/peci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/board/system76/common/peci.c b/src/board/system76/common/peci.c index 3a8ca06..e5fa19e 100644 --- a/src/board/system76/common/peci.c +++ b/src/board/system76/common/peci.c @@ -301,12 +301,17 @@ bool peci_get_temp(int16_t *data) { uint8_t status = HOSTAR; if (status & 0xEC) { ERROR("peci_get_temp: hardware error: 0x%02X\n", status); + // Clear status + HOSTAR = HOSTAR; return false; } else { // Read two byte temperature data if finished successfully uint8_t low = HORDDR; uint8_t high = HORDDR; *data = (((int16_t)high << 8) | (int16_t)low); + + // Clear status + HOSTAR = HOSTAR; return true; } } @@ -352,11 +357,16 @@ int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data) { uint8_t status = HOSTAR; if (status & 0xEC) { ERROR("peci_wr_pkg_config: hardware error: 0x%02X\n", status); + // Clear status + HOSTAR = HOSTAR; return -(0x1000 | status); } uint8_t cc = HORDDR; + // Clear status + HOSTAR = HOSTAR; + if (cc == 0x40) { TRACE("peci_wr_pkg_config: command successful\n"); return cc;