| 102 | } |
| 103 | |
| 104 | static int stop_cond(unsigned int bus) |
| 105 | { |
| 106 | spew("software_i2c(%d): Sending stop condition... ", bus); |
| 107 | |
| 108 | /* SDA is unknown, set it to low. SCL must be low. */ |
| 109 | software_i2c[bus]->set_sda(bus, 0); |
| 110 | wait(bus); |
| 111 | |
| 112 | /* Clock stretching */ |
| 113 | assert(!software_i2c[bus]->get_scl(bus)); |
| 114 | software_i2c[bus]->set_scl(bus, 1); |
| 115 | if (wait_for_scl(bus, "before stop condition")) |
| 116 | return ERR_TIMEOUT; |
| 117 | wait(bus); /* Stop bit setup time, minimum 4us */ |
| 118 | |
| 119 | /* SCL is high, transition SDA high to signal stop condition. */ |
| 120 | software_i2c[bus]->set_sda(bus, 1); |
| 121 | wait(bus); |
| 122 | if (!software_i2c[bus]->get_sda(bus)) { |
| 123 | printk(BIOS_WARNING, "software_i2c(%d): WARNING: SDA low after " |
| 124 | "stop condition... access by another master or line " |
| 125 | "stuck from faulty slave?\n", bus); |
| 126 | /* Could theoretically happen with multi-master, so no -1. */ |
| 127 | } |
| 128 | |
| 129 | spew("Stop condition transmitted\n"); |
| 130 | return 0; |
| 131 | } |
| 132 | |
| 133 | static int out_bit(unsigned int bus, int bit) |
| 134 | { |
no test coverage detected