summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-08-04 13:28:44 -0600
committerCommit Bot <commit-bot@chromium.org>2021-08-30 18:16:18 +0000
commitd32885333e9bba9915d5388b08e888e06dfad511 (patch)
treed07cbcfb8f0d1fdac413aad10cf55c3d536dcbbb
parent7b94aae9d3e5e5be882bbba5dded0833a6e146fd (diff)
downloadchrome-ec-stabilize-14189.B-main.tar.gz
USB MUX: Pull HPD update into mux configurestabilize-14189.B-main
The mux HPD update is the only function not currently going through configure_mux(). Pull out its contents so it may be run with the rest of the mux changes. BRANCH=None BUG=b:186777984 TEST=tast typec.Mode*.manual on voxel Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I5d91ca89dcdab0dcb0ba844494f9009948ee5abc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3078412 Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--driver/usb_mux/usb_mux.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/driver/usb_mux/usb_mux.c b/driver/usb_mux/usb_mux.c
index e49a5a76d5..5ae2b83848 100644
--- a/driver/usb_mux/usb_mux.c
+++ b/driver/usb_mux/usb_mux.c
@@ -45,6 +45,7 @@ enum mux_config_type {
USB_MUX_SET_MODE,
USB_MUX_GET_MODE,
USB_MUX_CHIPSET_RESET,
+ USB_MUX_HPD_UPDATE,
};
/* Configure the MUX */
@@ -135,6 +136,18 @@ static int configure_mux(int port,
*mux_state |= lcl_state;
}
break;
+
+ case USB_MUX_HPD_UPDATE:
+ lcl_state = *mux_state;
+
+ if (mux_ptr->hpd_update) {
+ int hpd_lvl = (lcl_state & USB_PD_MUX_HPD_LVL) ?
+ 1 : 0;
+ int hpd_irq = (lcl_state & USB_PD_MUX_HPD_IRQ) ?
+ 1 : 0;
+ mux_ptr->hpd_update(mux_ptr, hpd_lvl, hpd_irq);
+ }
+
}
if (ack_required) {
@@ -322,8 +335,8 @@ void usb_mux_flip(int port)
void usb_mux_hpd_update(int port, int hpd_lvl, int hpd_irq)
{
- mux_state_t mux_state;
- const struct usb_mux *mux_ptr = &usb_muxes[port];
+ mux_state_t mux_state = (hpd_lvl ? USB_PD_MUX_HPD_LVL : 0) |
+ (hpd_irq ? USB_PD_MUX_HPD_IRQ : 0);
if (port >= board_get_usb_pd_port_count()) {
return;
@@ -336,13 +349,11 @@ void usb_mux_hpd_update(int port, int hpd_lvl, int hpd_irq)
if (exit_low_power_mode(port) != EC_SUCCESS)
return;
- for (; mux_ptr; mux_ptr = mux_ptr->next_mux)
- if (mux_ptr->hpd_update)
- mux_ptr->hpd_update(mux_ptr, hpd_lvl, hpd_irq);
+ configure_mux(port, USB_MUX_HPD_UPDATE, &mux_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);
+ (hpd_irq ? USB_PD_MUX_HPD_IRQ : 0);
configure_mux(port, USB_MUX_SET_MODE, &mux_state);
}
}