mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Add a method to iicbus to request IIC_M_NOSTOP behaviour for multibyte
transfers to be default. It simplifies porting code which assumes such settings. Discussed with: avg, llos, nwhitehorn Sponsored by: The FreeBSD Foundation MFC after: 1 week
This commit is contained in:
parent
42ecb595f2
commit
9247911a58
2 changed files with 10 additions and 4 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue