summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-08-14 22:58:16 -0600
committerCommit Bot <commit-bot@chromium.org>2021-09-16 17:14:04 +0000
commitabc6c7ad71d85532db725198cecab0aa282e7b50 (patch)
tree49b217857e2079e69a4a7f472eddb95a83adff19
parent414feb169e244b2037e6a92a45500cc73faeea08 (diff)
downloadchrome-ec-abc6c7ad71d85532db725198cecab0aa282e7b50.tar.gz
USB MUX: Update mux HPD update interface to use mux_state_t
Since the drivers are now taking a mux_state_t set of flags to update, go ahead and unify the usb_mux API this way as well. It makes the parameters more apparent than the 1/0 inputs, and aligns the stack to use the same parameters. BRANCH=None BUG=b:172222942 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ie943dbdf03818d8497c0e328adf2b9794585d96e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3095438 Commit-Queue: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--baseboard/asurada/usb_pd_policy.c8
-rw-r--r--baseboard/cherry/usb_pd_policy.c8
-rw-r--r--baseboard/goroh/usb_pd_policy.c8
-rw-r--r--baseboard/grunt/baseboard.c3
-rw-r--r--baseboard/grunt/usb_pd_policy.c3
-rw-r--r--baseboard/herobrine/usb_pd_policy.c8
-rw-r--r--baseboard/kalista/baseboard.c3
-rw-r--r--baseboard/kukui/usb_pd_policy.c11
-rw-r--r--baseboard/octopus/baseboard.c3
-rw-r--r--baseboard/trogdor/usb_pd_policy.c8
-rw-r--r--board/atlas/board.c3
-rw-r--r--board/boldar/board.c3
-rw-r--r--board/chronicler/usbc_config.c3
-rw-r--r--board/coachz/board.c3
-rw-r--r--board/collis/board.c7
-rw-r--r--board/coral/board.c3
-rw-r--r--board/delbin/board.c6
-rw-r--r--board/eldrid/board.c3
-rw-r--r--board/elemi/board.c3
-rw-r--r--board/eve/board.c3
-rw-r--r--board/fizz/board.c3
-rw-r--r--board/gimble/usbc_config.c3
-rw-r--r--board/herobrine_npcx7/usbc_config.c3
-rw-r--r--board/herobrine_npcx9/usbc_config.c3
-rw-r--r--board/homestar/board.c4
-rw-r--r--board/kingoftown/usbc_config.c3
-rw-r--r--board/lazor/usbc_config.c3
-rw-r--r--board/lindar/board.c3
-rw-r--r--board/marzipan/board.c4
-rw-r--r--board/mrbland/board.c4
-rw-r--r--board/nami/board.c3
-rw-r--r--board/nautilus/board.c3
-rw-r--r--board/pazquel/board.c3
-rw-r--r--board/pompom/board.c3
-rw-r--r--board/poppy/board.c3
-rw-r--r--board/rammus/board.c3
-rw-r--r--board/reef/board.c3
-rw-r--r--board/reef_it8320/board.c3
-rw-r--r--board/reef_mchp/board.c3
-rw-r--r--board/trogdor/usbc_config.c3
-rw-r--r--board/voema/board.c3
-rw-r--r--board/volet/board.c3
-rw-r--r--board/volteer/usbc_config.c3
-rw-r--r--board/wormdingler/board.c4
-rw-r--r--common/usb_pd_alt_mode_dfp.c11
-rw-r--r--driver/usb_mux/usb_mux.c16
-rw-r--r--include/usb_mux.h5
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/src/usb_pd_policy.c8
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/src/usbc_config.c3
49 files changed, 143 insertions, 76 deletions
diff --git a/baseboard/asurada/usb_pd_policy.c b/baseboard/asurada/usb_pd_policy.c
index 019e4871a2..f9ba7e5a4d 100644
--- a/baseboard/asurada/usb_pd_policy.c
+++ b/baseboard/asurada/usb_pd_policy.c
@@ -64,6 +64,7 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
#ifdef CONFIG_USB_PD_DP_HPD_GPIO
int cur_lvl = svdm_get_hpd_gpio(port);
#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
+ mux_state_t mux_state;
dp_status[port] = payload[1];
@@ -125,7 +126,9 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
svdm_hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL;
#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
- usb_mux_hpd_update(port, lvl, irq);
+ mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) |
+ (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ usb_mux_hpd_update(port, mux_state);
#ifdef USB_PD_PORT_TCPC_MST
if (port == USB_PD_PORT_TCPC_MST)
@@ -141,7 +144,8 @@ __override void svdm_exit_dp_mode(int port)
#ifdef CONFIG_USB_PD_DP_HPD_GPIO
svdm_set_hpd_gpio(port, 0);
#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
#ifdef USB_PD_PORT_TCPC_MST
if (port == USB_PD_PORT_TCPC_MST)
diff --git a/baseboard/cherry/usb_pd_policy.c b/baseboard/cherry/usb_pd_policy.c
index 5ef026b95a..a520228ef6 100644
--- a/baseboard/cherry/usb_pd_policy.c
+++ b/baseboard/cherry/usb_pd_policy.c
@@ -73,6 +73,7 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
#ifdef CONFIG_USB_PD_DP_HPD_GPIO
int cur_lvl = svdm_get_hpd_gpio(port);
#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
+ mux_state_t mux_state;
dp_status[port] = payload[1];
@@ -142,7 +143,9 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
svdm_hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL;
#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
- usb_mux_hpd_update(port, lvl, irq);
+ mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) |
+ (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ usb_mux_hpd_update(port, mux_state);
#ifdef USB_PD_PORT_TCPC_MST
if (port == USB_PD_PORT_TCPC_MST)
@@ -158,7 +161,8 @@ __override void svdm_exit_dp_mode(int port)
#ifdef CONFIG_USB_PD_DP_HPD_GPIO
svdm_set_hpd_gpio(port, 0);
#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
aux_display_disconnected(port);
diff --git a/baseboard/goroh/usb_pd_policy.c b/baseboard/goroh/usb_pd_policy.c
index 2643d198ad..72213d311c 100644
--- a/baseboard/goroh/usb_pd_policy.c
+++ b/baseboard/goroh/usb_pd_policy.c
@@ -61,6 +61,7 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
#ifdef CONFIG_USB_PD_DP_HPD_GPIO
int cur_lvl = svdm_get_hpd_gpio(port);
#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
+ mux_state_t mux_state;
dp_status[port] = payload[1];
@@ -122,7 +123,9 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
svdm_hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL;
#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
- usb_mux_hpd_update(port, lvl, irq);
+ mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) |
+ (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ usb_mux_hpd_update(port, mux_state);
#ifdef USB_PD_PORT_TCPC_MST
if (port == USB_PD_PORT_TCPC_MST)
@@ -138,7 +141,8 @@ __override void svdm_exit_dp_mode(int port)
#ifdef CONFIG_USB_PD_DP_HPD_GPIO
svdm_set_hpd_gpio(port, 0);
#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
#ifdef USB_PD_PORT_TCPC_MST
if (port == USB_PD_PORT_TCPC_MST)
diff --git a/baseboard/grunt/baseboard.c b/baseboard/grunt/baseboard.c
index 7fc756ec47..cf49fc0566 100644
--- a/baseboard/grunt/baseboard.c
+++ b/baseboard/grunt/baseboard.c
@@ -155,7 +155,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1);
diff --git a/baseboard/grunt/usb_pd_policy.c b/baseboard/grunt/usb_pd_policy.c
index 6d78680bf5..7c4fff953c 100644
--- a/baseboard/grunt/usb_pd_policy.c
+++ b/baseboard/grunt/usb_pd_policy.c
@@ -142,7 +142,8 @@ __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;
- usb_mux_hpd_update(port, 1, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
#endif /* CONFIG_USB_PD_ALT_MODE_DFP */
diff --git a/baseboard/herobrine/usb_pd_policy.c b/baseboard/herobrine/usb_pd_policy.c
index c17ca0c565..7ca2688aef 100644
--- a/baseboard/herobrine/usb_pd_policy.c
+++ b/baseboard/herobrine/usb_pd_policy.c
@@ -147,6 +147,7 @@ __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 cur_lvl = gpio_get_level(hpd);
+ mux_state_t mux_state;
dp_status[port] = payload[1];
@@ -213,7 +214,9 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
pd_notify_dp_alt_mode_entry(port);
/* Configure TCPC for the HPD event, for proper muxing */
- usb_mux_hpd_update(port, lvl, irq);
+ mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) |
+ (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ usb_mux_hpd_update(port, mux_state);
/* Signal AP for the HPD event, through GPIO to AP */
if (irq & cur_lvl) {
@@ -251,7 +254,8 @@ __override void svdm_exit_dp_mode(int port)
gpio_set_level(GPIO_DP_MUX_SEL, 0);
/* Signal AP for the HPD low event */
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
gpio_set_level(GPIO_DP_HOT_PLUG_DET, 0);
}
}
diff --git a/baseboard/kalista/baseboard.c b/baseboard/kalista/baseboard.c
index a443f1919a..f6a6b23110 100644
--- a/baseboard/kalista/baseboard.c
+++ b/baseboard/kalista/baseboard.c
@@ -203,7 +203,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/baseboard/kukui/usb_pd_policy.c b/baseboard/kukui/usb_pd_policy.c
index 92c09525c9..28ef005ee8 100644
--- a/baseboard/kukui/usb_pd_policy.c
+++ b/baseboard/kukui/usb_pd_policy.c
@@ -227,7 +227,8 @@ __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;
- usb_mux_hpd_update(port, 1, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
__override int svdm_dp_attention(int port, uint32_t *payload)
@@ -235,6 +236,7 @@ __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]);
+ mux_state_t mux_state;
dp_status[port] = payload[1];
@@ -245,7 +247,9 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
return 1;
}
- usb_mux_hpd_update(port, lvl, irq);
+ mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) |
+ (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ usb_mux_hpd_update(port, mux_state);
if (irq & cur_lvl) {
uint64_t now = get_time().val;
@@ -288,6 +292,7 @@ __override void svdm_exit_dp_mode(int port)
#ifdef VARIANT_KUKUI_DP_MUX_GPIO
board_set_dp_mux_control(0, 0);
#endif
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
#endif /* CONFIG_USB_PD_ALT_MODE_DFP */
diff --git a/baseboard/octopus/baseboard.c b/baseboard/octopus/baseboard.c
index 89da53e6dc..4f338ab131 100644
--- a/baseboard/octopus/baseboard.c
+++ b/baseboard/octopus/baseboard.c
@@ -237,7 +237,8 @@ void baseboard_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < board_get_usb_pd_port_count(); ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
/* Called after the cbi_init (via +2) */
DECLARE_HOOK(HOOK_INIT, baseboard_tcpc_init, HOOK_PRIO_INIT_I2C + 2);
diff --git a/baseboard/trogdor/usb_pd_policy.c b/baseboard/trogdor/usb_pd_policy.c
index 79726cc5e6..d7ed03e941 100644
--- a/baseboard/trogdor/usb_pd_policy.c
+++ b/baseboard/trogdor/usb_pd_policy.c
@@ -147,6 +147,7 @@ __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 cur_lvl = gpio_get_level(hpd);
+ mux_state_t mux_state;
dp_status[port] = payload[1];
@@ -213,7 +214,9 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
pd_notify_dp_alt_mode_entry(port);
/* Configure TCPC for the HPD event, for proper muxing */
- usb_mux_hpd_update(port, lvl, irq);
+ mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) |
+ (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ usb_mux_hpd_update(port, mux_state);
/* Signal AP for the HPD event, through GPIO to AP */
if (irq & cur_lvl) {
@@ -251,7 +254,8 @@ __override void svdm_exit_dp_mode(int port)
gpio_set_level(GPIO_DP_MUX_SEL, 0);
/* Signal AP for the HPD low event */
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
gpio_set_level(GPIO_DP_HOT_PLUG_DET, 0);
}
}
diff --git a/board/atlas/board.c b/board/atlas/board.c
index 8d89bee074..4881ed6898 100644
--- a/board/atlas/board.c
+++ b/board/atlas/board.c
@@ -221,7 +221,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/boldar/board.c b/board/boldar/board.c
index abc3fecfe0..128b27b385 100644
--- a/board/boldar/board.c
+++ b/board/boldar/board.c
@@ -336,7 +336,8 @@ void board_reset_pd_mcu(void)
/* Daughterboard specific reset for port 1 */
if (usb_db == DB_USB3_ACTIVE) {
ps8815_reset();
- usb_mux_hpd_update(USBC_PORT_C1, 0, 0);
+ usb_mux_hpd_update(USBC_PORT_C1, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
}
diff --git a/board/chronicler/usbc_config.c b/board/chronicler/usbc_config.c
index 449179af32..b378299f86 100644
--- a/board/chronicler/usbc_config.c
+++ b/board/chronicler/usbc_config.c
@@ -206,7 +206,8 @@ void board_reset_pd_mcu(void)
/* No reset available for TCPC on port 0 */
/* Daughterboard specific reset for port 1 */
ps8815_reset();
- usb_mux_hpd_update(USBC_PORT_C1, 0, 0);
+ usb_mux_hpd_update(USBC_PORT_C1, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
static void board_tcpc_init(void)
diff --git a/board/coachz/board.c b/board/coachz/board.c
index 377ce00939..d1f31a64c3 100644
--- a/board/coachz/board.c
+++ b/board/coachz/board.c
@@ -522,7 +522,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/collis/board.c b/board/collis/board.c
index 76cffc4d22..42a0f1469a 100644
--- a/board/collis/board.c
+++ b/board/collis/board.c
@@ -430,8 +430,9 @@ static void ps8815_reset(int port)
void board_reset_pd_mcu(void)
{
ps8815_reset(USBC_PORT_C0);
- usb_mux_hpd_update(USBC_PORT_C0, 0, 0);
+ usb_mux_hpd_update(USBC_PORT_C0, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
ps8815_reset(USBC_PORT_C1);
- usb_mux_hpd_update(USBC_PORT_C1, 0, 0);
+ usb_mux_hpd_update(USBC_PORT_C1, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
-
diff --git a/board/coral/board.c b/board/coral/board.c
index 57866f30da..a563071294 100644
--- a/board/coral/board.c
+++ b/board/coral/board.c
@@ -399,7 +399,8 @@ static void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_DEFAULT);
diff --git a/board/delbin/board.c b/board/delbin/board.c
index b1d7754992..5984c4d157 100644
--- a/board/delbin/board.c
+++ b/board/delbin/board.c
@@ -283,9 +283,11 @@ static void ps8815_reset(int port)
void board_reset_pd_mcu(void)
{
ps8815_reset(USBC_PORT_C0);
- usb_mux_hpd_update(USBC_PORT_C0, 0, 0);
+ usb_mux_hpd_update(USBC_PORT_C0, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
ps8815_reset(USBC_PORT_C1);
- usb_mux_hpd_update(USBC_PORT_C1, 0, 0);
+ usb_mux_hpd_update(USBC_PORT_C1, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
/******************************************************************************/
diff --git a/board/eldrid/board.c b/board/eldrid/board.c
index 90d663e6f7..601c23df84 100644
--- a/board/eldrid/board.c
+++ b/board/eldrid/board.c
@@ -393,7 +393,8 @@ void board_reset_pd_mcu(void)
/* Daughterboard specific reset for port 1 */
if (usb_db == DB_USB3_ACTIVE) {
ps8815_reset();
- usb_mux_hpd_update(USBC_PORT_C1, 0, 0);
+ usb_mux_hpd_update(USBC_PORT_C1, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
}
diff --git a/board/elemi/board.c b/board/elemi/board.c
index 5eab31d871..bb59308213 100644
--- a/board/elemi/board.c
+++ b/board/elemi/board.c
@@ -290,7 +290,8 @@ void board_reset_pd_mcu(void)
/* No reset available for TCPC on port 0 */
/* Daughterboard specific reset for port 1 */
ps8815_reset();
- usb_mux_hpd_update(USBC_PORT_C1, 0, 0);
+ usb_mux_hpd_update(USBC_PORT_C1, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
__override void board_cbi_init(void)
diff --git a/board/eve/board.c b/board/eve/board.c
index cedcd6c5e4..f73118e8f2 100644
--- a/board/eve/board.c
+++ b/board/eve/board.c
@@ -330,7 +330,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
uint16_t tcpc_get_alert_status(void)
diff --git a/board/fizz/board.c b/board/fizz/board.c
index 0605b68e09..5b830b9150 100644
--- a/board/fizz/board.c
+++ b/board/fizz/board.c
@@ -239,7 +239,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/gimble/usbc_config.c b/board/gimble/usbc_config.c
index 83042ab91e..9f9f702364 100644
--- a/board/gimble/usbc_config.c
+++ b/board/gimble/usbc_config.c
@@ -182,7 +182,8 @@ void board_reset_pd_mcu(void)
/* Port1 */
ps8815_reset();
- usb_mux_hpd_update(USBC_PORT_C1, 0, 0);
+ usb_mux_hpd_update(USBC_PORT_C1, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
static void board_tcpc_init(void)
diff --git a/board/herobrine_npcx7/usbc_config.c b/board/herobrine_npcx7/usbc_config.c
index c78fe80191..3662b966e0 100644
--- a/board/herobrine_npcx7/usbc_config.c
+++ b/board/herobrine_npcx7/usbc_config.c
@@ -185,7 +185,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1);
diff --git a/board/herobrine_npcx9/usbc_config.c b/board/herobrine_npcx9/usbc_config.c
index c78fe80191..3662b966e0 100644
--- a/board/herobrine_npcx9/usbc_config.c
+++ b/board/herobrine_npcx9/usbc_config.c
@@ -185,7 +185,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1);
diff --git a/board/homestar/board.c b/board/homestar/board.c
index 8292a697ce..22f940eec2 100644
--- a/board/homestar/board.c
+++ b/board/homestar/board.c
@@ -477,7 +477,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
@@ -695,4 +696,3 @@ int battery_set_vendor_param(uint32_t param, uint32_t value)
{
return EC_ERROR_UNIMPLEMENTED;
}
-
diff --git a/board/kingoftown/usbc_config.c b/board/kingoftown/usbc_config.c
index f3ca3b0f2a..dddc1d87a6 100644
--- a/board/kingoftown/usbc_config.c
+++ b/board/kingoftown/usbc_config.c
@@ -185,7 +185,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1);
diff --git a/board/lazor/usbc_config.c b/board/lazor/usbc_config.c
index 475162b4c3..f8c9662136 100644
--- a/board/lazor/usbc_config.c
+++ b/board/lazor/usbc_config.c
@@ -222,7 +222,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1);
diff --git a/board/lindar/board.c b/board/lindar/board.c
index c9576f0e9b..030940cfb1 100644
--- a/board/lindar/board.c
+++ b/board/lindar/board.c
@@ -447,7 +447,8 @@ static void ps8815_reset(void)
void board_reset_pd_mcu(void)
{
ps8815_reset();
- usb_mux_hpd_update(USBC_PORT_C1, 0, 0);
+ usb_mux_hpd_update(USBC_PORT_C1, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
/******************************************************************************/
diff --git a/board/marzipan/board.c b/board/marzipan/board.c
index 26b2c286c4..915f96743d 100644
--- a/board/marzipan/board.c
+++ b/board/marzipan/board.c
@@ -513,7 +513,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
@@ -665,4 +666,3 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-
diff --git a/board/mrbland/board.c b/board/mrbland/board.c
index b837c44861..fc48888a55 100644
--- a/board/mrbland/board.c
+++ b/board/mrbland/board.c
@@ -434,7 +434,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
@@ -647,4 +648,3 @@ int battery_set_vendor_param(uint32_t param, uint32_t value)
{
return EC_ERROR_UNIMPLEMENTED;
}
-
diff --git a/board/nami/board.c b/board/nami/board.c
index 016537e13f..c45d11bd25 100644
--- a/board/nami/board.c
+++ b/board/nami/board.c
@@ -329,7 +329,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 2);
diff --git a/board/nautilus/board.c b/board/nautilus/board.c
index 743beb40b0..bcdaf568e7 100644
--- a/board/nautilus/board.c
+++ b/board/nautilus/board.c
@@ -229,7 +229,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/pazquel/board.c b/board/pazquel/board.c
index 190432bdfd..8d7e679190 100644
--- a/board/pazquel/board.c
+++ b/board/pazquel/board.c
@@ -327,7 +327,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/pompom/board.c b/board/pompom/board.c
index 8978b75981..855a8c305d 100644
--- a/board/pompom/board.c
+++ b/board/pompom/board.c
@@ -330,7 +330,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/poppy/board.c b/board/poppy/board.c
index 838c0d1724..2124faa421 100644
--- a/board/poppy/board.c
+++ b/board/poppy/board.c
@@ -318,7 +318,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/rammus/board.c b/board/rammus/board.c
index e1d3f76268..1f88cf4388 100644
--- a/board/rammus/board.c
+++ b/board/rammus/board.c
@@ -260,7 +260,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
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 8bb7291449..ed8e83d0a8 100644
--- a/board/reef/board.c
+++ b/board/reef/board.c
@@ -393,7 +393,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
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 96fad41763..92fdc66806 100644
--- a/board/reef_it8320/board.c
+++ b/board/reef_it8320/board.c
@@ -224,7 +224,8 @@ static void board_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
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 98d9b4fca4..b934264510 100644
--- a/board/reef_mchp/board.c
+++ b/board/reef_mchp/board.c
@@ -509,7 +509,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/trogdor/usbc_config.c b/board/trogdor/usbc_config.c
index f3ca3b0f2a..dddc1d87a6 100644
--- a/board/trogdor/usbc_config.c
+++ b/board/trogdor/usbc_config.c
@@ -185,7 +185,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1);
diff --git a/board/voema/board.c b/board/voema/board.c
index 91dd9f144a..ef428089a4 100644
--- a/board/voema/board.c
+++ b/board/voema/board.c
@@ -261,7 +261,8 @@ void board_reset_pd_mcu(void)
/* No reset available for TCPC on port 0 */
/* Daughterboard specific reset for port 1 */
ps8815_reset();
- usb_mux_hpd_update(USBC_PORT_C1, 0, 0);
+ usb_mux_hpd_update(USBC_PORT_C1, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
__override void board_cbi_init(void)
diff --git a/board/volet/board.c b/board/volet/board.c
index 603536fd68..a47bd3d8c6 100644
--- a/board/volet/board.c
+++ b/board/volet/board.c
@@ -326,7 +326,8 @@ void board_reset_pd_mcu(void)
* already handled by the bb_retimer.c driver.
*/
ps8815_reset();
- usb_mux_hpd_update(USBC_PORT_C1, 0, 0);
+ usb_mux_hpd_update(USBC_PORT_C1, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
/******************************************************************************/
diff --git a/board/volteer/usbc_config.c b/board/volteer/usbc_config.c
index 1fec96a2a3..4f025d4cd2 100644
--- a/board/volteer/usbc_config.c
+++ b/board/volteer/usbc_config.c
@@ -320,7 +320,8 @@ void board_reset_pd_mcu(void)
/* Daughterboard specific reset for port 1 */
if (usb_db == DB_USB3_ACTIVE) {
ps8815_reset();
- usb_mux_hpd_update(USBC_PORT_C1, 0, 0);
+ usb_mux_hpd_update(USBC_PORT_C1, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
}
diff --git a/board/wormdingler/board.c b/board/wormdingler/board.c
index 2acc1518aa..796409cb80 100644
--- a/board/wormdingler/board.c
+++ b/board/wormdingler/board.c
@@ -472,7 +472,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1);
@@ -689,4 +690,3 @@ int battery_set_vendor_param(uint32_t param, uint32_t value)
{
return EC_ERROR_UNIMPLEMENTED;
}
-
diff --git a/common/usb_pd_alt_mode_dfp.c b/common/usb_pd_alt_mode_dfp.c
index d04c9e18b2..49fbf4cc65 100644
--- a/common/usb_pd_alt_mode_dfp.c
+++ b/common/usb_pd_alt_mode_dfp.c
@@ -1325,7 +1325,8 @@ __overridable void svdm_dp_post_config(int port)
svdm_hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL;
#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
- usb_mux_hpd_update(port, 1, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
#ifdef USB_PD_PORT_TCPC_MST
if (port == USB_PD_PORT_TCPC_MST)
@@ -1340,6 +1341,7 @@ __overridable int svdm_dp_attention(int port, uint32_t *payload)
#ifdef CONFIG_USB_PD_DP_HPD_GPIO
int cur_lvl = svdm_get_hpd_gpio(port);
#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
+ mux_state_t mux_state;
dp_status[port] = payload[1];
@@ -1387,7 +1389,9 @@ __overridable int svdm_dp_attention(int port, uint32_t *payload)
svdm_hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL;
#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
- usb_mux_hpd_update(port, lvl, irq);
+ mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) |
+ (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ usb_mux_hpd_update(port, mux_state);
#ifdef USB_PD_PORT_TCPC_MST
if (port == USB_PD_PORT_TCPC_MST)
@@ -1405,7 +1409,8 @@ __overridable void svdm_exit_dp_mode(int port)
#ifdef CONFIG_USB_PD_DP_HPD_GPIO
svdm_set_hpd_gpio(port, 0);
#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
#ifdef USB_PD_PORT_TCPC_MST
if (port == USB_PD_PORT_TCPC_MST)
baseboard_mst_enable_control(port, 0);
diff --git a/driver/usb_mux/usb_mux.c b/driver/usb_mux/usb_mux.c
index 56eb104b5d..a362412995 100644
--- a/driver/usb_mux/usb_mux.c
+++ b/driver/usb_mux/usb_mux.c
@@ -326,10 +326,9 @@ void usb_mux_flip(int port)
configure_mux(port, USB_MUX_SET_MODE, &mux_state);
}
-void usb_mux_hpd_update(int port, int hpd_lvl, int hpd_irq)
+void usb_mux_hpd_update(int port, mux_state_t hpd_state)
{
- mux_state_t mux_state = (hpd_lvl ? USB_PD_MUX_HPD_LVL : 0) |
- (hpd_irq ? USB_PD_MUX_HPD_IRQ : 0);
+ mux_state_t get_state;
if (port >= board_get_usb_pd_port_count()) {
return;
@@ -342,12 +341,11 @@ void usb_mux_hpd_update(int port, int hpd_lvl, int hpd_irq)
if (exit_low_power_mode(port) != EC_SUCCESS)
return;
- configure_mux(port, USB_MUX_HPD_UPDATE, &mux_state);
+ configure_mux(port, USB_MUX_HPD_UPDATE, &hpd_state);
- if (!configure_mux(port, USB_MUX_GET_MODE, &mux_state)) {
- mux_state |= (hpd_lvl ? USB_PD_MUX_HPD_LVL : 0) |
- (hpd_irq ? USB_PD_MUX_HPD_IRQ : 0);
- configure_mux(port, USB_MUX_SET_MODE, &mux_state);
+ if (!configure_mux(port, USB_MUX_GET_MODE, &get_state)) {
+ get_state |= hpd_state;
+ configure_mux(port, USB_MUX_SET_MODE, &get_state);
}
}
@@ -475,7 +473,7 @@ static enum ec_status hc_usb_pd_mux_info(struct host_cmd_handler_args *args)
/* Clear HPD IRQ event since we're about to inform host of it. */
if (IS_ENABLED(CONFIG_USB_MUX_VIRTUAL) &&
(r->flags & USB_PD_MUX_HPD_IRQ)) {
- usb_mux_hpd_update(port, r->flags & USB_PD_MUX_HPD_LVL, 0);
+ usb_mux_hpd_update(port, r->flags & USB_PD_MUX_HPD_LVL);
}
args->response_size = sizeof(*r);
diff --git a/include/usb_mux.h b/include/usb_mux.h
index c3f673b93a..9909f1c1c5 100644
--- a/include/usb_mux.h
+++ b/include/usb_mux.h
@@ -247,10 +247,9 @@ void usb_mux_flip(int port);
* Update the hot-plug event.
*
* @param port port number.
- * @param hpd_lvl HPD level.
- * @param hpd_irq HPD IRQ.
+ * @param mux_state HPD IRQ and LVL mux flags
*/
-void usb_mux_hpd_update(int port, int hpd_lvl, int hpd_irq);
+void usb_mux_hpd_update(int port, mux_state_t mux_state);
/**
* Port information about retimer firmware update support.
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/src/usb_pd_policy.c b/zephyr/projects/herobrine/herobrine_npcx9/src/usb_pd_policy.c
index c17ca0c565..7ca2688aef 100644
--- a/zephyr/projects/herobrine/herobrine_npcx9/src/usb_pd_policy.c
+++ b/zephyr/projects/herobrine/herobrine_npcx9/src/usb_pd_policy.c
@@ -147,6 +147,7 @@ __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 cur_lvl = gpio_get_level(hpd);
+ mux_state_t mux_state;
dp_status[port] = payload[1];
@@ -213,7 +214,9 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
pd_notify_dp_alt_mode_entry(port);
/* Configure TCPC for the HPD event, for proper muxing */
- usb_mux_hpd_update(port, lvl, irq);
+ mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) |
+ (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ usb_mux_hpd_update(port, mux_state);
/* Signal AP for the HPD event, through GPIO to AP */
if (irq & cur_lvl) {
@@ -251,7 +254,8 @@ __override void svdm_exit_dp_mode(int port)
gpio_set_level(GPIO_DP_MUX_SEL, 0);
/* Signal AP for the HPD low event */
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
gpio_set_level(GPIO_DP_HOT_PLUG_DET, 0);
}
}
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/src/usbc_config.c b/zephyr/projects/herobrine/herobrine_npcx9/src/usbc_config.c
index a3da4b5592..20646c28c2 100644
--- a/zephyr/projects/herobrine/herobrine_npcx9/src/usbc_config.c
+++ b/zephyr/projects/herobrine/herobrine_npcx9/src/usbc_config.c
@@ -231,7 +231,8 @@ void board_tcpc_init(void)
* HPD pulse to enable video path
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, 0, 0);
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1);