diff options
author | Diana Z <dzigterman@chromium.org> | 2021-09-15 20:50:17 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-09-16 21:35:47 +0000 |
commit | 932def91a81712f59202b492d2c746bb218a6299 (patch) | |
tree | 8e09514be748b82903728140b1aac1551d935e6a | |
parent | 54345c537da385c8e1924451dfdf00d13c532148 (diff) | |
download | chrome-ec-932def91a81712f59202b492d2c746bb218a6299.tar.gz |
BB Retimer: Create HPD update function
The BB retimer may use a simple read/modify/write on its configuration
register to set HPD fields, rather than needing to rely on a call to a
full mux set later to achieve this. Introduce an API so boards using
the BB retimer may move to using this function.
BRANCH=None
BUG=b:195773400
TEST=make -j buildall
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: Iae87c0860350fed32f69e0ea3b6530cd7e5ba111
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3163929
Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r-- | driver/retimer/bb_retimer.c | 32 | ||||
-rw-r--r-- | include/driver/retimer/bb_retimer_public.h | 12 |
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 */ |