Lines Matching defs:dev

58 #include <dev/ofw/ofw_bus.h>
59 #include <dev/ofw/ofw_bus_subr.h>
60 #include <dev/fdt/fdt_common.h>
63 #include <dev/iicbus/iiconf.h>
64 #include <dev/iicbus/iicbus.h>
66 #include <dev/smbus/smbconf.h>
93 static int iicbb_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs);
134 iicbb_probe(device_t dev)
136 device_set_desc(dev, "I2C bit-banging driver");
142 iicbb_attach(device_t dev)
144 struct iicbb_softc *sc = (struct iicbb_softc *)device_get_softc(dev);
146 sc->iicbus = device_add_child(dev, "iicbus", DEVICE_UNIT_ANY);
152 SYSCTL_ADD_UINT(device_get_sysctl_ctx(dev),
153 SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
157 SYSCTL_ADD_UINT(device_get_sysctl_ctx(dev),
158 SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
161 SYSCTL_ADD_UINT(device_get_sysctl_ctx(dev),
162 SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
166 bus_attach_children(dev);
172 iicbb_get_node(device_t bus, device_t dev)
181 iicbb_child_detached( device_t dev, device_t child )
183 struct iicbb_softc *sc = (struct iicbb_softc *)device_get_softc(dev);
190 iicbb_print_child(device_t bus, device_t dev)
196 retval += bus_print_child_header(bus, dev);
228 #define I2C_GETSDA(dev) (IICBB_GETSDA(device_get_parent(dev)))
229 #define I2C_SETSDA(dev, x) (IICBB_SETSDA(device_get_parent(dev), x))
230 #define I2C_GETSCL(dev) (IICBB_GETSCL(device_get_parent(dev)))
231 #define I2C_SETSCL(dev, x) (IICBB_SETSCL(device_get_parent(dev), x))
234 iicbb_waitforscl(device_t dev)
236 struct iicbb_softc *sc = device_get_softc(dev);
245 if (I2C_GETSCL(dev))
253 if (I2C_GETSCL(dev))
264 iicbb_clockin(device_t dev, int sda)
278 I2C_SETSDA(dev, sda);
279 I2C_SETSCL(dev, 1);
280 return (iicbb_waitforscl(dev));
288 iicbb_clockout(device_t dev)
290 struct iicbb_softc *sc = device_get_softc(dev);
297 I2C_SETSCL(dev, 0);
302 iicbb_sendbit(device_t dev, int bit)
304 struct iicbb_softc *sc = device_get_softc(dev);
307 err = iicbb_clockin(dev, bit);
311 iicbb_clockout(dev);
330 iicbb_getack(device_t dev)
332 struct iicbb_softc *sc = device_get_softc(dev);
337 err = iicbb_clockin(dev, 1);
345 noack = I2C_GETSDA(dev);
352 iicbb_clockout(dev);
359 iicbb_sendbyte(device_t dev, uint8_t data)
364 err = iicbb_sendbit(dev, (data & (1 << i)) != 0);
375 iicbb_readbyte(device_t dev, bool last, uint8_t *data)
377 struct iicbb_softc *sc = device_get_softc(dev);
386 I2C_SETSDA(dev, 1);
388 I2C_SETSCL(dev, 1);
389 err = iicbb_waitforscl(dev);
395 if (I2C_GETSDA(dev))
398 iicbb_clockout(dev);
405 iicbb_sendbit(dev, last);
411 iicbb_callback(device_t dev, int index, caddr_t data)
413 return (IICBB_CALLBACK(device_get_parent(dev), index, data));
417 iicbb_reset(device_t dev, u_char speed, u_char addr, u_char *oldaddr)
419 iicbb_set_speed(device_get_softc(dev), speed);
420 return (IICBB_RESET(device_get_parent(dev), speed, addr, oldaddr));
424 iicbb_start_impl(device_t dev, u_char slave, bool repstart)
426 struct iicbb_softc *sc = device_get_softc(dev);
433 if (iicbb_waitforscl(dev) != 0) {
439 error = iicbb_clockin(dev, 1);
451 if (!I2C_GETSDA(dev)) {
457 I2C_SETSDA(dev, 0);
463 iicbb_clockout(dev);
466 error = iicbb_sendbyte(dev, slave);
470 error = iicbb_getack(dev);
472 (void)iicbb_stop(dev);
478 iicbb_start(device_t dev, u_char slave, int timeout)
480 return (iicbb_start_impl(dev, slave, false));
485 iicbb_repstart(device_t dev, u_char slave, int timeout)
487 return (iicbb_start_impl(dev, slave, true));
491 iicbb_stop(device_t dev)
493 struct iicbb_softc *sc = device_get_softc(dev);
499 err = iicbb_clockin(dev, 0);
503 I2C_SETSDA(dev, 1);
513 iicbb_write(device_t dev, const char *buf, int len, int *sent, int timeout)
520 iicbb_sendbyte(dev, (uint8_t)*buf++);
523 error = iicbb_getack(dev);
536 iicbb_read(device_t dev, char *buf, int len, int *read, int last, int delay)
542 err = iicbb_readbyte(dev, (len == 1) ? last : 0,
556 iicbb_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs)
560 error = IICBB_PRE_XFER(device_get_parent(dev));
564 error = iicbus_transfer_gen(dev, msgs, nmsgs);
566 IICBB_POST_XFER(device_get_parent(dev));