diff options
author | Jeff Chase <jnchase@google.com> | 2020-07-31 14:54:23 -0400 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-08-14 21:41:40 +0000 |
commit | d31bb8257e8baff006bbf174e8fdaf20666abc02 (patch) | |
tree | 271c1c0fa11c9aa615676fea6e4f7e29f4541ebc /board/endeavour/pse.c | |
parent | a27cf95f95439f3af0d312d176b9f2d4d8a80da4 (diff) | |
download | chrome-ec-d31bb8257e8baff006bbf174e8fdaf20666abc02.tar.gz |
endeavour: fix PSE init timing
The PSE controller is unpowered when the AP is not running so it
should be initialized whenever the AP resumes.
It can take up to 15ms after coming out of reset to respond to I2C
accesses so retry as needed.
BRANCH=endeavour
BUG=b:162311755
TEST=EC reboot with various options. Cr50 reboot. Shutdown/power on.
Change-Id: Ic4df0c2ded2c47b30e6ddea945158f664bb77efb
Signed-off-by: Jeff Chase <jnchase@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2332859
Reviewed-by: Joe Tessler <jrt@chromium.org>
(cherry picked from commit 8c5e48f0c7a1d6cd6bf39ab2e6278c6a42e72a4d)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2355491
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'board/endeavour/pse.c')
-rw-r--r-- | board/endeavour/pse.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/board/endeavour/pse.c b/board/endeavour/pse.c index c4484d257c..ad481b46da 100644 --- a/board/endeavour/pse.c +++ b/board/endeavour/pse.c @@ -43,7 +43,7 @@ #define LTC4291_HPMD_MIN 0x00 #define LTC4291_HPMD_MAX 0xA8 -#define LTC4291_RESET_DELAY_MS 10 +#define LTC4291_RESET_DELAY_US 20000 #define I2C_PSE_READ(reg, data) \ i2c_read8(I2C_PORT_PSE, LTC4291_I2C_ADDR, LTC4291_REG_##reg, (data)) @@ -82,17 +82,17 @@ static int pse_port_hpmd[4] = { static int pse_init_worker(void) { + timestamp_t deadline; int err, id, devid, statpin, port; - err = I2C_PSE_WRITE(RSTPB, LTC4291_FLD_RSTPB_RSTALL); - if (err != 0) - return err; + /* Ignore errors -- may already be resetting */ + I2C_PSE_WRITE(RSTPB, LTC4291_FLD_RSTPB_RSTALL); - msleep(LTC4291_RESET_DELAY_MS); - - err = I2C_PSE_READ(ID, &id); - if (err != 0) - return err; + deadline.val = get_time().val + LTC4291_RESET_DELAY_US; + while ((err = I2C_PSE_READ(ID, &id)) != 0) { + if (timestamp_expired(deadline, NULL)) + return err; + } err = I2C_PSE_READ(DEVID, &devid); if (err != 0) @@ -144,7 +144,7 @@ static void pse_init(void) else CPRINTS("PSE init done"); } -DECLARE_HOOK(HOOK_INIT, pse_init, HOOK_PRIO_INIT_I2C); +DECLARE_HOOK(HOOK_CHIPSET_RESUME, pse_init, HOOK_PRIO_DEFAULT); static int command_pse(int argc, char **argv) { |