mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 18:11:05 +00:00
pdchipinfo: Add option to force renewal
This change adds an option to pdchipinfo command to force ec to get the version from the chip instead of the cache (if it's available). This option will be used after firmware update, which makes the cache value stale. BUG=chrome-os-partner:62383 BRANCH=none TEST=Run ectool as follows: localhost ~ # /tmp/ectool pdchipinfo 0 on vendor_id: 0xaaaa product_id: 0x3429 device_id: 0xad fw_version: 0x15 localhost ~ # /tmp/ectool pdchipinfo 1 on EC result 2 (ERROR) Change-Id: Icefe96d7fc1208b991a4caa13aaf4f04052edba7 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/441271 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
c9ea4bddbc
commit
4d6eb1bc01
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -6872,8 +6872,8 @@ int cmd_pd_chip_info(int argc, char *argv[])
|
||||
char *e;
|
||||
int rv;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage: %s <port>\n", argv[0]);
|
||||
if (argc < 2 || 3 < argc) {
|
||||
fprintf(stderr, "Usage: %s <port> [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;
|
||||
|
||||
Reference in New Issue
Block a user