| 131 | } |
| 132 | |
| 133 | static int out_bit(unsigned int bus, int bit) |
| 134 | { |
| 135 | spew("software_i2c(%d): Sending a %d bit... ", bus, bit); |
| 136 | |
| 137 | software_i2c[bus]->set_sda(bus, bit); |
| 138 | wait(bus); |
| 139 | |
| 140 | if (bit && !software_i2c[bus]->get_sda(bus)) { |
| 141 | printk(BIOS_ERR, "software_i2c(%d): ERROR: SDA wedged low " |
| 142 | "by slave before clock pulse on transmit!\n", bus); |
| 143 | return ERR_WEDGE; |
| 144 | } |
| 145 | |
| 146 | /* Clock stretching */ |
| 147 | assert(!software_i2c[bus]->get_scl(bus)); |
| 148 | software_i2c[bus]->set_scl(bus, 1); |
| 149 | if (wait_for_scl(bus, "on transmit")) |
| 150 | return ERR_TIMEOUT; |
| 151 | wait(bus); |
| 152 | |
| 153 | if (bit && !software_i2c[bus]->get_sda(bus)) { |
| 154 | printk(BIOS_ERR, "software_i2c(%d): ERROR: SDA wedged low " |
| 155 | "by slave after clock pulse on transmit!\n", bus); |
| 156 | return ERR_WEDGE; |
| 157 | } |
| 158 | |
| 159 | assert(software_i2c[bus]->get_scl(bus)); |
| 160 | software_i2c[bus]->set_scl(bus, 0); |
| 161 | |
| 162 | spew("%d bit sent!\n", bit); |
| 163 | return 0; |
| 164 | } |
| 165 | |
| 166 | static int in_bit(unsigned int bus) |
| 167 | { |
no test coverage detected