diff options
author | johnwc_yeh <johnwc_yeh@compal.corp-partner.google.com> | 2022-11-23 09:58:24 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-12-13 19:24:29 +0000 |
commit | 78eaccf378e8db32c4721f45e1325b1e06096313 (patch) | |
tree | 35a23e9903aa472607f445abcaa78b87d7d616bb | |
parent | f439c4f2098d14e66f29d2ac65dadc095d984e5d (diff) | |
download | chrome-ec-78eaccf378e8db32c4721f45e1325b1e06096313.tar.gz |
BB retimer: Add condition to set 'DP CONNECTION' bit
Set 'DP CONNECTION' bit when mux_state gets HPD event only on
the ports with HDMI/DP card
It will increase BBR power consumption, so set 'DP CONNECTION'
bit only when mux_state gets HPD event only on the ports with
HDMI/DP card.
BUG=b:233975818
BRANCH=None
TEST=Test on Banshee, when only hdmi card 'DP CONNECTION' bit
is 0. Enter console command bb 1 r 4 =0x403, plug in hdmi
monitor bb 1 r 4 =0x8503.
Run ./twister -T zephyr/test/drivers
Signed-off-by: johnwc_yeh <johnwc_yeh@compal.corp-partner.google.com>
Change-Id: I87b2a4379e66e08830c556d703390a7fb96d3258
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4050320
Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Commit-Queue: Boris Mittelberg <bmbm@google.com>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Reviewed-by: Boris Mittelberg <bmbm@google.com>
-rw-r--r-- | driver/retimer/bb_retimer.c | 22 | ||||
-rw-r--r-- | include/driver/retimer/bb_retimer_public.h | 8 | ||||
-rw-r--r-- | include/usb_pd.h | 4 | ||||
-rw-r--r-- | zephyr/test/drivers/default/src/bb_retimer.c | 29 |
4 files changed, 63 insertions, 0 deletions
diff --git a/driver/retimer/bb_retimer.c b/driver/retimer/bb_retimer.c index 3bee94bb56..5c07e43e71 100644 --- a/driver/retimer/bb_retimer.c +++ b/driver/retimer/bb_retimer.c @@ -523,6 +523,28 @@ static int bb_set_idle_mode(const struct usb_mux *me, bool idle) return rv; } +int bb_retimer_set_dp_connection(const struct usb_mux *me, bool enable) +{ + int rv; + uint32_t reg_val; + int port = me->usb_port; + + mutex_lock(&bb_retimer_lock[port]); + + rv = bb_retimer_read(me, BB_RETIMER_REG_CONNECTION_STATE, ®_val); + if (rv != EC_SUCCESS) { + mutex_unlock(&bb_retimer_lock[port]); + return rv; + } + /* Bit 8: BB_RETIMER_DP_CONNECTION */ + WRITE_BIT(reg_val, 8, enable); + rv = bb_retimer_write(me, BB_RETIMER_REG_CONNECTION_STATE, reg_val); + + mutex_unlock(&bb_retimer_lock[port]); + + return rv; +} + void bb_retimer_hpd_update(const struct usb_mux *me, mux_state_t hpd_state, bool *ack_required) { diff --git a/include/driver/retimer/bb_retimer_public.h b/include/driver/retimer/bb_retimer_public.h index 35e289e2f2..fd63d81a35 100644 --- a/include/driver/retimer/bb_retimer_public.h +++ b/include/driver/retimer/bb_retimer_public.h @@ -56,4 +56,12 @@ __override_proto int bb_retimer_power_enable(const struct usb_mux *me, void bb_retimer_hpd_update(const struct usb_mux *me, mux_state_t hpd_state, bool *ack_required); +/** + * Enable/disable the DP state of BB retimer + * + * @param me Pointer to USB mux + * @param enable BB retimer DP state to be changed + */ +int bb_retimer_set_dp_connection(const struct usb_mux *me, bool enable); + #endif /* __CROS_EC_DRIVER_RETIMER_BB_RETIMER_PUBLIC_H */ diff --git a/include/usb_pd.h b/include/usb_pd.h index e4ab8f6432..ea8675318d 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -855,6 +855,10 @@ struct pd_cable { #define USB_VID_INTEL 0x8087 +#define USB_VID_FRAMEWORK 0X32ac +#define USB_PID_FRAMEWORK_HDMI_CARD 0X2 +#define USB_PID_FRAMEWORK_DP_CARD 0X3 + /* Timeout for message receive in microseconds */ #define USB_PD_RX_TMOUT_US 1800 diff --git a/zephyr/test/drivers/default/src/bb_retimer.c b/zephyr/test/drivers/default/src/bb_retimer.c index 78d483817a..c6e66d7626 100644 --- a/zephyr/test/drivers/default/src/bb_retimer.c +++ b/zephyr/test/drivers/default/src/bb_retimer.c @@ -240,6 +240,35 @@ ZTEST_USER(bb_retimer_no_tasks, test_bb_set_idle_mode) usb3_conn, conn); } +/** Test retimer dp connection setting. */ +ZTEST_USER(bb_retimer_no_tasks, test_bb_retimer_set_dp_connection) +{ + const uint32_t enable_dp_conn = BB_RETIMER_DP_CONNECTION; + const uint32_t disable_dp_conn = 0; + const struct emul *emul = EMUL_DT_GET(BB_RETIMER_NODE); + struct usb_mux usb_mux_c1; + uint32_t conn; + + set_test_runner_tid(); + + usb_mux_c1 = *usb_muxes[USBC_PORT_C1].mux; + + /* Check if DP is enabled */ + zassert_equal(EC_SUCCESS, + bb_retimer_set_dp_connection(&usb_mux_c1, true), NULL); + conn = bb_emul_get_reg(emul, BB_RETIMER_REG_CONNECTION_STATE); + zassert_equal(conn, enable_dp_conn, "Expected state 0x%02x, got 0x%02x", + enable_dp_conn, conn); + + /* Check if DP is disabled */ + zassert_equal(EC_SUCCESS, + bb_retimer_set_dp_connection(&usb_mux_c1, false), NULL); + conn = bb_emul_get_reg(emul, BB_RETIMER_REG_CONNECTION_STATE); + zassert_equal(conn, disable_dp_conn, + "Expected state 0x%02x, got 0x%02x", disable_dp_conn, + conn); +} + /** Test setting different options for DFP role */ ZTEST_USER(bb_retimer_no_tasks, test_bb_set_dfp_state) { |