diff options
author | xuxinxiong <xuxinxiong@huaqin.corp-partner.google.com> | 2021-08-18 17:02:30 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-08-25 03:05:36 +0000 |
commit | 5180bf06996a5e4cba957b85a66da1491ddc9fcc (patch) | |
tree | d5122cbbcb3bc17ea3bb5f2a54f8653d3692b8c3 | |
parent | dd057f600a4dd52a398a059e01bfaa67ac424e60 (diff) | |
download | chrome-ec-5180bf06996a5e4cba957b85a66da1491ddc9fcc.tar.gz |
Homestar: Distinguish PS8755 with hidden register
When TCPC PS8755 is upgraded to PS8805 firmware, the product id cannot
distinguish whether the chip is PS8755 or PS8805. Only the hidden
register value of PS8755 is 0x80, so use this hidden register to
distinguish whether it is PS8755.
BRANCH=trogdor
BUG=b:196889096
TEST=emerge-strongbad chromeos-ec
Change-Id: I99b50dfb2f5ae47c3d4dbb3334dcdae20c281478
Signed-off-by: xuxinxiong <xuxinxiong@huaqin.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3113261
Reviewed-by: Wai-Hong Tam <waihong@google.com>
Reviewed-by: wen zhang <zhangwen6@huaqin.corp-partner.google.com>
Commit-Queue: Wai-Hong Tam <waihong@google.com>
-rw-r--r-- | board/homestar/board.c | 4 | ||||
-rw-r--r-- | driver/tcpm/ps8xxx.c | 15 | ||||
-rw-r--r-- | driver/tcpm/ps8xxx.h | 11 |
3 files changed, 30 insertions, 0 deletions
diff --git a/board/homestar/board.c b/board/homestar/board.c index 8d277c4793..8292a697ce 100644 --- a/board/homestar/board.c +++ b/board/homestar/board.c @@ -450,6 +450,10 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); __overridable uint16_t board_get_ps8xxx_product_id(int port) { + /* Check if the chip is PS8755 for rev-0, rev-1 and rev-2 */ + if (system_get_board_version() < 3 && check_ps8755_chip(port)) + return PS8755_PRODUCT_ID; + return PS8805_PRODUCT_ID; } diff --git a/driver/tcpm/ps8xxx.c b/driver/tcpm/ps8xxx.c index 51b6c4c412..37bfb30cc0 100644 --- a/driver/tcpm/ps8xxx.c +++ b/driver/tcpm/ps8xxx.c @@ -367,6 +367,21 @@ uint16_t board_get_ps8xxx_product_id(int port) return 0; } +bool check_ps8755_chip(int port) +{ + int val; + int p0_addr; + int status; + bool is_ps8755 = false; + + p0_addr = PS8751_P3_TO_P0_FLAGS(tcpc_config[port].i2c_info.addr_flags); + status = tcpc_addr_read(port, p0_addr, PS8755_P0_REG_SM, &val); + if (status == EC_SUCCESS && val == PS8755_P0_REG_SM_VALUE) + is_ps8755 = true; + + return is_ps8755; +} + void ps8xxx_tcpc_update_hpd_status(const struct usb_mux *me, int hpd_lvl, int hpd_irq) { diff --git a/driver/tcpm/ps8xxx.h b/driver/tcpm/ps8xxx.h index b27946dc1e..8458dbb7e5 100644 --- a/driver/tcpm/ps8xxx.h +++ b/driver/tcpm/ps8xxx.h @@ -45,6 +45,9 @@ #define PS8XXX_P1_REG_MUX_USB_DCI_CFG 0x4B +#define PS8755_P0_REG_SM 0x06 +#define PS8755_P0_REG_SM_VALUE 0x80 + #if defined(CONFIG_USB_PD_TCPM_PS8751) /* Vendor defined registers */ #define PS8XXX_REG_VENDOR_ID_L 0x00 @@ -124,6 +127,14 @@ int ps8805_gpio_set_level(int port, enum ps8805_gpio signal, int level); */ int ps8805_gpio_get_level(int port, enum ps8805_gpio signal, int *level); +/** + * Check if the chip is PS8755 + * + * @param port: The Type-C port number. + * @return true if hidden register sm is 0x80 + */ +bool check_ps8755_chip(int port); + /* * Allow boards to customize for PS8XXX initial if board has * specific settings. |