diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 216886d0c7..51133b741b 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -1648,7 +1648,7 @@ void pd_task(void) #ifndef CONFIG_USB_PD_TCPC if (!res) { struct ec_response_pd_chip_info *info; - tcpm_get_chip_info(port, &info); + tcpm_get_chip_info(port, 0, &info); CPRINTS("TCPC p%d VID:0x%x PID:0x%x DID:0x%x FWV:0x%lx", port, info->vendor_id, info->product_id, info->device_id, info->fw_version_number); @@ -3725,7 +3725,7 @@ static int hc_remote_pd_chip_info(struct host_cmd_handler_args *args) if (p->port >= CONFIG_USB_PD_PORT_COUNT) return EC_RES_INVALID_PARAM; - if (tcpm_get_chip_info(p->port, &info)) + if (tcpm_get_chip_info(p->port, p->renew, &info)) return EC_RES_ERROR; memcpy(r, info, sizeof(*r)); diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c index be98248e1f..cbbed9c05e 100644 --- a/driver/tcpm/tcpci.c +++ b/driver/tcpm/tcpci.c @@ -324,7 +324,8 @@ void tcpci_tcpc_alert(int port) * will be stored in cache, which can be accessed by tcpm_get_chip_info without * worrying about chip states. */ -int tcpci_get_chip_info(int port, struct ec_response_pd_chip_info **chip_info) +int tcpci_get_chip_info(int port, int renew, + struct ec_response_pd_chip_info **chip_info) { static struct ec_response_pd_chip_info info[CONFIG_USB_PD_PORT_COUNT]; struct ec_response_pd_chip_info *i; @@ -341,7 +342,8 @@ int tcpci_get_chip_info(int port, struct ec_response_pd_chip_info **chip_info) if (chip_info) *chip_info = i; - if (i->vendor_id) + /* If already populated and renewal is not asked, return cache value */ + if (i->vendor_id && !renew) return EC_SUCCESS; error = tcpc_read16(port, TCPC_REG_VENDOR_ID, &val); @@ -421,7 +423,7 @@ int tcpci_tcpm_init(int port) return error; /* Read chip info here when we know the chip is awake. */ - tcpm_get_chip_info(port, NULL); + tcpm_get_chip_info(port, 1, NULL); return EC_SUCCESS; } diff --git a/driver/tcpm/tcpci.h b/driver/tcpm/tcpci.h index a11050eaf0..ce1b082fca 100644 --- a/driver/tcpm/tcpci.h +++ b/driver/tcpm/tcpci.h @@ -137,6 +137,7 @@ int tcpci_tcpm_transmit(int port, enum tcpm_transmit_type type, int tcpci_tcpm_mux_init(int i2c_addr); int tcpci_tcpm_mux_set(int i2c_addr, mux_state_t mux_state); int tcpci_tcpm_mux_get(int i2c_addr, mux_state_t *mux_state); -int tcpci_get_chip_info(int port, struct ec_response_pd_chip_info **chip_info); +int tcpci_get_chip_info(int port, int renew, + struct ec_response_pd_chip_info **chip_info); #endif /* __CROS_EC_USB_PD_TCPM_TCPCI_H */ diff --git a/driver/tcpm/tcpm.h b/driver/tcpm/tcpm.h index 9f8e38cbfc..797a8c0dad 100644 --- a/driver/tcpm/tcpm.h +++ b/driver/tcpm/tcpm.h @@ -163,11 +163,11 @@ static inline int tcpc_i2c_write(const int port, const int addr, } #endif -static inline int tcpm_get_chip_info(int port, +static inline int tcpm_get_chip_info(int port, int renew, struct ec_response_pd_chip_info **info) { if (tcpc_config[port].drv->get_chip_info) - return tcpc_config[port].drv->get_chip_info(port, info); + return tcpc_config[port].drv->get_chip_info(port, renew, info); return EC_ERROR_UNIMPLEMENTED; } diff --git a/include/ec_commands.h b/include/ec_commands.h index d2ef825130..86fac1d45c 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -3999,6 +3999,7 @@ struct __ec_align1 ec_response_usb_pd_mux_info { struct __ec_align1 ec_params_pd_chip_info { uint8_t port; /* USB-C port number */ + uint8_t renew; /* Force renewal */ }; struct __ec_align2 ec_response_pd_chip_info { diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h index d95d994184..c8526239d1 100644 --- a/include/usb_pd_tcpm.h +++ b/include/usb_pd_tcpm.h @@ -202,11 +202,13 @@ struct tcpm_drv { * Get firmware version. * * @param port Type-C port number + * @param renew Force renewal * @param info Pointer to pointer to PD chip info * * @return EC_SUCCESS or error */ - int (*get_chip_info)(int port, struct ec_response_pd_chip_info **info); + int (*get_chip_info)(int port, int renew, + struct ec_response_pd_chip_info **info); }; enum tcpc_alert_polarity { diff --git a/util/ectool.c b/util/ectool.c index 2c9bda2f8e..3375935d4b 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -6872,8 +6872,8 @@ int cmd_pd_chip_info(int argc, char *argv[]) char *e; int rv; - if (argc < 2) { - fprintf(stderr, "Usage: %s \n", argv[0]); + if (argc < 2 || 3 < argc) { + fprintf(stderr, "Usage: %s [renew(on/off)]\n", argv[0]); return -1; } @@ -6883,6 +6883,16 @@ int cmd_pd_chip_info(int argc, char *argv[]) return -1; } + p.renew = 0; + if (argc == 3) { + int val; + if (!parse_bool(argv[2], &val)) { + fprintf(stderr, "invalid arg \"%s\"\n", argv[2]); + return -1; + } + p.renew = val; + } + rv = ec_command(EC_CMD_PD_CHIP_INFO, 0, &p, sizeof(p), &r, sizeof(r)); if (rv < 0) return rv;