summaryrefslogtreecommitdiff
path: root/include/i2c.h
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2018-03-08 22:25:27 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-03-20 19:30:14 -0700
commit699838c0c1b9222d2d01d1575be3519fa8e3b9ba (patch)
tree3d74e13fd51364b5ca24095b61452139ebf06d75 /include/i2c.h
parent228430afdd463c77a016e24370f64178e3102166 (diff)
downloadchrome-ec-699838c0c1b9222d2d01d1575be3519fa8e3b9ba.tar.gz
i2c: Add option for calling board-specific functions before and after every i2c transaction
This change adds a new config option CONFIG_I2C_XFER_CALLBACK that makes i2c_xfer callback into board-provided functions before the start and after the end of every I2C transaction. This can be used by boards to implement any I2C device-specific quirks e.g. requiring minimum bus-free time between every I2C transaction when the slave device cannot actually do clock stretching. BUG=b:73147310 BRANCH=None TEST=make -j buildall Change-Id: I452de4f22a81ffd97ca4944e1b940a3537637df9 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/956934 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include/i2c.h')
-rw-r--r--include/i2c.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/i2c.h b/include/i2c.h
index 63169ec055..78038ea6af 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -335,4 +335,27 @@ void i2cm_init(void);
* @return true, if passthru should be allowed on the port.
*/
int board_allow_i2c_passthru(int port);
+
+/**
+ * Function to allow board to take any action before starting a new i2c
+ * transaction on a given port. Board must implement this if it defines
+ * CONFIG_I2C_XFER_BOARD_CALLBACK.
+ *
+ * @param port: I2C port number
+ * @param slave_addr: Slave device address
+ *
+ */
+void i2c_start_xfer_notify(int port, int slave_addr);
+
+/**
+ * Function to allow board to take any action after an i2c transaction on a
+ * given port has completed. Board must implement this if it defines
+ * CONFIG_I2C_XFER_BOARD_CALLBACK.
+ *
+ * @param port: I2C port number
+ * @param slave_addr: Slave device address
+ *
+ */
+void i2c_end_xfer_notify(int port, int slave_addr);
+
#endif /* __CROS_EC_I2C_H */