diff options
author | Lee, Shawn C <shawn.c.lee@intel.com> | 2019-02-17 18:50:54 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-09-12 21:59:13 +0000 |
commit | 89267691e5cce30ef80fd1d1b1c360d912db30cf (patch) | |
tree | 3e7a2c5cd0c9ea0c3f4c1869c455d8c1ce321a54 /driver | |
parent | 8f47673f345df83c67e930113043c45d1c698b44 (diff) | |
download | chrome-ec-89267691e5cce30ef80fd1d1b1c360d912db30cf.tar.gz |
anx7447: Add proper mux setting for DP alt mode and DTS mode (CCD)
This patch must be with removing the external 100k pull up/down
resistors on the Aux P/Aux N lines which avoids the 3.3V DC bias
voltage adds 0.8V pulse of aux channel to turn on TCPC internal
P-MOSFET that causes the signal effect on CCD communication.
BUG=b:124410548
BRANCH=None
TEST=Connect external monitor,usb device or CCD cable to type-c port0
Each type-c device should work normally.
Signed-off-by: Xin Ji <xji@analogixsemi.com>
Signed-off-by: Jack Lai <jack.lai@intel.com>
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Zhuohao Lee <zhuohao@chromium.org>
Commit-Queue: Zhuohao Lee <zhuohao@chromium.org>
Tested-by: Zhuohao Lee <zhuohao@chromium.org>
Change-Id: Ic920c83232163292c3d6dbfce1b23a8e3a1c6b6e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1680664
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Commit-Queue: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/tcpm/anx7447.c | 68 | ||||
-rw-r--r-- | driver/tcpm/anx7447.h | 4 |
2 files changed, 70 insertions, 2 deletions
diff --git a/driver/tcpm/anx7447.c b/driver/tcpm/anx7447.c index d8c3cece6f..ebefe785cc 100644 --- a/driver/tcpm/anx7447.c +++ b/driver/tcpm/anx7447.c @@ -361,6 +361,15 @@ static int anx7447_init(int port) reg |= ANX7447_REG_R_VCONN_PWR_PRT_INRUSH_TIME_2430US; rv = tcpc_write(port, ANX7447_REG_ANALOG_CTRL_10, reg); +#ifdef CONFIG_USB_PD_TCPM_MUX + /* + * Run mux_set() here for considering CCD(Case-Closed Debugging) case + * If this TCPC is not also the MUX then don't initialize to NONE + */ + if (!(usb_muxes[port].flags & USB_MUX_FLAG_NOT_TCPC)) + rv |= anx7447_mux_set(port, TYPEC_MUX_NONE); +#endif /* CONFIG_USB_PD_TCPM_MUX */ + return rv; } @@ -497,6 +506,41 @@ static int anx7447_mux_init(int port) return anx7447_mux_set(port, TYPEC_MUX_NONE); } +#ifdef CONFIG_USB_PD_TCPM_ANX7447_AUX_PU_PD +static void anx7447_mux_safemode(int port, int on_off) +{ + int reg; + + mux_read(port, ANX7447_REG_ANALOG_CTRL_9, ®); + + if (on_off) + reg |= ANX7447_REG_SAFE_MODE; + else + reg &= ~(ANX7447_REG_SAFE_MODE); + + mux_write(port, ANX7447_REG_ANALOG_CTRL_9, reg); + CPRINTS("C%d set mux to safemode %s, reg = 0x%x", + port, (on_off) ? "on" : "off", reg); +} + +static inline void anx7447_configure_aux_src(int port, int on_off) +{ + int reg; + + mux_read(port, ANX7447_REG_ANALOG_CTRL_9, ®); + + if (on_off) + reg |= ANX7447_REG_R_AUX_RES_PULL_SRC; + else + reg &= ~(ANX7447_REG_R_AUX_RES_PULL_SRC); + + mux_write(port, ANX7447_REG_ANALOG_CTRL_9, reg); + + CPRINTS("C%d set aux_src to %s, reg = 0x%x", + port, (on_off) ? "on" : "off", reg); +} +#endif + /* * Set mux. * @@ -515,8 +559,8 @@ static int anx7447_mux_set(int port, mux_state_t mux_state) cc_direction = mux_state & MUX_POLARITY_INVERTED; mux_type = mux_state & TYPEC_MUX_DOCK; - CPRINTS("mux_state = 0x%x, mux_type = 0x%x", mux_state, mux_type); - + CPRINTS("C%d mux_state = 0x%x, mux_type = 0x%x", + port, mux_state, mux_type); if (cc_direction == 0) { /* cc1 connection */ if (mux_type == TYPEC_MUX_DOCK) { @@ -550,12 +594,32 @@ static int anx7447_mux_set(int port, mux_state_t mux_state) sw_sel = 0x10; } } + + /* + * Once need to configure the Mux, should set the mux to safe mode + * first. After the mux configured, should set mux to normal mode. + */ +#ifdef CONFIG_USB_PD_TCPM_ANX7447_AUX_PU_PD + anx7447_mux_safemode(port, 1); +#endif rv = mux_write(port, ANX7447_REG_TCPC_SWITCH_0, sw_sel); rv |= mux_write(port, ANX7447_REG_TCPC_SWITCH_1, sw_sel); rv |= mux_write(port, ANX7447_REG_TCPC_AUX_SWITCH, aux_sw); mux[port].state = mux_state; +#ifdef CONFIG_USB_PD_TCPM_ANX7447_AUX_PU_PD + /* + * DP and Dock mode: after configured the Mux, change the Mux to + * normal mode, otherwise: keep safe mode. + */ + if (mux_type != TYPEC_MUX_NONE) { + anx7447_configure_aux_src(port, 1); + anx7447_mux_safemode(port, 0); + } else + anx7447_configure_aux_src(port, 0); +#endif + return rv; } diff --git a/driver/tcpm/anx7447.h b/driver/tcpm/anx7447.h index f4827180da..4da300884c 100644 --- a/driver/tcpm/anx7447.h +++ b/driver/tcpm/anx7447.h @@ -49,6 +49,10 @@ #define ANX7447_REG_R_VCONN_PWR_PRT_INRUSH_TIME_1210US 0x30 #define ANX7447_REG_R_VCONN_PWR_PRT_INRUSH_TIME_2430US 0x38 +#define ANX7447_REG_ANALOG_CTRL_9 0xA9 +#define ANX7447_REG_SAFE_MODE 0x80 +#define ANX7447_REG_R_AUX_RES_PULL_SRC 0x20 + /* * This section of defines are only required to support the config option * CONFIG_USB_PD_TCPM_ANX7447_OCM_ERASE_COMMAND. |