diff options
author | arthur.lin <arthur.lin@lcfc.corp-partner.google.com> | 2022-05-09 23:41:51 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-05-18 04:19:52 +0000 |
commit | ba7d794b0f708c902cb1f8ea4bddeb1aa372285a (patch) | |
tree | 3213de1fcac1729afdc51a64a9ccbaa29561b592 /driver/tcpm/anx7447.c | |
parent | ef6873604e8495e9800593fdc6eab14f0263f279 (diff) | |
download | chrome-ec-ba7d794b0f708c902cb1f8ea4bddeb1aa372285a.tar.gz |
anx7447: Read ANX7447 firmware version
Add ANX7447 firmware version reading for new adding PD firmware.
BUG=b:227705897
BRANCH=None
TEST=make buildall -j
Signed-off-by: arthur.lin <arthur.lin@lcfc.corp-partner.google.com>
Change-Id: I0eeedf9059bda8fead8cc05405dac4723da9d0e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3635937
Reviewed-by: Marco Chen <marcochen@chromium.org>
Tested-by: Jimmy Wu <jimmy.wu@lcfc.corp-partner.google.com>
Diffstat (limited to 'driver/tcpm/anx7447.c')
-rw-r--r-- | driver/tcpm/anx7447.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/driver/tcpm/anx7447.c b/driver/tcpm/anx7447.c index 2bcfab4a92..8eaa478f1c 100644 --- a/driver/tcpm/anx7447.c +++ b/driver/tcpm/anx7447.c @@ -847,6 +847,34 @@ static void anx7447_dump_registers(int port) } #endif /* defined(CONFIG_CMD_TCPC_DUMP) */ + +static int anx7447_get_chip_info(int port, int live, + struct ec_response_pd_chip_info_v1 *chip_info) +{ + int rv = tcpci_get_chip_info(port, live, chip_info); + int val; + + if (rv) + return rv; + + if (chip_info->fw_version_number == -1 || live) { + /* + * Before reading ANX7447 SPI slave address 0x7e for + * new added FW version, need to read ANX7447 I2c + * slave address 0x58 first to wake up ANX7447. + */ + tcpc_read(port, ANX7447_REG_OCM_VERSION, &val); + rv = anx7447_reg_read(port, ANX7447_REG_OCM_VERSION, &val); + + if (rv) + return rv; + if (val != 0) + chip_info->fw_version_number = val; + } + + return rv; +} + /* * ANX7447 is a TCPCI compatible port controller, with some caveats. * It seems to require both CC lines to be set always, instead of just @@ -880,7 +908,7 @@ const struct tcpm_drv anx7447_tcpm_drv = { #ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE .drp_toggle = anx7447_tcpc_drp_toggle, #endif - .get_chip_info = &tcpci_get_chip_info, + .get_chip_info = &anx7447_get_chip_info, .set_snk_ctrl = &tcpci_tcpm_set_snk_ctrl, .set_src_ctrl = &tcpci_tcpm_set_src_ctrl, #ifdef CONFIG_USB_PD_TCPC_LOW_POWER |