summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-10-18 15:27:01 -0600
committerCommit Bot <commit-bot@chromium.org>2021-12-02 23:09:27 +0000
commit18f6c4d3b2a56635ce880788047083115637885c (patch)
treec735046c4f418c6addfd2c6228252a81388f8b4f
parent5175aa6b6d38c1819e3820d889d8f02d7226fac1 (diff)
downloadchrome-ec-18f6c4d3b2a56635ce880788047083115637885c.tar.gz
USB MUX: Wait on ACK for HPD changes when required
In order to correctly sequence HPD sets with the AP, allow the HPD set to wait on an ACK from the AP before proceeding. BRANCH=None BUG=b:202137658 TEST=on brya, validate retimer and virtual mux are kept in sync as expected Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I368c3290b69d627829a70847876d7b47a8c36948 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3232293 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--baseboard/octopus/variant_usbc_ec_tcpcs.c6
-rw-r--r--board/burnet/board.c6
-rw-r--r--board/cerise/board.c6
-rw-r--r--board/damu/board.c6
-rw-r--r--board/fennel/board.c6
-rw-r--r--board/icarus/board.c6
-rw-r--r--board/jacuzzi/board.c6
-rw-r--r--board/kakadu/board.c6
-rw-r--r--board/kappa/board.c6
-rw-r--r--board/katsu/board.c6
-rw-r--r--board/kodama/board.c6
-rw-r--r--board/kukui/board.c6
-rw-r--r--board/makomo/board.c6
-rw-r--r--board/munna/board.c6
-rw-r--r--board/pdeval-stm32f072/usb_pd_policy.c8
-rw-r--r--board/pico/board.c6
-rw-r--r--board/reef_it8320/board.c6
-rw-r--r--board/stern/board.c6
-rw-r--r--board/willow/board.c6
-rw-r--r--driver/retimer/bb_retimer.c6
-rw-r--r--driver/tcpm/anx7447.c6
-rw-r--r--driver/tcpm/anx7447.h3
-rw-r--r--driver/tcpm/anx74xx.c6
-rw-r--r--driver/tcpm/anx74xx.h3
-rw-r--r--driver/tcpm/ps8xxx.c6
-rw-r--r--driver/usb_mux/tusb1064.c6
-rw-r--r--driver/usb_mux/tusb1064.h3
-rw-r--r--driver/usb_mux/usb_mux.c8
-rw-r--r--driver/usb_mux/virtual.c7
-rw-r--r--include/driver/retimer/bb_retimer_public.h9
-rw-r--r--include/driver/tcpm/ps8xxx_public.h3
-rw-r--r--include/usb_mux.h14
-rw-r--r--zephyr/test/drivers/src/usb_mux.c5
33 files changed, 154 insertions, 47 deletions
diff --git a/baseboard/octopus/variant_usbc_ec_tcpcs.c b/baseboard/octopus/variant_usbc_ec_tcpcs.c
index 2e3248410f..8fa5f513e3 100644
--- a/baseboard/octopus/variant_usbc_ec_tcpcs.c
+++ b/baseboard/octopus/variant_usbc_ec_tcpcs.c
@@ -49,13 +49,17 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
/* TODO(crbug.com/826441): Consolidate this logic with other impls */
static void board_it83xx_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
int hpd_lvl = (mux_state & USB_PD_MUX_HPD_LVL) ? 1 : 0;
int hpd_irq = (mux_state & USB_PD_MUX_HPD_IRQ) ? 1 : 0;
enum gpio_signal gpio = me->usb_port ?
GPIO_USB_C1_HPD_1V8_ODL : GPIO_USB_C0_HPD_1V8_ODL;
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/* Invert HPD level since GPIOs are active low. */
hpd_lvl = !hpd_lvl;
diff --git a/board/burnet/board.c b/board/burnet/board.c
index fbb531fef1..5ee2ad3965 100644
--- a/board/burnet/board.c
+++ b/board/burnet/board.c
@@ -160,8 +160,12 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
};
static void board_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/*
* svdm_dp_attention() did most of the work, we only need to notify
* host here.
diff --git a/board/cerise/board.c b/board/cerise/board.c
index 4430d22533..9f2f93e12d 100644
--- a/board/cerise/board.c
+++ b/board/cerise/board.c
@@ -158,8 +158,12 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
};
static void board_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/*
* svdm_dp_attention() did most of the work, we only need to notify
* host here.
diff --git a/board/damu/board.c b/board/damu/board.c
index b5867377a5..f66d05eb5b 100644
--- a/board/damu/board.c
+++ b/board/damu/board.c
@@ -158,8 +158,12 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
};
static void board_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/*
* svdm_dp_attention() did most of the work, we only need to notify
* host here.
diff --git a/board/fennel/board.c b/board/fennel/board.c
index 60024e7a9f..3335c80240 100644
--- a/board/fennel/board.c
+++ b/board/fennel/board.c
@@ -159,8 +159,12 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
};
static void board_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/*
* svdm_dp_attention() did most of the work, we only need to notify
* host here.
diff --git a/board/icarus/board.c b/board/icarus/board.c
index b1f9c3ef5d..a95b94c8c9 100644
--- a/board/icarus/board.c
+++ b/board/icarus/board.c
@@ -140,8 +140,12 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
};
static void board_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/*
* svdm_dp_attention() did most of the work, we only need to notify
* host here.
diff --git a/board/jacuzzi/board.c b/board/jacuzzi/board.c
index f31f712386..5e3c2f0c22 100644
--- a/board/jacuzzi/board.c
+++ b/board/jacuzzi/board.c
@@ -168,8 +168,12 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
};
static void board_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/*
* svdm_dp_attention() did most of the work, we only need to notify
* host here.
diff --git a/board/kakadu/board.c b/board/kakadu/board.c
index 9ac5ed8de4..c63e9fd267 100644
--- a/board/kakadu/board.c
+++ b/board/kakadu/board.c
@@ -120,8 +120,12 @@ struct mt6370_thermal_bound thermal_bound = {
};
static void board_hpd_update(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/*
* svdm_dp_attention() did most of the work, we only need to notify
* host here.
diff --git a/board/kappa/board.c b/board/kappa/board.c
index f3c17f32c3..e70054b18f 100644
--- a/board/kappa/board.c
+++ b/board/kappa/board.c
@@ -156,8 +156,12 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
};
static void board_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/*
* svdm_dp_attention() did most of the work, we only need to notify
* host here.
diff --git a/board/katsu/board.c b/board/katsu/board.c
index 5f91f64348..8909886abd 100644
--- a/board/katsu/board.c
+++ b/board/katsu/board.c
@@ -119,8 +119,12 @@ struct mt6370_thermal_bound thermal_bound = {
};
static void board_hpd_update(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/*
* svdm_dp_attention() did most of the work, we only need to notify
* host here.
diff --git a/board/kodama/board.c b/board/kodama/board.c
index 5ecfc794f5..ba5e4a27a4 100644
--- a/board/kodama/board.c
+++ b/board/kodama/board.c
@@ -123,8 +123,12 @@ struct mt6370_thermal_bound thermal_bound = {
};
static void board_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/*
* svdm_dp_attention() did most of the work, we only need to notify
* host here.
diff --git a/board/kukui/board.c b/board/kukui/board.c
index 97fff0a80c..a3468b62ca 100644
--- a/board/kukui/board.c
+++ b/board/kukui/board.c
@@ -135,8 +135,12 @@ void board_set_dp_mux_control(int output_enable, int polarity)
}
static void board_hpd_update(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/*
* svdm_dp_attention() did most of the work, we only need to notify
* host here.
diff --git a/board/makomo/board.c b/board/makomo/board.c
index 8f9dbdc12c..616b50003d 100644
--- a/board/makomo/board.c
+++ b/board/makomo/board.c
@@ -157,8 +157,12 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
};
static void board_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/*
* svdm_dp_attention() did most of the work, we only need to notify
* host here.
diff --git a/board/munna/board.c b/board/munna/board.c
index 4e8f19eb8b..6cba87ada2 100644
--- a/board/munna/board.c
+++ b/board/munna/board.c
@@ -158,8 +158,12 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
};
static void board_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/*
* svdm_dp_attention() did most of the work, we only need to notify
* host here.
diff --git a/board/pdeval-stm32f072/usb_pd_policy.c b/board/pdeval-stm32f072/usb_pd_policy.c
index 6fdb894eed..b7425ce66c 100644
--- a/board/pdeval-stm32f072/usb_pd_policy.c
+++ b/board/pdeval-stm32f072/usb_pd_policy.c
@@ -243,6 +243,7 @@ __override int svdm_dp_config(int port, uint32_t *payload)
__override void svdm_dp_post_config(int port)
{
+ bool unused;
const struct usb_mux *mux = &usb_muxes[port];
dp_flags[port] |= DP_FLAGS_DP_ON;
@@ -252,7 +253,8 @@ __override void svdm_dp_post_config(int port)
/* Note: Usage is deprecated, use usb_mux_hpd_update instead */
if (IS_ENABLED(CONFIG_USB_PD_TCPM_ANX7447))
anx7447_tcpc_update_hpd_status(mux, USB_PD_MUX_HPD_LVL |
- USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ USB_PD_MUX_HPD_IRQ_DEASSERTED,
+ &unused);
}
__override int svdm_dp_attention(int port, uint32_t *payload)
@@ -261,6 +263,8 @@ __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]);
const struct usb_mux *mux = &usb_muxes[port];
+ bool unused;
+
mux_state_t mux_state = (lvl ? USB_PD_MUX_HPD_LVL :
USB_PD_MUX_HPD_LVL_DEASSERTED) |
(irq ? USB_PD_MUX_HPD_IRQ :
@@ -268,7 +272,7 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
/* Note: Usage is deprecated, use usb_mux_hpd_update instead */
CPRINTS("Attention: 0x%x", payload[1]);
- anx7447_tcpc_update_hpd_status(mux, mux_state);
+ anx7447_tcpc_update_hpd_status(mux, mux_state, &unused);
#endif
dp_status[port] = payload[1];
diff --git a/board/pico/board.c b/board/pico/board.c
index fbb21be654..eaecf77f31 100644
--- a/board/pico/board.c
+++ b/board/pico/board.c
@@ -260,8 +260,12 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
};
static void board_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/*
* svdm_dp_attention() did most of the work, we only need to notify
* host here.
diff --git a/board/reef_it8320/board.c b/board/reef_it8320/board.c
index d965b53593..db5bf728fd 100644
--- a/board/reef_it8320/board.c
+++ b/board/reef_it8320/board.c
@@ -121,7 +121,8 @@ 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(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
int hpd_lvl = (mux_state & USB_PD_MUX_HPD_LVL) ? 1 : 0;
int hpd_irq = (mux_state & USB_PD_MUX_HPD_IRQ) ? 1 : 0;
@@ -129,6 +130,9 @@ static void it83xx_tcpc_update_hpd_status(const struct usb_mux *me,
me->usb_port ? GPIO_USB_C1_HPD_1P8_ODL
: GPIO_USB_C0_HPD_1P8_ODL;
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
hpd_lvl = !hpd_lvl;
gpio_set_level(gpio, hpd_lvl);
diff --git a/board/stern/board.c b/board/stern/board.c
index d6006eecc0..53690e8c94 100644
--- a/board/stern/board.c
+++ b/board/stern/board.c
@@ -158,8 +158,12 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
};
static void board_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/*
* svdm_dp_attention() did most of the work, we only need to notify
* host here.
diff --git a/board/willow/board.c b/board/willow/board.c
index c5de7d2d95..463550ddb2 100644
--- a/board/willow/board.c
+++ b/board/willow/board.c
@@ -155,8 +155,12 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
};
static void board_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/*
* svdm_dp_attention() did most of the work, we only need to notify
* host here.
diff --git a/driver/retimer/bb_retimer.c b/driver/retimer/bb_retimer.c
index bf3da60b32..627f61b3e6 100644
--- a/driver/retimer/bb_retimer.c
+++ b/driver/retimer/bb_retimer.c
@@ -472,10 +472,14 @@ static int retimer_set_state(const struct usb_mux *me, mux_state_t mux_state,
set_retimer_con);
}
-void bb_retimer_hpd_update(const struct usb_mux *me, mux_state_t mux_state)
+void bb_retimer_hpd_update(const struct usb_mux *me, mux_state_t mux_state,
+ bool *ack_required)
{
uint32_t retimer_con_reg = 0;
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
if (bb_retimer_read(me, BB_RETIMER_REG_CONNECTION_STATE,
&retimer_con_reg) != EC_SUCCESS)
return;
diff --git a/driver/tcpm/anx7447.c b/driver/tcpm/anx7447.c
index dde7b7e306..9ef281bc99 100644
--- a/driver/tcpm/anx7447.c
+++ b/driver/tcpm/anx7447.c
@@ -455,13 +455,17 @@ static void anx7447_tcpc_alert(int port)
static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT];
void anx7447_tcpc_update_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
int reg = 0;
int port = me->usb_port;
int hpd_lvl = (mux_state & USB_PD_MUX_HPD_LVL) ? 1 : 0;
int hpd_irq = (mux_state & USB_PD_MUX_HPD_IRQ) ? 1 : 0;
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/*
* All calls within this method need to update to a mux_read/write calls
* that use the secondary address. This is a non-trival change and no
diff --git a/driver/tcpm/anx7447.h b/driver/tcpm/anx7447.h
index 75982e6b91..3b27a19e2d 100644
--- a/driver/tcpm/anx7447.h
+++ b/driver/tcpm/anx7447.h
@@ -143,7 +143,8 @@ extern const struct tcpm_drv anx7447_tcpm_drv;
extern const struct usb_mux_driver anx7447_usb_mux_driver;
void anx7447_tcpc_clear_hpd_status(int port);
void anx7447_tcpc_update_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state);
+ mux_state_t mux_state,
+ bool *ack_required);
/**
* Erase OCM flash if it's not empty
diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c
index 567005920e..1fc813c448 100644
--- a/driver/tcpm/anx74xx.c
+++ b/driver/tcpm/anx74xx.c
@@ -233,13 +233,17 @@ static void anx74xx_tcpc_discharge_vbus(int port, int enable)
static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT];
void anx74xx_tcpc_update_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
int reg;
int port = me->usb_port;
int hpd_lvl = (mux_state & USB_PD_MUX_HPD_LVL) ? 1 : 0;
int hpd_irq = (mux_state & USB_PD_MUX_HPD_IRQ) ? 1 : 0;
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
mux_read(me, ANX74XX_REG_HPD_CTRL_0, &reg);
if (hpd_lvl)
reg |= ANX74XX_REG_HPD_OUT_DATA;
diff --git a/driver/tcpm/anx74xx.h b/driver/tcpm/anx74xx.h
index 8d700d4d86..19ac3e304f 100644
--- a/driver/tcpm/anx74xx.h
+++ b/driver/tcpm/anx74xx.h
@@ -220,7 +220,8 @@ extern const struct usb_mux_driver anx74xx_tcpm_usb_mux_driver;
void anx74xx_tcpc_set_vbus(int port, int enable);
void anx74xx_tcpc_clear_hpd_status(int port);
void anx74xx_tcpc_update_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state);
+ mux_state_t mux_state,
+ bool *ack_required);
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
extern struct i2c_stress_test_dev anx74xx_i2c_stress_test_dev;
diff --git a/driver/tcpm/ps8xxx.c b/driver/tcpm/ps8xxx.c
index e84aee8077..572616efb4 100644
--- a/driver/tcpm/ps8xxx.c
+++ b/driver/tcpm/ps8xxx.c
@@ -383,12 +383,16 @@ bool check_ps8755_chip(int port)
}
void ps8xxx_tcpc_update_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
int port = me->usb_port;
int hpd_lvl = (mux_state & USB_PD_MUX_HPD_LVL) ? 1 : 0;
int hpd_irq = (mux_state & USB_PD_MUX_HPD_IRQ) ? 1 : 0;
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
if (IS_ENABLED(CONFIG_USB_PD_TCPM_PS8751_CUSTOM_MUX_DRIVER) &&
product_id[me->usb_port] == PS8751_PRODUCT_ID &&
me->flags & USB_MUX_FLAG_NOT_TCPC)
diff --git a/driver/usb_mux/tusb1064.c b/driver/usb_mux/tusb1064.c
index 6a82aca68f..d0e8678039 100644
--- a/driver/usb_mux/tusb1064.c
+++ b/driver/usb_mux/tusb1064.c
@@ -30,11 +30,15 @@ static int tusb1064_write(const struct usb_mux *me, uint8_t reg, uint8_t val)
}
#if defined(CONFIG_USB_MUX_TUSB1044)
-void tusb1044_hpd_update(const struct usb_mux *me, mux_state_t mux_state)
+void tusb1044_hpd_update(const struct usb_mux *me, mux_state_t mux_state,
+ bool *ack_required)
{
int res;
uint8_t reg;
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
res = tusb1064_read(me, TUSB1064_REG_GENERAL, &reg);
if (res)
return;
diff --git a/driver/usb_mux/tusb1064.h b/driver/usb_mux/tusb1064.h
index a71d6defa3..5ab8b60e16 100644
--- a/driver/usb_mux/tusb1064.h
+++ b/driver/usb_mux/tusb1064.h
@@ -137,7 +137,8 @@
* or when no HPD physical pin is connected.
* Writes HPD infomration to the General_1 Registor.
*/
-void tusb1044_hpd_update(const struct usb_mux *me, mux_state_t mux_state);
+void tusb1044_hpd_update(const struct usb_mux *me, mux_state_t mux_state,
+ bool *ack_required);
#endif
/**
diff --git a/driver/usb_mux/usb_mux.c b/driver/usb_mux/usb_mux.c
index 319f802ff5..c53a21ce65 100644
--- a/driver/usb_mux/usb_mux.c
+++ b/driver/usb_mux/usb_mux.c
@@ -317,9 +317,6 @@ static int configure_mux(int port,
break;
}
- if (ack_required)
- ack_task[port] = task_get_current();
-
/* Apply board specific setting */
if (mux_ptr->board_set)
rv = mux_ptr->board_set(mux_ptr, lcl_state);
@@ -343,7 +340,8 @@ static int configure_mux(int port,
case USB_MUX_HPD_UPDATE:
if (mux_ptr->hpd_update)
- mux_ptr->hpd_update(mux_ptr, *mux_state);
+ mux_ptr->hpd_update(mux_ptr, *mux_state,
+ &ack_required);
}
@@ -351,6 +349,8 @@ static int configure_mux(int port,
mutex_unlock(&mux_lock[port]);
if (ack_required) {
+ ack_task[port] = task_get_current();
+
/*
* This should only be called from the PD task or usb
* mux task
diff --git a/driver/usb_mux/virtual.c b/driver/usb_mux/virtual.c
index 0ca6c2a8d9..23987fd676 100644
--- a/driver/usb_mux/virtual.c
+++ b/driver/usb_mux/virtual.c
@@ -106,17 +106,16 @@ static int virtual_get_mux(const struct usb_mux *me, mux_state_t *mux_state)
return EC_SUCCESS;
}
-void virtual_hpd_update(const struct usb_mux *me, mux_state_t mux_state)
+void virtual_hpd_update(const struct usb_mux *me, mux_state_t mux_state,
+ bool *ack_required)
{
int port = me->usb_port;
- bool unused;
/* Current HPD related mux status + existing USB & DP mux status */
mux_state_t new_mux_state = mux_state |
(virtual_mux_state[port] & USB_PD_MUX_USB_DP_STATE);
- /* HPD ACK isn't required for the EC to continue with its tasks */
- virtual_mux_update_state(port, new_mux_state, &unused);
+ virtual_mux_update_state(port, new_mux_state, ack_required);
}
const struct usb_mux_driver virtual_usb_mux_driver = {
diff --git a/include/driver/retimer/bb_retimer_public.h b/include/driver/retimer/bb_retimer_public.h
index f1a924f67e..d79b051504 100644
--- a/include/driver/retimer/bb_retimer_public.h
+++ b/include/driver/retimer/bb_retimer_public.h
@@ -48,9 +48,12 @@ __override_proto int bb_retimer_power_enable(const struct usb_mux *me,
*
* Set the HPD related fields in the BB retimer
*
- * @param me Pointer to USB mux
- * @param mux_state USB mux state containing HPD level and IRQ
+ * @param[in] me Pointer to USB mux
+ * @param[in] mux_state USB mux state containing HPD level and IRQ
+ * @param[out] ack_required Outputs whether the given change will require
+ * the AP to ACK before proceeding
*/
-void bb_retimer_hpd_update(const struct usb_mux *me, mux_state_t mux_state);
+void bb_retimer_hpd_update(const struct usb_mux *me, mux_state_t mux_state,
+ bool *ack_required);
#endif /* __CROS_EC_DRIVER_RETIMER_BB_RETIMER_PUBLIC_H */
diff --git a/include/driver/tcpm/ps8xxx_public.h b/include/driver/tcpm/ps8xxx_public.h
index 0e200cb395..b186eacec7 100644
--- a/include/driver/tcpm/ps8xxx_public.h
+++ b/include/driver/tcpm/ps8xxx_public.h
@@ -79,7 +79,8 @@ __override_proto
uint16_t board_get_ps8xxx_product_id(int port);
void ps8xxx_tcpc_update_hpd_status(const struct usb_mux *me,
- mux_state_t mux_state);
+ mux_state_t mux_state,
+ bool *ack_required);
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
extern struct i2c_stress_test_dev ps8xxx_i2c_stress_test_dev;
diff --git a/include/usb_mux.h b/include/usb_mux.h
index 41e5881a81..e251d74f4c 100644
--- a/include/usb_mux.h
+++ b/include/usb_mux.h
@@ -139,12 +139,15 @@ struct usb_mux {
* USB Type-C DP alt mode support. Notify Type-C controller
* there is DP dongle hot-plug.
*
- * @param me usb_mux
- * @param mux_state with HPD IRQ and HPD LVL flags set
- * accordingly
+ * @param[in] me usb_mux
+ * @param[in] mux_state with HPD IRQ and HPD LVL flags set
+ * accordingly
+ * @param[out] ack_required: indication of whether this function
+ * requires a wait for an AP ACK after
*/
void (*hpd_update)(const struct usb_mux *me,
- mux_state_t mux_state);
+ mux_state_t mux_state,
+ bool *ack_required);
};
/* Supported USB mux drivers */
@@ -168,7 +171,8 @@ extern const struct usb_mux usb_muxes[];
#endif
/* Supported hpd_update functions */
-void virtual_hpd_update(const struct usb_mux *me, mux_state_t mux_state);
+void virtual_hpd_update(const struct usb_mux *me, mux_state_t mux_state,
+ bool *ack_required);
/*
* Helper methods that either use tcpc communication or direct i2c
diff --git a/zephyr/test/drivers/src/usb_mux.c b/zephyr/test/drivers/src/usb_mux.c
index 42e65b0779..ff5d934d50 100644
--- a/zephyr/test/drivers/src/usb_mux.c
+++ b/zephyr/test/drivers/src/usb_mux.c
@@ -152,7 +152,8 @@ static bool proxy_fw_update_cap(void)
}
/** Proxy function which check calls from usb_mux framework to driver */
-static void proxy_hpd_update(const struct usb_mux *me, mux_state_t mux_state)
+static void proxy_hpd_update(const struct usb_mux *me, mux_state_t mux_state,
+ bool *ack_required)
{
int i = me->i2c_addr_flags;
@@ -163,7 +164,7 @@ static void proxy_hpd_update(const struct usb_mux *me, mux_state_t mux_state)
if (org_mux[i] != NULL &&
org_mux[i]->hpd_update != NULL) {
- org_mux[i]->hpd_update(org_mux[i], mux_state);
+ org_mux[i]->hpd_update(org_mux[i], mux_state, ack_required);
}
}