summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDino Li <Dino.Li@ite.com.tw>2021-07-07 15:55:04 +0800
committerCommit Bot <commit-bot@chromium.org>2021-07-22 19:54:04 +0000
commit154f661f50d08adc3a546360be020a7e0321fe2e (patch)
tree0a85a77f8aa5215595a91cf9c5d3c39972387c27 /include
parent506a1ee872aad4ef21d7c90717f1917963dec6b1 (diff)
downloadchrome-ec-154f661f50d08adc3a546360be020a7e0321fe2e.tar.gz
zephyr: i2c: protect physical port
If i2c devices are connected to the same port, they should use the same mutex_lock() index. So the new transaction won't break the ongoing transaction. BRANCH=none BUG=b:189855648 TEST=Enable CONFIG_SMBUS_PEC and voltage regulator function on asurada. No i2c transaction is broken. Change-Id: Ib848e3c2e60b99ce66ad5fd2fc7095f90820a15d Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3010920 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/i2c.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/i2c.h b/include/i2c.h
index 231561caea..4d49ec96e8 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -590,4 +590,18 @@ enum i2c_freq i2c_get_freq(int port);
/* Find the matching port in i2c_ports[] table. */
const struct i2c_port_t *get_i2c_port(const int port);
+/**
+ * @brief Get soc's i2c port number where i2c device is connected to.
+ *
+ * This function translate a i2c port enum value (enum-name property listed in
+ * named-i2c-ports) to soc's i2c port. Devices which are connected to the
+ * same port of soc should have the same number.
+ *
+ * @param enum_port i2c port enum value.
+ * @return i2c port of soc used in mutex_lock().
+ * -1 if physical port is not defined or i2c port number is out of
+ * port_mutex space.
+ */
+int i2c_get_physical_port(int enum_port);
+
#endif /* __CROS_EC_I2C_H */