summaryrefslogtreecommitdiff
path: root/chip/host
diff options
context:
space:
mode:
authorSheng-Liang Song <ssl@chromium.org>2014-07-24 09:22:11 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-08-29 02:57:00 +0000
commit7bea5174a19b6d3b4cd9f5a7e96f7d492a24fc8f (patch)
tree4bf5f92421086f20668dd19d85ee129cfd6e93f7 /chip/host
parentb7f1d5261917c88e734d0e788de74b2bc419c431 (diff)
downloadchrome-ec-7bea5174a19b6d3b4cd9f5a7e96f7d492a24fc8f.tar.gz
EC: Add smbus interface read & write APIs
Ref: http://smbus.org/specs/smbus20.pdf - Support software CRC8 generation and checking. - Support read/write word (2-bytes) - Support read/write blocks (up to 32 bytes) BUG=chrome-os-partner:24741 BRANCH=ToT,glimmer TEST=Verified with smart battery firmware update application on glimmer. Passed LGC & Simplo Battery. Change-Id: Ic2e7f759af80c06741ed49fee1826213429fbf8a Signed-off-by: Sheng-Liang Song <ssl@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209747 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'chip/host')
-rw-r--r--chip/host/i2c.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/chip/host/i2c.c b/chip/host/i2c.c
index 3f8a8b8241..1ce7da9340 100644
--- a/chip/host/i2c.c
+++ b/chip/host/i2c.c
@@ -150,3 +150,24 @@ int i2c_read_string(int port, int slave_addr, int offset, uint8_t *data,
}
return EC_ERROR_UNKNOWN;
}
+
+int smbus_write_word(uint8_t i2c_port, uint8_t slave_addr,
+ uint8_t smbus_cmd, uint16_t d16)
+{
+ return i2c_write16(i2c_port, slave_addr, smbus_cmd, d16);
+}
+
+int smbus_read_word(uint8_t i2c_port, uint8_t slave_addr,
+ uint8_t smbus_cmd, uint16_t *p16)
+{
+ int rv, d16 = 0;
+ rv = i2c_read16(i2c_port, slave_addr, smbus_cmd, &d16);
+ *p16 = d16;
+ return rv;
+}
+
+int smbus_read_string(int i2c_port, uint8_t slave_addr, uint8_t smbus_cmd,
+ uint8_t *data, int len)
+{
+ return i2c_read_string(i2c_port, slave_addr, smbus_cmd, data, len);
+}