summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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