summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorli feng <li1.feng@intel.com>2021-01-26 21:03:56 -0800
committerCommit Bot <commit-bot@chromium.org>2021-02-09 17:16:55 +0000
commit909e426470a202a3520c9124623f120b4834b879 (patch)
tree138450370b91560e052cc5874b1e76fd9ff32cd5
parent0609536aeecda56224265ef91d3401eb40a014a7 (diff)
downloadchrome-ec-909e426470a202a3520c9124623f120b4834b879.tar.gz
retimer: PD port retimer firmware update support
Added one field to struct usb_mux_driver, which returns true if retimer update is supported. Moved query function from usb_retimer_fw_update.c to usb_mux.c. BUG=b:162528867 BRANCH=none TEST=Tested on Voxel, together with related coreboot and kernel changes. EC returns correct port information to kernel. Signed-off-by: li feng <li1.feng@intel.com> Change-Id: I5cab34a14adbf0470cffe6a13234ad53b6f6a90c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2651866 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2681290 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org> Tested-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--board/volteer/usbc_config.c6
-rw-r--r--board/voxel/board.c6
-rw-r--r--common/usbc/usb_retimer_fw_update.c7
-rw-r--r--driver/retimer/bb_retimer.c6
-rw-r--r--driver/usb_mux/usb_mux.c19
-rw-r--r--include/usb_common.h10
-rw-r--r--include/usb_mux.h19
7 files changed, 45 insertions, 28 deletions
diff --git a/board/volteer/usbc_config.c b/board/volteer/usbc_config.c
index 40d4f9d0f3..1fec96a2a3 100644
--- a/board/volteer/usbc_config.c
+++ b/board/volteer/usbc_config.c
@@ -241,12 +241,6 @@ struct bb_usb_control bb_controls[] = {
};
BUILD_ASSERT(ARRAY_SIZE(bb_controls) == USBC_PORT_COUNT);
-__override int usb_retimer_fw_update_query_port(void)
-{
- /* USBC_PORT_C1 has burnside bridge retimer */
- return BIT(1);
-}
-
__override enum tbt_compat_cable_speed board_get_max_tbt_speed(int port)
{
enum ec_cfg_usb_db_type usb_db = ec_cfg_usb_db_type();
diff --git a/board/voxel/board.c b/board/voxel/board.c
index 6edea86fcc..ef392b5afd 100644
--- a/board/voxel/board.c
+++ b/board/voxel/board.c
@@ -455,12 +455,6 @@ static void board_tcpc_init(void)
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_CHIPSET);
-__override int usb_retimer_fw_update_query_port(void)
-{
- /* Both USBC_PORT_C0 and USBC_PORT_C1 have burnside bridge retimer */
- return BIT(1) | BIT(0);
-}
-
/******************************************************************************/
/* TCPC support routines */
uint16_t tcpc_get_alert_status(void)
diff --git a/common/usbc/usb_retimer_fw_update.c b/common/usbc/usb_retimer_fw_update.c
index 7ae833b8c9..f85a197c40 100644
--- a/common/usbc/usb_retimer_fw_update.c
+++ b/common/usbc/usb_retimer_fw_update.c
@@ -52,11 +52,6 @@ static int last_op; /* Operation received from AP via ACPI_WRITE */
/* MUX value returned to ACPI_READ */
static int last_mux_result = USB_RETIMER_FW_UPDATE_INVALID_MUX;
-__overridable int usb_retimer_fw_update_query_port(void)
-{
- return 0;
-}
-
int usb_retimer_fw_update_get_result(void)
{
int result = 0;
@@ -67,7 +62,7 @@ int usb_retimer_fw_update_get_result(void)
result = pd_is_port_enabled(cur_port);
break;
case USB_RETIMER_FW_UPDATE_QUERY_PORT:
- result = usb_retimer_fw_update_query_port();
+ result = usb_mux_retimer_fw_update_port_info();
break;
case USB_RETIMER_FW_UPDATE_GET_MUX:
case USB_RETIMER_FW_UPDATE_SET_USB:
diff --git a/driver/retimer/bb_retimer.c b/driver/retimer/bb_retimer.c
index 6fd629c3a9..b5d7fbf0ff 100644
--- a/driver/retimer/bb_retimer.c
+++ b/driver/retimer/bb_retimer.c
@@ -493,6 +493,11 @@ static int retimer_low_power_mode(const struct usb_mux *me)
return EC_SUCCESS;
}
+static bool is_retimer_fw_update_capable(void)
+{
+ return true;
+}
+
static int retimer_init(const struct usb_mux *me)
{
int rv;
@@ -527,6 +532,7 @@ const struct usb_mux_driver bb_usb_retimer = {
.init = retimer_init,
.set = retimer_set_state,
.enter_low_power_mode = retimer_low_power_mode,
+ .is_retimer_fw_update_capable = is_retimer_fw_update_capable,
};
#ifdef CONFIG_CMD_RETIMER
diff --git a/driver/usb_mux/usb_mux.c b/driver/usb_mux/usb_mux.c
index 01f8f0ab6f..6f2739de4a 100644
--- a/driver/usb_mux/usb_mux.c
+++ b/driver/usb_mux/usb_mux.c
@@ -348,6 +348,25 @@ void usb_mux_hpd_update(int port, int hpd_lvl, int hpd_irq)
}
}
+int usb_mux_retimer_fw_update_port_info(void)
+{
+ int i;
+ int port_info = 0;
+ const struct usb_mux *mux_ptr;
+
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ mux_ptr = &usb_muxes[i];
+ while (mux_ptr) {
+ if (mux_ptr->driver &&
+ mux_ptr->driver->is_retimer_fw_update_capable &&
+ mux_ptr->driver->is_retimer_fw_update_capable())
+ port_info |= BIT(i);
+ mux_ptr = mux_ptr->next_mux;
+ }
+ }
+ return port_info;
+}
+
static void mux_chipset_reset(void)
{
int port;
diff --git a/include/usb_common.h b/include/usb_common.h
index c5912b1952..526143138a 100644
--- a/include/usb_common.h
+++ b/include/usb_common.h
@@ -202,16 +202,6 @@ void pd_update_saved_port_flags(int port, uint8_t flag, uint8_t do_set);
int pd_build_alert_msg(uint32_t *msg, uint32_t *len, enum pd_power_role pr);
/**
- * Query USB-C ports state for USB retimer firmware update.
- * Support up to 8 ports.
- *
- * @return Bits[7:0]: represent PD ports 0-7
- * 1 - This port has retimer;
- * 0 - not retimer.
- */
-__override_proto int usb_retimer_fw_update_query_port(void);
-
-/**
* During USB retimer firmware update, process operation
* requested by AP
*
diff --git a/include/usb_mux.h b/include/usb_mux.h
index cb50497ef7..4391eed1e8 100644
--- a/include/usb_mux.h
+++ b/include/usb_mux.h
@@ -58,6 +58,14 @@ struct usb_mux_driver {
int (*get)(const struct usb_mux *me, mux_state_t *mux_state);
/**
+ * Return if retimer supports firmware update
+ *
+ * @return true - supported
+ * false - not supported
+ */
+ bool (*is_retimer_fw_update_capable)(void);
+
+ /**
* Optional method that is called after the mux fully disconnects.
*
* Note: this method does not need to be defined for TCPC/MUX combos
@@ -242,6 +250,17 @@ void usb_mux_flip(int port);
void usb_mux_hpd_update(int port, int hpd_lvl, int hpd_irq);
/**
+ * Port information about retimer firmware update support.
+ *
+ * @return which ports support retimer firmware update
+ * Bits[7:0]: represent PD ports 0-7;
+ * each bit
+ * = 1, this port supports retimer firmware update;
+ * = 0, not support.
+ */
+int usb_mux_retimer_fw_update_port_info(void);
+
+/**
* Get the disconnect latch flag so that the Kernel Mux driver doesn't
* miss the unnoticed disconnection status.
*