summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2018-11-02 15:03:28 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-11-07 20:27:01 -0800
commit5ffa5f9a44c9f392ac90849fe5146892796594bf (patch)
tree71bfd3febc09b9fc0de044170436460d68de9f7b /board
parentb498f108bd28c4bc2aec9749b3ef80263d916e85 (diff)
downloadchrome-ec-5ffa5f9a44c9f392ac90849fe5146892796594bf.tar.gz
cheza: Make USB mux handled by TCPC chips and HPD handled by AP
In Cheza design, the USB mux (switching USB lanes to DP and/or USB SS) is handled by TCPC chips and the HPD is handled by AP (DP PHY). The CL adds some custom drivers to override the get() function (Linux extcon driver uses it to check the USB mux and HPD IRQ) by checking the virtual driver and redirect the other functions to the TCPC drivers. BRANCH=none BUG=b:118898133 TEST=Manually added a new console command to issue a HPD IRQ. +static int command_hpd_irq(int argc, char **argv) +{ + char *e; + int port; + const struct usb_mux *mux; + + if (argc != 2) + return EC_ERROR_PARAM_COUNT; + + port = strtoi(argv[1], &e, 10); + if (*e || port >= CONFIG_USB_PD_PORT_COUNT) + return EC_ERROR_PARAM1; + + mux = &usb_muxes[port]; + mux->hpd_update(port, 0, 1); + return EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(hpd_irq, command_hpd_irq, + "[port]", + "Issue a HPD IRQ"); In EC console, typed "hpd_irq 0" and checked the result on AP: localhost ~ # ectool usbpdmuxinfo 0 Port 0: USB DP HPD_IRQ Port 1: USB INV Checked it again and HPD_IRQ should be cleared. localhost ~ # ectool usbpdmuxinfo 0 Port 0: USB DP Port 1: USB INV Change-Id: I4ddc274a637393391dd654c9ee75de7646746ad5 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/1316370 Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Diffstat (limited to 'board')
-rw-r--r--board/cheza/board.c86
-rw-r--r--board/cheza/board.h1
2 files changed, 83 insertions, 4 deletions
diff --git a/board/cheza/board.c b/board/cheza/board.c
index c8126790c0..715e8fa768 100644
--- a/board/cheza/board.c
+++ b/board/cheza/board.c
@@ -246,14 +246,92 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
TCPC_ALERT_ACTIVE_LOW},
};
+/*
+ * Port-0 USB mux driver.
+ *
+ * The USB mux is handled by TCPC chip and the HPD is handled by AP.
+ * Redirect to anx74xx_tcpm_usb_mux_driver but override the get() function
+ * to check the HPD_IRQ mask from virtual_usb_mux_driver.
+ */
+static int port0_usb_mux_init(int port)
+{
+ return anx74xx_tcpm_usb_mux_driver.init(port);
+}
+
+static int port0_usb_mux_set(int i2c_addr, mux_state_t mux_state)
+{
+ return anx74xx_tcpm_usb_mux_driver.set(i2c_addr, mux_state);
+}
+
+static int port0_usb_mux_get(int port, mux_state_t *mux_state)
+{
+ int rv;
+ mux_state_t virtual_mux_state;
+
+ rv = anx74xx_tcpm_usb_mux_driver.get(port, mux_state);
+ rv |= virtual_usb_mux_driver.get(port, &virtual_mux_state);
+
+ if (virtual_mux_state & USB_PD_MUX_HPD_IRQ)
+ *mux_state |= USB_PD_MUX_HPD_IRQ;
+ return rv;
+}
+
+const struct usb_mux_driver port0_usb_mux_driver = {
+ .init = port0_usb_mux_init,
+ .set = port0_usb_mux_set,
+ .get = port0_usb_mux_get,
+};
+
+/*
+ * Port-1 USB mux driver.
+ *
+ * The USB mux is handled by TCPC chip and the HPD is handled by AP.
+ * Redirect to tcpci_tcpm_usb_mux_driver but override the get() function
+ * to check the HPD_IRQ mask from virtual_usb_mux_driver.
+ */
+static int port1_usb_mux_init(int port)
+{
+ return tcpci_tcpm_usb_mux_driver.init(port);
+}
+
+static int port1_usb_mux_set(int i2c_addr, mux_state_t mux_state)
+{
+ return tcpci_tcpm_usb_mux_driver.set(i2c_addr, mux_state);
+}
+
+static int port1_usb_mux_get(int port, mux_state_t *mux_state)
+{
+ int rv;
+ mux_state_t virtual_mux_state;
+
+ rv = tcpci_tcpm_usb_mux_driver.get(port, mux_state);
+ rv |= virtual_usb_mux_driver.get(port, &virtual_mux_state);
+
+ if (virtual_mux_state & USB_PD_MUX_HPD_IRQ)
+ *mux_state |= USB_PD_MUX_HPD_IRQ;
+ return rv;
+}
+
+static int port1_usb_mux_enter_low_power(int port)
+{
+ return tcpci_tcpm_usb_mux_driver.enter_low_power_mode(port);
+}
+
+const struct usb_mux_driver port1_usb_mux_driver = {
+ .init = &port1_usb_mux_init,
+ .set = &port1_usb_mux_set,
+ .get = &port1_usb_mux_get,
+ .enter_low_power_mode = &port1_usb_mux_enter_low_power,
+};
+
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
- .driver = &anx74xx_tcpm_usb_mux_driver,
- .hpd_update = &anx74xx_tcpc_update_hpd_status,
+ .driver = &port0_usb_mux_driver,
+ .hpd_update = &virtual_hpd_update,
},
{
- .driver = &tcpci_tcpm_usb_mux_driver,
- .hpd_update = &ps8xxx_tcpc_update_hpd_status,
+ .driver = &port1_usb_mux_driver,
+ .hpd_update = &virtual_hpd_update,
}
};
diff --git a/board/cheza/board.h b/board/cheza/board.h
index 9998233356..84dd89ee4c 100644
--- a/board/cheza/board.h
+++ b/board/cheza/board.h
@@ -115,6 +115,7 @@
#define CONFIG_USB_PD_TRY_SRC
#define CONFIG_USB_PD_VBUS_DETECT_CHARGER
#define CONFIG_USB_PD_5V_EN_CUSTOM
+#define CONFIG_USB_MUX_VIRTUAL
#define CONFIG_USBC_PPC_SN5S330
#define CONFIG_USBC_SS_MUX
#define CONFIG_USBC_VCONN