Patrick Georgi submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Tim Wawrzynczak: Looks good to me, approved
drivers/intel/usb4: Enable retimer FW upgrade mux interaction

In order to update the BB retimers for usb4/tbt they need to be turned
on and into TBT mode. Expand the current DSM to allow for the use of an
EC RAM byte RFWU to get the current state of each port and whether or
not it has a retimer. It also allows Kernel to issue state transitions
for the retimer to be put into TBT mode for firmware update.

BUG=b:162528867
TEST=Along with work in progress kernel and EC patches, the Retimer
firmware update is verified under device attached and no device attached
scenarios.

Change-Id: I768cfb56790049c231173b0ea0f8e08fe6b64b93
Signed-off-by: Brandon Breitenstein <brandon.breitenstein@intel.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/48630
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
---
M src/drivers/intel/usb4/retimer/retimer.c
A src/drivers/intel/usb4/retimer/retimer.h
2 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/src/drivers/intel/usb4/retimer/retimer.c b/src/drivers/intel/usb4/retimer/retimer.c
index 7a693ff..f884ac60 100644
--- a/src/drivers/intel/usb4/retimer/retimer.c
+++ b/src/drivers/intel/usb4/retimer/retimer.c
@@ -8,6 +8,7 @@
#include <gpio.h>
#include <string.h>
#include "chip.h"
+#include "retimer.h"

/* Unique ID for the retimer _DSM. */
#define INTEL_USB4_RETIMER_DSM_UUID "61788900-C470-42BB-80F0-23A313864593"
@@ -19,6 +20,8 @@
* 0: Query command implemented
* 1: Query force power enable state
* 2: Set force power state
+ * 3: Get Retimer FW Update EC Ram value
+ * 4: Set Retimer FW Update EC Ram value
* Arg3: A package containing parameters for the function specified
* by the UUID, revision ID and function index.
*/
@@ -28,15 +31,15 @@
/*
* ToInteger (Arg1, Local2)
* If (Local2 == 1) {
- * Return(Buffer() {0x07})
+ * Return(Buffer() {0x1f})
* }
* Return (Buffer() {0x01})
*/
acpigen_write_to_integer(ARG1_OP, LOCAL2_OP);

- /* Revision 1 supports 2 Functions beyond the standard query */
+ /* Revision 1 supports 4 Functions beyond the standard query */
acpigen_write_if_lequal_op_int(LOCAL2_OP, 1);
- acpigen_write_return_singleton_buffer(0x07);
+ acpigen_write_return_singleton_buffer(0x1f);
acpigen_pop_len(); /* If */

/* Other revisions support no additional functions */
@@ -48,7 +51,7 @@
struct acpi_gpio *power_gpio = arg;

/*
- * // Read power gpio into Local0
+ * Read power gpio into Local0
* Store (\_SB.PCI0.GTXS (power_gpio), Local0)
* Return (Local0)
*/
@@ -61,7 +64,7 @@
struct acpi_gpio *power_gpio = arg;

/*
- * // Get argument for on/off from Arg3[0]
+ * Get information to set to retimer info from Arg3[0]
* Local0 = DeRefOf (Arg3[0])
*/
acpigen_get_package_op_element(ARG3_OP, 0, LOCAL0_OP);
@@ -90,10 +93,32 @@
acpigen_write_return_integer(0);
}

-static void (*usb4_retimer_callbacks[3])(void *) = {
+static void usb4_retimer_cb_get_retimer_info(void *arg)
+{
+ const char *RFWU = ec_retimer_fw_update_path();
+
+ /*
+ * Read Mux Retimer info from EC RAM
+ * Return RFWU if RFWU is not NULL. Otherwise return -1 to
+ * inform kernel about error.
+ */
+ if (!RFWU)
+ acpigen_write_return_byte(-1);
+ else
+ acpigen_write_return_namestr(RFWU);
+}
+
+static void usb4_retimer_cb_set_retimer_info(void *arg)
+{
+ ec_retimer_fw_update(arg);
+}
+
+static void (*usb4_retimer_callbacks[5])(void *) = {
usb4_retimer_cb_standard_query, /* Function 0 */
usb4_retimer_cb_get_power_state, /* Function 1 */
usb4_retimer_cb_set_power_state, /* Function 2 */
+ usb4_retimer_cb_get_retimer_info, /* Function 3 */
+ usb4_retimer_cb_set_retimer_info, /* Function 4 */
};

static void usb4_retimer_fill_ssdt(const struct device *dev)
@@ -134,3 +159,12 @@
CHIP_NAME("Intel USB4 Retimer")
.enable_dev = usb4_retimer_enable
};
+
+__weak const char *ec_retimer_fw_update_path(void)
+{
+ return NULL;
+}
+
+__weak void ec_retimer_fw_update(void *arg)
+{
+}
diff --git a/src/drivers/intel/usb4/retimer/retimer.h b/src/drivers/intel/usb4/retimer/retimer.h
new file mode 100644
index 0000000..4c4044a
--- /dev/null
+++ b/src/drivers/intel/usb4/retimer/retimer.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef _DRIVERS_INTEL_USB4_RETIMER_H_
+#define _DRIVERS_INTEL_USB4_RETIMER_H_
+
+const char *ec_retimer_fw_update_path(void);
+void ec_retimer_fw_update(void *arg);
+
+#endif /* _DRIVERS_INTEL_USB4_RETIMER_H_ */

To view, visit change 48630. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I768cfb56790049c231173b0ea0f8e08fe6b64b93
Gerrit-Change-Number: 48630
Gerrit-PatchSet: 18
Gerrit-Owner: Brandon Breitenstein <brandon.breitenstein@intel.com>
Gerrit-Reviewer: Duncan Laurie <dlaurie@chromium.org>
Gerrit-Reviewer: John Zhao <john.zhao@intel.com>
Gerrit-Reviewer: Martin Roth <martinroth@google.com>
Gerrit-Reviewer: Patrick Georgi <pgeorgi@google.com>
Gerrit-Reviewer: Patrick Rudolph <siro@das-labor.org>
Gerrit-Reviewer: Tim Wawrzynczak <twawrzynczak@chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: John Zhao <john.zhao@intel.corp-partner.google.com>
Gerrit-CC: Paul Menzel <paulepanter@users.sourceforge.net>
Gerrit-CC: Rajmohan Mani <rajmohan.mani@intel.com>
Gerrit-MessageType: merged