diff options
Diffstat (limited to 'common/host_command_master.c')
-rw-r--r-- | common/host_command_master.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/common/host_command_master.c b/common/host_command_master.c index 15748d4e82..a669f22111 100644 --- a/common/host_command_master.c +++ b/common/host_command_master.c @@ -83,8 +83,8 @@ static int pd_host_command_internal(int command, int version, &req_buf[0], outsize + sizeof(rq) + 1, &resp_buf[0], 2, I2C_XFER_START); i2c_set_timeout(I2C_PORT_PD_MCU, 0); - i2c_lock(I2C_PORT_PD_MCU, 0); if (ret) { + i2c_lock(I2C_PORT_PD_MCU, 0); CPRINTF("[%T i2c transaction 1 failed: %d]\n", ret); return -ret; } @@ -97,13 +97,16 @@ static int pd_host_command_internal(int command, int version, ret); if (resp_len > (insize + sizeof(rs))) { + /* Do a dummy read to generate stop condition */ + i2c_xfer(I2C_PORT_PD_MCU, CONFIG_USB_PD_I2C_SLAVE_ADDR, + 0, 0, &resp_buf[2], 1, I2C_XFER_STOP); + i2c_lock(I2C_PORT_PD_MCU, 0); CPRINTF("[%T response size is too large %d > %d]\n", resp_len, insize + sizeof(rs)); return -EC_RES_RESPONSE_TOO_BIG; } /* Receive remaining data */ - i2c_lock(I2C_PORT_PD_MCU, 1); ret = i2c_xfer(I2C_PORT_PD_MCU, CONFIG_USB_PD_I2C_SLAVE_ADDR, 0, 0, &resp_buf[2], resp_len, I2C_XFER_STOP); i2c_lock(I2C_PORT_PD_MCU, 0); |