drivers/intel/usb4: Add parameter to explicitly define EC Type-C port

This patch adds the parameter which allows for custom port mapping
between CPU Type-C port and EC Type-C port to accommodate the
non-sequential mapping. Mainboard code must configure this parameter
if the CPU Type-C port to EC Type-C port mapping is not sequential.

BUG=b:399032094
TEST=build and verify TCSS port and EC port mapping

Change-Id: Id92f942e5c6b27342777b3e6fd12aff264ccec1b
Signed-off-by: Derek Huang <derekhuang@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86703
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Subrata Banik <subratabanik@google.com>
Reviewed-by: Kapil Porwal <kapilporwal@google.com>
This commit is contained in:
Derek Huang 2025-03-04 09:19:37 +00:00 committed by Matt DeVillier
commit c53b3efa4e
2 changed files with 17 additions and 1 deletions

View file

@ -9,6 +9,14 @@
#define DFP_NUM_MAX 2
enum ec_typec_port {
UNDEFINED = 0,
EC_TYPEC_PORT_0,
EC_TYPEC_PORT_1,
EC_TYPEC_PORT_2,
EC_TYPEC_PORT_3
};
struct drivers_intel_usb4_retimer_config {
/* Downstream facing port(DFP) */
struct {
@ -16,6 +24,11 @@ struct drivers_intel_usb4_retimer_config {
struct acpi_gpio power_gpio;
/* Type-C port associated with retimer */
DEVTREE_CONST struct device *typec_port;
/*
* EC Type-C port associated with retimer. This parameter must be configured
* correctly if the CPU Type-C port to EC port mapping is not sequential.
*/
enum ec_typec_port ec_port;
} dfp[DFP_NUM_MAX];
};

View file

@ -400,7 +400,10 @@ static void usb4_retimer_fill_ssdt(const struct device *dev)
usb_device = config->dfp[dfp_port].typec_port;
usb_port = usb_device->path.usb.port_id;
ec_port = retimer_get_index_for_typec(usb_port);
/* Map to the EC port number if it is explicitly defined in the device tree */
ec_port = (config->dfp[dfp_port].ec_port) ?
config->dfp[dfp_port].ec_port - EC_TYPEC_PORT_0 :
retimer_get_index_for_typec(usb_port);
if (ec_port == -1) {
printk(BIOS_ERR, "%s: No relative EC port found for TC port %d\n",
__func__, usb_port);