diff options
author | Jitao Shi <jitao.shi@mediatek.com> | 2016-02-01 17:33:49 +0800 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2016-03-12 09:11:43 +0100 |
commit | 5ffb6887c27d86215c5ffa603131ff9b1f0929ae (patch) | |
tree | 05b1e7c548145987e318767bab9ffeaa42a9f1b4 /src | |
parent | 358f66a44266afd5b6ee9cfa3bcbe45b0dd3a799 (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/include/device/i2c.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/include/device/i2c.h b/src/include/device/i2c.h index 78817bb300..8e59ba7c21 100644 --- a/src/include/device/i2c.h +++ b/src/include/device/i2c.h @@ -88,6 +88,28 @@ static inline int i2c_write_raw(unsigned bus, uint8_t chip, uint8_t *data, } /** + * 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 * * [start][slave addr][w][register addr][start][slave addr][r][data][stop] |