aboutsummaryrefslogtreecommitdiff
path: root/src/soc/intel
diff options
context:
space:
mode:
authorSridhar Siricilla <sridhar.siricilla@intel.com>2022-12-08 16:15:16 +0530
committerFelix Held <felix-coreboot@felixheld.de>2022-12-14 13:35:36 +0000
commitf9ee35ea3416929519a12ba9148b4c39168d1209 (patch)
tree7acaa7b73256202aaf2b200522c77812a49d5afa /src/soc/intel
parente64b8ac1e73c75d7b55f9f80c3fb7e2927bdbd0e (diff)
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 <sridhar.siricilla@intel.com> Change-Id: I02ed1f818e77c37ead8ce962fa12fddfdc8efeb6 Reviewed-on: https://review.coreboot.org/c/coreboot/+/70507 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Subrata Banik <subratabanik@google.com>
Diffstat (limited to 'src/soc/intel')
-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,