device/i2c: Add i2c_read_bytes() API
Add multi-bytes read support. BRANCH=none BUG=none TEST=saw edid log and dev screen Change-Id: I106be98e751e2a3b998ccaedb28f71f3c6e18994 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: 94ee0b834947e8d971943aa24e61a9353c7b7306 Original-Change-Id: Iac5fe497da92b7d09383e0d6a04d98709aea5b20 Original-Signed-off-by: Jitao Shi <jitao.shi@mediatek.com> Original-Reviewed-on: https://chromium-review.googlesource.com/325211 Original-Commit-Ready: Yidi Lin <yidi.lin@mediatek.com> Original-Tested-by: Yidi Lin <yidi.lin@mediatek.com> Original-Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/13978 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
358f66a442
commit
5ffb6887c2
|
@ -87,6 +87,28 @@ static inline int i2c_write_raw(unsigned bus, uint8_t chip, uint8_t *data,
|
||||||
return i2c_transfer(bus, &seg, 1);
|
return i2c_transfer(bus, &seg, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read multi-bytes with two segments in one frame
|
||||||
|
*
|
||||||
|
* [start][slave addr][w][register addr][start][slave addr][r][data...][stop]
|
||||||
|
*/
|
||||||
|
static inline int i2c_read_bytes(unsigned bus, uint8_t chip, uint8_t reg,
|
||||||
|
uint8_t *data, int len)
|
||||||
|
{
|
||||||
|
struct i2c_seg seg[2];
|
||||||
|
|
||||||
|
seg[0].read = 0;
|
||||||
|
seg[0].chip = chip;
|
||||||
|
seg[0].buf = ®
|
||||||
|
seg[0].len = 1;
|
||||||
|
seg[1].read = 1;
|
||||||
|
seg[1].chip = chip;
|
||||||
|
seg[1].buf = data;
|
||||||
|
seg[1].len = len;
|
||||||
|
|
||||||
|
return i2c_transfer(bus, seg, ARRAY_SIZE(seg));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a byte with two segments in one frame
|
* Read a byte with two segments in one frame
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue