From b8c7e589114d1461cf351c72b2157d83a06020cf Mon Sep 17 00:00:00 2001 From: Ruibin Chang Date: Mon, 21 Sep 2020 18:01:19 +0800 Subject: driver/it83xx: change Rd_DB to Rd_5.1k in EC hibernate We change Rd_DB to Rd_5.1k in EC hibernate. HW auto asserts Rd_DB on CCs when EC is power off. BUG=none BRANCH=none TEST=on board reef_it8320 and it8320_evb, in EC hibernate mode: 1.can wakeup by AC plug in, then pd state to SNK_READY. 2.Rd_5.1k power consumption is more 1uA than Rd_DB. Signed-off-by: Ruibin Chang Change-Id: I2d78838c9076dbe36a5d27204207c9da7cad9948 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2423668 Tested-by: Ruibin Chang Reviewed-by: Jett Rink Commit-Queue: Ruibin Chang --- chip/it83xx/clock.c | 2 +- driver/tcpm/it83xx.c | 32 ++++++++++++++++++++++---------- driver/tcpm/it83xx_pd.h | 4 +--- driver/tcpm/it8xxx2.c | 2 +- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/chip/it83xx/clock.c b/chip/it83xx/clock.c index 25486c1e3b..d38197379a 100644 --- a/chip/it83xx/clock.c +++ b/chip/it83xx/clock.c @@ -515,7 +515,7 @@ void __enter_hibernate(uint32_t seconds, uint32_t microseconds) * Rd_DB) alive in hibernate for better power consumption. */ for (i = 0; i < CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT; i++) - it83xx_disable_pd_module(i); + it83xx_Rd_5_1K_only_for_hibernate(i); } if (IS_ENABLED(CONFIG_ADC_VOLTAGE_COMPARATOR)) { diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c index 8e6abbc15b..3327cfdfed 100644 --- a/driver/tcpm/it83xx.c +++ b/driver/tcpm/it83xx.c @@ -47,22 +47,34 @@ const struct usbpd_ctrl_t usbpd_ctrl_regs[] = { BUILD_ASSERT(ARRAY_SIZE(usbpd_ctrl_regs) == IT83XX_USBPD_PHY_PORT_COUNT); /* - * This function disables integrated pd module and enables 5.1K resistor for - * dead battery. A EC reset or calling _init() is able to re-active pd module. + * Disable cc analog and pd digital module, but only left Rd_5.1K (Not + * Dead Battery) analog module alive to assert Rd on CCs. EC reset or + * calling _init() are able to re-active cc and pd. */ -void it83xx_disable_pd_module(int port) +void it83xx_Rd_5_1K_only_for_hibernate(int port) { - /* This only apply to PD port. */ + /* This only apply to active PD port */ if (*usbpd_ctrl_regs[port].cc1 == IT83XX_USBPD_CC_PIN_CONFIG && *usbpd_ctrl_regs[port].cc2 == IT83XX_USBPD_CC_PIN_CONFIG) { /* Disable PD PHY */ IT83XX_USBPD_GCR(port) &= ~(BIT(0) | BIT(4)); - /* Power down CC1/CC2 */ - IT83XX_USBPD_CCGCR(port) |= 0x1f; - /* Disable CC1/CC2 voltage detector */ - IT83XX_USBPD_CCCSR(port) = 0xff; - /* Connect 5.1K resistor to CC1/CC2 for dead battery. */ - IT83XX_USBPD_CCPSR(port) = 0x33; + /* + * Disable CCs voltage detector, and + * connect CCs analog module (ex.UP/RD/DET/TX/RX), and + * connect CCs 5.1K to GND + */ + IT83XX_USBPD_CCCSR(port) = 0x22; + /* Disconnect CCs 5V tolerant */ + IT83XX_USBPD_CCPSR(port) |= + (USBPD_REG_MASK_DISCONNECT_POWER_CC2 | + USBPD_REG_MASK_DISCONNECT_POWER_CC1); + /* + * Select Rp reserved value for not current leakage, and + * CCs assert Rd, and + * enable CCs analog module + */ + IT83XX_USBPD_BMCSR(port) &= ~0x08; + IT83XX_USBPD_CCGCR(port) &= ~0x1f; } } diff --git a/driver/tcpm/it83xx_pd.h b/driver/tcpm/it83xx_pd.h index aac418f791..b04570a65d 100644 --- a/driver/tcpm/it83xx_pd.h +++ b/driver/tcpm/it83xx_pd.h @@ -398,9 +398,7 @@ struct usbpd_ctrl_t { extern const struct usbpd_ctrl_t usbpd_ctrl_regs[]; extern const struct tcpm_drv it83xx_tcpm_drv; -/* Disable cc module */ -void it83xx_disable_cc_module(int port); -void it83xx_disable_pd_module(int port); +void it83xx_Rd_5_1K_only_for_hibernate(int port); #ifdef CONFIG_USB_PD_TCPM_DRIVER_IT8XXX2 void it83xx_clear_tx_error_status(enum usbpd_port port); void it83xx_get_tx_error_status(enum usbpd_port port); diff --git a/driver/tcpm/it8xxx2.c b/driver/tcpm/it8xxx2.c index 321f9c0633..50339393f6 100644 --- a/driver/tcpm/it8xxx2.c +++ b/driver/tcpm/it8xxx2.c @@ -55,7 +55,7 @@ BUILD_ASSERT(ARRAY_SIZE(usbpd_ctrl_regs) >= IT83XX_USBPD_PHY_PORT_COUNT); * Rd_DB) analog module alive to assert Rd on CCs. EC reset or calling * _init() are able to re-active cc and pd. */ -void it83xx_disable_pd_module(int port) +void it83xx_Rd_5_1K_only_for_hibernate(int port) { uint8_t cc_config = (port == USBPD_PORT_C ? IT83XX_USBPD_CC_PIN_CONFIG2 : -- cgit v1.2.1