diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2015-06-13 19:41:24 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-06-17 13:10:58 +0000 |
commit | cca70a517b21d32e45880d1296997436d026e7b7 (patch) | |
tree | 1c37f28074f4d9050070d7a540780fd592ff9719 /chip/host | |
parent | b33531e262561e297ba1a02fc829a2110c6df515 (diff) | |
download | chrome-ec-cca70a517b21d32e45880d1296997436d026e7b7.tar.gz |
common: Add i2c 32bit read/write
Add functions and associated test to read/write a 32 bit register
BRANCH=smaug
TEST=Test on smaug with bm160 driver
BUG=chromium:39900
Change-Id: Ieff24b65f1eb8610874fe13c4a8fadf583a218cb
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/277535
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'chip/host')
-rw-r--r-- | chip/host/i2c.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/chip/host/i2c.c b/chip/host/i2c.c index 1ce7da9340..ebf3894a43 100644 --- a/chip/host/i2c.c +++ b/chip/host/i2c.c @@ -75,6 +75,36 @@ static int test_check_detached(int port, int slave_addr) return 0; } +int i2c_read32(int port, int slave_addr, int offset, int *data) +{ + const struct test_i2c_read_dev *p; + int rv; + + if (test_check_detached(port, slave_addr)) + return EC_ERROR_UNKNOWN; + for (p = __test_i2c_read32; p < __test_i2c_read32_end; ++p) { + rv = p->routine(port, slave_addr, offset, data); + if (rv != EC_ERROR_INVAL) + return rv; + } + return EC_ERROR_UNKNOWN; +} + +int i2c_write32(int port, int slave_addr, int offset, int data) +{ + const struct test_i2c_write_dev *p; + int rv; + + if (test_check_detached(port, slave_addr)) + return EC_ERROR_UNKNOWN; + for (p = __test_i2c_write32; p < __test_i2c_write32_end; ++p) { + rv = p->routine(port, slave_addr, offset, data); + if (rv != EC_ERROR_INVAL) + return rv; + } + return EC_ERROR_UNKNOWN; +} + int i2c_read16(int port, int slave_addr, int offset, int *data) { const struct test_i2c_read_dev *p; |