| 70 | } |
| 71 | |
| 72 | static int start_cond(unsigned int bus) |
| 73 | { |
| 74 | spew("software_i2c(%d): Sending start condition... ", bus); |
| 75 | |
| 76 | /* SDA might not yet be high if repeated start. */ |
| 77 | software_i2c[bus]->set_sda(bus, 1); |
| 78 | wait(bus); |
| 79 | |
| 80 | /* Might need to wait for clock stretching if repeated start. */ |
| 81 | software_i2c[bus]->set_scl(bus, 1); |
| 82 | if (wait_for_scl(bus, "before start condition")) |
| 83 | return ERR_TIMEOUT; |
| 84 | wait(bus); /* Repeated start setup time, minimum 4.7us */ |
| 85 | |
| 86 | if (!software_i2c[bus]->get_sda(bus)) { |
| 87 | printk(BIOS_ERR, "software_i2c(%d): Arbitration lost trying " |
| 88 | "to send start condition!\n", bus); |
| 89 | return ERR_ARB; |
| 90 | } |
| 91 | |
| 92 | /* SCL is high, transition SDA low as first part of start condition. */ |
| 93 | software_i2c[bus]->set_sda(bus, 0); |
| 94 | wait(bus); |
| 95 | assert(software_i2c[bus]->get_scl(bus)); |
| 96 | |
| 97 | /* Pull SCL low to finish start condition (next pulse will be data). */ |
| 98 | software_i2c[bus]->set_scl(bus, 0); |
| 99 | |
| 100 | spew("Start condition transmitted!\n"); |
| 101 | return 0; |
| 102 | } |
| 103 | |
| 104 | static int stop_cond(unsigned int bus) |
| 105 | { |
no test coverage detected