From 154f661f50d08adc3a546360be020a7e0321fe2e Mon Sep 17 00:00:00 2001 From: Dino Li Date: Wed, 7 Jul 2021 15:55:04 +0800 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3010920 Reviewed-by: Jack Rosenthal Reviewed-by: Denis Brockus Commit-Queue: Denis Brockus --- include/i2c.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include/i2c.h') 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 */ -- cgit v1.2.1