Lines Matching +full:slave +full:- +full:kernel
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
50 #include <sys/kernel.h>
74 u_char devaddr; /* slave device address */
90 static int iicsmb_quick(device_t dev, u_char slave, int how);
91 static int iicsmb_sendb(device_t dev, u_char slave, char byte);
92 static int iicsmb_recvb(device_t dev, u_char slave, char *byte);
93 static int iicsmb_writeb(device_t dev, u_char slave, char cmd, char byte);
94 static int iicsmb_writew(device_t dev, u_char slave, char cmd, short word);
95 static int iicsmb_readb(device_t dev, u_char slave, char cmd, char *byte);
96 static int iicsmb_readw(device_t dev, u_char slave, char cmd, short *word);
97 static int iicsmb_pcall(device_t dev, u_char slave, char cmd, short sdata, short *rdata);
98 static int iicsmb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf);
99 static int iicsmb_bread(device_t dev, u_char slave, char cmd, u_char *count, char *buf);
137 if (device_find_child(parent, "iicsmb", -1) == NULL) in iicsmb_identify()
153 mtx_init(&sc->lock, "iicsmb", NULL, MTX_DEF); in iicsmb_attach()
155 sc->smbus = device_add_child(dev, "smbus", DEVICE_UNIT_ANY); in iicsmb_attach()
170 mtx_destroy(&sc->lock); in iicsmb_detach()
185 mtx_lock(&sc->lock); in iicsmb_intr()
189 sc->state = SMB_WAITING_ADDR; in iicsmb_intr()
194 smbus_intr(sc->smbus, sc->devaddr, in iicsmb_intr()
195 sc->low, sc->high, SMB_ENOERR); in iicsmb_intr()
199 switch (sc->state) { in iicsmb_intr()
203 sc->devaddr & 0xff); in iicsmb_intr()
207 sc->devaddr = (u_char)*buf; in iicsmb_intr()
208 sc->state = SMB_WAITING_LOW; in iicsmb_intr()
212 sc->low = *buf; in iicsmb_intr()
213 sc->state = SMB_WAITING_HIGH; in iicsmb_intr()
217 sc->high = *buf; in iicsmb_intr()
218 sc->state = SMB_DONE; in iicsmb_intr()
231 smbus_intr(sc->smbus, sc->devaddr, 0, 0, SMB_EBUSERR); in iicsmb_intr()
244 mtx_unlock(&sc->lock); in iicsmb_intr()
309 iicsmb_quick(device_t dev, u_char slave, int how) in iicsmb_quick() argument
312 { slave, how == SMB_QWRITE ? IIC_M_WR : IIC_M_RD, 0, NULL }, in iicsmb_quick()
329 iicsmb_sendb(device_t dev, u_char slave, char byte) in iicsmb_sendb() argument
332 { slave, IIC_M_WR, 1, &byte }, in iicsmb_sendb()
341 iicsmb_recvb(device_t dev, u_char slave, char *byte) in iicsmb_recvb() argument
344 { slave, IIC_M_RD, 1, byte }, in iicsmb_recvb()
353 iicsmb_writeb(device_t dev, u_char slave, char cmd, char byte) in iicsmb_writeb() argument
357 { slave, IIC_M_WR, nitems(bytes), bytes }, in iicsmb_writeb()
366 iicsmb_writew(device_t dev, u_char slave, char cmd, short word) in iicsmb_writew() argument
370 { slave, IIC_M_WR, nitems(bytes), bytes }, in iicsmb_writew()
379 iicsmb_readb(device_t dev, u_char slave, char cmd, char *byte) in iicsmb_readb() argument
382 { slave, IIC_M_WR | IIC_M_NOSTOP, 1, &cmd }, in iicsmb_readb()
383 { slave, IIC_M_RD, 1, byte }, in iicsmb_readb()
392 iicsmb_readw(device_t dev, u_char slave, char cmd, short *word) in iicsmb_readw() argument
396 { slave, IIC_M_WR | IIC_M_NOSTOP, 1, &cmd }, in iicsmb_readw()
397 { slave, IIC_M_RD, nitems(buf), buf }, in iicsmb_readw()
408 iicsmb_pcall(device_t dev, u_char slave, char cmd, short sdata, short *rdata) in iicsmb_pcall() argument
413 { slave, IIC_M_WR | IIC_M_NOSTOP, nitems(in), in }, in iicsmb_pcall()
414 { slave, IIC_M_RD, nitems(out), out }, in iicsmb_pcall()
425 iicsmb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf) in iicsmb_bwrite() argument
429 { slave, IIC_M_WR | IIC_M_NOSTOP, nitems(bytes), bytes }, in iicsmb_bwrite()
430 { slave, IIC_M_WR | IIC_M_NOSTART, count, buf }, in iicsmb_bwrite()
441 iicsmb_bread(device_t dev, u_char slave, char cmd, u_char *count, char *buf) in iicsmb_bread() argument
444 { slave, IIC_M_WR | IIC_M_NOSTOP, 1, &cmd }, in iicsmb_bread()
445 { slave, IIC_M_RD | IIC_M_NOSTOP, 1, count }, in iicsmb_bread()
448 { slave, IIC_M_RD | IIC_M_NOSTART, 0, buf }, in iicsmb_bread()
459 * If the slave offers an empty or a too long reply, in iicsmb_bread()