summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2017-02-10 14:11:54 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2017-02-22 03:24:44 +0000
commit7adcb9eeac6a2fc6e4ff10bf6ab4dae841f4d5df (patch)
treef0c1a9dfdb862c5f39c97bddac084119f15726f9
parent14575cec09ca0a63a13722675a63b6c3406fc0c2 (diff)
downloadchrome-ec-7adcb9eeac6a2fc6e4ff10bf6ab4dae841f4d5df.tar.gz
pdchipinfo: Increase compatibility of fw_version
The firmware version formats may vary chip to chip. fw_version field is changed to a union of a 8 byte string and an 64-bit integer. BUG=chrome-os-partner:62383 BRANCH=none TEST=ectool pdchipinfo 0/1 on Electro Change-Id: Id51e66c44338a09ed897ee61f54cd6a394400e63 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/441270 Reviewed-on: https://chromium-review.googlesource.com/446069 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
-rw-r--r--common/usb_pd_protocol.c4
-rw-r--r--driver/tcpm/anx74xx.c2
-rw-r--r--driver/tcpm/tcpci.c23
-rw-r--r--include/ec_commands.h9
-rw-r--r--util/ectool.c12
5 files changed, 33 insertions, 17 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 06d3995844..ed8bdd1cbe 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -1473,9 +1473,9 @@ void pd_task(void)
if (!res) {
struct ec_response_pd_chip_info *info;
tcpm_get_chip_info(port, &info);
- CPRINTS("TCPC p%d VID:0x%x PID:0x%x DID:0x%x FWV:0x%x",
+ 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);
+ info->device_id, info->fw_version_number);
}
#endif
diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c
index 5909831803..7416d6371d 100644
--- a/driver/tcpm/anx74xx.c
+++ b/driver/tcpm/anx74xx.c
@@ -859,8 +859,6 @@ int anx74xx_tcpm_init(int port)
if (rv)
return EC_ERROR_UNKNOWN;
- tcpm_get_chip_info(port, NULL);
-
return EC_SUCCESS;
}
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index c22e67bda7..fd806ec850 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -306,36 +306,39 @@ void tcpci_tcpc_alert(int port)
int tcpci_get_chip_info(int port, 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;
int error;
int val;
if (port >= CONFIG_USB_PD_PORT_COUNT)
return EC_ERROR_INVAL;
+ i = &info[port];
+
/* If chip_info is NULL, chip info will be stored in cache and can be
* read later by another call. */
if (chip_info)
- *chip_info = &info[port];
+ *chip_info = i;
- if (info[port].vendor_id)
+ if (i->vendor_id)
return EC_SUCCESS;
error = tcpc_read16(port, TCPC_REG_VENDOR_ID, &val);
if (error)
return error;
- info[port].vendor_id = val;
+ i->vendor_id = val;
error = tcpc_read16(port, TCPC_REG_PRODUCT_ID, &val);
if (error)
return error;
- info[port].product_id = val;
+ i->product_id = val;
error = tcpc_read16(port, TCPC_REG_BCD_DEV, &val);
if (error)
return error;
- info[port].device_id = val;
+ i->device_id = val;
- switch(info[port].vendor_id) {
+ switch (i->vendor_id) {
#ifdef CONFIG_USB_PD_TCPM_ANX74XX
case ANX74XX_VENDOR_ID:
error = anx74xx_tcpc_get_fw_version(port, &val);
@@ -348,12 +351,14 @@ int tcpci_get_chip_info(int port, struct ec_response_pd_chip_info **chip_info)
#endif
default:
/* Even if the chip doesn't implement get_fw_version, we
- * return success. The version will be 0xffff. */
- return EC_SUCCESS;
+ * return success.*/
+ val = -1;
+ error = EC_SUCCESS;
}
if (error)
return error;
- info[port].fw_version = val;
+ /* This may vary chip to chip. For now everything fits in this format */
+ i->fw_version_number = val;
return EC_SUCCESS;
}
diff --git a/include/ec_commands.h b/include/ec_commands.h
index e3032853ae..9f7a4616f3 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -3916,17 +3916,20 @@ struct __ec_align1 ec_response_usb_pd_mux_info {
uint8_t flags; /* USB_PD_MUX_*-encoded USB mux state */
};
-#define EC_CMD_PD_CHIP_INFO 0x011B
+#define EC_CMD_PD_CHIP_INFO 0x011B
struct __ec_align1 ec_params_pd_chip_info {
- uint8_t port; /* USB-C port number */
+ uint8_t port; /* USB-C port number */
};
struct __ec_align2 ec_response_pd_chip_info {
uint16_t vendor_id;
uint16_t product_id;
uint16_t device_id;
- uint16_t fw_version;
+ union {
+ uint8_t fw_version_string[8];
+ uint64_t fw_version_number;
+ };
};
#endif /* !__ACPI__ */
diff --git a/util/ectool.c b/util/ectool.c
index 1deeefea79..416ace6efe 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -14,6 +14,7 @@
#include <time.h>
#include <unistd.h>
+#include "anx74xx.h"
#include "battery.h"
#include "comm-host.h"
#include "compile_time_macros.h"
@@ -24,6 +25,7 @@
#include "lock/gec_lock.h"
#include "misc_util.h"
#include "panic.h"
+#include "ps8751.h"
#include "usb_pd.h"
/* Command line options */
@@ -6764,7 +6766,15 @@ int cmd_pd_chip_info(int argc, char *argv[])
printf("vendor_id: 0x%x\n", r.vendor_id);
printf("product_id: 0x%x\n", r.product_id);
printf("device_id: 0x%x\n", r.device_id);
- printf("fw_version: 0x%x\n", r.fw_version);
+
+ switch (r.vendor_id) {
+ case ANX74XX_VENDOR_ID:
+ case PS8751_VENDOR_ID:
+ printf("fw_version: 0x%" PRIx64 "\n", r.fw_version_number);
+ break;
+ default:
+ printf("fw_version: UNSUPPORTED\n");
+ }
return 0;
}