summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2017-03-13 16:01:53 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-03-16 18:06:59 -0700
commit1851495eb2bea80c49f8e5a4951a003088e960f6 (patch)
treea231b773995a4dcaf6a4fdf11ae6e80a1ee7d59b
parent391056f9eea24cf19bc7d1571d7db18a3d0ae683 (diff)
downloadchrome-ec-1851495eb2bea80c49f8e5a4951a003088e960f6.tar.gz
tcpm: Call usb_mux board_init on exit from low power mode
PS8751 does not restore all register contents when resuming from low power mode. This change makes tcpm call board_init when it stops auto-toggling so that register contents can be restored. BUG=b:35585399 BRACH=none TEST=On Snappy, the board_init funciton is called every time a device is plugged in and register contents are restored. Change-Id: I50c51334f43c02e3c4d8453e1e966bf6eb3ce769 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/454139 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--board/reef/board.c13
-rw-r--r--common/usb_pd_protocol.c9
-rw-r--r--driver/tcpm/anx74xx.c5
-rw-r--r--driver/tcpm/ps8751.h2
-rw-r--r--driver/tcpm/tcpci.c12
-rw-r--r--driver/tcpm/tcpm.h4
-rw-r--r--include/usb_mux.h3
-rw-r--r--include/usb_pd_tcpm.h3
8 files changed, 38 insertions, 13 deletions
diff --git a/board/reef/board.c b/board/reef/board.c
index c0ba7c3667..c39a038aa4 100644
--- a/board/reef/board.c
+++ b/board/reef/board.c
@@ -279,6 +279,14 @@ const enum gpio_signal hibernate_wake_pins[] = {
const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
+static int ps8751_tune_mux(const struct usb_mux *mux)
+{
+ /* 0x98 sets lower EQ of DP port (4.5db) */
+ i2c_write8(NPCX_I2C_PORT0_1, 0x16, PS8751_REG_MUX_DP_EQ_CONFIGURATION,
+ 0x98);
+ return EC_SUCCESS;
+}
+
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
{
.port_addr = USB_PD_PORT_ANX74XX, /* don't care / unused */
@@ -289,6 +297,7 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
.port_addr = USB_PD_PORT_PS8751,
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8751_tcpc_update_hpd_status,
+ .board_init = &ps8751_tune_mux,
}
};
@@ -375,10 +384,6 @@ void board_tcpc_init(void)
mux->hpd_update(port, 0, 0);
}
-
- /* 0x98 sets lower EQ of DP port (4.5db) */
- i2c_write8(NPCX_I2C_PORT0_1, 0x16, PS8751_REG_MUX_DP_EQ_Configuration,
- 0x98);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 84c4ba9acd..1447dccc71 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -2954,6 +2954,13 @@ defined(CONFIG_CASE_CLOSED_DEBUG_EXTERNAL)
/* Anything else, keep toggling */
next_state = PD_STATE_DRP_AUTO_TOGGLE;
+ if (next_state != PD_STATE_DRP_AUTO_TOGGLE) {
+ tcpm_set_drp_toggle(port, 0);
+#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
+ CPRINTS("TCPC p%d Exit Low Power Mode", port);
+#endif
+ }
+
if (next_state == PD_STATE_SNK_DISCONNECTED) {
tcpm_set_cc(port, TYPEC_CC_RD);
pd[port].power_role = PD_ROLE_SINK;
@@ -2963,7 +2970,7 @@ defined(CONFIG_CASE_CLOSED_DEBUG_EXTERNAL)
pd[port].power_role = PD_ROLE_SOURCE;
timeout = 2*MSEC;
} else {
- tcpm_set_drp_toggle(port);
+ tcpm_set_drp_toggle(port, 1);
pd[port].flags |= PD_FLAGS_TCPC_DRP_TOGGLE;
timeout = -1;
#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c
index e3d7d081e7..128890a8dd 100644
--- a/driver/tcpm/anx74xx.c
+++ b/driver/tcpm/anx74xx.c
@@ -632,8 +632,11 @@ void anx74xx_handle_power_mode(int port, int mode)
}
}
-static int anx74xx_tcpc_drp_toggle(int port)
+static int anx74xx_tcpc_drp_toggle(int port, int enable)
{
+ if (!enable)
+ /* TODO: Switch to normal mode here (Issue 702277) */
+ return EC_SUCCESS;
anx74xx_handle_power_mode(port, ANX74XX_STANDBY_MODE);
return EC_SUCCESS;
}
diff --git a/driver/tcpm/ps8751.h b/driver/tcpm/ps8751.h
index 0b91572c34..9dd922208a 100644
--- a/driver/tcpm/ps8751.h
+++ b/driver/tcpm/ps8751.h
@@ -18,7 +18,7 @@
#define PS8751_REG_CTRL_1 0xD0
#define PS8751_REG_CTRL_1_HPD (1 << 0)
#define PS8751_REG_CTRL_1_IRQ (1 << 1)
-#define PS8751_REG_MUX_DP_EQ_Configuration 0xD3
+#define PS8751_REG_MUX_DP_EQ_CONFIGURATION 0xD3
#define PS8751_REG_MUX_USB_C2SS_EQ 0xe7
#define PS8751_REG_MUX_USB_C2SS_HS_THRESHOLD 0xe8
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index cbbed9c05e..8da8bdd532 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -127,10 +127,18 @@ int tcpci_tcpm_set_cc(int port, int pull)
}
#ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE
-static int tcpci_tcpc_drp_toggle(int port)
+static int tcpci_tcpc_drp_toggle(int port, int enable)
{
int rv;
+ if (!enable) {
+#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
+ struct usb_mux *mux = &usb_muxes[port];
+ if (mux->board_init)
+ return mux->board_init(mux);
+#endif
+ return EC_SUCCESS;
+ }
/* Set auto drp toggle */
rv = set_role_ctrl(port, 1, TYPEC_RP_USB, TYPEC_CC_OPEN);
@@ -507,7 +515,7 @@ const struct tcpm_drv tcpci_tcpm_drv = {
.tcpc_discharge_vbus = &tcpci_tcpc_discharge_vbus,
#endif
#ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE
- .drp_toggle = &tcpci_tcpc_drp_toggle,
+ .drp_toggle = &tcpci_tcpc_drp_toggle,
#endif
.get_chip_info = &tcpci_get_chip_info,
};
diff --git a/driver/tcpm/tcpm.h b/driver/tcpm/tcpm.h
index 797a8c0dad..71af9361f9 100644
--- a/driver/tcpm/tcpm.h
+++ b/driver/tcpm/tcpm.h
@@ -143,9 +143,9 @@ static inline int tcpm_auto_toggle_supported(int port)
return !!tcpc_config[port].drv->drp_toggle;
}
-static inline int tcpm_set_drp_toggle(int port)
+static inline int tcpm_set_drp_toggle(int port, int enable)
{
- return tcpc_config[port].drv->drp_toggle(port);
+ return tcpc_config[port].drv->drp_toggle(port, enable);
}
#endif
diff --git a/include/usb_mux.h b/include/usb_mux.h
index c9bd76ba21..5e1fb6945a 100644
--- a/include/usb_mux.h
+++ b/include/usb_mux.h
@@ -71,7 +71,8 @@ struct usb_mux {
/**
* Board specific initialization for USB mux that is
- * called after mux->driver->init() function.
+ * called after mux->driver->init() function and every time the port
+ * leaves auto-toggle state.
*
* @param mux USB mux to tune
* @return EC_SUCCESS on success, non-zero error code on failure.
diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h
index c8526239d1..fe5d6232e6 100644
--- a/include/usb_pd_tcpm.h
+++ b/include/usb_pd_tcpm.h
@@ -192,10 +192,11 @@ struct tcpm_drv {
* Enable TCPC auto DRP toggling.
*
* @param port Type-C port number
+ * @param enable 1: Enable 0: Disable
*
* @return EC_SUCCESS or error
*/
- int (*drp_toggle)(int port);
+ int (*drp_toggle)(int port, int enable);
#endif
/**