summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
Diffstat (limited to 'board')
-rw-r--r--board/akemi/board.c4
-rw-r--r--board/ampton/board.c20
-rw-r--r--board/ampton/board.h2
-rw-r--r--board/atlas/board.c13
-rw-r--r--board/chell/board.c8
-rw-r--r--board/cheza/board.c45
-rw-r--r--board/cheza/usb_pd_policy.c3
-rw-r--r--board/coral/board.c17
-rw-r--r--board/damu/board.c10
-rw-r--r--board/dratini/board.c4
-rw-r--r--board/elm/board.c3
-rw-r--r--board/eve/board.c13
-rw-r--r--board/fizz/board.c15
-rw-r--r--board/flapjack/board.c3
-rw-r--r--board/flapjack/usb_pd_policy.c11
-rw-r--r--board/glados/board.c9
-rw-r--r--board/glkrvp/chg_usb_pd.c10
-rw-r--r--board/glkrvp_ite/chg_usb_pd.c10
-rw-r--r--board/hatch/board.c4
-rw-r--r--board/helios/board.c4
-rw-r--r--board/jacuzzi/board.c10
-rw-r--r--board/jinlon/board.c4
-rw-r--r--board/kakadu/board.c9
-rw-r--r--board/kappa/board.c10
-rw-r--r--board/kindred/board.c4
-rw-r--r--board/kodama/board.c9
-rw-r--r--board/kohaku/board.c4
-rw-r--r--board/kukui/board.c7
-rw-r--r--board/kukui/board.h1
-rw-r--r--board/mchpevb1/board.c9
-rw-r--r--board/mushu/board.c4
-rw-r--r--board/nami/board.c14
-rw-r--r--board/nami/board.h1
-rw-r--r--board/nautilus/board.c13
-rw-r--r--board/nocturne/board.c4
-rw-r--r--board/oak/board.c20
-rw-r--r--board/pdeval-stm32f072/usb_pd_policy.c20
-rw-r--r--board/poppy/board.c13
-rw-r--r--board/puff/board.c3
-rw-r--r--board/rainier/board.c3
-rw-r--r--board/rammus/board.c12
-rw-r--r--board/reef/board.c17
-rw-r--r--board/reef_it8320/board.c23
-rw-r--r--board/reef_mchp/board.c17
-rw-r--r--board/samus_pd/usb_mux.c14
-rw-r--r--board/scarlet/board.c3
-rw-r--r--board/strago/board.c7
-rw-r--r--board/stryke/board.c4
-rw-r--r--board/trogdor/board.c13
-rw-r--r--board/trogdor/usb_pd_policy.c7
-rw-r--r--board/waddledoo/board.c28
51 files changed, 279 insertions, 236 deletions
diff --git a/board/akemi/board.c b/board/akemi/board.c
index c2f6b14d76..ad5fce6d71 100644
--- a/board/akemi/board.c
+++ b/board/akemi/board.c
@@ -141,12 +141,14 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
+ .usb_port = USB_PD_PORT_TCPC_0,
.driver = &anx7447_usb_mux_driver,
.hpd_update = &anx7447_tcpc_update_hpd_status,
},
[USB_PD_PORT_TCPC_1] = {
+ .usb_port = USB_PD_PORT_TCPC_1,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
}
diff --git a/board/ampton/board.c b/board/ampton/board.c
index df151c8918..4f1f0880df 100644
--- a/board/ampton/board.c
+++ b/board/ampton/board.c
@@ -66,13 +66,14 @@ int ppc_get_alert_status(int port)
#define USB_PD_PORT_ITE_0 0
#define USB_PD_PORT_ITE_1 1
-static int tune_mux(int port);
+static int tune_mux(const struct usb_mux *me);
-struct usb_mux ampton_usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux ampton_usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_ITE_0] = {
/* Use PS8751 as mux only */
- .port_addr = MUX_PORT_AND_ADDR(
- I2C_PORT_USBC0, PS8751_I2C_ADDR1_FLAGS),
+ .usb_port = USB_PD_PORT_ITE_0,
+ .i2c_port = I2C_PORT_USBC0,
+ .i2c_addr_flags = PS8751_I2C_ADDR1_FLAGS,
.flags = USB_MUX_FLAG_NOT_TCPC,
.driver = &ps8xxx_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
@@ -80,8 +81,9 @@ struct usb_mux ampton_usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
[USB_PD_PORT_ITE_1] = {
/* Use PS8751 as mux only */
- .port_addr = MUX_PORT_AND_ADDR(
- I2C_PORT_USBC1, PS8751_I2C_ADDR1_FLAGS),
+ .usb_port = USB_PD_PORT_ITE_1,
+ .i2c_port = I2C_PORT_USBC1,
+ .i2c_addr_flags = PS8751_I2C_ADDR1_FLAGS,
.flags = USB_MUX_FLAG_NOT_TCPC,
.driver = &ps8xxx_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
@@ -92,12 +94,12 @@ struct usb_mux ampton_usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
/* Some external monitors can't display content normally (eg. ViewSonic VX2880).
* We need to turn the mux for monitors to function normally.
*/
-static int tune_mux(int port)
+static int tune_mux(const struct usb_mux *me)
{
/* Auto EQ disabled, compensate for channel lost up to 3.6dB */
- mux_write(port, PS8XXX_REG_MUX_DP_EQ_CONFIGURATION, 0x98);
+ mux_write(me, PS8XXX_REG_MUX_DP_EQ_CONFIGURATION, 0x98);
/* DP output swing adjustment +15% */
- mux_write(port, PS8XXX_REG_MUX_DP_OUTPUT_CONFIGURATION, 0xc0);
+ mux_write(me, PS8XXX_REG_MUX_DP_OUTPUT_CONFIGURATION, 0xc0);
return EC_SUCCESS;
}
diff --git a/board/ampton/board.h b/board/ampton/board.h
index 96b135d774..0420bc5ccf 100644
--- a/board/ampton/board.h
+++ b/board/ampton/board.h
@@ -58,6 +58,8 @@
#undef CONFIG_UART_TX_BUF_SIZE
#define CONFIG_UART_TX_BUF_SIZE 4096
+#define CONFIG_USB_MUX_RUNTIME_CONFIG
+
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
diff --git a/board/atlas/board.c b/board/atlas/board.c
index 5a0659ba97..82dc847623 100644
--- a/board/atlas/board.c
+++ b/board/atlas/board.c
@@ -189,12 +189,14 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
+ .usb_port = 0,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
},
{
+ .usb_port = 1,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
},
@@ -209,8 +211,6 @@ void board_reset_pd_mcu(void)
void board_tcpc_init(void)
{
- int port;
-
/* Only reset TCPC if not sysjump */
if (!system_jumped_to_this_image())
board_reset_pd_mcu();
@@ -222,11 +222,8 @@ void board_tcpc_init(void)
* Initialize HPD to low; after sysjump SOC needs to see
* HPD pulse to enable video path
*/
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) {
- const struct usb_mux *mux = &usb_muxes[port];
-
- mux->hpd_update(port, 0, 0);
- }
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
+ usb_mux_hpd_update(port, 0, 0);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/chell/board.c b/board/chell/board.c
index 7b56ca621a..1472d7e5e9 100644
--- a/board/chell/board.c
+++ b/board/chell/board.c
@@ -183,12 +183,16 @@ static int ps874x_tune_mux(int port)
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = 0x1A,
+ .usb_port = 0,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = 0x1A,
.driver = &ps874x_usb_mux_driver,
.board_init = &ps874x_tune_mux,
},
{
- .port_addr = 0x10,
+ .usb_port = 1,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = 0x10,
.driver = &ps874x_usb_mux_driver,
.board_init = &ps874x_tune_mux,
}
diff --git a/board/cheza/board.c b/board/cheza/board.c
index 232f6cfc3d..855451049d 100644
--- a/board/cheza/board.c
+++ b/board/cheza/board.c
@@ -294,23 +294,23 @@ const unsigned int chg_cnt = ARRAY_SIZE(chg_chips);
* Redirect to anx74xx_tcpm_usb_mux_driver but override the get() function
* to check the HPD_IRQ mask from virtual_usb_mux_driver.
*/
-static int port0_usb_mux_init(int port)
+static int port0_usb_mux_init(const struct usb_mux *me)
{
- return anx74xx_tcpm_usb_mux_driver.init(port);
+ return anx74xx_tcpm_usb_mux_driver.init(me);
}
-static int port0_usb_mux_set(int i2c_addr, mux_state_t mux_state)
+static int port0_usb_mux_set(const struct usb_mux *me, mux_state_t mux_state)
{
- return anx74xx_tcpm_usb_mux_driver.set(i2c_addr, mux_state);
+ return anx74xx_tcpm_usb_mux_driver.set(me, mux_state);
}
-static int port0_usb_mux_get(int port, mux_state_t *mux_state)
+static int port0_usb_mux_get(const struct usb_mux *me, mux_state_t *mux_state)
{
int rv;
mux_state_t virtual_mux_state;
- rv = anx74xx_tcpm_usb_mux_driver.get(port, mux_state);
- rv |= virtual_usb_mux_driver.get(port, &virtual_mux_state);
+ rv = anx74xx_tcpm_usb_mux_driver.get(me, mux_state);
+ rv |= virtual_usb_mux_driver.get(me, &virtual_mux_state);
if (virtual_mux_state & USB_PD_MUX_HPD_IRQ)
*mux_state |= USB_PD_MUX_HPD_IRQ;
@@ -330,32 +330,32 @@ const struct usb_mux_driver port0_usb_mux_driver = {
* Redirect to tcpci_tcpm_usb_mux_driver but override the get() function
* to check the HPD_IRQ mask from virtual_usb_mux_driver.
*/
-static int port1_usb_mux_init(int port)
+static int port1_usb_mux_init(const struct usb_mux *me)
{
- return tcpci_tcpm_usb_mux_driver.init(port);
+ return tcpci_tcpm_usb_mux_driver.init(me);
}
-static int port1_usb_mux_set(int i2c_addr, mux_state_t mux_state)
+static int port1_usb_mux_set(const struct usb_mux *me, mux_state_t mux_state)
{
- return tcpci_tcpm_usb_mux_driver.set(i2c_addr, mux_state);
+ return tcpci_tcpm_usb_mux_driver.set(me, mux_state);
}
-static int port1_usb_mux_get(int port, mux_state_t *mux_state)
+static int port1_usb_mux_get(const struct usb_mux *me, mux_state_t *mux_state)
{
int rv;
mux_state_t virtual_mux_state;
- rv = tcpci_tcpm_usb_mux_driver.get(port, mux_state);
- rv |= virtual_usb_mux_driver.get(port, &virtual_mux_state);
+ rv = tcpci_tcpm_usb_mux_driver.get(me, mux_state);
+ rv |= virtual_usb_mux_driver.get(me, &virtual_mux_state);
if (virtual_mux_state & USB_PD_MUX_HPD_IRQ)
*mux_state |= USB_PD_MUX_HPD_IRQ;
return rv;
}
-static int port1_usb_mux_enter_low_power(int port)
+static int port1_usb_mux_enter_low_power(const struct usb_mux *me)
{
- return tcpci_tcpm_usb_mux_driver.enter_low_power_mode(port);
+ return tcpci_tcpm_usb_mux_driver.enter_low_power_mode(me);
}
const struct usb_mux_driver port1_usb_mux_driver = {
@@ -365,12 +365,14 @@ const struct usb_mux_driver port1_usb_mux_driver = {
.enter_low_power_mode = &port1_usb_mux_enter_low_power,
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
+ .usb_port = 0,
.driver = &port0_usb_mux_driver,
.hpd_update = &virtual_hpd_update,
},
{
+ .usb_port = 1,
.driver = &port1_usb_mux_driver,
.hpd_update = &virtual_hpd_update,
}
@@ -406,8 +408,6 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
void board_tcpc_init(void)
{
- int port;
-
/* Only reset TCPC if not sysjump */
if (!system_jumped_to_this_image()) {
/* TODO(crosbug.com/p/61098): How long do we need to wait? */
@@ -428,11 +428,8 @@ void board_tcpc_init(void)
* Initialize HPD to low; after sysjump SOC needs to see
* HPD pulse to enable video path
*/
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) {
- const struct usb_mux *mux = &usb_muxes[port];
-
- mux->hpd_update(port, 0, 0);
- }
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
+ usb_mux_hpd_update(port, 0, 0);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/cheza/usb_pd_policy.c b/board/cheza/usb_pd_policy.c
index 17f75136f9..694899ab79 100644
--- a/board/cheza/usb_pd_policy.c
+++ b/board/cheza/usb_pd_policy.c
@@ -177,11 +177,10 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]);
int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]);
int mf_pref = PD_VDO_DPSTS_MF_PREF(payload[1]);
- const struct usb_mux *mux = &usb_muxes[port];
dp_status[port] = payload[1];
- mux->hpd_update(port, lvl, irq);
+ usb_mux_hpd_update(port, lvl, irq);
if (lvl && is_dp_muxable(port)) {
/*
diff --git a/board/coral/board.c b/board/coral/board.c
index 9da7fb375a..3af03d6e0d 100644
--- a/board/coral/board.c
+++ b/board/coral/board.c
@@ -274,19 +274,21 @@ const enum gpio_signal hibernate_wake_pins[] = {
const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
-static int ps8751_tune_mux(int port)
+static int ps8751_tune_mux(const struct usb_mux *me)
{
/* 0x98 sets lower EQ of DP port (4.5db) */
- mux_write(port, PS8XXX_REG_MUX_DP_EQ_CONFIGURATION, 0x98);
+ mux_write(me, PS8XXX_REG_MUX_DP_EQ_CONFIGURATION, 0x98);
return EC_SUCCESS;
}
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_ANX74XX] = {
+ .usb_port = USB_PD_PORT_ANX74XX,
.driver = &anx74xx_tcpm_usb_mux_driver,
.hpd_update = &anx74xx_tcpc_update_hpd_status,
},
[USB_PD_PORT_PS8751] = {
+ .usb_port = USB_PD_PORT_PS8751,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
.board_init = &ps8751_tune_mux,
@@ -357,7 +359,7 @@ void board_reset_pd_mcu(void)
static void board_tcpc_init(void)
{
- int port, reg;
+ int reg;
int count = 0;
/* Wait for disconnected battery to wake up */
@@ -398,11 +400,8 @@ static void board_tcpc_init(void)
* Initialize HPD to low; after sysjump SOC needs to see
* HPD pulse to enable video path
*/
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) {
- const struct usb_mux *mux = &usb_muxes[port];
-
- mux->hpd_update(port, 0, 0);
- }
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
+ usb_mux_hpd_update(port, 0, 0);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_DEFAULT);
diff --git a/board/damu/board.c b/board/damu/board.c
index 87e78c5043..92b8a43b14 100644
--- a/board/damu/board.c
+++ b/board/damu/board.c
@@ -134,7 +134,8 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-static void board_hpd_status(int port, int hpd_lvl, int hpd_irq)
+static void board_hpd_status(const struct usb_mux *me,
+ int hpd_lvl, int hpd_irq)
{
/*
* svdm_dp_attention() did most of the work, we only need to notify
@@ -143,10 +144,11 @@ static void board_hpd_status(int port, int hpd_lvl, int hpd_irq)
host_set_single_event(EC_HOST_EVENT_USB_MUX);
}
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- /* Driver uses I2C_PORT_USB_MUX as I2C port */
- .port_addr = IT5205_I2C_ADDR1_FLAGS,
+ .usb_port = 0,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = IT5205_I2C_ADDR1_FLAGS,
.driver = &it5205_usb_mux_driver,
.hpd_update = &board_hpd_status,
},
diff --git a/board/dratini/board.c b/board/dratini/board.c
index 97b6a07eab..c4670cd65c 100644
--- a/board/dratini/board.c
+++ b/board/dratini/board.c
@@ -146,12 +146,14 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
+ .usb_port = USB_PD_PORT_TCPC_0,
.driver = &anx7447_usb_mux_driver,
.hpd_update = &anx7447_tcpc_update_hpd_status,
},
[USB_PD_PORT_TCPC_1] = {
+ .usb_port = USB_PD_PORT_TCPC_1,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
}
diff --git a/board/elm/board.c b/board/elm/board.c
index 29c1b2e510..578e7ac312 100644
--- a/board/elm/board.c
+++ b/board/elm/board.c
@@ -163,8 +163,9 @@ const struct temp_sensor_t temp_sensors[] = {
};
BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
+ .usb_port = 0,
.driver = &anx7688_usb_mux_driver,
},
};
diff --git a/board/eve/board.c b/board/eve/board.c
index 452732e393..8d1b21ccd6 100644
--- a/board/eve/board.c
+++ b/board/eve/board.c
@@ -221,12 +221,14 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
+ .usb_port = 0,
.driver = &anx74xx_tcpm_usb_mux_driver,
.hpd_update = &anx74xx_tcpc_update_hpd_status,
},
{
+ .usb_port = 1,
.driver = &anx74xx_tcpm_usb_mux_driver,
.hpd_update = &anx74xx_tcpc_update_hpd_status,
},
@@ -299,8 +301,6 @@ void board_reset_pd_mcu(void)
void board_tcpc_init(void)
{
- int port;
-
/* Only reset TCPC if not sysjump */
if (!system_jumped_to_this_image())
board_reset_pd_mcu();
@@ -319,11 +319,8 @@ void board_tcpc_init(void)
* Initialize HPD to low; after sysjump SOC needs to see
* HPD pulse to enable video path
*/
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) {
- const struct usb_mux *mux = &usb_muxes[port];
-
- mux->hpd_update(port, 0, 0);
- }
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
+ usb_mux_hpd_update(port, 0, 0);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/fizz/board.c b/board/fizz/board.c
index 8461cc3ae3..b3627afa7b 100644
--- a/board/fizz/board.c
+++ b/board/fizz/board.c
@@ -185,15 +185,16 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-static int ps8751_tune_mux(int port)
+static int ps8751_tune_mux(const struct usb_mux *me)
{
/* 0x98 sets lower EQ of DP port (4.5db) */
- mux_write(port, PS8XXX_REG_MUX_DP_EQ_CONFIGURATION, 0x98);
+ mux_write(me, PS8XXX_REG_MUX_DP_EQ_CONFIGURATION, 0x98);
return EC_SUCCESS;
}
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
+ .usb_port = 0,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
.board_init = &ps8751_tune_mux,
@@ -217,7 +218,7 @@ void board_reset_pd_mcu(void)
void board_tcpc_init(void)
{
- int port, reg;
+ int reg;
/* This needs to be executed only once per boot. It could be run by RO
* if we boot in recovery mode. It could be run by RW if we boot in
@@ -238,10 +239,8 @@ void board_tcpc_init(void)
* Initialize HPD to low; after sysjump SOC needs to see
* HPD pulse to enable video path
*/
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) {
- const struct usb_mux *mux = &usb_muxes[port];
- mux->hpd_update(port, 0, 0);
- }
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
+ usb_mux_hpd_update(port, 0, 0);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/flapjack/board.c b/board/flapjack/board.c
index 0035bc01dd..3d0e08afe5 100644
--- a/board/flapjack/board.c
+++ b/board/flapjack/board.c
@@ -304,8 +304,9 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
.drv = &mt6370_tcpm_drv},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
+ .usb_port = 0,
.driver = &virtual_usb_mux_driver,
.hpd_update = &virtual_hpd_update,
},
diff --git a/board/flapjack/usb_pd_policy.c b/board/flapjack/usb_pd_policy.c
index 7174389dde..20de95dc3b 100644
--- a/board/flapjack/usb_pd_policy.c
+++ b/board/flapjack/usb_pd_policy.c
@@ -77,8 +77,6 @@ void pd_power_supply_reset(int port)
#ifdef CONFIG_USB_PD_ALT_MODE_DFP
__override void svdm_dp_post_config(int port)
{
- const struct usb_mux * const mux = &usb_muxes[port];
-
dp_flags[port] |= DP_FLAGS_DP_ON;
if (!(dp_flags[port] & DP_FLAGS_HPD_HI_PENDING))
return;
@@ -89,7 +87,7 @@ __override void svdm_dp_post_config(int port)
/* set the minimum time delay (2ms) for the next HPD IRQ */
svdm_hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL;
- mux->hpd_update(port, 1, 0);
+ usb_mux_hpd_update(port, 1, 0);
}
__override int svdm_dp_attention(int port, uint32_t *payload)
@@ -97,7 +95,6 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
int cur_lvl = gpio_get_level(GPIO_USB_C0_HPD_OD);
int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]);
int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]);
- const struct usb_mux * const mux = &usb_muxes[port];
dp_status[port] = payload[1];
@@ -111,7 +108,7 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
usb_mux_set(port, lvl ? USB_PD_MUX_DP_ENABLED : USB_PD_MUX_NONE,
USB_SWITCH_CONNECT, pd_get_polarity(port));
- mux->hpd_update(port, lvl, irq);
+ usb_mux_hpd_update(port, lvl, irq);
if (irq & cur_lvl) {
uint64_t now = get_time().val;
@@ -148,11 +145,9 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
__override void svdm_exit_dp_mode(int port)
{
- const struct usb_mux * const mux = &usb_muxes[port];
-
svdm_safe_dp_mode(port);
gpio_set_level(GPIO_USB_C0_HPD_OD, 0);
gpio_set_level(GPIO_USB_C0_DP_OE_L, 1);
- mux->hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, 0, 0);
}
#endif /* CONFIG_USB_PD_ALT_MODE_DFP */
diff --git a/board/glados/board.c b/board/glados/board.c
index 2b70233631..f973e4f74b 100644
--- a/board/glados/board.c
+++ b/board/glados/board.c
@@ -166,12 +166,15 @@ BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) ==
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_USB_MUX,
- PI3USB3X532_I2C_ADDR0),
+ .usb_port = 0,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = PI3USB3X532_I2C_ADDR0,
.driver = &pi3usb3x532_usb_mux_driver,
},
{
- .port_addr = 0x10,
+ .usb_port = 1,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = 0x10,
.driver = &ps874x_usb_mux_driver,
}
};
diff --git a/board/glkrvp/chg_usb_pd.c b/board/glkrvp/chg_usb_pd.c
index f143dcece5..634da73a1c 100644
--- a/board/glkrvp/chg_usb_pd.c
+++ b/board/glkrvp/chg_usb_pd.c
@@ -50,13 +50,17 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
};
BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == CONFIG_USB_PD_PORT_MAX_COUNT);
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = 0x10,
+ .usb_port = 0,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = 0x10,
.driver = &ps874x_usb_mux_driver,
},
{
- .port_addr = 0x11,
+ .usb_port = 1,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = 0x11,
.driver = &ps874x_usb_mux_driver,
},
};
diff --git a/board/glkrvp_ite/chg_usb_pd.c b/board/glkrvp_ite/chg_usb_pd.c
index 0dbf286b7e..87ff5bf6d9 100644
--- a/board/glkrvp_ite/chg_usb_pd.c
+++ b/board/glkrvp_ite/chg_usb_pd.c
@@ -50,13 +50,17 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
};
BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == CONFIG_USB_PD_PORT_MAX_COUNT);
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = 0x10,
+ .usb_port = 0,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = 0x10,
.driver = &ps874x_usb_mux_driver,
},
{
- .port_addr = 0x11,
+ .usb_port = 1,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = 0x11,
.driver = &ps874x_usb_mux_driver,
},
};
diff --git a/board/hatch/board.c b/board/hatch/board.c
index 4e68b7d215..8060de471e 100644
--- a/board/hatch/board.c
+++ b/board/hatch/board.c
@@ -145,12 +145,14 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
+ .usb_port = USB_PD_PORT_TCPC_0,
.driver = &anx7447_usb_mux_driver,
.hpd_update = &anx7447_tcpc_update_hpd_status,
},
[USB_PD_PORT_TCPC_1] = {
+ .usb_port = USB_PD_PORT_TCPC_1,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
}
diff --git a/board/helios/board.c b/board/helios/board.c
index dd0b2c87a3..7ab13d5734 100644
--- a/board/helios/board.c
+++ b/board/helios/board.c
@@ -167,12 +167,14 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
+ .usb_port = USB_PD_PORT_TCPC_0,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
},
[USB_PD_PORT_TCPC_1] = {
+ .usb_port = USB_PD_PORT_TCPC_1,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
}
diff --git a/board/jacuzzi/board.c b/board/jacuzzi/board.c
index 7fb0f45fcc..defcebd884 100644
--- a/board/jacuzzi/board.c
+++ b/board/jacuzzi/board.c
@@ -142,7 +142,8 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-static void board_hpd_status(int port, int hpd_lvl, int hpd_irq)
+static void board_hpd_status(const struct usb_mux *me,
+ int hpd_lvl, int hpd_irq)
{
/*
* svdm_dp_attention() did most of the work, we only need to notify
@@ -151,10 +152,11 @@ static void board_hpd_status(int port, int hpd_lvl, int hpd_irq)
host_set_single_event(EC_HOST_EVENT_USB_MUX);
}
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- /* Driver uses I2C_PORT_USB_MUX as I2C port */
- .port_addr = IT5205_I2C_ADDR1_FLAGS,
+ .usb_port = 0,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = IT5205_I2C_ADDR1_FLAGS,
.driver = &it5205_usb_mux_driver,
.hpd_update = &board_hpd_status,
},
diff --git a/board/jinlon/board.c b/board/jinlon/board.c
index a9646a7794..56082fde2c 100644
--- a/board/jinlon/board.c
+++ b/board/jinlon/board.c
@@ -147,12 +147,14 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
+ .usb_port = USB_PD_PORT_TCPC_0,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
},
[USB_PD_PORT_TCPC_1] = {
+ .usb_port = USB_PD_PORT_TCPC_1,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
}
diff --git a/board/kakadu/board.c b/board/kakadu/board.c
index 0a408d0c36..e6e63a9bc7 100644
--- a/board/kakadu/board.c
+++ b/board/kakadu/board.c
@@ -106,7 +106,8 @@ struct mt6370_thermal_bound thermal_bound = {
.err = 4,
};
-static void board_hpd_update(int port, int hpd_lvl, int hpd_irq)
+static void board_hpd_update(const struct usb_mux *me,
+ int hpd_lvl, int hpd_irq)
{
/*
* svdm_dp_attention() did most of the work, we only need to notify
@@ -129,9 +130,11 @@ __override const struct rt946x_init_setting *board_rt946x_init_setting(void)
return &battery_init_setting;
}
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = IT5205_I2C_ADDR1_FLAGS,
+ .usb_port = 0,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = IT5205_I2C_ADDR1_FLAGS,
.driver = &it5205_usb_mux_driver,
.hpd_update = &board_hpd_update,
},
diff --git a/board/kappa/board.c b/board/kappa/board.c
index 6f4628ab8a..b4f37975ae 100644
--- a/board/kappa/board.c
+++ b/board/kappa/board.c
@@ -138,7 +138,8 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-static void board_hpd_status(int port, int hpd_lvl, int hpd_irq)
+static void board_hpd_status(const struct usb_mux *me,
+ int hpd_lvl, int hpd_irq)
{
/*
* svdm_dp_attention() did most of the work, we only need to notify
@@ -147,10 +148,11 @@ static void board_hpd_status(int port, int hpd_lvl, int hpd_irq)
host_set_single_event(EC_HOST_EVENT_USB_MUX);
}
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- /* Driver uses I2C_PORT_USB_MUX as I2C port */
- .port_addr = IT5205_I2C_ADDR1_FLAGS,
+ .usb_port = 0,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = IT5205_I2C_ADDR1_FLAGS,
.driver = &it5205_usb_mux_driver,
.hpd_update = &board_hpd_status,
},
diff --git a/board/kindred/board.c b/board/kindred/board.c
index 308ccf2eca..fa5b064016 100644
--- a/board/kindred/board.c
+++ b/board/kindred/board.c
@@ -168,12 +168,14 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
+ .usb_port = USB_PD_PORT_TCPC_0,
.driver = &anx7447_usb_mux_driver,
.hpd_update = &anx7447_tcpc_update_hpd_status,
},
[USB_PD_PORT_TCPC_1] = {
+ .usb_port = USB_PD_PORT_TCPC_1,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
}
diff --git a/board/kodama/board.c b/board/kodama/board.c
index abc44c43d4..03ecf1afe7 100644
--- a/board/kodama/board.c
+++ b/board/kodama/board.c
@@ -104,7 +104,8 @@ struct mt6370_thermal_bound thermal_bound = {
.err = 4,
};
-static void board_hpd_status(int port, int hpd_lvl, int hpd_irq)
+static void board_hpd_status(const struct usb_mux *me,
+ int hpd_lvl, int hpd_irq)
{
/*
* svdm_dp_attention() did most of the work, we only need to notify
@@ -128,9 +129,11 @@ __override const struct rt946x_init_setting *board_rt946x_init_setting(void)
return &battery_init_setting;
}
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = IT5205_I2C_ADDR1_FLAGS,
+ .usb_port = 0,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = IT5205_I2C_ADDR1_FLAGS,
.driver = &it5205_usb_mux_driver,
.hpd_update = &board_hpd_status,
},
diff --git a/board/kohaku/board.c b/board/kohaku/board.c
index dc56f432e1..ef59e36afb 100644
--- a/board/kohaku/board.c
+++ b/board/kohaku/board.c
@@ -131,12 +131,14 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
+ .usb_port = USB_PD_PORT_TCPC_0,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
},
[USB_PD_PORT_TCPC_1] = {
+ .usb_port = USB_PD_PORT_TCPC_1,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
}
diff --git a/board/kukui/board.c b/board/kukui/board.c
index 91b989aec8..5476030130 100644
--- a/board/kukui/board.c
+++ b/board/kukui/board.c
@@ -119,7 +119,8 @@ void board_set_dp_mux_control(int output_enable, int polarity)
gpio_set_level(GPIO_USB_C0_DP_POLARITY, polarity);
}
-static void board_hpd_update(int port, int hpd_lvl, int hpd_irq)
+static void board_hpd_update(const struct usb_mux *me,
+ int hpd_lvl, int hpd_irq)
{
/*
* svdm_dp_attention() did most of the work, we only need to notify
@@ -144,7 +145,9 @@ __override const struct rt946x_init_setting *board_rt946x_init_setting(void)
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = IT5205_I2C_ADDR1_FLAGS,
+ .usb_port = 0,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = IT5205_I2C_ADDR1_FLAGS,
.driver = &it5205_usb_mux_driver,
.hpd_update = &board_hpd_update,
},
diff --git a/board/kukui/board.h b/board/kukui/board.h
index 9b299bc02a..2057ab191a 100644
--- a/board/kukui/board.h
+++ b/board/kukui/board.h
@@ -28,6 +28,7 @@
#define CONFIG_USB_MUX_IT5205
#define CONFIG_USB_MUX_VIRTUAL
#define CONFIG_VOLUME_BUTTONS
+#define CONFIG_USB_MUX_RUNTIME_CONFIG
/* Battery */
#ifdef BOARD_KRANE
diff --git a/board/mchpevb1/board.c b/board/mchpevb1/board.c
index 7fd2c16575..d6e8da3a02 100644
--- a/board/mchpevb1/board.c
+++ b/board/mchpevb1/board.c
@@ -389,12 +389,15 @@ BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) ==
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_USB_MUX,
- PI3USB3X532_I2C_ADDR0),
+ .usb_port = 0,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = PI3USB3X532_I2C_ADDR0,
.driver = &pi3usb3x532_usb_mux_driver,
},
{
- .port_addr = 0x10,
+ .usb_port = 1,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = 0x10,
.driver = &ps874x_usb_mux_driver,
}
};
diff --git a/board/mushu/board.c b/board/mushu/board.c
index 1656e4adf0..bd5d2750b3 100644
--- a/board/mushu/board.c
+++ b/board/mushu/board.c
@@ -147,12 +147,14 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
+ .usb_port = USB_PD_PORT_TCPC_0,
.driver = &anx7447_usb_mux_driver,
.hpd_update = &anx7447_tcpc_update_hpd_status,
},
[USB_PD_PORT_TCPC_1] = {
+ .usb_port = USB_PD_PORT_TCPC_1,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
}
diff --git a/board/nami/board.c b/board/nami/board.c
index b6cbbd359d..9bbffdc755 100644
--- a/board/nami/board.c
+++ b/board/nami/board.c
@@ -252,19 +252,21 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-static int ps8751_tune_mux(int port)
+static int ps8751_tune_mux(const struct usb_mux *me)
{
/* 0x98 sets lower EQ of DP port (3.6db) */
- mux_write(port, PS8XXX_REG_MUX_DP_EQ_CONFIGURATION, 0x98);
+ mux_write(me, PS8XXX_REG_MUX_DP_EQ_CONFIGURATION, 0x98);
return EC_SUCCESS;
}
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_PS8751] = {
+ .usb_port = USB_PD_PORT_PS8751,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
},
[USB_PD_PORT_ANX7447] = {
+ .usb_port = USB_PD_PORT_ANX7447,
.driver = &anx7447_usb_mux_driver,
.hpd_update = &anx7447_tcpc_update_hpd_status,
}
@@ -314,8 +316,6 @@ void board_reset_pd_mcu(void)
void board_tcpc_init(void)
{
- int port;
-
/* Only reset TCPC if not sysjump */
if (!system_jumped_to_this_image())
board_reset_pd_mcu();
@@ -331,10 +331,8 @@ void board_tcpc_init(void)
* Initialize HPD to low; after sysjump SOC needs to see
* HPD pulse to enable video path
*/
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) {
- const struct usb_mux *mux = &usb_muxes[port];
- mux->hpd_update(port, 0, 0);
- }
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
+ usb_mux_hpd_update(port, 0, 0);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 2);
diff --git a/board/nami/board.h b/board/nami/board.h
index e039f0dcb5..8159f13c7a 100644
--- a/board/nami/board.h
+++ b/board/nami/board.h
@@ -186,6 +186,7 @@
#define CONFIG_USBC_SS_MUX
#define CONFIG_USBC_VCONN
#define CONFIG_USBC_VCONN_SWAP
+#define CONFIG_USB_MUX_RUNTIME_CONFIG
/* BC 1.2 charger */
diff --git a/board/nautilus/board.c b/board/nautilus/board.c
index c9897212f8..3f01a70f6c 100644
--- a/board/nautilus/board.c
+++ b/board/nautilus/board.c
@@ -166,12 +166,14 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
+ .usb_port = 0,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
},
{
+ .usb_port = 1,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
}
@@ -216,8 +218,6 @@ void board_reset_pd_mcu(void)
void board_tcpc_init(void)
{
- int port;
-
/* Only reset TCPC if not sysjump */
if (!system_jumped_to_this_image()) {
board_reset_pd_mcu();
@@ -231,11 +231,8 @@ void board_tcpc_init(void)
* Initialize HPD to low; after sysjump SOC needs to see
* HPD pulse to enable video path
*/
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) {
- const struct usb_mux *mux = &usb_muxes[port];
-
- mux->hpd_update(port, 0, 0);
- }
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
+ usb_mux_hpd_update(port, 0, 0);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/nocturne/board.c b/board/nocturne/board.c
index 9a397d1298..3184b6293b 100644
--- a/board/nocturne/board.c
+++ b/board/nocturne/board.c
@@ -318,13 +318,15 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
+ .usb_port = 0,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
},
{
+ .usb_port = 1,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
},
diff --git a/board/oak/board.c b/board/oak/board.c
index ec871824bc..e79dc31460 100644
--- a/board/oak/board.c
+++ b/board/oak/board.c
@@ -195,24 +195,24 @@ struct als_t als[] = {
BUILD_ASSERT(ARRAY_SIZE(als) == ALS_COUNT);
#endif
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_USB_MUX,
- PI3USB3X532_I2C_ADDR0),
+ .usb_port = 0,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = PI3USB3X532_I2C_ADDR0,
.driver = &pi3usb3x532_usb_mux_driver,
},
-#if (BOARD_REV <= OAK_REV4)
{
- .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_USB_MUX,
- PI3USB3X532_I2C_ADDR1),
+ .usb_port = 1,
+ .i2c_port = I2C_PORT_USB_MUX,
+#if (BOARD_REV <= OAK_REV4)
+ .i2c_addr_flags = PI3USB3X532_I2C_ADDR1,
.driver = &pi3usb3x532_usb_mux_driver,
- },
#else
- {
- .port_addr = 0x10,
+ .i2c_addr_flags = 0x10,
.driver = &ps874x_usb_mux_driver,
- },
#endif
+ },
};
/**
diff --git a/board/pdeval-stm32f072/usb_pd_policy.c b/board/pdeval-stm32f072/usb_pd_policy.c
index 2f0022d211..775f8b8876 100644
--- a/board/pdeval-stm32f072/usb_pd_policy.c
+++ b/board/pdeval-stm32f072/usb_pd_policy.c
@@ -36,8 +36,9 @@ const uint32_t pd_snk_pdo[] = {
const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo);
#if defined(CONFIG_USB_PD_TCPM_MUX) && defined(CONFIG_USB_PD_TCPM_ANX7447)
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
+ .usb_port = 0,
.driver = &anx7447_usb_mux_driver,
},
};
@@ -200,6 +201,9 @@ __override int svdm_dp_config(int port, uint32_t *payload)
{
int opos = pd_alt_mode(port, USB_SID_DISPLAYPORT);
int pin_mode = pd_dfp_dp_get_pin_mode(port, dp_status[port]);
+#if defined(CONFIG_USB_PD_TCPM_MUX) && defined(CONFIG_USB_PD_TCPM_ANX7447)
+ const struct usb_mux *mux = &usb_muxes[port];
+#endif
#ifdef CONFIG_USB_PD_TCPM_ANX7447
mux_state_t mux_state = USB_PD_MUX_NONE;
@@ -217,13 +221,13 @@ __override int svdm_dp_config(int port, uint32_t *payload)
case MODE_DP_PIN_C:
case MODE_DP_PIN_E:
mux_state |= USB_PD_MUX_DP_ENABLED;
- usb_muxes[port].driver->set(port, mux_state);
+ mux->driver->set(mux, mux_state);
break;
case MODE_DP_PIN_B:
case MODE_DP_PIN_D:
case MODE_DP_PIN_F:
mux_state |= USB_PD_MUX_DOCK;
- usb_muxes[port].driver->set(port, mux_state);
+ mux->driver->set(mux, mux_state);
break;
}
#endif
@@ -242,13 +246,14 @@ __override int svdm_dp_config(int port, uint32_t *payload)
__override void svdm_dp_post_config(int port)
{
+ const struct usb_mux *mux = &usb_muxes[port];
+
dp_flags[port] |= DP_FLAGS_DP_ON;
if (!(dp_flags[port] & DP_FLAGS_HPD_HI_PENDING))
return;
-#ifdef CONFIG_USB_PD_TCPM_ANX7447
- anx7447_tcpc_update_hpd_status(port, 1, 0);
-#endif
+ if (IS_ENABLED(CONFIG_USB_PD_TCPM_ANX7447))
+ anx7447_tcpc_update_hpd_status(mux, 1, 0);
}
__override int svdm_dp_attention(int port, uint32_t *payload)
@@ -256,9 +261,10 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
#ifdef CONFIG_USB_PD_TCPM_ANX7447
int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]);
int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]);
+ const struct usb_mux *mux = &usb_muxes[port];
CPRINTS("Attention: 0x%x", payload[1]);
- anx7447_tcpc_update_hpd_status(port, lvl, irq);
+ anx7447_tcpc_update_hpd_status(mux, lvl, irq);
#endif
dp_status[port] = payload[1];
diff --git a/board/poppy/board.c b/board/poppy/board.c
index 9ccd9774b4..80bcf98433 100644
--- a/board/poppy/board.c
+++ b/board/poppy/board.c
@@ -208,12 +208,14 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
+ .usb_port = 0,
.driver = &anx74xx_tcpm_usb_mux_driver,
.hpd_update = &anx74xx_tcpc_update_hpd_status,
},
{
+ .usb_port = 1,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
}
@@ -284,7 +286,7 @@ void board_reset_pd_mcu(void)
void board_tcpc_init(void)
{
- int port, reg;
+ int reg;
/* Only reset TCPC if not sysjump */
if (!system_jumped_to_this_image()) {
@@ -318,11 +320,8 @@ void board_tcpc_init(void)
* Initialize HPD to low; after sysjump SOC needs to see
* HPD pulse to enable video path
*/
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) {
- const struct usb_mux *mux = &usb_muxes[port];
-
- mux->hpd_update(port, 0, 0);
- }
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
+ usb_mux_hpd_update(port, 0, 0);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/puff/board.c b/board/puff/board.c
index 4917432d6b..1f8162b147 100644
--- a/board/puff/board.c
+++ b/board/puff/board.c
@@ -244,8 +244,9 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
.flags = TCPC_FLAGS_RESET_ACTIVE_HIGH,
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
+ .usb_port = USB_PD_PORT_TCPC_0,
.driver = &anx7447_usb_mux_driver,
.hpd_update = &anx7447_tcpc_update_hpd_status,
},
diff --git a/board/rainier/board.c b/board/rainier/board.c
index 99751de860..a2592bd54d 100644
--- a/board/rainier/board.c
+++ b/board/rainier/board.c
@@ -137,8 +137,9 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
+ .usb_port = 0,
.driver = &virtual_usb_mux_driver,
.hpd_update = &virtual_hpd_update,
},
diff --git a/board/rammus/board.c b/board/rammus/board.c
index 9ce61ef501..6f6d175959 100644
--- a/board/rammus/board.c
+++ b/board/rammus/board.c
@@ -178,12 +178,14 @@ struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_PS8751] = {
+ .usb_port = USB_PD_PORT_PS8751,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
},
[USB_PD_PORT_ANX7447] = {
+ .usb_port = USB_PD_PORT_ANX7447,
.driver = &anx7447_usb_mux_driver,
.hpd_update = &anx7447_tcpc_update_hpd_status,
}
@@ -242,8 +244,6 @@ static void ps8751_i2c_remap(void)
void board_tcpc_init(void)
{
- int port;
-
ps8751_i2c_remap();
/* Only reset TCPC if not sysjump */
@@ -259,10 +259,8 @@ void board_tcpc_init(void)
* Initialize HPD to low; after sysjump SOC needs to see
* HPD pulse to enable video path
*/
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) {
- const struct usb_mux *mux = &usb_muxes[port];
- mux->hpd_update(port, 0, 0);
- }
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
+ usb_mux_hpd_update(port, 0, 0);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/reef/board.c b/board/reef/board.c
index 0a9d453ce5..30b3058161 100644
--- a/board/reef/board.c
+++ b/board/reef/board.c
@@ -279,19 +279,21 @@ const enum gpio_signal hibernate_wake_pins[] = {
const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
-static int ps8751_tune_mux(int port)
+static int ps8751_tune_mux(const struct usb_mux *me)
{
/* 0x98 sets lower EQ of DP port (4.5db) */
- mux_write(port, PS8XXX_REG_MUX_DP_EQ_CONFIGURATION, 0x98);
+ mux_write(me, PS8XXX_REG_MUX_DP_EQ_CONFIGURATION, 0x98);
return EC_SUCCESS;
}
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_ANX74XX] = {
+ .usb_port = USB_PD_PORT_ANX74XX,
.driver = &anx74xx_tcpm_usb_mux_driver,
.hpd_update = &anx74xx_tcpc_update_hpd_status,
},
[USB_PD_PORT_PS8751] = {
+ .usb_port = USB_PD_PORT_PS8751,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
.board_init = &ps8751_tune_mux,
@@ -361,7 +363,7 @@ void board_reset_pd_mcu(void)
void board_tcpc_init(void)
{
- int port, reg;
+ int reg;
/* Only reset TCPC if not sysjump */
if (!system_jumped_to_this_image())
@@ -392,11 +394,8 @@ void board_tcpc_init(void)
* Initialize HPD to low; after sysjump SOC needs to see
* HPD pulse to enable video path
*/
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) {
- const struct usb_mux *mux = &usb_muxes[port];
-
- mux->hpd_update(port, 0, 0);
- }
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
+ usb_mux_hpd_update(port, 0, 0);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/reef_it8320/board.c b/board/reef_it8320/board.c
index c06ceaa87e..5c5796bb9e 100644
--- a/board/reef_it8320/board.c
+++ b/board/reef_it8320/board.c
@@ -146,10 +146,12 @@ const enum gpio_signal hibernate_wake_pins[] = {
const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
-static void it83xx_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq)
+static void it83xx_tcpc_update_hpd_status(const struct usb_mux *me,
+ int hpd_lvl, int hpd_irq)
{
enum gpio_signal gpio =
- port ? GPIO_USB_C1_HPD_1P8_ODL : GPIO_USB_C0_HPD_1P8_ODL;
+ me->usb_port ? GPIO_USB_C1_HPD_1P8_ODL
+ : GPIO_USB_C0_HPD_1P8_ODL;
hpd_lvl = !hpd_lvl;
@@ -161,15 +163,18 @@ static void it83xx_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq)
}
}
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_USB_MUX,
- PI3USB3X532_I2C_ADDR0),
+ .usb_port = 0,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = PI3USB3X532_I2C_ADDR0,
.driver = &pi3usb3x532_usb_mux_driver,
.hpd_update = &it83xx_tcpc_update_hpd_status,
},
{
- .port_addr = 0x10,
+ .usb_port = 1,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = 0x10,
.driver = &ps874x_usb_mux_driver,
.hpd_update = &it83xx_tcpc_update_hpd_status,
},
@@ -245,8 +250,6 @@ static void board_set_tablet_mode(void)
/* Initialize board. */
static void board_init(void)
{
- int port;
-
board_set_tablet_mode();
/* Enable charger interrupts */
gpio_enable_interrupt(GPIO_CHARGER_INT_L);
@@ -255,8 +258,8 @@ static void board_init(void)
* Initialize HPD to low; after sysjump SOC needs to see
* HPD pulse to enable video path
*/
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++)
- usb_muxes[port].hpd_update(port, 0, 0);
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
+ usb_mux_hpd_update(port, 0, 0);
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_INIT_I2C + 1);
diff --git a/board/reef_mchp/board.c b/board/reef_mchp/board.c
index 89fc2ec139..b9927976ab 100644
--- a/board/reef_mchp/board.c
+++ b/board/reef_mchp/board.c
@@ -406,12 +406,12 @@ const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
* results taking up to 10ms before I2C communication with PS8751
* is stable. Don't know how to fix this.
*/
-static int ps8751_tune_mux(int port)
+static int ps8751_tune_mux(const struct usb_mux *me)
{
int rv;
/* 0x98 sets lower EQ of DP port (4.5db) */
- rv = mux_write(port, PS8XXX_REG_MUX_DP_EQ_CONFIGURATION, 0x98);
+ rv = mux_write(me, PS8XXX_REG_MUX_DP_EQ_CONFIGURATION, 0x98);
/* TCPCI spec. delay msleep(6); */
@@ -423,12 +423,14 @@ static int ps8751_tune_mux(int port)
* tcpc_config array. The tcpc_config array contains the actual EC I2C
* port, device slave address, and a function pointer into the driver code.
*/
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_ANX74XX] = {
+ .usb_port = USB_PD_PORT_ANX74XX,
.driver = &anx74xx_tcpm_usb_mux_driver,
.hpd_update = &anx74xx_tcpc_update_hpd_status,
},
[USB_PD_PORT_PS8751] = {
+ .usb_port = USB_PD_PORT_PS8751,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
.board_init = &ps8751_tune_mux,
@@ -501,7 +503,7 @@ void board_reset_pd_mcu(void)
void board_tcpc_init(void)
{
- int port, reg;
+ int reg;
/* Only reset TCPC if not sysjump */
if (!system_jumped_to_this_image())
@@ -538,11 +540,8 @@ void board_tcpc_init(void)
* Initialize HPD to low; after sysjump SOC needs to see
* HPD pulse to enable video path
*/
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) {
- const struct usb_mux *mux = &usb_muxes[port];
-
- mux->hpd_update(port, 0, 0);
- }
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
+ usb_mux_hpd_update(port, 0, 0);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/samus_pd/usb_mux.c b/board/samus_pd/usb_mux.c
index 732de79968..2213fc41e0 100644
--- a/board/samus_pd/usb_mux.c
+++ b/board/samus_pd/usb_mux.c
@@ -40,14 +40,14 @@ static const struct usb_port_mux mux_gpios[] = {
BUILD_ASSERT(ARRAY_SIZE(mux_gpios) == CONFIG_USB_PD_PORT_MAX_COUNT);
-static int board_init_usb_mux(int port)
+static int board_init_usb_mux(const struct usb_mux *me)
{
return EC_SUCCESS;
}
-static int board_set_usb_mux(int port, mux_state_t mux_state)
+static int board_set_usb_mux(const struct usb_mux *me, mux_state_t mux_state)
{
- const struct usb_port_mux *usb_mux = mux_gpios + port;
+ const struct usb_port_mux *usb_mux = mux_gpios + me->usb_port;
int polarity = mux_state & USB_PD_MUX_POLARITY_INVERTED;
/* reset everything */
@@ -80,9 +80,9 @@ static int board_set_usb_mux(int port, mux_state_t mux_state)
return EC_SUCCESS;
}
-static int board_get_usb_mux(int port, mux_state_t *mux_state)
+static int board_get_usb_mux(const struct usb_mux *me, mux_state_t *mux_state)
{
- const struct usb_port_mux *usb_mux = mux_gpios + port;
+ const struct usb_port_mux *usb_mux = mux_gpios + me->usb_port;
*mux_state = 0;
@@ -105,11 +105,13 @@ const struct usb_mux_driver board_custom_usb_mux_driver = {
.get = board_get_usb_mux,
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
+ .usb_port = 0,
.driver = &board_custom_usb_mux_driver,
},
{
+ .usb_port = 1,
.driver = &board_custom_usb_mux_driver,
},
};
diff --git a/board/scarlet/board.c b/board/scarlet/board.c
index 5f20812a23..8de3de4bf5 100644
--- a/board/scarlet/board.c
+++ b/board/scarlet/board.c
@@ -144,8 +144,9 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
+ .usb_port = 0,
.driver = &virtual_usb_mux_driver,
.hpd_update = &virtual_hpd_update,
},
diff --git a/board/strago/board.c b/board/strago/board.c
index 73f105cd24..308c4ee8ce 100644
--- a/board/strago/board.c
+++ b/board/strago/board.c
@@ -141,10 +141,11 @@ struct pi3usb9281_config pi3usb9281_chips[] = {
BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) ==
CONFIG_BC12_DETECT_PI3USB9281_CHIP_COUNT);
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_USB_MUX,
- PI3USB3X532_I2C_ADDR1),
+ .usb_port = 0,
+ .i2c_port = I2C_PORT_USB_MUX,
+ .i2c_addr_flags = PI3USB3X532_I2C_ADDR1,
.driver = &pi3usb3x532_usb_mux_driver,
},
};
diff --git a/board/stryke/board.c b/board/stryke/board.c
index dc5de9d253..5f74ea26f6 100644
--- a/board/stryke/board.c
+++ b/board/stryke/board.c
@@ -144,12 +144,14 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_TCPC_0] = {
+ .usb_port = USB_PD_PORT_TCPC_0,
.driver = &anx7447_usb_mux_driver,
.hpd_update = &anx7447_tcpc_update_hpd_status,
},
[USB_PD_PORT_TCPC_1] = {
+ .usb_port = USB_PD_PORT_TCPC_1,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
}
diff --git a/board/trogdor/board.c b/board/trogdor/board.c
index 717392a1a2..c8d770fc37 100644
--- a/board/trogdor/board.c
+++ b/board/trogdor/board.c
@@ -266,12 +266,14 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
* to AP. But the TCPC chip is also needed to know the HPD status; otherwise,
* the mux misbehaves.
*/
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
+ .usb_port = 0,
.driver = &ps8xxx_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
},
{
+ .usb_port = 1,
.driver = &ps8xxx_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
}
@@ -328,8 +330,6 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
void board_tcpc_init(void)
{
- int port;
-
/* Only reset TCPC if not sysjump */
if (!system_jumped_to_this_image()) {
/* TODO(crosbug.com/p/61098): How long do we need to wait? */
@@ -347,11 +347,8 @@ void board_tcpc_init(void)
* Initialize HPD to low; after sysjump SOC needs to see
* HPD pulse to enable video path
*/
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) {
- const struct usb_mux *mux = &usb_muxes[port];
-
- mux->hpd_update(port, 0, 0);
- }
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
+ usb_mux_hpd_update(port, 0, 0);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/trogdor/usb_pd_policy.c b/board/trogdor/usb_pd_policy.c
index c88768f63a..6840ae919e 100644
--- a/board/trogdor/usb_pd_policy.c
+++ b/board/trogdor/usb_pd_policy.c
@@ -152,7 +152,6 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
enum gpio_signal hpd = GPIO_DP_HOT_PLUG_DET;
int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]);
int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]);
- const struct usb_mux *mux = &usb_muxes[port];
int cur_lvl = gpio_get_level(hpd);
dp_status[port] = payload[1];
@@ -217,7 +216,7 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
pd_notify_dp_alt_mode_entry();
/* Configure TCPC for the HPD event, for proper muxing */
- mux->hpd_update(port, lvl, irq);
+ usb_mux_hpd_update(port, lvl, irq);
/* Signal AP for the HPD event, through GPIO to AP */
if (irq & cur_lvl) {
@@ -249,8 +248,6 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
__override void svdm_exit_dp_mode(int port)
{
- const struct usb_mux *mux = &usb_muxes[port];
-
/* Disconnect the DP port selection mux. */
gpio_set_level(GPIO_DP_MUX_OE_L, 1);
@@ -258,7 +255,7 @@ __override void svdm_exit_dp_mode(int port)
svdm_safe_dp_mode(port);
/* Signal AP for the HPD low event */
- mux->hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, 0, 0);
gpio_set_level(GPIO_DP_HOT_PLUG_DET, 0);
}
#endif /* CONFIG_USB_PD_ALT_MODE_DFP */
diff --git a/board/waddledoo/board.c b/board/waddledoo/board.c
index cf697d6564..6979a326fe 100644
--- a/board/waddledoo/board.c
+++ b/board/waddledoo/board.c
@@ -344,28 +344,28 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usbc1_retimer = {
+ .usb_port = 1,
+ .i2c_port = I2C_PORT_SUB_USB_C1,
+ .i2c_addr_flags = NB7V904M_I2C_ADDR0,
+ .driver = &nb7v904m_usb_redriver_drv,
+};
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_USB_C0,
- PI3USB3X532_I2C_ADDR0),
+ .usb_port = 0,
+ .i2c_port = I2C_PORT_USB_C0,
+ .i2c_addr_flags = PI3USB3X532_I2C_ADDR0,
.driver = &pi3usb3x532_usb_mux_driver,
},
{
- .port_addr = MUX_PORT_AND_ADDR(I2C_PORT_SUB_USB_C1,
- PI3USB3X532_I2C_ADDR0),
+ .usb_port = 1,
+ .i2c_port = I2C_PORT_SUB_USB_C1,
+ .i2c_addr_flags = PI3USB3X532_I2C_ADDR0,
.driver = &pi3usb3x532_usb_mux_driver,
+ .next_mux = &usbc1_retimer,
}
};
-struct usb_retimer usb_retimers[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- { 0 }, /* There's no retimer on Port 0 */
- {
- .i2c_port = I2C_PORT_SUB_USB_C1,
- .i2c_addr_flags = NB7V904M_I2C_ADDR0,
- .driver = &nb7v904m_usb_redriver_drv,
- },
-};
-
uint16_t tcpc_get_alert_status(void)
{
uint16_t status = 0;