Lines Matching +full:idle +full:- +full:wait +full:- +full:delay
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
31 * Generic I2C bit-banging code
42 * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de>
76 u_int udelay; /* signal toggle delay in usec */
137 device_set_desc(dev, "I2C bit-banging driver");
147 sc->iicbus = device_add_child(dev, "iicbus", DEVICE_UNIT_ANY);
148 if (!sc->iicbus)
151 sc->scl_low_timeout = DEFAULT_SCL_LOW_TIMEOUT;
155 "delay", CTLFLAG_RD, &sc->udelay,
156 0, "Signal change delay controlled by bus frequency, microseconds");
160 "scl_low_timeout", CTLFLAG_RWTUN, &sc->scl_low_timeout,
164 "io_latency", CTLFLAG_RWTUN, &sc->io_latency,
196 if (child == sc->iicbus)
197 sc->iicbus = NULL;
211 retval += printf(" on %s master-only\n",
230 &i2c_debug, 0, "Enable i2c bit-banging driver debug");
254 timeout = now + sc->scl_low_timeout * SBT_1US;
263 pause_sbt("iicbb-scl-low", SBT_1MS, 0, C_PREL(2));
281 * - set SDA to the value;
282 * - release SCL and wait until it's high.
285 * There should be a data set-up time, 250 ns minimum, between setting
287 * naturally provide that delay.
295 * End the high phase of the clock and wait out the low phase
306 * - pull SCL low and hold for udelay.
309 DELAY(sc->udelay);
321 DELAY(sc->udelay);
332 * Now it must wait for the SLAVE to pull the DATA line low.
355 for (t = 0; t < sc->udelay; t++) {
359 DELAY(1);
362 DELAY(sc->udelay - t);
365 I2C_DEBUG(printf("%c ", noack ? '-' : '+'));
374 for (i = 7; i >= 0; i--) {
398 for (i = 7; i >= 0; i--) {
405 DELAY((sc->udelay + 1) / 2);
408 DELAY((sc->udelay + 1) / 2);
413 * Send master->slave ACK (low) for more data,
417 I2C_DEBUG(printf("r%02x%c ", *data, last ? '-' : '+'));
443 /* SCL must be high on the idle bus. */
455 DELAY((sc->udelay + 1) / 2);
467 /* Start: SDA high->low. */
470 /* Wait the second half of the SCL high phase. */
471 DELAY((sc->udelay + 1) / 2);
513 DELAY((sc->udelay + 1) / 2);
515 DELAY((sc->udelay + 1) / 2);
538 len--;
545 /* NB: whatever delay is, it's ignored. */
547 iicbb_read(device_t dev, char *buf, int len, int *read, int last, int delay)
559 len--;
590 busfreq = IICBUS_GET_FREQUENCY(sc->iicbus, speed);
591 period = 1000000 / 2 / busfreq; /* Hz -> uS */
592 period -= sc->io_latency;
593 sc->udelay = MAX(period, 1);