summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--driver/retimer/bb_retimer.c32
-rw-r--r--include/driver/retimer/bb_retimer_public.h12
2 files changed, 44 insertions, 0 deletions
diff --git a/driver/retimer/bb_retimer.c b/driver/retimer/bb_retimer.c
index 319c965228..2e2e15f44f 100644
--- a/driver/retimer/bb_retimer.c
+++ b/driver/retimer/bb_retimer.c
@@ -492,6 +492,38 @@ 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)
+{
+ uint32_t retimer_con_reg = 0;
+
+ if (bb_retimer_read(me, BB_RETIMER_REG_CONNECTION_STATE,
+ &retimer_con_reg) != EC_SUCCESS)
+ return;
+
+ /*
+ * Bit 14: IRQ_HPD (ignored if BIT8 = 0)
+ * 0 - No IRQ_HPD
+ * 1 - IRQ_HPD received
+ */
+ if (mux_state & USB_PD_MUX_HPD_IRQ)
+ retimer_con_reg |= BB_RETIMER_IRQ_HPD;
+ else
+ retimer_con_reg &= ~BB_RETIMER_IRQ_HPD;
+
+ /*
+ * Bit 15: HPD_LVL (ignored if BIT8 = 0)
+ * 0 - HPD_State Low
+ * 1 - HPD_State High
+ */
+ if (mux_state & USB_PD_MUX_HPD_LVL)
+ retimer_con_reg |= BB_RETIMER_HPD_LVL;
+ else
+ retimer_con_reg &= ~BB_RETIMER_HPD_LVL;
+
+ /* Writing the register4 */
+ bb_retimer_write(me, BB_RETIMER_REG_CONNECTION_STATE, retimer_con_reg);
+}
+
static int retimer_low_power_mode(const struct usb_mux *me)
{
return bb_retimer_power_enable(me, false);
diff --git a/include/driver/retimer/bb_retimer_public.h b/include/driver/retimer/bb_retimer_public.h
index e4a6e4ca2f..91c1a45636 100644
--- a/include/driver/retimer/bb_retimer_public.h
+++ b/include/driver/retimer/bb_retimer_public.h
@@ -8,6 +8,8 @@
#ifndef __CROS_EC_DRIVER_RETIMER_BB_RETIMER_PUBLIC_H
#define __CROS_EC_DRIVER_RETIMER_BB_RETIMER_PUBLIC_H
+#include "usb_mux.h"
+
struct usb_mux;
/* Supported USB retimer drivers */
@@ -53,4 +55,14 @@ __override_proto int bb_retimer_power_enable(const struct usb_mux *me,
*/
__override_proto int bb_retimer_reset(const struct usb_mux *me);
+/**
+ * Set HPD on the BB retimer
+ *
+ * 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
+ */
+void bb_retimer_hpd_update(const struct usb_mux *me, mux_state_t mux_state);
+
#endif /* __CROS_EC_DRIVER_RETIMER_BB_RETIMER_PUBLIC_H */