From f9ee35ea3416929519a12ba9148b4c39168d1209 Mon Sep 17 00:00:00 2001 From: Sridhar Siricilla Date: Thu, 8 Dec 2022 16:15:16 +0530 Subject: soc/intel/common: Add helper function to get DP mode The patch adds helper function to get the DP mode. TEST=Build the code for Rex Signed-off-by: Sridhar Siricilla Change-Id: I02ed1f818e77c37ead8ce962fa12fddfdc8efeb6 Reviewed-on: https://review.coreboot.org/c/coreboot/+/70507 Tested-by: build bot (Jenkins) Reviewed-by: Subrata Banik --- src/soc/intel/common/block/tcss/tcss.c | 41 ++++++++++++++-------------------- 1 file changed, 17 insertions(+), 24 deletions(-) (limited to 'src/soc/intel/common/block/tcss') diff --git a/src/soc/intel/common/block/tcss/tcss.c b/src/soc/intel/common/block/tcss/tcss.c index 2ae07fdfc1..16669ba403 100644 --- a/src/soc/intel/common/block/tcss/tcss.c +++ b/src/soc/intel/common/block/tcss/tcss.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -204,6 +205,21 @@ static int send_pmc_dp_hpd_request(int port, const struct usbc_mux_info *mux_dat return send_pmc_req(HPD_REQ, &req, &rsp, PMC_IPC_HPD_REQ_SIZE); } +static uint8_t get_dp_mode(uint8_t dp_pin_mode) +{ + switch (dp_pin_mode) { + case MODE_DP_PIN_A: + case MODE_DP_PIN_B: + case MODE_DP_PIN_C: + case MODE_DP_PIN_D: + case MODE_DP_PIN_E: + case MODE_DP_PIN_F: + return log2(dp_pin_mode) + 1; + default: + return 0; + } +} + static int send_pmc_dp_mode_request(int port, const struct usbc_mux_info *mux_data, const struct tcss_port_map *port_map) { @@ -227,30 +243,7 @@ static int send_pmc_dp_mode_request(int port, const struct usbc_mux_info *mux_da GET_TCSS_ALT_FIELD(USB3, cmd), GET_TCSS_ALT_FIELD(MODE, cmd)); - switch (mux_data->dp_pin_mode) { - case MODE_DP_PIN_A: - dp_mode = 1; - break; - case MODE_DP_PIN_B: - dp_mode = 2; - break; - case MODE_DP_PIN_C: - dp_mode = 3; - break; - case MODE_DP_PIN_D: - dp_mode = 4; - break; - case MODE_DP_PIN_E: - dp_mode = 5; - break; - case MODE_DP_PIN_F: - dp_mode = 6; - break; - default: - dp_mode = 0; - break; - } - + dp_mode = get_dp_mode(mux_data->dp_pin_mode); cmd = tcss_make_alt_mode_cmd_buf_1( mux_data->polarity, mux_data->cable, -- cgit v1.2.3