diff options
author | Paul Moy <pmoy@chromium.org> | 2018-10-18 14:56:14 -0600 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-10-23 02:55:33 -0700 |
commit | 9b28515c5bf8a9274f414ab319d9504b388812b4 (patch) | |
tree | 28102a4c8ad958df0c13ed7e18efd23cac639ce2 | |
parent | a9b454f3f8f28bf4bb556d9467c730b255af329b (diff) | |
download | chrome-ec-9b28515c5bf8a9274f414ab319d9504b388812b4.tar.gz |
tcpm: cache the firmware version for anx74xx and ps8xxx chips.
All chip info for the anx74xx and ps8xxx chips should be cached
after the first read, so that the info can be accessed in the
future without worrying about chip state. Now that we check the
version registers for these two chips, we need to cache that
information as well.
BRANCH=none
BUG=b:117301622
TEST=on warm reboot with GBB flags cleared, cbmem -t shows
the EC verification stage taking ~30ms instead of ~65ms.
Change-Id: I6077438b58e64b66a23db2992ba025ae3a864c19
Signed-off-by: Paul Moy <pmoy@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1291794
Commit-Ready: Martin Roth <martinroth@chromium.org>
Reviewed-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r-- | driver/tcpm/anx74xx.c | 16 | ||||
-rw-r--r-- | driver/tcpm/ps8xxx.c | 16 |
2 files changed, 14 insertions, 18 deletions
diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c index 22f1f51e77..4ad5eb67c0 100644 --- a/driver/tcpm/anx74xx.c +++ b/driver/tcpm/anx74xx.c @@ -746,11 +746,6 @@ static int anx74xx_tcpm_set_polarity(int port, int polarity) return rv; } -static int anx74xx_tcpc_get_fw_version(int port, int *version) -{ - return tcpc_read(port, ANX74XX_REG_FW_VERSION, version); -} - static int anx74xx_tcpm_set_vconn(int port, int enable) { int reg, rv = EC_SUCCESS; @@ -1053,12 +1048,15 @@ static int anx74xx_get_chip_info(int port, int renew, if (rv) return rv; - rv = anx74xx_tcpc_get_fw_version(port, &val); + if ((*chip_info)->fw_version_number == 0 || + (*chip_info)->fw_version_number == -1 || renew) { + rv = tcpc_read(port, ANX74XX_REG_FW_VERSION, &val); - if (rv) - return rv; + if (rv) + return rv; - (*chip_info)->fw_version_number = val; + (*chip_info)->fw_version_number = val; + } #ifdef CONFIG_USB_PD_TCPM_ANX3429 /* diff --git a/driver/tcpm/ps8xxx.c b/driver/tcpm/ps8xxx.c index e6649a61c1..3bf2ab5b12 100644 --- a/driver/tcpm/ps8xxx.c +++ b/driver/tcpm/ps8xxx.c @@ -87,11 +87,6 @@ void ps8xxx_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq) hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL; } -static int ps8xxx_tcpc_get_fw_version(int port, int *version) -{ - return tcpc_read(port, FW_VER_REG, version); -} - static int ps8xxx_tcpc_bist_mode_2(int port) { int rv; @@ -145,12 +140,15 @@ static int ps8xxx_get_chip_info(int port, int renew, if (rv) return rv; - rv = ps8xxx_tcpc_get_fw_version(port, &val); + if ((*chip_info)->fw_version_number == 0 || + (*chip_info)->fw_version_number == -1 || renew) { + rv = tcpc_read(port, FW_VER_REG, &val); - if (rv) - return rv; + if (rv) + return rv; - (*chip_info)->fw_version_number = val; + (*chip_info)->fw_version_number = val; + } #if defined(CONFIG_USB_PD_TCPM_PS8751) && \ defined(CONFIG_USB_PD_VBUS_DETECT_TCPC) |