summaryrefslogtreecommitdiff
path: root/src/drivers/intel
diff options
context:
space:
mode:
authorReka Norman <rekanorman@google.com>2021-12-09 12:09:27 +1100
committerFelix Held <felix-coreboot@felixheld.de>2021-12-23 14:33:28 +0000
commitd448f8ce0fe9955e7792f54cc278897152d53590 (patch)
tree90c3700fd8945569c7936a3f0649e6907997fae3 /src/drivers/intel
parent9fe2ce802af0751b2df657e487631df8fb60ab9f (diff)
drivers/intel/pmc_mux/conn: Change usb{23}_port_number fields to device pointers
Currently, the pmc_mux/conn driver uses integer fields to store the USB-2 and USB-3 port numbers from the SoC's point of view. Specifying these as integers in the devicetree is error-prone, and this information can instead be represented using pointers to the USB-2 and USB-3 devices. The port numbers can then be obtained from the paths of the linked devices, i.e. dev->path.usb.port_id. Modify the driver to store device pointers instead of integer port numbers, and update all devicetrees using the driver. These are the mainboards affected (all are Intel TGL or ADL based): google/brya google/volteer intel/adlrvp intel/shadowmountain intel/tglrvp system76/darp7 system76/galp5 system76/lemp10 Command used to update the devicetrees: git grep -l "usb._port_number" src/mainboard/ | \ xargs sed -i \ -e 's/register "usb2_port_number" = "\(.*\)"/use usb2_port\1 as usb2_port/g' \ -e 's/register "usb3_port_number" = "\(.*\)"/use tcss_usb3_port\1 as usb3_port/g' BUG=b:208502191 TEST=Build test all affected boards. On brya0, boot device and check that the ACPI tables generated with and without the change are the same. Change-Id: I5045b8ea57e8ca6f9ebd7d68a19486736b7e2809 Signed-off-by: Reka Norman <rekanorman@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/60143 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Tim Crawford <tcrawford@system76.com> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
Diffstat (limited to 'src/drivers/intel')
-rw-r--r--src/drivers/intel/pmc_mux/conn/chip.h8
-rw-r--r--src/drivers/intel/pmc_mux/conn/conn.c17
2 files changed, 15 insertions, 10 deletions
diff --git a/src/drivers/intel/pmc_mux/conn/chip.h b/src/drivers/intel/pmc_mux/conn/chip.h
index 96347ae4a0..08a08e184d 100644
--- a/src/drivers/intel/pmc_mux/conn/chip.h
+++ b/src/drivers/intel/pmc_mux/conn/chip.h
@@ -6,10 +6,10 @@
#include <boot/coreboot_tables.h>
struct drivers_intel_pmc_mux_conn_config {
- /* 1-based port numbers (from SoC point of view) */
- int usb2_port_number;
- /* 1-based port numbers (from SoC point of view) */
- int usb3_port_number;
+ /* A pointer to the SoC's USB-2 device */
+ DEVTREE_CONST struct device *usb2_port;
+ /* A pointer to the SoC's USB-3 device */
+ DEVTREE_CONST struct device *usb3_port;
/* Orientation of the sideband signals (SBU) */
enum type_c_orientation sbu_orientation;
/* Orientation of the High Speed lines */
diff --git a/src/drivers/intel/pmc_mux/conn/conn.c b/src/drivers/intel/pmc_mux/conn/conn.c
index caff166392..f238397245 100644
--- a/src/drivers/intel/pmc_mux/conn/conn.c
+++ b/src/drivers/intel/pmc_mux/conn/conn.c
@@ -16,6 +16,11 @@ static void conn_init(struct device *dev)
total_conn_count++;
}
+static unsigned int get_usb_port_number(const struct device *usb_port)
+{
+ return usb_port->path.usb.port_id + 1;
+}
+
static struct type_c_info *conn_get_cbmem_buffer(void)
{
struct type_c_info *info;
@@ -57,8 +62,8 @@ static void conn_write_cbmem_entry(struct device *dev)
count = info->port_count;
port_info = &info->port_info[count];
- port_info->usb2_port_number = config->usb2_port_number;
- port_info->usb3_port_number = config->usb3_port_number;
+ port_info->usb2_port_number = get_usb_port_number(config->usb2_port);
+ port_info->usb3_port_number = get_usb_port_number(config->usb3_port);
port_info->sbu_orientation = config->sbu_orientation;
port_info->data_orientation = config->hsl_orientation;
@@ -109,8 +114,8 @@ static void conn_fill_ssdt(const struct device *dev)
/* _DSD, Device-Specific Data */
dsd = acpi_dp_new_table("_DSD");
- acpi_dp_add_integer(dsd, "usb2-port-number", config->usb2_port_number);
- acpi_dp_add_integer(dsd, "usb3-port-number", config->usb3_port_number);
+ acpi_dp_add_integer(dsd, "usb2-port-number", get_usb_port_number(config->usb2_port));
+ acpi_dp_add_integer(dsd, "usb3-port-number", get_usb_port_number(config->usb3_port));
/*
* The kernel assumes that these Type-C signals (SBUs and HSLs) follow the CC lines,
@@ -161,8 +166,8 @@ bool intel_pmc_mux_conn_get_ports(const struct device *conn, unsigned int *usb2_
return false;
mux_config = conn->chip_info;
- *usb2_port = mux_config->usb2_port_number;
- *usb3_port = mux_config->usb3_port_number;
+ *usb2_port = get_usb_port_number(mux_config->usb2_port);
+ *usb3_port = get_usb_port_number(mux_config->usb3_port);
return true;
};