summaryrefslogtreecommitdiff
path: root/driver/tcpm
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2018-09-24 10:48:33 -0600
committerchrome-bot <chrome-bot@chromium.org>2018-09-28 13:34:32 -0700
commitc6c0d021d16eb686254bde767264f7f3151df7f2 (patch)
tree5a38b1178189ffb0ad3ba0754a0b775399c928a7 /driver/tcpm
parent64c792829c2fd6bda4985e2add424cce41c5cfd9 (diff)
downloadchrome-ec-c6c0d021d16eb686254bde767264f7f3151df7f2.tar.gz
pdchipinfo: add min firmware version to pdchipinfo
Add a new field to the pdchipinfo host command that exposes the minimum required firmware version that we know about. This will allow factory tests or automated test to compare this version to the current version and fail. BRANCH=none BUG=b:116068318 TEST=with corresponding ectool change, min value is reported correctly Change-Id: Idf338795c3fd6f9f95e51471d0f6a7a422901d52 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1240457 Reviewed-by: Justin TerAvest <teravest@chromium.org>
Diffstat (limited to 'driver/tcpm')
-rw-r--r--driver/tcpm/anx74xx.c23
-rw-r--r--driver/tcpm/anx74xx.h1
-rw-r--r--driver/tcpm/it83xx.c4
-rw-r--r--driver/tcpm/ps8xxx.c24
-rw-r--r--driver/tcpm/ps8xxx.h1
-rw-r--r--driver/tcpm/tcpci.c48
-rw-r--r--driver/tcpm/tcpci.h2
-rw-r--r--driver/tcpm/tcpm.h2
8 files changed, 60 insertions, 45 deletions
diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c
index f9a4b09089..79af4c054b 100644
--- a/driver/tcpm/anx74xx.c
+++ b/driver/tcpm/anx74xx.c
@@ -746,7 +746,7 @@ static int anx74xx_tcpm_set_polarity(int port, int polarity)
return rv;
}
-int anx74xx_tcpc_get_fw_version(int port, int *version)
+static int anx74xx_tcpc_get_fw_version(int port, int *version)
{
return tcpc_read(port, ANX74XX_REG_FW_VERSION, version);
}
@@ -1043,6 +1043,25 @@ static int anx74xx_tcpm_init(int port)
return EC_SUCCESS;
}
+static int anx74xx_get_chip_info(int port, int renew,
+ struct ec_response_pd_chip_info_v1 **chip_info)
+{
+ int rv = tcpci_get_chip_info(port, renew, chip_info);
+ int val;
+
+ if (rv)
+ return rv;
+
+ rv = anx74xx_tcpc_get_fw_version(port, &val);
+
+ if (rv)
+ return rv;
+
+ (*chip_info)->fw_version_number = val;
+
+ return rv;
+}
+
/*
* Dissociate from the TCPC.
*/
@@ -1071,7 +1090,7 @@ const struct tcpm_drv anx74xx_tcpm_drv = {
#ifdef CONFIG_USB_PD_DISCHARGE_TCPC
.tcpc_discharge_vbus = &anx74xx_tcpc_discharge_vbus,
#endif
- .get_chip_info = &tcpci_get_chip_info,
+ .get_chip_info = &anx74xx_get_chip_info,
#if defined(CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE) && \
defined(CONFIG_USB_PD_TCPC_LOW_POWER)
.drp_toggle = &anx74xx_tcpc_drp_toggle,
diff --git a/driver/tcpm/anx74xx.h b/driver/tcpm/anx74xx.h
index 9bdaadadcd..a8f51232a5 100644
--- a/driver/tcpm/anx74xx.h
+++ b/driver/tcpm/anx74xx.h
@@ -211,7 +211,6 @@ extern const struct usb_mux_driver anx74xx_tcpm_usb_mux_driver;
void anx74xx_tcpc_set_vbus(int port, int enable);
void anx74xx_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq);
void anx74xx_tcpc_clear_hpd_status(int port);
-int anx74xx_tcpc_get_fw_version(int port, int *version);
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
extern struct i2c_stress_test_dev anx74xx_i2c_stress_test_dev;
diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c
index 24097e1199..8fb6b985c0 100644
--- a/driver/tcpm/it83xx.c
+++ b/driver/tcpm/it83xx.c
@@ -554,9 +554,9 @@ static int it83xx_tcpm_transmit(int port,
}
static int it83xx_tcpm_get_chip_info(int port, int renew,
- struct ec_response_pd_chip_info **chip_info)
+ struct ec_response_pd_chip_info_v1 **chip_info)
{
- static struct ec_response_pd_chip_info i;
+ static struct ec_response_pd_chip_info_v1 i;
*chip_info = &i;
i.vendor_id = USB_VID_ITE;
diff --git a/driver/tcpm/ps8xxx.c b/driver/tcpm/ps8xxx.c
index d58f3cde35..19d0c21396 100644
--- a/driver/tcpm/ps8xxx.c
+++ b/driver/tcpm/ps8xxx.c
@@ -87,7 +87,7 @@ void ps8xxx_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq)
hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL;
}
-int ps8xxx_tcpc_get_fw_version(int port, int *version)
+static int ps8xxx_tcpc_get_fw_version(int port, int *version)
{
return tcpc_read(port, FW_VER_REG, version);
}
@@ -136,6 +136,26 @@ static int ps8xxx_tcpm_release(int port)
return tcpci_tcpm_release(port);
}
+static int ps8xxx_get_chip_info(int port, int renew,
+ struct ec_response_pd_chip_info_v1 **chip_info)
+{
+ int val;
+ int rv = tcpci_get_chip_info(port, renew, chip_info);
+
+ if (rv)
+ return rv;
+
+ rv = ps8xxx_tcpc_get_fw_version(port, &val);
+
+ if (rv)
+ return rv;
+
+ (*chip_info)->fw_version_number = val;
+
+ return rv;
+}
+
+
const struct tcpm_drv ps8xxx_tcpm_drv = {
.init = &tcpci_tcpm_init,
.release = &ps8xxx_tcpm_release,
@@ -162,7 +182,7 @@ const struct tcpm_drv ps8xxx_tcpm_drv = {
.set_snk_ctrl = &tcpci_tcpm_set_snk_ctrl,
.set_src_ctrl = &tcpci_tcpm_set_src_ctrl,
#endif
- .get_chip_info = &tcpci_get_chip_info,
+ .get_chip_info = &ps8xxx_get_chip_info,
#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
.enter_low_power_mode = &tcpci_enter_low_power_mode,
#endif
diff --git a/driver/tcpm/ps8xxx.h b/driver/tcpm/ps8xxx.h
index 6c66210982..1459bb4b3e 100644
--- a/driver/tcpm/ps8xxx.h
+++ b/driver/tcpm/ps8xxx.h
@@ -62,7 +62,6 @@
extern const struct tcpm_drv ps8xxx_tcpm_drv;
void ps8xxx_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq);
-int ps8xxx_tcpc_get_fw_version(int port, int *version);
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
extern struct i2c_stress_test_dev ps8xxx_i2c_stress_test_dev;
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index 84e22bda06..1c1c04868d 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -587,21 +587,18 @@ void tcpci_tcpc_alert(int port)
}
/*
- * For PS8751, this function will fail if the chip is in low power mode.
- * PS8751 has to be woken up by reading a random register first then wait for
- * 10ms.
+ * This call will wake up the TCPC if it is in low power mode upon accessing the
+ * i2c bus (but the pd state machine should put it back into low power mode).
*
- * This code doesn't have the wake-up read to avoid 10ms delay. Instead, we
- * call this function immediately after the chip is reset or initialized
- * because it'll gurantee the chip is awake. 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.
+ * 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,
- struct ec_response_pd_chip_info **chip_info)
+ struct ec_response_pd_chip_info_v1 **chip_info)
{
- static struct ec_response_pd_chip_info info[CONFIG_USB_PD_PORT_COUNT];
- struct ec_response_pd_chip_info *i;
+ static struct ec_response_pd_chip_info_v1
+ info[CONFIG_USB_PD_PORT_COUNT];
+ struct ec_response_pd_chip_info_v1 *i;
int error;
int val;
@@ -634,30 +631,11 @@ int tcpci_get_chip_info(int port, int renew,
return error;
i->device_id = val;
- switch (i->vendor_id) {
-#if defined(CONFIG_USB_PD_TCPM_ANX3429) || \
- defined(CONFIG_USB_PD_TCPM_ANX740X) || \
- defined(CONFIG_USB_PD_TCPM_ANX741X)
- case ANX74XX_VENDOR_ID:
- error = anx74xx_tcpc_get_fw_version(port, &val);
- break;
-#endif
-#if defined(CONFIG_USB_PD_TCPM_PS8751) || defined(CONFIG_USB_PD_TCPM_PS8805)
- /* The PS8751 and PS8805 share the same vendor ID. */
- case PS8XXX_VENDOR_ID:
- error = ps8xxx_tcpc_get_fw_version(port, &val);
- break;
-#endif
- default:
- /* Even if the chip doesn't implement get_fw_version, we
- * return success.*/
- val = -1;
- error = EC_SUCCESS;
- }
- if (error)
- return error;
- /* This may vary chip to chip. For now everything fits in this format */
- i->fw_version_number = val;
+ /*
+ * This varies chip to chip; more specific driver code is expected to
+ * override this value if it can.
+ */
+ i->fw_version_number = -1;
return EC_SUCCESS;
}
diff --git a/driver/tcpm/tcpci.h b/driver/tcpm/tcpci.h
index 24c5d9c2f6..f5fe1a1a0b 100644
--- a/driver/tcpm/tcpci.h
+++ b/driver/tcpm/tcpci.h
@@ -155,7 +155,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_get_chip_info(int port, int renew,
- struct ec_response_pd_chip_info **chip_info);
+ struct ec_response_pd_chip_info_v1 **chip_info);
#ifdef CONFIG_USBC_PPC
int tcpci_tcpm_set_snk_ctrl(int port, int enable);
int tcpci_tcpm_set_src_ctrl(int port, int enable);
diff --git a/driver/tcpm/tcpm.h b/driver/tcpm/tcpm.h
index 02cdbe2cb6..fc0cd2791d 100644
--- a/driver/tcpm/tcpm.h
+++ b/driver/tcpm/tcpm.h
@@ -234,7 +234,7 @@ static inline int tcpc_i2c_write(const int port, const int addr,
#endif
static inline int tcpm_get_chip_info(int port, int renew,
- struct ec_response_pd_chip_info **info)
+ 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);