diff options
author | Philip Chen <philipchen@google.com> | 2018-01-26 18:35:10 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-01-30 17:47:14 -0800 |
commit | df229ee8e6c474c0169133aeb04b515e17dafdcc (patch) | |
tree | be3f69dd79f0e228e1641d7bbd388a86ba7a4b26 /driver | |
parent | 3a95a6829266782673dbcedb57d867bcd724e5f5 (diff) | |
download | chrome-ec-df229ee8e6c474c0169133aeb04b515e17dafdcc.tar.gz |
charger/rt946x: Clear irq flags correctly
rt946x_block_read() is not implemented right.
It not only makes rt946x_init_irq() fail but also put
RT946x i2c module in an erroneous state temporarily.
BUG=b:72228350
BRANCH=none
TEST=manually on scarlet rev3:
1)Insert Plugable USB-C hub w/o AC
2)Run cutoff command on ec console
3)Hold Pwr button for a few seconds to wake up DUT
4)Repeat 2 - 3 for 10 times without seeing PD loops
Change-Id: I9304617f924e44288483afca5ab1b2923eb68ff0
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/890027
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/charger/rt946x.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/driver/charger/rt946x.c b/driver/charger/rt946x.c index 338af25b02..f59eba4887 100644 --- a/driver/charger/rt946x.c +++ b/driver/charger/rt946x.c @@ -107,11 +107,6 @@ static int rt946x_write8(int reg, int val) return i2c_write8(I2C_PORT_CHARGER, RT946X_ADDR, reg, val); } -static int rt946x_block_read(int reg, uint8_t *val, int len) -{ - return i2c_read_string(I2C_PORT_CHARGER, RT946X_ADDR, reg, val, len); -} - static int rt946x_block_write(int reg, const uint8_t *val, int len) { int rv; @@ -313,17 +308,22 @@ static int rt946x_set_ircmp_res(unsigned int res) static int rt946x_init_irq(void) { int rv = 0; - uint8_t dummy[RT946X_IRQ_COUNT] = {0}; + int dummy; + int i; /* Mask all interrupts */ rv = rt946x_block_write(RT946X_REG_CHGSTATCCTRL, rt946x_irq_maskall, RT946X_IRQ_COUNT); if (rv) return rv; + /* Clear all interrupt flags */ - rv = rt946x_block_read(RT946X_REG_CHGSTATC, dummy, RT946X_IRQ_COUNT); - if (rv) - return rv; + for (i = 0; i < RT946X_IRQ_COUNT; i++) { + rv = rt946x_read8(RT946X_REG_CHGSTATC + i, &dummy); + if (rv) + return rv; + } + /* Init interrupt */ return rt946x_block_write(RT946X_REG_CHGSTATCCTRL, rt946x_irqmask, ARRAY_SIZE(rt946x_irqmask)); |