summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhuohao Lee <zhuohao@chromium.org>2018-12-17 21:16:28 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-12-20 13:49:46 -0800
commit9b8b6743cd3984bc85688a61fa70f35fd6f244e8 (patch)
treed567f040d7edc802dc2576f7e16f32cb0da0f2b8
parent5c0d4b1ea1882c52148106986a18c2761742742a (diff)
downloadchrome-ec-9b8b6743cd3984bc85688a61fa70f35fd6f244e8.tar.gz
rammus: reconfig the PS8751 i2c port according to the board version
On Shyvana, we found that if we put the Parade PS8751 and Analogix ANX3447 on the same i2c bus, the ANX3447 would be broken because of PS8751 i2c bus error. To avoid this kind of problem, we decided to separate the TCPC i2c bus starting from board version >= 2. The new assignment are ANX3447:i2c_0_0, PS8751:i2c_0_1. This patch also adds a new config CONFIG_USB_PD_TCPC_RUNTIME_CONFIG for enabling runtime switching the TCPC setting. BUG=b:118063849 BRANCH=firmware-rammus-11275 TEST=verified on DUT with board_version <= 1 verified on reworked DUT with board_version >= 2 Change-Id: I0bdc930c1a5e691239f5f5c256d380d0111eed91 Signed-off-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1381600 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r--board/rammus/board.c25
-rw-r--r--board/rammus/board.h4
-rw-r--r--driver/tcpm/tcpm.h4
-rw-r--r--include/config.h3
4 files changed, 34 insertions, 2 deletions
diff --git a/board/rammus/board.c b/board/rammus/board.c
index 340cca0028..46afccbb2f 100644
--- a/board/rammus/board.c
+++ b/board/rammus/board.c
@@ -17,6 +17,7 @@
#include "charger.h"
#include "chipset.h"
#include "console.h"
+#include "cros_board_info.h"
#include "driver/accelgyro_bmi160.h"
#include "driver/accel_bma2x2.h"
#include "driver/tcpm/ps8xxx.h"
@@ -160,7 +161,7 @@ const struct i2c_port_t i2c_ports[] = {
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
/* TCPC mux configuration */
-const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
+struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_PS8751] = {
.i2c_host_port = I2C_PORT_TCPC1,
.i2c_slave_addr = PS8751_I2C_ADDR1,
@@ -217,10 +218,32 @@ void board_reset_pd_mcu(void)
msleep(2);
}
+/*
+ * Read CBI data from EEPROM via i2c and remap the ps8751 i2c port
+ */
+static void ps8751_i2c_remap(void)
+{
+ uint32_t board_version;
+
+ if (cbi_get_board_version(&board_version) != EC_SUCCESS ||
+ board_version > 1)
+ return;
+ /*
+ * Due to b/118063849, we separate the ps8751 and anx3447 to
+ * different i2c bus which start from board_version >= 2.
+ * For the board_version <= 1, the ps8751 and anx3447 TCPC
+ * use the same i2c bus. Thus, reconfig the ps8751 i2c port
+ * to i2c_0_0.
+ */
+ tcpc_config[USB_PD_PORT_PS8751].i2c_host_port = I2C_PORT_TCPC0;
+}
+
void board_tcpc_init(void)
{
int port;
+ ps8751_i2c_remap();
+
/* Only reset TCPC if not sysjump */
if (!system_jumped_to_this_image()) {
board_reset_pd_mcu();
diff --git a/board/rammus/board.h b/board/rammus/board.h
index 2e2fa5bef0..3eba283818 100644
--- a/board/rammus/board.h
+++ b/board/rammus/board.h
@@ -144,6 +144,8 @@
#define CONFIG_USB_PD_PORT_COUNT 2
#define CONFIG_USB_PD_VBUS_DETECT_GPIO
#define CONFIG_USB_PD_TCPC_LOW_POWER
+/* TODO(b:121222079): Remove the config before FSI */
+#define CONFIG_USB_PD_TCPC_RUNTIME_CONFIG
#define CONFIG_USB_PD_TCPM_MUX
#define CONFIG_USB_PD_TCPM_TCPCI
#define CONFIG_USB_PD_TCPM_ANX7447
@@ -167,7 +169,7 @@
/* I2C ports */
#define I2C_PORT_TCPC0 NPCX_I2C_PORT0_0
-#define I2C_PORT_TCPC1 NPCX_I2C_PORT0_0
+#define I2C_PORT_TCPC1 NPCX_I2C_PORT0_1
#define I2C_PORT_USB_CHARGER_1 NPCX_I2C_PORT0_1
#define I2C_PORT_USB_CHARGER_0 NPCX_I2C_PORT1
#define I2C_PORT_CHARGER NPCX_I2C_PORT1
diff --git a/driver/tcpm/tcpm.h b/driver/tcpm/tcpm.h
index 66792d34c8..52314151ae 100644
--- a/driver/tcpm/tcpm.h
+++ b/driver/tcpm/tcpm.h
@@ -22,7 +22,11 @@
#endif
#ifndef CONFIG_USB_PD_TCPC
+#ifndef CONFIG_USB_PD_TCPC_RUNTIME_CONFIG
extern const struct tcpc_config_t tcpc_config[];
+#else
+extern struct tcpc_config_t tcpc_config[];
+#endif
/* I2C wrapper functions - get I2C port / slave addr from config struct. */
#ifndef CONFIG_USB_PD_TCPC_LOW_POWER
diff --git a/include/config.h b/include/config.h
index df677ef7cf..903365de9d 100644
--- a/include/config.h
+++ b/include/config.h
@@ -3271,6 +3271,9 @@
*/
#undef CONFIG_USB_PD_TCPC_TRACK_VBUS
+/* Enable runtime config the TCPC */
+#undef CONFIG_USB_PD_TCPC_RUNTIME_CONFIG
+
/*
* Choose one of the following TCPMs (type-C port manager) to manage TCPC. The
* TCPM stub is used to make direct function calls to TCPC when TCPC is on