diff options
author | Gene Chen <gene_chen@mediatek.corp-partner.google.com> | 2019-09-04 16:48:46 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-09-17 14:54:06 +0000 |
commit | 5e333117e96fd78d48fc1be632c43e8bcb6d9df5 (patch) | |
tree | 19d9d1e27e8226d9187201771136d4cf46ec3cec /driver/tcpm/mt6370.c | |
parent | 4a0ad118628467805340d6ea4739b9669bd19ba2 (diff) | |
download | chrome-ec-5e333117e96fd78d48fc1be632c43e8bcb6d9df5.tar.gz |
tcpc/mt6370: Change rp_def level and enable rx deadzone as sink
Change rp_def level and enable rx deadzone as sink
BUG=b:139400105
BRANCH=None
TEST=Run "TDA.2.1.2.2 BMC PHY RX INT REJ" pass
Change-Id: Ieb684f7a3d38e3b36aab9bcf27cbc823b5a7df39
Signed-off-by: Gene Chen <gene_chen@mediatek.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1784269
Reviewed-by: Yilun Lin <yllin@chromium.org>
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Commit-Queue: Sean Abraham <seanabraham@chromium.org>
Diffstat (limited to 'driver/tcpm/mt6370.c')
-rw-r--r-- | driver/tcpm/mt6370.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/driver/tcpm/mt6370.c b/driver/tcpm/mt6370.c index cad8a7fbbc..8a50b480f6 100644 --- a/driver/tcpm/mt6370.c +++ b/driver/tcpm/mt6370.c @@ -19,6 +19,8 @@ #define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) #define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args) +static int mt6370_polarity; + /* i2c_write function which won't wake TCPC from low power mode. */ static int mt6370_i2c_write8(int port, int reg, int val) { @@ -71,6 +73,23 @@ static int mt6370_init(int port) return rv; } +static inline int mt6370_init_cc_params(int port, int cc_res) +{ + int rv, en, sel; + + if (cc_res == TYPEC_CC_VOLT_RP_DEF) { /* RXCC threshold : 0.55V */ + en = 1; + sel = MT6370_OCCTRL_600MA | MT6370_MASK_BMCIO_RXDZSEL; + } else { /* RD threshold : 0.4V & RP threshold : 0.7V */ + en = 0; + sel = MT6370_OCCTRL_600MA; + } + rv = tcpc_write(port, MT6370_REG_BMCIO_RXDZEN, en); + if (!rv) + rv = tcpc_write(port, MT6370_REG_BMCIO_RXDZSEL, sel); + return rv; +} + static int mt6370_get_cc(int port, enum tcpc_cc_voltage_status *cc1, enum tcpc_cc_voltage_status *cc2) { @@ -113,9 +132,17 @@ static int mt6370_get_cc(int port, enum tcpc_cc_voltage_status *cc1, *cc2 |= 0x04; } + rv = mt6370_init_cc_params(port, (int)mt6370_polarity ? *cc1 : *cc2); return rv; } +static int mt6370_set_cc(int port, int pull) +{ + if (pull == TYPEC_CC_RD) + mt6370_init_cc_params(port, TYPEC_CC_VOLT_RP_DEF); + return tcpci_tcpm_set_cc(port, pull); +} + #ifdef CONFIG_USB_PD_TCPC_LOW_POWER static int mt6370_enter_low_power_mode(int port) { @@ -132,6 +159,15 @@ static int mt6370_enter_low_power_mode(int port) } #endif +static int mt6370_set_polarity(int port, int polarity) +{ + enum tcpc_cc_voltage_status cc1, cc2; + + mt6370_polarity = polarity; + mt6370_get_cc(port, &cc1, &cc2); + return tcpci_tcpm_set_polarity(port, polarity); +} + int mt6370_vconn_discharge(int port) { /* @@ -157,8 +193,8 @@ const struct tcpm_drv mt6370_tcpm_drv = { .get_vbus_level = &tcpci_tcpm_get_vbus_level, #endif .select_rp_value = &tcpci_tcpm_select_rp_value, - .set_cc = &tcpci_tcpm_set_cc, - .set_polarity = &tcpci_tcpm_set_polarity, + .set_cc = &mt6370_set_cc, + .set_polarity = &mt6370_set_polarity, .set_vconn = &tcpci_tcpm_set_vconn, .set_msg_header = &tcpci_tcpm_set_msg_header, .set_rx_enable = &tcpci_tcpm_set_rx_enable, |