Fix i2c communication interface to be compatible with

vendor tools, e.g. embedded controller tool

Submitted by:	Maxim Ignatenko <gelraen.ua@gmail.com>
This commit is contained in:
Ruslan Bukin 2014-06-01 08:45:27 +00:00
parent 08ae4ac990
commit 53dc9d3d9c
2 changed files with 10 additions and 3 deletions

View File

@ -165,7 +165,7 @@ ec_command(uint8_t cmd, uint8_t *dout, uint8_t dout_len,
int i;
msg_dout = malloc(dout_len + 4, M_DEVBUF, M_NOWAIT);
msg_dinp = malloc(dinp_len + 4, M_DEVBUF, M_NOWAIT);
msg_dinp = malloc(dinp_len + 3, M_DEVBUF, M_NOWAIT);
if (ec_sc == NULL)
return (-1);
@ -184,7 +184,7 @@ ec_command(uint8_t cmd, uint8_t *dout, uint8_t dout_len,
struct iic_msg msgs[] = {
{ 0x1e, IIC_M_WR, dout_len + 4, msg_dout, },
{ 0x1e, IIC_M_RD, dinp_len + 4, msg_dinp, },
{ 0x1e, IIC_M_RD, dinp_len + 3, msg_dinp, },
};
ret = iicbus_transfer(sc->dev, msgs, 2);
@ -196,7 +196,7 @@ ec_command(uint8_t cmd, uint8_t *dout, uint8_t dout_len,
}
for (i = 0; i < dinp_len; i++) {
dinp[i] = msg_dinp[i + 3];
dinp[i] = msg_dinp[i + 2];
};
free(msg_dout, M_DEVBUF);

View File

@ -372,6 +372,13 @@ i2c_read(device_t dev, char *buf, int len,
mtx_lock(&sc->mutex);
/* dummy read */
clear_ipend(sc);
error = wait_for_iif(sc);
if (error) {
DPRINTF("cant i2c read: iif error\n");
mtx_unlock(&sc->mutex);
return (error);
}
READ1(sc, I2CDS);
DPRINTF("Read ");