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

Function software_i2c_transfer

src/device/software_i2c.c:233–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233int software_i2c_transfer(unsigned int bus, struct i2c_msg *segments, int count)
234{
235 int i, ret;
236 struct i2c_msg *seg;
237
238 for (seg = segments; seg - segments < count; seg++) {
239 if ((ret = start_cond(bus)) < 0)
240 return ret;
241 const u8 addr_dir = seg->slave << 1 | !!(seg->flags & I2C_M_RD);
242 if ((ret = out_byte(bus, addr_dir)) < 0)
243 return ret;
244 for (i = 0; i < seg->len; i++) {
245 if (seg->flags & I2C_M_RD) {
246 ret = in_byte(bus, i < seg->len - 1);
247 seg->buf[i] = (u8)ret;
248 } else {
249 ret = out_byte(bus, seg->buf[i]);
250 }
251 if (ret < 0)
252 return ret;
253 }
254 }
255 if ((ret = stop_cond(bus)) < 0)
256 return ret;
257
258 return 0;
259}
260
261void software_i2c_wedge_ack(unsigned int bus, u8 chip)
262{

Callers 1

i2c_transferFunction · 0.85

Calls 4

start_condFunction · 0.85
out_byteFunction · 0.85
in_byteFunction · 0.85
stop_condFunction · 0.85

Tested by

no test coverage detected