summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--baseboard/dragonegg/baseboard.c9
-rw-r--r--baseboard/grunt/baseboard.c14
-rw-r--r--baseboard/intelrvp/ite_ec.c2
-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--baseboard/zork/baseboard.c14
-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/flapjack/board.c8
-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/hatch/board.c15
-rw-r--r--board/helios/board.c15
-rw-r--r--board/kohaku/board.c16
-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.c20
-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
44 files changed, 412 insertions, 186 deletions
diff --git a/baseboard/dragonegg/baseboard.c b/baseboard/dragonegg/baseboard.c
index dbf3a8fedd..dda630e739 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_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_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_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 e743c195a4..a39aba54bb 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_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/intelrvp/ite_ec.c b/baseboard/intelrvp/ite_ec.c
index d6640bf10f..67ae77eed0 100644
--- a/baseboard/intelrvp/ite_ec.c
+++ b/baseboard/intelrvp/ite_ec.c
@@ -16,11 +16,13 @@
/* USB-C TPCP Configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
[TYPE_C_PORT_0] = {
+ .bus_type = EC_BUS_TYPE_EMBEDDED,
/* TCPC is embedded within EC so no i2c config needed */
.drv = &it83xx_tcpm_drv,
},
#ifdef HAS_TASK_PD_C1
[TYPE_C_PORT_1] = {
+ .bus_type = EC_BUS_TYPE_EMBEDDED,
/* TCPC is embedded within EC so no i2c config needed */
.drv = &it83xx_tcpm_drv,
},
diff --git a/baseboard/kalista/baseboard.c b/baseboard/kalista/baseboard.c
index 08fa73dd92..5956223f48 100644
--- a/baseboard/kalista/baseboard.c
+++ b/baseboard/kalista/baseboard.c
@@ -151,7 +151,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_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 2bdb7d2c1d..2d50402924 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_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 4d4ac83b6d..cc47633586 100644
--- a/baseboard/octopus/variant_usbc_standalone_tcpcs.c
+++ b/baseboard/octopus/variant_usbc_standalone_tcpcs.c
@@ -31,25 +31,29 @@
/* USB-C TPCP Configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_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/baseboard/zork/baseboard.c b/baseboard/zork/baseboard.c
index 36786ce34d..eca652210f 100644
--- a/baseboard/zork/baseboard.c
+++ b/baseboard/zork/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_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/board/atlas/board.c b/board/atlas/board.c
index 618838714c..78fbcd53f2 100644
--- a/board/atlas/board.c
+++ b/board/atlas/board.c
@@ -169,16 +169,22 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_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 a3f7875166..14b1e56d2c 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_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 5d9413b4a2..d13f06e61f 100644
--- a/board/cheza/board.c
+++ b/board/cheza/board.c
@@ -257,10 +257,23 @@ unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
/* TCPC mux configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_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 ccd63c5022..2872b7357d 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_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 312caa6509..cdd0a0f998 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_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 bb8bef1b55..c7eb7e6c57 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_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 69759eb68e..693c26c9b4 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_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/flapjack/board.c b/board/flapjack/board.c
index d8ede41890..c8524dca4e 100644
--- a/board/flapjack/board.c
+++ b/board/flapjack/board.c
@@ -283,7 +283,13 @@ const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices);
/******************************************************************************/
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_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_COUNT] = {
diff --git a/board/glados/board.c b/board/glados/board.c
index 48e1acac8b..c24c3ebef6 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_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 020b628083..bba185202f 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_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_COUNT);
diff --git a/board/glkrvp_ite/chg_usb_pd.c b/board/glkrvp_ite/chg_usb_pd.c
index 5fb88a919a..01c8f43f1e 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_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_COUNT);
diff --git a/board/hatch/board.c b/board/hatch/board.c
index 14f8855ab8..4737239042 100644
--- a/board/hatch/board.c
+++ b/board/hatch/board.c
@@ -127,16 +127,21 @@ BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
/* USB-C TPCP Configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
- .i2c_host_port = I2C_PORT_TCPC0,
- .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,
.flags = TCPC_FLAGS_RESET_ACTIVE_HIGH,
},
[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,
- .flags = 0,
},
};
diff --git a/board/helios/board.c b/board/helios/board.c
index 79c41d08db..55359affdb 100644
--- a/board/helios/board.c
+++ b/board/helios/board.c
@@ -122,16 +122,21 @@ BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
/* USB-C TPCP Configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
- .i2c_host_port = I2C_PORT_TCPC0,
- .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,
.flags = TCPC_FLAGS_RESET_ACTIVE_HIGH,
},
[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,
- .flags = 0,
},
};
diff --git a/board/kohaku/board.c b/board/kohaku/board.c
index ba9ef38e62..23b6124ad7 100644
--- a/board/kohaku/board.c
+++ b/board/kohaku/board.c
@@ -112,16 +112,20 @@ BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
/* USB-C TPCP Configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
- .i2c_host_port = I2C_PORT_TCPC0,
- .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,
- .flags = 0,
},
[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,
- .flags = 0,
},
};
diff --git a/board/kukui/board.c b/board/kukui/board.c
index 534a994258..65e98ea788 100644
--- a/board/kukui/board.c
+++ b/board/kukui/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_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_COUNT] = {
diff --git a/board/nami/board.c b/board/nami/board.c
index fc56150239..59fc0b4c1c 100644
--- a/board/nami/board.c
+++ b/board/nami/board.c
@@ -245,15 +245,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_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 5bb202982e..b0071bc84c 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_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 f8e188b36c..02d4a1f6dc 100644
--- a/board/nocturne/board.c
+++ b/board/nocturne/board.c
@@ -313,19 +313,20 @@ unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_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 845eeebe10..4e7d317a4b 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_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 a306d853ac..5a632ced06 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_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 c65d65260c..3c27da46ba 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_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 1065bbf6ef..890aa8be80 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_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_COUNT] = {
diff --git a/board/rammus/board.c b/board/rammus/board.c
index 03aabe7514..472bb81ebc 100644
--- a/board/rammus/board.c
+++ b/board/rammus/board.c
@@ -163,18 +163,20 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
/* TCPC mux configuration */
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,
+ .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,
},
};
@@ -237,7 +239,7 @@ static void ps8751_i2c_remap(void)
* 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;
+ tcpc_config[USB_PD_PORT_PS8751].i2c_info.port = I2C_PORT_TCPC0;
}
void board_tcpc_init(void)
diff --git a/board/reef/board.c b/board/reef/board.c
index 15e1627651..579627d536 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_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 03ce723338..47c63c0599 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_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 11266a9ca0..21a64bd60b 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_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 80a3a73c4e..4e100b3ed7 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_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_COUNT] = {
diff --git a/board/strago/board.c b/board/strago/board.c
index 57dff8a71a..f1852bb9ab 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_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 74ae1db216..20917fd0be 100644
--- a/common/i2c_master.c
+++ b/common/i2c_master.c
@@ -881,9 +881,9 @@ static void i2c_passthru_protect_tcpc_ports(void)
for (i = 0; i < CONFIG_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 103a32206e..4f16cd981d 100644
--- a/common/peripheral.c
+++ b/common/peripheral.c
@@ -33,10 +33,13 @@ static int hc_locate_chip(struct host_cmd_handler_args *args)
#if defined(CONFIG_USB_PD_PORT_COUNT) && !defined(CONFIG_USB_PD_TCPC)
if (params->index >= CONFIG_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_COUNT */
diff --git a/driver/tcpm/anx7447.c b/driver/tcpm/anx7447.c
index c57504bb09..9e540f95aa 100644
--- a/driver/tcpm/anx7447.c
+++ b/driver/tcpm/anx7447.c
@@ -68,7 +68,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
@@ -79,7 +79,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
@@ -287,7 +287,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;
@@ -296,7 +296,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 e478d560a0..dc6c86d2c4 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 b7150a4935..2e6f2a6fca 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -40,8 +40,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;
@@ -53,8 +53,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;
@@ -66,8 +66,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;
@@ -79,8 +79,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;
@@ -92,8 +92,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;
@@ -105,8 +105,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;
@@ -131,8 +131,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 0dee179e36..e5fec627c5 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 cb6c5b0b26..19a8d2212f 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -5388,6 +5388,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 c28230c721..db970266d8 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 89704737b7..9e5f5689de 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
@@ -326,8 +327,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;