summaryrefslogtreecommitdiff
path: root/src/soc
diff options
context:
space:
mode:
Diffstat (limited to 'src/soc')
-rw-r--r--src/soc/intel/common/block/tcss/tcss.c41
1 files changed, 17 insertions, 24 deletions
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 <intelblocks/systemagent.h>
#include <intelblocks/tcss.h>
#include <inttypes.h>
+#include <lib.h>
#include <security/vboot/vboot_common.h>
#include <soc/pci_devs.h>
#include <soc/pcr_ids.h>
@@ -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,