summaryrefslogtreecommitdiff
path: root/include/i2c.h
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2015-05-22 17:17:47 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-05-27 19:40:00 +0000
commit1b2f6b64510c061ddabd8d6a3d5e01fc71a68712 (patch)
treea1564c27d1bce516e8ab4433aeff30b7526124fe /include/i2c.h
parent315afdff429f08dd91193883348bc74e4f9edfb1 (diff)
downloadchrome-ec-1b2f6b64510c061ddabd8d6a3d5e01fc71a68712.tar.gz
i2c: Make i2c_xfer a wrapper function to chip_i2c_xfer
i2c_xfer was previously implemented at the chip-level, but now we want to add some global retry logic. Rename the chip-level i2c_xfer functions to chip_i2c_xfer and add a new global wrapper function i2c_xfer. BUG=chrome-os-partner:39613 TEST=Run "battery" from EC console on Cyan, verify that values + strings are correctly printed. BRANCH=None Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: If37c85cc3cf94fd53feb6931553e10c30ad6cad6 Reviewed-on: https://chromium-review.googlesource.com/272939 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include/i2c.h')
-rw-r--r--include/i2c.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/include/i2c.h b/include/i2c.h
index 753efa0aec..f3495bac41 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -33,8 +33,8 @@ extern const unsigned int i2c_ports_used;
/**
* Transmit one block of raw data, then receive one block of raw data.
*
- * This is a low-level platform-dependent function used by the other functions
- * below. It must be called between i2c_lock(port, 1) and i2c_lock(port, 0).
+ * This is a wrapper function for chip_i2c_xfer(), a low-level chip-dependent
+ * function. It must be called between i2c_lock(port, 1) and i2c_lock(port, 0).
*
* @param port Port to access
* @param slave_addr Slave device address
@@ -53,6 +53,25 @@ int i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
#define I2C_LINE_IDLE (I2C_LINE_SCL_HIGH | I2C_LINE_SDA_HIGH)
/**
+ * Chip-level function to transmit one block of raw data, then receive one
+ * block of raw data.
+ *
+ * This is a low-level chip-dependent function and should only be called by
+ * i2c_xfer().
+ *
+ * @param port Port to access
+ * @param slave_addr Slave device address
+ * @param out Data to send
+ * @param out_size Number of bytes to send
+ * @param in Destination buffer for received data
+ * @param in_size Number of bytes to receive
+ * @param flags Flags (see I2C_XFER_* above)
+ * @return EC_SUCCESS, or non-zero if error.
+ */
+int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
+ uint8_t *in, int in_size, int flags);
+
+/**
* Return raw I/O line levels (I2C_LINE_*) for a port when port is in alternate
* function mode.
*