MCPcopy Create free account
hub / github.com/coreboot/coreboot / __wait

Function __wait

src/device/software_i2c.c:30–52  ·  view source on GitHub ↗

* Waits until either timeout_us have passed or (iff for_scl is set) until SCL * goes high. Will report random line changes during the wait and return SCL. */

Source from the content-addressed store, hash-verified

28 * goes high. Will report random line changes during the wait and return SCL.
29 */
30static int __wait(unsigned int bus, int timeout_us, int for_scl)
31{
32 int us;
33 int sda = software_i2c[bus]->get_sda(bus);
34 int scl = software_i2c[bus]->get_scl(bus);
35 struct stopwatch sw;
36
37 stopwatch_init_usecs_expire(&sw, timeout_us);
38
39 do {
40 int old_sda = sda;
41 int old_scl = scl;
42
43 us = stopwatch_duration_usecs(&sw);
44
45 if (old_sda != (sda = software_i2c[bus]->get_sda(bus)))
46 spew("[SDA transitioned to %d after %dus] ", sda, us);
47 if (old_scl != (scl = software_i2c[bus]->get_scl(bus)))
48 spew("[SCL transitioned to %d after %dus] ", scl, us);
49 } while (!stopwatch_expired(&sw) && (!for_scl || !scl));
50
51 return scl;
52}
53
54/* Waits the default DELAY_US to allow line state to stabilize. */
55static void wait(unsigned int bus)

Callers 2

waitFunction · 0.85
wait_for_sclFunction · 0.85

Calls 3

stopwatch_duration_usecsFunction · 0.85
stopwatch_expiredFunction · 0.85

Tested by

no test coverage detected