summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2019-05-31 16:45:32 -0700
committerCommit Bot <commit-bot@chromium.org>2020-09-01 12:42:19 +0000
commit9c880833331e25bf436aa6628e837b9c98a47bc2 (patch)
treeab8ecc2fdb6199a11854418754eac07f2fa29e56
parent4864eef4d84624a6fcc7f4fe428ae5a377a506ae (diff)
downloadchrome-ec-9c880833331e25bf436aa6628e837b9c98a47bc2.tar.gz
TCPC: Make tcpc_config handle other bus types
Currently, tcpc_config assumes TCPCs are on I2C bus. ITE's EC has an embedded TCPC. This patch adds bus_type field to struct tcpc_config_t so that a TCPC location on other type of bus can be specified. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=buildall Change-Id: Ieac733011700b351e6323f46070dcf46d9e1154b Reviewed-on: https://chromium-review.googlesource.com/1640305 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2315961 Tested-by: Devin Lu <Devin.Lu@quantatw.com> Reviewed-by: Marco Chen <marcochen@chromium.org> Commit-Queue: Marco Chen <marcochen@chromium.org>
-rw-r--r--baseboard/dragonegg/baseboard.c9
-rw-r--r--baseboard/grunt/baseboard.c14
-rw-r--r--baseboard/kalista/baseboard.c9
-rw-r--r--baseboard/octopus/variant_usbc_ec_tcpcs.c2
-rw-r--r--baseboard/octopus/variant_usbc_standalone_tcpcs.c26
-rw-r--r--board/atlas/board.c14
-rw-r--r--board/chell/board.c19
-rw-r--r--board/cheza/board.c21
-rw-r--r--board/coral/board.c18
-rw-r--r--board/elm/board.c9
-rw-r--r--board/eve/board.c18
-rw-r--r--board/fizz/board.c10
-rw-r--r--board/glados/board.c18
-rw-r--r--board/glkrvp/chg_usb_pd.c20
-rw-r--r--board/glkrvp_ite/chg_usb_pd.c20
-rw-r--r--board/kukui/board.c9
-rw-r--r--board/nami/board.c14
-rw-r--r--board/nautilus/board.c18
-rw-r--r--board/nocturne/board.c19
-rw-r--r--board/oak/board.c18
-rw-r--r--board/pdeval-stm32f072/board.c9
-rw-r--r--board/poppy/board.c18
-rw-r--r--board/rainier/board.c9
-rw-r--r--board/rammus/board.c18
-rw-r--r--board/reef/board.c18
-rw-r--r--board/reef_it8320/board.c10
-rw-r--r--board/reef_mchp/board.c18
-rw-r--r--board/scarlet/board.c9
-rw-r--r--board/strago/board.c9
-rw-r--r--common/i2c_master.c4
-rw-r--r--common/peripheral.c11
-rw-r--r--driver/tcpm/anx7447.c8
-rw-r--r--driver/tcpm/mt6370.c4
-rw-r--r--driver/tcpm/tcpci.c28
-rw-r--r--driver/tcpm/tcpm.h34
-rw-r--r--include/ec_commands.h1
-rw-r--r--include/i2c.h6
-rw-r--r--include/usb_pd_tcpm.h7
38 files changed, 362 insertions, 164 deletions
diff --git a/baseboard/dragonegg/baseboard.c b/baseboard/dragonegg/baseboard.c
index 08c6c30927..801516f91d 100644
--- a/baseboard/dragonegg/baseboard.c
+++ b/baseboard/dragonegg/baseboard.c
@@ -164,6 +164,7 @@ void board_hibernate(void)
/* USB-C TPCP Configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_ITE_0] = {
+ .bus_type = EC_BUS_TYPE_EMBEDDED,
/* TCPC is embedded within EC so no i2c config needed */
.drv = &it83xx_tcpm_drv,
/* Alert is active-low, push-pull */
@@ -171,6 +172,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
[USB_PD_PORT_ITE_1] = {
+ .bus_type = EC_BUS_TYPE_EMBEDDED,
/* TCPC is embedded within EC so no i2c config needed */
.drv = &it83xx_tcpm_drv,
/* Alert is active-low, push-pull */
@@ -178,8 +180,11 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
[USB_PD_PORT_TUSB422_2] = {
- .i2c_host_port = I2C_PORT_USBC1C2,
- .i2c_slave_addr = TUSB422_I2C_ADDR,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_USBC1C2,
+ .addr = TUSB422_I2C_ADDR,
+ },
.drv = &tusb422_tcpm_drv,
/* Alert is active-low, push-pull */
.flags = 0,
diff --git a/baseboard/grunt/baseboard.c b/baseboard/grunt/baseboard.c
index 4958ad9324..1041894c5d 100644
--- a/baseboard/grunt/baseboard.c
+++ b/baseboard/grunt/baseboard.c
@@ -86,15 +86,21 @@ BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_ANX74XX] = {
- .i2c_host_port = I2C_PORT_TCPC0,
- .i2c_slave_addr = ANX74XX_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC0,
+ .addr = ANX74XX_I2C_ADDR1,
+ },
.drv = &anx74xx_tcpm_drv,
/* Alert is active-low, open-drain */
.flags = TCPC_FLAGS_ALERT_OD,
},
[USB_PD_PORT_PS8751] = {
- .i2c_host_port = I2C_PORT_TCPC1,
- .i2c_slave_addr = PS8751_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC1,
+ .addr = PS8751_I2C_ADDR1,
+ },
.drv = &ps8xxx_tcpm_drv,
/* Alert is active-low, push-pull */
.flags = 0,
diff --git a/baseboard/kalista/baseboard.c b/baseboard/kalista/baseboard.c
index c6cb842277..4eaeecad28 100644
--- a/baseboard/kalista/baseboard.c
+++ b/baseboard/kalista/baseboard.c
@@ -159,7 +159,14 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
/* TCPC mux configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
/* Alert is active-low, push-pull */
- {I2C_PORT_TCPC0, I2C_ADDR_TCPC0, &ps8xxx_tcpm_drv, 0},
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC0,
+ .addr = I2C_ADDR_TCPC0,
+ },
+ .drv = &ps8xxx_tcpm_drv,
+ },
};
static int ps8751_tune_mux(int port)
diff --git a/baseboard/octopus/variant_usbc_ec_tcpcs.c b/baseboard/octopus/variant_usbc_ec_tcpcs.c
index 60e4b6b5db..4b2d8ae29e 100644
--- a/baseboard/octopus/variant_usbc_ec_tcpcs.c
+++ b/baseboard/octopus/variant_usbc_ec_tcpcs.c
@@ -29,12 +29,14 @@
/* USB-C TPCP Configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_ITE_0] = {
+ .bus_type = EC_BUS_TYPE_EMBEDDED,
/* TCPC is embedded within EC so no i2c config needed */
.drv = &it83xx_tcpm_drv,
/* Alert is active-low, push-pull */
.flags = 0,
},
[USB_PD_PORT_ITE_1] = {
+ .bus_type = EC_BUS_TYPE_EMBEDDED,
/* TCPC is embedded within EC so no i2c config needed */
.drv = &it83xx_tcpm_drv,
/* Alert is active-low, push-pull */
diff --git a/baseboard/octopus/variant_usbc_standalone_tcpcs.c b/baseboard/octopus/variant_usbc_standalone_tcpcs.c
index 1d47c6ff9d..a09691478b 100644
--- a/baseboard/octopus/variant_usbc_standalone_tcpcs.c
+++ b/baseboard/octopus/variant_usbc_standalone_tcpcs.c
@@ -28,25 +28,29 @@
/* USB-C TPCP Configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
- .i2c_host_port = I2C_PORT_TCPC0,
#if defined(VARIANT_OCTOPUS_TCPC_0_PS8751)
- .i2c_slave_addr = PS8751_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC0,
+ .addr = PS8751_I2C_ADDR1,
+ },
.drv = &ps8xxx_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
#else
- .i2c_slave_addr = AN7447_TCPC0_I2C_ADDR,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC0,
+ .addr = AN7447_TCPC0_I2C_ADDR,
+ },
.drv = &anx7447_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
#endif
},
[USB_PD_PORT_TCPC_1] = {
- .i2c_host_port = I2C_PORT_TCPC1,
- .i2c_slave_addr = PS8751_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC1,
+ .addr = PS8751_I2C_ADDR1,
+ },
.drv = &ps8xxx_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
},
};
diff --git a/board/atlas/board.c b/board/atlas/board.c
index 57951e4a81..87aa3e1c68 100644
--- a/board/atlas/board.c
+++ b/board/atlas/board.c
@@ -171,16 +171,22 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
/* left port */
- .i2c_host_port = I2C_PORT_TCPC0,
- .i2c_slave_addr = I2C_ADDR_TCPC,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC0,
+ .addr = I2C_ADDR_TCPC,
+ },
.drv = &ps8xxx_tcpm_drv,
/* Alert is active-low, push-pull */
.flags = 0,
},
{
/* right port */
- .i2c_host_port = I2C_PORT_TCPC1,
- .i2c_slave_addr = I2C_ADDR_TCPC,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC1,
+ .addr = I2C_ADDR_TCPC,
+ },
.drv = &ps8xxx_tcpm_drv,
/* Alert is active-low, push-pull */
.flags = 0,
diff --git a/board/chell/board.c b/board/chell/board.c
index c7cf53641e..dfaf8f8d5c 100644
--- a/board/chell/board.c
+++ b/board/chell/board.c
@@ -122,8 +122,23 @@ const struct i2c_port_t i2c_ports[] = {
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {I2C_PORT_TCPC, CONFIG_TCPC_I2C_BASE_ADDR, &tcpci_tcpm_drv},
- {I2C_PORT_TCPC, CONFIG_TCPC_I2C_BASE_ADDR + 2, &tcpci_tcpm_drv},
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC,
+ .addr = CONFIG_TCPC_I2C_BASE_ADDR,
+ },
+ .drv = &tcpci_tcpm_drv,
+ },
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC,
+ .addr = CONFIG_TCPC_I2C_BASE_ADDR + 2,
+ },
+ .drv = &tcpci_tcpm_drv,
+
+ },
};
/* SPI devices */
diff --git a/board/cheza/board.c b/board/cheza/board.c
index 1966465533..42f9db6059 100644
--- a/board/cheza/board.c
+++ b/board/cheza/board.c
@@ -255,10 +255,23 @@ unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
/* TCPC mux configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
/* Alert is active-low, open-drain */
- [USB_PD_PORT_ANX3429] = {I2C_PORT_TCPC0, 0x50, &anx74xx_tcpm_drv,
- TCPC_FLAGS_ALERT_OD},
- /* Alert is active-low, push-pull */
- [USB_PD_PORT_PS8751] = {I2C_PORT_TCPC1, 0x16, &ps8xxx_tcpm_drv, 0},
+ [USB_PD_PORT_ANX3429] = {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC0,
+ .addr = 0x50,
+ },
+ .drv = &anx74xx_tcpm_drv,
+ .flags = TCPC_FLAGS_ALERT_OD,
+ },
+ [USB_PD_PORT_PS8751] = {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC1,
+ .addr = 0x16,
+ },
+ .drv = &ps8xxx_tcpm_drv,
+ },
};
/*
diff --git a/board/coral/board.c b/board/coral/board.c
index 94e39c9382..7b0725db84 100644
--- a/board/coral/board.c
+++ b/board/coral/board.c
@@ -242,18 +242,20 @@ const int i2c_test_dev_used = ARRAY_SIZE(i2c_stress_tests);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_ANX74XX] = {
- .i2c_host_port = NPCX_I2C_PORT0_0,
- .i2c_slave_addr = ANX74XX_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = NPCX_I2C_PORT0_0,
+ .addr = ANX74XX_I2C_ADDR1,
+ },
.drv = &anx74xx_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
},
[USB_PD_PORT_PS8751] = {
- .i2c_host_port = NPCX_I2C_PORT0_1,
- .i2c_slave_addr = PS8751_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = NPCX_I2C_PORT0_1,
+ .addr = PS8751_I2C_ADDR1,
+ },
.drv = &ps8xxx_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
},
};
diff --git a/board/elm/board.c b/board/elm/board.c
index 990bd3ebd2..9a064ad77b 100644
--- a/board/elm/board.c
+++ b/board/elm/board.c
@@ -121,7 +121,14 @@ const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices);
/* TCPC */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {I2C_PORT_TCPC, CONFIG_TCPC_I2C_BASE_ADDR, &anx7688_tcpm_drv},
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC,
+ .addr = CONFIG_TCPC_I2C_BASE_ADDR,
+ },
+ .drv = &anx7688_tcpm_drv,
+ },
};
struct pi3usb9281_config pi3usb9281_chips[] = {
diff --git a/board/eve/board.c b/board/eve/board.c
index 45780cd8b0..307d0763c4 100644
--- a/board/eve/board.c
+++ b/board/eve/board.c
@@ -215,18 +215,20 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
/* TCPC mux configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .i2c_host_port = I2C_PORT_TCPC0,
- .i2c_slave_addr = ANX74XX_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC0,
+ .addr = ANX74XX_I2C_ADDR1,
+ },
.drv = &anx74xx_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
},
{
- .i2c_host_port = I2C_PORT_TCPC1,
- .i2c_slave_addr = ANX74XX_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC1,
+ .addr = ANX74XX_I2C_ADDR1,
+ },
.drv = &anx74xx_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
},
};
diff --git a/board/fizz/board.c b/board/fizz/board.c
index 8beb89fce8..373cde0126 100644
--- a/board/fizz/board.c
+++ b/board/fizz/board.c
@@ -191,8 +191,14 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
/* TCPC mux configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- /* Alert is active-low, push-pull */
- {NPCX_I2C_PORT0_0, I2C_ADDR_TCPC0, &ps8xxx_tcpm_drv, 0},
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = NPCX_I2C_PORT0_0,
+ .addr = I2C_ADDR_TCPC0,
+ },
+ .drv = &ps8xxx_tcpm_drv,
+ },
};
static int ps8751_tune_mux(int port)
diff --git a/board/glados/board.c b/board/glados/board.c
index 7e126b1888..d1394a14f4 100644
--- a/board/glados/board.c
+++ b/board/glados/board.c
@@ -129,8 +129,22 @@ const struct i2c_port_t i2c_ports[] = {
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {I2C_PORT_TCPC, CONFIG_TCPC_I2C_BASE_ADDR, &tcpci_tcpm_drv},
- {I2C_PORT_TCPC, CONFIG_TCPC_I2C_BASE_ADDR + 2, &tcpci_tcpm_drv},
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC,
+ .addr = CONFIG_TCPC_I2C_BASE_ADDR,
+ },
+ .drv = &tcpci_tcpm_drv,
+ },
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC,
+ .addr = CONFIG_TCPC_I2C_BASE_ADDR + 2,
+ },
+ .drv = &tcpci_tcpm_drv,
+ },
};
/* SPI devices */
diff --git a/board/glkrvp/chg_usb_pd.c b/board/glkrvp/chg_usb_pd.c
index 3e4d739d56..0447d5f641 100644
--- a/board/glkrvp/chg_usb_pd.c
+++ b/board/glkrvp/chg_usb_pd.c
@@ -31,10 +31,22 @@ enum glkrvp_charge_ports {
};
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- /* Alert is active-low, push-pull */
- {NPCX_I2C_PORT7_0, 0xA0, &tcpci_tcpm_drv, 0},
- /* Alert is active-low, push-pull */
- {NPCX_I2C_PORT7_0, 0xA4, &tcpci_tcpm_drv, 0},
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = NPCX_I2C_PORT7_0,
+ .addr = 0xa0,
+ },
+ .drv = &tcpci_tcpm_drv,
+ },
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = NPCX_I2C_PORT7_0,
+ .addr = 0xa4,
+ },
+ .drv = &tcpci_tcpm_drv,
+ },
};
BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == CONFIG_USB_PD_PORT_MAX_COUNT);
diff --git a/board/glkrvp_ite/chg_usb_pd.c b/board/glkrvp_ite/chg_usb_pd.c
index 36d3acfa85..3eff74b5b4 100644
--- a/board/glkrvp_ite/chg_usb_pd.c
+++ b/board/glkrvp_ite/chg_usb_pd.c
@@ -31,10 +31,22 @@ enum glkrvp_charge_ports {
};
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- /* Alert is active-low, push-pull */
- {IT83XX_I2C_CH_B, 0xA0, &tcpci_tcpm_drv, 0},
- /* Alert is active-low, push-pull */
- {IT83XX_I2C_CH_B, 0xA4, &tcpci_tcpm_drv, 0},
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = IT83XX_I2C_CH_B,
+ .addr = 0xa0,
+ },
+ .drv = &tcpci_tcpm_drv,
+ },
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = IT83XX_I2C_CH_B,
+ .addr = 0xa4,
+ },
+ .drv = &tcpci_tcpm_drv,
+ },
};
BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == CONFIG_USB_PD_PORT_MAX_COUNT);
diff --git a/board/kukui/board.c b/board/kukui/board.c
index cb0ceca478..86f4c39c5a 100644
--- a/board/kukui/board.c
+++ b/board/kukui/board.c
@@ -122,7 +122,14 @@ const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices);
/******************************************************************************/
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {I2C_PORT_TCPC0, MT6370_TCPC_I2C_ADDR, &mt6370_tcpm_drv},
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC0,
+ .addr = MT6370_TCPC_I2C_ADDR,
+ },
+ .drv = &mt6370_tcpm_drv,
+ },
};
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
diff --git a/board/nami/board.c b/board/nami/board.c
index a0fdc9152d..c1ddf682c3 100644
--- a/board/nami/board.c
+++ b/board/nami/board.c
@@ -218,15 +218,21 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
/* TCPC mux configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_PS8751] = {
- .i2c_host_port = NPCX_I2C_PORT0_0,
- .i2c_slave_addr = PS8751_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = NPCX_I2C_PORT0_0,
+ .addr = PS8751_I2C_ADDR1,
+ },
.drv = &ps8xxx_tcpm_drv,
/* Alert is active-low, push-pull */
.flags = 0,
},
[USB_PD_PORT_ANX7447] = {
- .i2c_host_port = NPCX_I2C_PORT0_1,
- .i2c_slave_addr = AN7447_TCPC3_I2C_ADDR, /* Verified on v1.1 */
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = NPCX_I2C_PORT0_1,
+ .addr = AN7447_TCPC3_I2C_ADDR,
+ },
.drv = &anx7447_tcpm_drv,
/* Alert is active-low, push-pull */
.flags = 0,
diff --git a/board/nautilus/board.c b/board/nautilus/board.c
index ca83ec2ea0..e393ac288b 100644
--- a/board/nautilus/board.c
+++ b/board/nautilus/board.c
@@ -168,18 +168,20 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
/* TCPC mux configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .i2c_host_port = NPCX_I2C_PORT0_0,
- .i2c_slave_addr = PS8751_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = NPCX_I2C_PORT0_0,
+ .addr = PS8751_I2C_ADDR1,
+ },
.drv = &ps8xxx_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
},
{
- .i2c_host_port = NPCX_I2C_PORT0_1,
- .i2c_slave_addr = PS8751_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = NPCX_I2C_PORT0_1,
+ .addr = PS8751_I2C_ADDR1,
+ },
.drv = &ps8xxx_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
},
};
diff --git a/board/nocturne/board.c b/board/nocturne/board.c
index 1eac2e7c57..222dffb92a 100644
--- a/board/nocturne/board.c
+++ b/board/nocturne/board.c
@@ -298,19 +298,20 @@ unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .i2c_host_port = I2C_PORT_USB_C0,
- .i2c_slave_addr = PS8751_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_USB_C0,
+ .addr = PS8751_I2C_ADDR1,
+ },
.drv = &tcpci_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
},
-
{
- .i2c_host_port = I2C_PORT_USB_C1,
- .i2c_slave_addr = PS8751_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_USB_C1,
+ .addr = PS8751_I2C_ADDR1,
+ },
.drv = &tcpci_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
},
};
diff --git a/board/oak/board.c b/board/oak/board.c
index 86f9f16dac..97164f2242 100644
--- a/board/oak/board.c
+++ b/board/oak/board.c
@@ -113,8 +113,22 @@ const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices);
#endif
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {I2C_PORT_TCPC, CONFIG_TCPC_I2C_BASE_ADDR, &tcpci_tcpm_drv},
- {I2C_PORT_TCPC, CONFIG_TCPC_I2C_BASE_ADDR + 2, &tcpci_tcpm_drv},
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC,
+ .addr = CONFIG_TCPC_I2C_BASE_ADDR,
+ },
+ .drv = &tcpci_tcpm_drv,
+ },
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC,
+ .addr = CONFIG_TCPC_I2C_BASE_ADDR + 2,
+ },
+ .drv = &tcpci_tcpm_drv,
+ },
};
struct mutex pericom_mux_lock;
diff --git a/board/pdeval-stm32f072/board.c b/board/pdeval-stm32f072/board.c
index 2e8fd072b3..99629abc05 100644
--- a/board/pdeval-stm32f072/board.c
+++ b/board/pdeval-stm32f072/board.c
@@ -58,7 +58,14 @@ const struct i2c_port_t i2c_ports[] = {
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {I2C_PORT_TCPC, AN7447_TCPC3_I2C_ADDR, &anx7447_tcpm_drv}
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC,
+ .addr = AN7447_TCPC3_I2C_ADDR,
+ },
+ .drv = &anx7447_tcpm_drv,
+ },
};
uint16_t tcpc_get_alert_status(void)
diff --git a/board/poppy/board.c b/board/poppy/board.c
index f49a2f0823..da2bbb65ba 100644
--- a/board/poppy/board.c
+++ b/board/poppy/board.c
@@ -210,18 +210,20 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
/* TCPC mux configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .i2c_host_port = NPCX_I2C_PORT0_0,
- .i2c_slave_addr = ANX74XX_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = NPCX_I2C_PORT0_0,
+ .addr = ANX74XX_I2C_ADDR1,
+ },
.drv = &anx74xx_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
},
{
- .i2c_host_port = NPCX_I2C_PORT0_0,
- .i2c_slave_addr = PS8751_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = NPCX_I2C_PORT0_0,
+ .addr = PS8751_I2C_ADDR1,
+ },
.drv = &ps8xxx_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
},
};
diff --git a/board/rainier/board.c b/board/rainier/board.c
index 097f73f8fc..179ec94965 100644
--- a/board/rainier/board.c
+++ b/board/rainier/board.c
@@ -127,7 +127,14 @@ const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
/******************************************************************************/
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {I2C_PORT_TCPC0, FUSB302_I2C_SLAVE_ADDR, &fusb302_tcpm_drv},
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC0,
+ .addr = FUSB302_I2C_SLAVE_ADDR,
+ },
+ .drv = &fusb302_tcpm_drv,
+ },
};
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
diff --git a/board/rammus/board.c b/board/rammus/board.c
index d1219e4124..b47ccaa1b1 100644
--- a/board/rammus/board.c
+++ b/board/rammus/board.c
@@ -162,18 +162,20 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
/* TCPC mux configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_PS8751] = {
- .i2c_host_port = I2C_PORT_TCPC1,
- .i2c_slave_addr = PS8751_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC1,
+ .addr = PS8751_I2C_ADDR1,
+ },
.drv = &ps8xxx_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
},
[USB_PD_PORT_ANX7447] = {
- .i2c_host_port = I2C_PORT_TCPC0,
- .i2c_slave_addr = AN7447_TCPC3_I2C_ADDR, /* Verified on v1.1 */
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC0,
+ .addr = AN7447_TCPC3_I2C_ADDR, /* Verified on v1.1 */
+ },
.drv = &anx7447_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
},
};
diff --git a/board/reef/board.c b/board/reef/board.c
index 4bfdb4c2a2..d524c20e12 100644
--- a/board/reef/board.c
+++ b/board/reef/board.c
@@ -247,18 +247,20 @@ const int i2c_test_dev_used = ARRAY_SIZE(i2c_stress_tests);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_ANX74XX] = {
- .i2c_host_port = NPCX_I2C_PORT0_0,
- .i2c_slave_addr = ANX74XX_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = NPCX_I2C_PORT0_0,
+ .addr = ANX74XX_I2C_ADDR1,
+ },
.drv = &anx74xx_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
},
[USB_PD_PORT_PS8751] = {
- .i2c_host_port = NPCX_I2C_PORT0_1,
- .i2c_slave_addr = PS8751_I2C_ADDR1,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = NPCX_I2C_PORT0_1,
+ .addr = PS8751_I2C_ADDR1,
+ },
.drv = &ps8xxx_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
},
};
diff --git a/board/reef_it8320/board.c b/board/reef_it8320/board.c
index 0cf8b22fb2..e35cb474ea 100644
--- a/board/reef_it8320/board.c
+++ b/board/reef_it8320/board.c
@@ -94,8 +94,14 @@ const struct i2c_port_t i2c_ports[] = {
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {-1, -1, &it83xx_tcpm_drv, 0},
- {-1, -1, &it83xx_tcpm_drv, 0},
+ {
+ .bus_type = EC_BUS_TYPE_EMBEDDED,
+ .drv = &it83xx_tcpm_drv
+ },
+ {
+ .bus_type = EC_BUS_TYPE_EMBEDDED,
+ .drv = &it83xx_tcpm_drv
+ },
};
void board_pd_vconn_ctrl(int port, int cc_pin, int enabled)
diff --git a/board/reef_mchp/board.c b/board/reef_mchp/board.c
index eb1db092ce..fb80a316e1 100644
--- a/board/reef_mchp/board.c
+++ b/board/reef_mchp/board.c
@@ -361,18 +361,20 @@ const int i2c_test_dev_used = ARRAY_SIZE(i2c_stress_tests);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_ANX74XX] = {
- .i2c_host_port = MCHP_I2C_PORT0,
- .i2c_slave_addr = 0x50,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = MCHP_I2C_PORT0,
+ .addr = 0x50,
+ },
.drv = &anx74xx_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
},
[USB_PD_PORT_PS8751] = {
- .i2c_host_port = MCHP_I2C_PORT2,
- .i2c_slave_addr = 0x16,
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = MCHP_I2C_PORT2,
+ .addr = 0x16,
+ },
.drv = &ps8xxx_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
},
};
diff --git a/board/scarlet/board.c b/board/scarlet/board.c
index 138df1f132..a36e450972 100644
--- a/board/scarlet/board.c
+++ b/board/scarlet/board.c
@@ -123,7 +123,14 @@ const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices);
/******************************************************************************/
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {I2C_PORT_TCPC0, FUSB302_I2C_SLAVE_ADDR, &fusb302_tcpm_drv},
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC0,
+ .addr = FUSB302_I2C_SLAVE_ADDR,
+ },
+ .drv = &fusb302_tcpm_drv,
+ },
};
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
diff --git a/board/strago/board.c b/board/strago/board.c
index d577da937f..6a31d5e795 100644
--- a/board/strago/board.c
+++ b/board/strago/board.c
@@ -106,7 +106,14 @@ const struct i2c_port_t i2c_ports[] = {
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {I2C_PORT_TCPC, CONFIG_TCPC_I2C_BASE_ADDR, &tcpci_tcpm_drv},
+ {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_TCPC,
+ .addr = CONFIG_TCPC_I2C_BASE_ADDR,
+ },
+ .drv = &tcpci_tcpm_drv,
+ },
};
/* SPI master ports */
diff --git a/common/i2c_master.c b/common/i2c_master.c
index 89c5be5335..f6d5b2fdc5 100644
--- a/common/i2c_master.c
+++ b/common/i2c_master.c
@@ -787,9 +787,9 @@ static void i2c_passthru_protect_tcpc_ports(void)
for (i = 0; i < board_get_usb_pd_port_count(); i++) {
/* TCPC tunnel not configured. No need to protect anything */
- if (!tcpc_config[i].i2c_slave_addr)
+ if (!tcpc_config[i].i2c_info.addr)
continue;
- i2c_passthru_protect_port(tcpc_config[i].i2c_host_port);
+ i2c_passthru_protect_port(tcpc_config[i].i2c_info.port);
}
#endif
}
diff --git a/common/peripheral.c b/common/peripheral.c
index 810b1279fd..718f122dbc 100644
--- a/common/peripheral.c
+++ b/common/peripheral.c
@@ -34,10 +34,13 @@ static int hc_locate_chip(struct host_cmd_handler_args *args)
#if defined(CONFIG_USB_PD_PORT_MAX_COUNT) && !defined(CONFIG_USB_PD_TCPC)
if (params->index >= board_get_usb_pd_port_count())
return EC_RES_OVERFLOW;
- resp->bus_type = EC_BUS_TYPE_I2C;
- resp->i2c_info.port = tcpc_config[params->index].i2c_host_port;
- resp->i2c_info.addr =
- tcpc_config[params->index].i2c_slave_addr >> 1;
+ resp->bus_type = tcpc_config[params->index].bus_type;
+ if (resp->bus_type == EC_BUS_TYPE_I2C) {
+ resp->i2c_info.port =
+ tcpc_config[params->index].i2c_info.port;
+ resp->i2c_info.addr =
+ tcpc_config[params->index].i2c_info.addr >> 1;
+ }
#else
return EC_RES_UNAVAILABLE;
#endif /* CONFIG_USB_PD_PORT_MAX_COUNT */
diff --git a/driver/tcpm/anx7447.c b/driver/tcpm/anx7447.c
index 3df6109a0e..d9f7d21f9f 100644
--- a/driver/tcpm/anx7447.c
+++ b/driver/tcpm/anx7447.c
@@ -69,7 +69,7 @@ const struct anx7447_i2c_addr anx7447_i2c_addrs[] = {
static inline int anx7447_reg_write(int port, int reg, int val)
{
- int rv = i2c_write8(tcpc_config[port].i2c_host_port,
+ int rv = i2c_write8(tcpc_config[port].i2c_info.port,
anx[port].i2c_slave_addr,
reg, val);
#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
@@ -80,7 +80,7 @@ static inline int anx7447_reg_write(int port, int reg, int val)
static inline int anx7447_reg_read(int port, int reg, int *val)
{
- int rv = i2c_read8(tcpc_config[port].i2c_host_port,
+ int rv = i2c_read8(tcpc_config[port].i2c_info.port,
anx[port].i2c_slave_addr,
reg, val);
#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
@@ -288,7 +288,7 @@ static int anx7447_init(int port)
* specified TCPC slave address
*/
for (i = 0; i < ARRAY_SIZE(anx7447_i2c_addrs); i++) {
- if (tcpc_config[port].i2c_slave_addr ==
+ if (tcpc_config[port].i2c_info.addr ==
anx7447_i2c_addrs[i].tcpc_slave_addr) {
anx[port].i2c_slave_addr =
anx7447_i2c_addrs[i].spi_slave_addr;
@@ -297,7 +297,7 @@ static int anx7447_init(int port)
}
if (!anx[port].i2c_slave_addr) {
ccprintf("TCPC I2C slave addr 0x%x is invalid for ANX7447\n",
- tcpc_config[port].i2c_slave_addr);
+ tcpc_config[port].i2c_info.addr);
return EC_ERROR_UNKNOWN;
}
diff --git a/driver/tcpm/mt6370.c b/driver/tcpm/mt6370.c
index dba3a045a0..6d77614aba 100644
--- a/driver/tcpm/mt6370.c
+++ b/driver/tcpm/mt6370.c
@@ -22,8 +22,8 @@
/* i2c_write function which won't wake TCPC from low power mode. */
static int mt6370_i2c_write8(int port, int reg, int val)
{
- return i2c_write8(tcpc_config[port].i2c_host_port,
- tcpc_config[port].i2c_slave_addr, reg, val);
+ return i2c_write8(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr, reg, val);
}
static int mt6370_init(int port)
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index 67a4f2b1f2..223527fc29 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -36,8 +36,8 @@ int tcpc_write(int port, int reg, int val)
pd_wait_exit_low_power(port);
- rv = i2c_write8(tcpc_config[port].i2c_host_port,
- tcpc_config[port].i2c_slave_addr, reg, val);
+ rv = i2c_write8(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr, reg, val);
pd_device_accessed(port);
return rv;
@@ -49,8 +49,8 @@ int tcpc_write16(int port, int reg, int val)
pd_wait_exit_low_power(port);
- rv = i2c_write16(tcpc_config[port].i2c_host_port,
- tcpc_config[port].i2c_slave_addr, reg, val);
+ rv = i2c_write16(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr, reg, val);
pd_device_accessed(port);
return rv;
@@ -62,8 +62,8 @@ int tcpc_read(int port, int reg, int *val)
pd_wait_exit_low_power(port);
- rv = i2c_read8(tcpc_config[port].i2c_host_port,
- tcpc_config[port].i2c_slave_addr, reg, val);
+ rv = i2c_read8(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr, reg, val);
pd_device_accessed(port);
return rv;
@@ -75,8 +75,8 @@ int tcpc_read16(int port, int reg, int *val)
pd_wait_exit_low_power(port);
- rv = i2c_read16(tcpc_config[port].i2c_host_port,
- tcpc_config[port].i2c_slave_addr, reg, val);
+ rv = i2c_read16(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr, reg, val);
pd_device_accessed(port);
return rv;
@@ -88,8 +88,8 @@ int tcpc_read_block(int port, int reg, uint8_t *in, int size)
pd_wait_exit_low_power(port);
- rv = i2c_read_block(tcpc_config[port].i2c_host_port,
- tcpc_config[port].i2c_slave_addr, reg, in, size);
+ rv = i2c_read_block(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr, reg, in, size);
pd_device_accessed(port);
return rv;
@@ -101,8 +101,8 @@ int tcpc_write_block(int port, int reg, const uint8_t *out, int size)
pd_wait_exit_low_power(port);
- rv = i2c_write_block(tcpc_config[port].i2c_host_port,
- tcpc_config[port].i2c_slave_addr, reg, out, size);
+ rv = i2c_write_block(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr, reg, out, size);
pd_device_accessed(port);
return rv;
@@ -127,8 +127,8 @@ int tcpc_xfer_unlocked(int port, const uint8_t *out, int out_size,
pd_wait_exit_low_power(port);
- rv = i2c_xfer_unlocked(tcpc_config[port].i2c_host_port,
- tcpc_config[port].i2c_slave_addr, out,
+ rv = i2c_xfer_unlocked(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr, out,
out_size, in, in_size, flags);
pd_device_accessed(port);
diff --git a/driver/tcpm/tcpm.h b/driver/tcpm/tcpm.h
index bb8aa1aff8..186c88a276 100644
--- a/driver/tcpm/tcpm.h
+++ b/driver/tcpm/tcpm.h
@@ -27,55 +27,55 @@
#ifndef CONFIG_USB_PD_TCPC_LOW_POWER
static inline int tcpc_write(int port, int reg, int val)
{
- return i2c_write8(tcpc_config[port].i2c_host_port,
- tcpc_config[port].i2c_slave_addr, reg, val);
+ return i2c_write8(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr, reg, val);
}
static inline int tcpc_write16(int port, int reg, int val)
{
- return i2c_write16(tcpc_config[port].i2c_host_port,
- tcpc_config[port].i2c_slave_addr, reg, val);
+ return i2c_write16(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr, reg, val);
}
static inline int tcpc_read(int port, int reg, int *val)
{
- return i2c_read8(tcpc_config[port].i2c_host_port,
- tcpc_config[port].i2c_slave_addr, reg, val);
+ return i2c_read8(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr, reg, val);
}
static inline int tcpc_read16(int port, int reg, int *val)
{
- return i2c_read16(tcpc_config[port].i2c_host_port,
- tcpc_config[port].i2c_slave_addr, reg, val);
+ return i2c_read16(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr, reg, val);
}
static inline int tcpc_xfer(int port, const uint8_t *out, int out_size,
uint8_t *in, int in_size)
{
- return i2c_xfer(tcpc_config[port].i2c_host_port,
- tcpc_config[port].i2c_slave_addr, out, out_size, in,
+ return i2c_xfer(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr, out, out_size, in,
in_size);
}
static inline int tcpc_xfer_unlocked(int port, const uint8_t *out, int out_size,
uint8_t *in, int in_size, int flags)
{
- return i2c_xfer_unlocked(tcpc_config[port].i2c_host_port,
- tcpc_config[port].i2c_slave_addr, out, out_size, in,
+ return i2c_xfer_unlocked(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr, out, out_size, in,
in_size, flags);
}
static inline int tcpc_read_block(int port, int reg, uint8_t *in, int size)
{
- return i2c_read_block(tcpc_config[port].i2c_host_port,
- tcpc_config[port].i2c_slave_addr, reg, in, size);
+ return i2c_read_block(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr, reg, in, size);
}
static inline int tcpc_write_block(int port, int reg,
const uint8_t *out, int size)
{
- return i2c_write_block(tcpc_config[port].i2c_host_port,
- tcpc_config[port].i2c_slave_addr, reg, out, size);
+ return i2c_write_block(tcpc_config[port].i2c_info.port,
+ tcpc_config[port].i2c_info.addr, reg, out, size);
}
#else /* !CONFIG_USB_PD_TCPC_LOW_POWER */
@@ -94,7 +94,7 @@ int tcpc_xfer_unlocked(int port, const uint8_t *out, int out_size,
static inline void tcpc_lock(int port, int lock)
{
- i2c_lock(tcpc_config[port].i2c_host_port, lock);
+ i2c_lock(tcpc_config[port].i2c_info.port, lock);
}
/* TCPM driver wrapper function */
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 0969000da0..1f43bff89b 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -5203,6 +5203,7 @@ enum ec_chip_type {
enum ec_bus_type {
EC_BUS_TYPE_I2C = 0,
+ EC_BUS_TYPE_EMBEDDED = 1,
EC_BUS_TYPE_COUNT,
EC_BUS_TYPE_MAX = 0xFF,
};
diff --git a/include/i2c.h b/include/i2c.h
index 1dcfe46332..3d6e445571 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -9,6 +9,7 @@
#define __CROS_EC_I2C_H
#include "common.h"
+#include "gpio.h"
#include "host_command.h"
/* Flags for slave address field, in addition to the 8-bit address */
@@ -31,6 +32,11 @@ enum i2c_freq {
I2C_FREQ_COUNT,
};
+struct i2c_info_t {
+ uint16_t port; /* Physical port for device */
+ uint16_t addr; /* 8-bit (or 11-bit) address */
+};
+
/* Data structure to define I2C port configuration. */
struct i2c_port_t {
const char *name; /* Port name */
diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h
index 40b16dbb43..f2ec7df664 100644
--- a/include/usb_pd_tcpm.h
+++ b/include/usb_pd_tcpm.h
@@ -9,6 +9,7 @@
#define __CROS_EC_USB_PD_TCPM_H
#include "ec_commands.h"
+#include "i2c.h"
/* Default retry count for transmitting */
#define PD_RETRY_COUNT 3
@@ -321,8 +322,10 @@ struct tcpm_drv {
#define TCPC_FLAGS_RESET_ACTIVE_HIGH BIT(2)
struct tcpc_config_t {
- int i2c_host_port;
- int i2c_slave_addr;
+ enum ec_bus_type bus_type; /* enum ec_bus_type */
+ union {
+ struct i2c_info_t i2c_info;
+ };
const struct tcpm_drv *drv;
/* See TCPC_FLAGS_* above */
uint32_t flags;