diff options
author | kib <kib@FreeBSD.org> | 2014-11-03 10:33:01 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2014-11-03 10:33:01 +0000 |
commit | 2a026f59371d03df1d811d2bee321c9ec5e168d8 (patch) | |
tree | 268c505cc81f60e5114e3fcdb2e9252acbead363 /sys/dev | |
parent | 9b2eda21cd891c3a08441e3f61158cc4e5103504 (diff) | |
download | FreeBSD-src-2a026f59371d03df1d811d2bee321c9ec5e168d8.zip FreeBSD-src-2a026f59371d03df1d811d2bee321c9ec5e168d8.tar.gz |
MFC r273728:
Add a method to iicbus to request IIC_M_NOSTOP behaviour for multibyte
transfers to be default.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/iicbus/iicbus.h | 5 | ||||
-rw-r--r-- | sys/dev/iicbus/iiconf.c | 9 |
2 files changed, 10 insertions, 4 deletions
diff --git a/sys/dev/iicbus/iicbus.h b/sys/dev/iicbus/iicbus.h index 92c250e..54fe980 100644 --- a/sys/dev/iicbus/iicbus.h +++ b/sys/dev/iicbus/iicbus.h @@ -49,16 +49,19 @@ struct iicbus_softc struct iicbus_ivar { uint32_t addr; + bool nostop; }; enum { - IICBUS_IVAR_ADDR /* Address or base address */ + IICBUS_IVAR_ADDR, /* Address or base address */ + IICBUS_IVAR_NOSTOP, /* nostop defaults */ }; #define IICBUS_ACCESSOR(A, B, T) \ __BUS_ACCESSOR(iicbus, A, IICBUS, B, T) IICBUS_ACCESSOR(addr, ADDR, uint32_t) +IICBUS_ACCESSOR(nostop, NOSTOP, bool) #define IICBUS_LOCK(sc) mtx_lock(&(sc)->lock) #define IICBUS_UNLOCK(sc) mtx_unlock(&(sc)->lock) diff --git a/sys/dev/iicbus/iiconf.c b/sys/dev/iicbus/iiconf.c index 7c22b51..940760b 100644 --- a/sys/dev/iicbus/iiconf.c +++ b/sys/dev/iicbus/iiconf.c @@ -365,6 +365,7 @@ iicbus_transfer_gen(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) { int i, error, lenread, lenwrote, nkid, rpstart, addr; device_t *children, bus; + bool nostop; if ((error = device_get_children(dev, &children, &nkid)) != 0) return (error); @@ -375,6 +376,7 @@ iicbus_transfer_gen(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) bus = children[0]; rpstart = 0; free(children, M_TEMP); + nostop = iicbus_get_nostop(dev); for (i = 0, error = 0; i < nmsgs && error == 0; i++) { addr = msgs[i].slave; if (msgs[i].flags & IIC_M_RD) @@ -399,11 +401,12 @@ iicbus_transfer_gen(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) error = iicbus_write(bus, msgs[i].buf, msgs[i].len, &lenwrote, 0); - if (!(msgs[i].flags & IIC_M_NOSTOP)) { + if ((msgs[i].flags & IIC_M_NOSTOP) != 0 || + (nostop && i + 1 < nmsgs)) { + rpstart = 1; /* Next message gets repeated start */ + } else { rpstart = 0; iicbus_stop(bus); - } else { - rpstart = 1; /* Next message gets repeated start */ } } return (error); |