35#include <sys/malloc.h>
36#include <sys/module.h>
53 return ((errno == 0) ? 0 : errno |
IIC_ERRNO);
87 if ((iic_status & 0xFFFF0000) != 0)
116 error = mtx_sleep(sc, &sc->
lock,
IICPRI|PCATCH,
"iicreq", 0);
120 error = mtx_sleep(sc, &sc->
lock,
IICPRI,
"iicreq", 0);
147 if (sc->
owner == NULL)
157 if (sc->
owner == NULL) {
166 if (device_get_state(
dev) < DS_ATTACHING)
182 error = IICBUS_CALLBACK(device_get_parent(bus),
262 if (!(error = IICBUS_START(device_get_parent(bus),
slave,
timeout)))
284 if (!(error = IICBUS_REPEATED_START(device_get_parent(bus),
slave,
timeout)))
306 error = IICBUS_STOP(device_get_parent(bus));
329 return (IICBUS_WRITE(device_get_parent(bus),
buf,
len, sent,
timeout));
445 return (IICBUS_TRANSFER(device_get_parent(bus),
msgs,
nmsgs));
455 bus = device_get_parent(
dev);
458 error = IICBUS_TRANSFER(bus,
msgs,
nmsgs);
471 int i, error, lenread, lenwrote, nkid, rpstart,
addr;
472 device_t *children, bus;
475 if ((error = device_get_children(
dev, &children, &nkid)) != 0)
478 free(children, M_TEMP);
483 free(children, M_TEMP);
485 for (i = 0, error = 0; i <
nmsgs && error == 0; i++) {
525 uint16_t buflen,
int waithow)
534 slaveaddr = iicbus_get_addr(slavedev);
550 uint16_t buflen,
int waithow)
553 uint8_t local_buffer[32];
571 bufsize = buflen + 1;
572 if (bufsize <=
sizeof(local_buffer)) {
573 bufptr = local_buffer;
575 bufptr = malloc(bufsize, M_DEVBUF,
576 (waithow &
IIC_WAIT) ? M_WAITOK : M_NOWAIT);
582 memcpy(&bufptr[1], buffer, buflen);
584 msg.
slave = iicbus_get_addr(slavedev);
591 if (bufptr != local_buffer)
592 free(bufptr, M_DEVBUF);
#define IICBUS_UNLOCK(sc)
#define IICBUS_ASSERT_LOCKED(sc)
int iicbus_request_bus(device_t bus, device_t dev, int how)
void iicbus_intr(device_t bus, int event, char *buf)
int iicbus_block_read(device_t bus, u_char slave, char *buf, int len, int *read)
int iicbus_transfer(device_t bus, struct iic_msg *msgs, uint32_t nmsgs)
int iicbus_read(device_t bus, char *buf, int len, int *read, int last, int delay)
int iic2errno(int iic_status)
int iicbus_release_bus(device_t bus, device_t dev)
int iicbus_started(device_t bus)
int iicdev_readfrom(device_t slavedev, uint8_t regaddr, void *buffer, uint16_t buflen, int waithow)
int iicbus_read_byte(device_t bus, char *byte, int timeout)
int iicbus_write(device_t bus, const char *buf, int len, int *sent, int timeout)
int iicbus_transfer_excl(device_t dev, struct iic_msg *msgs, uint32_t nmsgs, int how)
int iicbus_stop(device_t bus)
int iicdev_writeto(device_t slavedev, uint8_t regaddr, void *buffer, uint16_t buflen, int waithow)
int iicbus_repeated_start(device_t bus, u_char slave, int timeout)
int iicbus_start(device_t bus, u_char slave, int timeout)
int iicbus_write_byte(device_t bus, char byte, int timeout)
int iicbus_block_write(device_t bus, u_char slave, char *buf, int len, int *sent)
static int iicbus_poll(struct iicbus_softc *sc, int how)
int iicbus_transfer_gen(device_t dev, struct iic_msg *msgs, uint32_t nmsgs)