Lines Matching +full:bit +full:- +full:banging

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
31 * Generic I2C bit-banging code
42 * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de>
136 device_set_desc(dev, "I2C bit-banging driver");
146 sc->iicbus = device_add_child(dev, "iicbus", DEVICE_UNIT_ANY);
147 if (!sc->iicbus)
150 sc->scl_low_timeout = DEFAULT_SCL_LOW_TIMEOUT;
154 "delay", CTLFLAG_RD, &sc->udelay,
159 "scl_low_timeout", CTLFLAG_RWTUN, &sc->scl_low_timeout,
163 "io_latency", CTLFLAG_RWTUN, &sc->io_latency,
185 if (child == sc->iicbus)
186 sc->iicbus = NULL;
200 retval += printf(" on %s master-only\n",
219 &i2c_debug, 0, "Enable i2c bit-banging driver debug");
243 timeout = now + sc->scl_low_timeout * SBT_1US;
252 pause_sbt("iicbb-scl-low", SBT_1MS, 0, C_PREL(2));
270 * - set SDA to the value;
271 * - release SCL and wait until it's high.
274 * There should be a data set-up time, 250 ns minimum, between setting
295 * - pull SCL low and hold for udelay.
298 DELAY(sc->udelay);
302 iicbb_sendbit(device_t dev, int bit)
307 err = iicbb_clockin(dev, bit);
310 DELAY(sc->udelay);
344 for (t = 0; t < sc->udelay; t++) {
351 DELAY(sc->udelay - t);
354 I2C_DEBUG(printf("%c ", noack ? '-' : '+'));
363 for (i = 7; i >= 0; i--) {
387 for (i = 7; i >= 0; i--) {
394 DELAY((sc->udelay + 1) / 2);
397 DELAY((sc->udelay + 1) / 2);
402 * Send master->slave ACK (low) for more data,
406 I2C_DEBUG(printf("r%02x%c ", *data, last ? '-' : '+'));
444 DELAY((sc->udelay + 1) / 2);
456 /* Start: SDA high->low. */
460 DELAY((sc->udelay + 1) / 2);
502 DELAY((sc->udelay + 1) / 2);
504 DELAY((sc->udelay + 1) / 2);
527 len--;
548 len--;
579 busfreq = IICBUS_GET_FREQUENCY(sc->iicbus, speed);
580 period = 1000000 / 2 / busfreq; /* Hz -> uS */
581 period -= sc->io_latency;
582 sc->udelay = MAX(period, 1);