Attention is currently required from: Tim Wawrzynczak, Nick Vaccaro, Patrick Rudolph. Furquan Shaikh has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/57345 )
Change subject: driver/intel/pmc_mux/conn: Add type-c info to coreboot table ......................................................................
Patch Set 6:
(1 comment)
File src/drivers/intel/pmc_mux/conn/conn.c:
https://review.coreboot.org/c/coreboot/+/57345/comment/31827ced_1759ca46 PS5, Line 115: mux = pmc->link_list->children;
We can't write the info directly to the table from within .final() because .final() is called after each connector is registered, and we don't know how many registrations to wait for before we will have all the ports and can create our table entry.
.final() cannot write to the table directly since writes to table happen in the bootstate after that. I meant writing to CBMEM in .final() so that the information can be used in the next step.
You can get the total_conn_count by incrementing the connector count in .init:
``` diff --git a/src/drivers/intel/pmc_mux/conn/conn.c b/src/drivers/intel/pmc_mux/conn/conn.c index b6bf371471..19037c2b2f 100644 --- a/src/drivers/intel/pmc_mux/conn/conn.c +++ b/src/drivers/intel/pmc_mux/conn/conn.c @@ -69,11 +69,56 @@ static void conn_fill_ssdt(const struct device *dev) dev_path(dev)); }
+static size_t total_conn_count; + +static void conn_init(struct device *dev) +{ + total_conn_count++; +} + +static struct type_c_info *conn_get_cbmem_buffer(void) +{ + struct type_c_info *info; + size_t size; + + info = cbmem_find(CBMEM_ID_TYPE_C_INFO); + if (info) + return info; + + size = sizeof(struct type_c_info) + total_conn_count * sizeof(struct type_c_port); + info = cbmem_add(CBMEM_ID_TYPE_C_INFO, size); + + if (!info) + return NULL; + + memset(info, 0, size); + return info; +} + +static void conn_write_cbmem_entry(struct device *dev) +{ + struct type_c_info *info = conn_get_cbmem_buffer(); + + if (!info || (info->port_count == total_conn_count)) { + printk(BIOS_ERR, "ERROR: No space for Type-C port info!\n"); + return; + } + + info->port[info->port_count].usb2_port_number = config->usb2_port_number; + info->port[info->port_count].usb3_port_number = config->usb3_port_number; + info->port[info->port_count].sbu_orientation = config->sbu_orientation; + info->port[info->port_count].hsl_orientation = config->hsl_orientation; + + info->port_count++; +} + static struct device_operations conn_dev_ops = { .read_resources = noop_read_resources, .set_resources = noop_set_resources, .acpi_name = conn_acpi_name, .acpi_fill_ssdt = conn_fill_ssdt, + .init = conn_init, + .final = conn_write_cbmem_entry, };
static void conn_enable(struct device *dev) ```
Also, the structure in coreboot_tables.h might need a little update: ``` struct type_c_port { uint8_t usb2_port_number; uint8_t usb3_port_number; uint8_t sbu_orientation; uint8_t data_orientation; };
struct type_c_info { uint32_t port_count; struct type_c_port type_c_port[0]; };
struct lb_type_c_info { uint32_t tag; uint32_t size; struct type_c_info type_c_info; }; ```