From 21e235dbe468bfa80bab86900ab4baeb48533a94 Mon Sep 17 00:00:00 2001 From: Jonathan Brandmeyer Date: Tue, 7 Aug 2018 16:02:57 -0600 Subject: i2c master: Add block read/write commands. These commands are used by several modules that manage their own block read/write protocols today. This is the first of a series that refactors several modules to use the I2C driver functions instead of their own. BUG=chromium:871851 BRANCH=none TEST=make -j buildall; USB-PD and motionsense testing on Grunt convertible, which exercises several users of the new interface. Signed-off-by: Jonathan Brandmeyer Change-Id: I08475a72031e5fbf49dc344d5b4858622f0d5e93 Reviewed-on: https://chromium-review.googlesource.com/1167957 Commit-Ready: Jonathan Brandmeyer Tested-by: Jonathan Brandmeyer Reviewed-by: Jett Rink --- include/i2c.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'include/i2c.h') diff --git a/include/i2c.h b/include/i2c.h index 78038ea6af..0bd47fd24f 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -278,12 +278,29 @@ int i2c_unwedge(int port); * * : the max length of receiving buffer. to read N bytes * ascii, len should be at least N+1 to include the - * terminating 0. + * terminating 0. Similar to strlcpy, the terminating null is + * always written into the output buffer. * == 0 : buffer size > 255 */ int i2c_read_string(int port, int slave_addr, int offset, uint8_t *data, int len); +/** + * Read a data block of 8-bit transfers from the slave at 8-bit slave + * address , at the specified 8-bit in the slave's address + * space. + */ +int i2c_read_block(int port, int slave_addr, int offset, uint8_t *data, + int len); + +/** + * Write a data block of 8-bit transfers to the slave at 8-bit slave + * address , at the specified 8-bit in the slave's address + * space. + */ +int i2c_write_block(int port, int slave_addr, int offset, const uint8_t *data, + int len); + /** * Convert port number to controller number, for multi-port controllers. * This function will only be called if CONFIG_I2C_MULTI_PORT_CONTROLLER is -- cgit v1.2.1