Use a single write of 3 bytes instead of iicdev_writeto() in ads111x.
The iicdev_writeto() function basically does scatter-gather IO by filling in a pair of iic_msg structs to write the register address then the data from different locations but with a single bus START/xfer/STOP sequence. It turns out several low-level i2c controller drivers do not honor the IIC_NOSTART flag, so the second piece of the write gets a new START on the bus, and that confuses the ads111x chips which expect a continuous write of 3 bytes to set a register. A proper fix for this is to track down all the misbehaving controllers drivers and fix them. For now this change makes this driver work again.
This commit is contained in:
parent
f6a3b357e9
commit
acce2d7606
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=351887
@ -167,11 +167,21 @@ struct ads111x_softc {
|
||||
static int
|
||||
ads111x_write_2(struct ads111x_softc *sc, int reg, int val)
|
||||
{
|
||||
uint8_t data[2];
|
||||
uint8_t data[3];
|
||||
struct iic_msg msgs[1];
|
||||
uint8_t slaveaddr;
|
||||
|
||||
be16enc(data, val);
|
||||
slaveaddr = iicbus_get_addr(sc->dev);
|
||||
|
||||
return (iic2errno(iicdev_writeto(sc->dev, reg, data, 2, IIC_WAIT)));
|
||||
data[0] = reg;
|
||||
be16enc(&data[1], val);
|
||||
|
||||
msgs[0].slave = slaveaddr;
|
||||
msgs[0].flags = IIC_M_WR;
|
||||
msgs[0].len = sizeof(data);
|
||||
msgs[0].buf = data;
|
||||
|
||||
return (iicbus_transfer_excl(sc->dev, msgs, nitems(msgs), IIC_WAIT));
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user