ec_commands: Rename 'renew' to 'live' in EC_CMD_USB_PD_CHIP_INFO

Semantics of renew field in EC_CMD_USB_PD_CHIP_INFO is changing as
follows:
0 -> Return hard-coded info for Vendor ID/Product ID and cached info for
the Firmware Version
1 -> Return the live chip info for Vendor ID/Product ID/Firmware Version
Also rename the 'renew' field to 'live' to match the new semantics.

BUG=b:128820536,b:119046668
BRANCH=None
TEST=make -j buildall; Boot to ChromeOS.

Change-Id: Ie3dd022336b0be5c9728bb0ebabef32b7a6b5d57
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1617893
Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Commit-Queue: Karthikeyan Ramasubramanian <kramasub@chromium.org>
Auto-Submit: Karthikeyan Ramasubramanian <kramasub@chromium.org>
This commit is contained in:
Karthikeyan Ramasubramanian 2019-06-12 11:30:49 -06:00 committed by Commit Bot
parent 1251719cc5
commit 5936367096
11 changed files with 34 additions and 24 deletions

View File

@ -2880,7 +2880,8 @@ void pd_task(void *u)
if (!res) {
struct ec_response_pd_chip_info_v1 *info;
if (tcpm_get_chip_info(port, 0, &info) == EC_SUCCESS) {
if (tcpm_get_chip_info(port, 0, &info) ==
EC_SUCCESS) {
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);
@ -5569,7 +5570,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, p->renew, &info))
if (tcpm_get_chip_info(p->port, p->live, &info))
return EC_RES_ERROR;
/*

View File

@ -1099,17 +1099,17 @@ static int anx74xx_tcpm_init(int port)
return EC_SUCCESS;
}
static int anx74xx_get_chip_info(int port, int renew,
static int anx74xx_get_chip_info(int port, int live,
struct ec_response_pd_chip_info_v1 **chip_info)
{
int rv = tcpci_get_chip_info(port, renew, chip_info);
int rv = tcpci_get_chip_info(port, live, chip_info);
int val;
if (rv)
return rv;
if ((*chip_info)->fw_version_number == 0 ||
(*chip_info)->fw_version_number == -1 || renew) {
(*chip_info)->fw_version_number == -1 || live) {
rv = tcpc_read(port, ANX74XX_REG_FW_VERSION, &val);
if (rv)

View File

@ -577,7 +577,7 @@ static int it83xx_tcpm_transmit(int port,
return EC_SUCCESS;
}
static int it83xx_tcpm_get_chip_info(int port, int renew,
static int it83xx_tcpm_get_chip_info(int port, int live,
struct ec_response_pd_chip_info_v1 **chip_info)
{
static struct ec_response_pd_chip_info_v1 i;

View File

@ -131,17 +131,17 @@ static int ps8xxx_tcpm_release(int port)
return tcpci_tcpm_release(port);
}
static int ps8xxx_get_chip_info(int port, int renew,
static int ps8xxx_get_chip_info(int port, int live,
struct ec_response_pd_chip_info_v1 **chip_info)
{
int val;
int rv = tcpci_get_chip_info(port, renew, chip_info);
int rv = tcpci_get_chip_info(port, live, chip_info);
if (rv)
return rv;
if ((*chip_info)->fw_version_number == 0 ||
(*chip_info)->fw_version_number == -1 || renew) {
(*chip_info)->fw_version_number == -1 || live) {
rv = tcpc_read(port, FW_VER_REG, &val);
if (rv)

View File

@ -666,7 +666,7 @@ void tcpci_tcpc_alert(int port)
* Once it's called, the chip info 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, int renew,
int tcpci_get_chip_info(int port, int live,
struct ec_response_pd_chip_info_v1 **chip_info)
{
static struct ec_response_pd_chip_info_v1
@ -685,8 +685,8 @@ int tcpci_get_chip_info(int port, int renew,
if (chip_info)
*chip_info = i;
/* If already populated and renewal is not asked, return cache value */
if (i->vendor_id && !renew)
/* If already cached && live data is not asked, return cached value */
if (i->vendor_id && !live)
return EC_SUCCESS;
error = tcpc_read16(port, TCPC_REG_VENDOR_ID, &val);

View File

@ -161,7 +161,7 @@ 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_tcpm_mux_enter_low_power(int port);
int tcpci_get_chip_info(int port, int renew,
int tcpci_get_chip_info(int port, int live,
struct ec_response_pd_chip_info_v1 **chip_info);
#ifdef CONFIG_USBC_PPC
int tcpci_tcpm_set_snk_ctrl(int port, int enable);

View File

@ -238,11 +238,11 @@ static inline int tcpc_i2c_write__7bf(const int port, const uint16_t addr__7bf,
}
#endif
static inline int tcpm_get_chip_info(int port, int renew,
static inline int tcpm_get_chip_info(int port, int live,
struct ec_response_pd_chip_info_v1 **info)
{
if (tcpc_config[port].drv->get_chip_info)
return tcpc_config[port].drv->get_chip_info(port, renew, info);
return tcpc_config[port].drv->get_chip_info(port, live, info);
return EC_ERROR_UNIMPLEMENTED;
}

View File

@ -39,7 +39,7 @@ static int mock_tcpm_set_rx_enable(int port, int enable) { return EC_SUCCESS; }
static int mock_tcpm_transmit(int port, enum tcpm_transmit_type type,
uint16_t header, const uint32_t *data) { return EC_SUCCESS; }
static void mock_tcpc_alert(int port) {}
static int mock_tcpci_get_chip_info(int port, int renew,
static int mock_tcpci_get_chip_info(int port, int live,
struct ec_response_pd_chip_info_v1 **info)
{
return EC_ERROR_UNIMPLEMENTED;

View File

@ -5171,7 +5171,12 @@ struct ec_response_usb_pd_mux_info {
struct ec_params_pd_chip_info {
uint8_t port; /* USB-C port number */
uint8_t renew; /* Force renewal */
/*
* Fetch the live chip info or hard-coded + cached chip info
* 0: hardcoded value for VID/PID, cached value for FW version
* 1: live chip value for VID/PID/FW Version
*/
uint8_t live;
} __ec_align1;
struct ec_response_pd_chip_info {

View File

@ -270,12 +270,12 @@ struct tcpm_drv {
* Get firmware version.
*
* @param port Type-C port number
* @param renew Force renewal
* @param live Fetch live chip info or hard-coded + cached info
* @param info Pointer to pointer to PD chip info
*
* @return EC_SUCCESS or error
*/
int (*get_chip_info)(int port, int renew,
int (*get_chip_info)(int port, int live,
struct ec_response_pd_chip_info_v1 **info);
#ifdef CONFIG_USBC_PPC

View File

@ -8259,7 +8259,12 @@ int cmd_pd_chip_info(int argc, char *argv[])
int cmdver = 1;
if (argc < 2 || 3 < argc) {
fprintf(stderr, "Usage: %s <port> [renew(on/off)]\n", argv[0]);
fprintf(stderr, "Usage: %s <port> [<live>]\n"
"live parameter can take values 0 or 1\n"
"0 -> Return hard-coded value for VID/PID and\n"
" cached value for Firmware Version\n"
"1 -> Return live chip value for VID/PID/FW Version\n",
argv[0]);
return -1;
}
@ -8269,14 +8274,13 @@ int cmd_pd_chip_info(int argc, char *argv[])
return -1;
}
p.renew = 0;
p.live = 0;
if (argc == 3) {
int val;
if (!parse_bool(argv[2], &val)) {
p.live = strtol(argv[2], &e, 0);
if (e && *e) {
fprintf(stderr, "invalid arg \"%s\"\n", argv[2]);
return -1;
}
p.renew = val;
}
if (!ec_cmd_version_supported(EC_CMD_PD_CHIP_INFO, cmdver))