summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaveh Jalali <caveh@google.com>2017-08-15 15:23:21 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2017-08-22 21:06:47 +0000
commit8d5206fc948209d09ca06127d657bf440088bfde (patch)
tree75b960ddd29b09647c0b370e2b699aab793ccbc5
parent20fb169c4b46db7b51cc1ea112b4b91f7238ff17 (diff)
downloadchrome-ec-8d5206fc948209d09ca06127d657bf440088bfde.tar.gz
ps8xxx: use custom tcpm_drv
the ps8xxx family of TCPCs (ps8751, ps8805) have historically used the generic tcpci_tcpm_drv functions, but we need to override some of these entry points because the parade parts need to be woken up before accessing registers. in most cases, this doesn't matter because we access the chip in quick succession where we can "safely" assume the chip is awake -- and the code is structured to implicitly keep the chip awake. the new case we need to address here is where we need to suspend the pd_task and TCPC at an arbitrary point in time. the driver's .release method is called to shut down the chip, and that involves first waking up the chip to be able to access its regs to mask off interrupts, etc. BUG=b:35586896 BRANCH=none TEST=tested from depthcharge - we no longer get errors in the EC console logs about TCPC "release" failed. Reviewed-on: https://chromium-review.googlesource.com/616460 Reviewed-by: Shawn N <shawnn@chromium.org> Change-Id: Ic2a90b71050b3f68c697b1cef48d736ed88b3f41 Signed-off-by: Caveh Jalali <caveh@google.com> Reviewed-on: https://chromium-review.googlesource.com/625356
-rw-r--r--board/nasher/board.c2
-rw-r--r--board/pyro/board.c2
-rw-r--r--board/reef/board.c2
-rw-r--r--board/sand/board.c2
-rw-r--r--board/snappy/board.c2
-rw-r--r--driver/tcpm/ps8751.c40
-rw-r--r--driver/tcpm/ps8751.h2
-rw-r--r--driver/tcpm/tcpci.c4
-rw-r--r--driver/tcpm/tcpci.h9
9 files changed, 57 insertions, 8 deletions
diff --git a/board/nasher/board.c b/board/nasher/board.c
index 3b8c8e79c3..fbedbf8e19 100644
--- a/board/nasher/board.c
+++ b/board/nasher/board.c
@@ -228,7 +228,7 @@ const int i2c_test_dev_used = ARRAY_SIZE(i2c_stress_tests);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
{NPCX_I2C_PORT0_0, 0x50, &anx74xx_tcpm_drv, TCPC_ALERT_ACTIVE_LOW},
- {NPCX_I2C_PORT0_1, 0x16, &tcpci_tcpm_drv, TCPC_ALERT_ACTIVE_LOW},
+ {NPCX_I2C_PORT0_1, 0x16, &ps8751_tcpm_drv, TCPC_ALERT_ACTIVE_LOW},
};
uint16_t tcpc_get_alert_status(void)
diff --git a/board/pyro/board.c b/board/pyro/board.c
index 36bba24943..0cac3f1181 100644
--- a/board/pyro/board.c
+++ b/board/pyro/board.c
@@ -235,7 +235,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_PS8751] = {
.i2c_host_port = NPCX_I2C_PORT0_1,
.i2c_slave_addr = 0x16,
- .drv = &tcpci_tcpm_drv,
+ .drv = &ps8751_tcpm_drv,
.pol = TCPC_ALERT_ACTIVE_LOW,
},
};
diff --git a/board/reef/board.c b/board/reef/board.c
index 7452a7f219..0b8276a2c2 100644
--- a/board/reef/board.c
+++ b/board/reef/board.c
@@ -247,7 +247,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_PS8751] = {
.i2c_host_port = NPCX_I2C_PORT0_1,
.i2c_slave_addr = 0x16,
- .drv = &tcpci_tcpm_drv,
+ .drv = &ps8751_tcpm_drv,
.pol = TCPC_ALERT_ACTIVE_LOW,
},
};
diff --git a/board/sand/board.c b/board/sand/board.c
index 656e148dad..605dfb2a0c 100644
--- a/board/sand/board.c
+++ b/board/sand/board.c
@@ -190,7 +190,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_PS8751] = {
.i2c_host_port = NPCX_I2C_PORT0_1,
.i2c_slave_addr = 0x16,
- .drv = &tcpci_tcpm_drv,
+ .drv = &ps8751_tcpm_drv,
.pol = TCPC_ALERT_ACTIVE_LOW,
},
};
diff --git a/board/snappy/board.c b/board/snappy/board.c
index 25e06b3ab2..0641b96cdb 100644
--- a/board/snappy/board.c
+++ b/board/snappy/board.c
@@ -226,7 +226,7 @@ const int i2c_test_dev_used = ARRAY_SIZE(i2c_stress_tests);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
{NPCX_I2C_PORT0_0, TCPC_PORT0_I2C_ADDR, &anx74xx_tcpm_drv,
TCPC_ALERT_ACTIVE_LOW},
- {NPCX_I2C_PORT0_1, TCPC_PORT1_I2C_ADDR, &tcpci_tcpm_drv,
+ {NPCX_I2C_PORT0_1, TCPC_PORT1_I2C_ADDR, &ps8751_tcpm_drv,
TCPC_ALERT_ACTIVE_LOW},
};
diff --git a/driver/tcpm/ps8751.c b/driver/tcpm/ps8751.c
index 66b895696e..b675ba2216 100644
--- a/driver/tcpm/ps8751.c
+++ b/driver/tcpm/ps8751.c
@@ -7,6 +7,7 @@
#include "common.h"
#include "ps8751.h"
+#include "tcpci.h"
#include "tcpm.h"
#include "timer.h"
@@ -66,6 +67,45 @@ int ps8751_tcpc_get_fw_version(int port, int *version)
return tcpc_read(port, PS8751_REG_VERSION, version);
}
+static int ps8751_tcpm_release(int port)
+{
+ int version;
+ int status;
+
+ status = tcpc_read(port, PS8751_REG_VERSION, &version);
+ if (status != 0) {
+ /* wait for chip to wake up */
+ msleep(10);
+ }
+
+ return tcpci_tcpm_release(port);
+}
+
+const struct tcpm_drv ps8751_tcpm_drv = {
+ .init = &tcpci_tcpm_init,
+ .release = &ps8751_tcpm_release,
+ .get_cc = &tcpci_tcpm_get_cc,
+#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC
+ .get_vbus_level = &tcpci_tcpm_get_vbus_level,
+#endif
+ .select_rp_value = &tcpci_tcpm_select_rp_value,
+ .set_cc = &tcpci_tcpm_set_cc,
+ .set_polarity = &tcpci_tcpm_set_polarity,
+ .set_vconn = &tcpci_tcpm_set_vconn,
+ .set_msg_header = &tcpci_tcpm_set_msg_header,
+ .set_rx_enable = &tcpci_tcpm_set_rx_enable,
+ .get_message = &tcpci_tcpm_get_message,
+ .transmit = &tcpci_tcpm_transmit,
+ .tcpc_alert = &tcpci_tcpc_alert,
+#ifdef CONFIG_USB_PD_DISCHARGE_TCPC
+ .tcpc_discharge_vbus = &tcpci_tcpc_discharge_vbus,
+#endif
+#ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE
+ .drp_toggle = &tcpci_tcpc_drp_toggle,
+#endif
+ .get_chip_info = &tcpci_get_chip_info,
+};
+
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
struct i2c_stress_test_dev ps8751_i2c_stress_test_dev = {
.reg_info = {
diff --git a/driver/tcpm/ps8751.h b/driver/tcpm/ps8751.h
index 9dd922208a..ea658bee4c 100644
--- a/driver/tcpm/ps8751.h
+++ b/driver/tcpm/ps8751.h
@@ -22,6 +22,7 @@
#define PS8751_REG_MUX_USB_C2SS_EQ 0xe7
#define PS8751_REG_MUX_USB_C2SS_HS_THRESHOLD 0xe8
+extern const struct tcpm_drv ps8751_tcpm_drv;
void ps8751_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq);
int ps8751_tcpc_get_fw_version(int port, int *version);
@@ -30,4 +31,3 @@ extern struct i2c_stress_test_dev ps8751_i2c_stress_test_dev;
#endif
#endif /* __CROS_EC_USB_PD_TCPM_PS8751_H */
-
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index c7cdad4390..3e3dda9f44 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -108,7 +108,7 @@ int tcpci_tcpm_select_rp_value(int port, int rp)
}
#ifdef CONFIG_USB_PD_DISCHARGE_TCPC
-static void tcpci_tcpc_discharge_vbus(int port, int enable)
+void tcpci_tcpc_discharge_vbus(int port, int enable)
{
int reg;
@@ -137,7 +137,7 @@ int tcpci_tcpm_set_cc(int port, int pull)
}
#ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE
-static int tcpci_tcpc_drp_toggle(int port, int enable)
+int tcpci_tcpc_drp_toggle(int port, int enable)
{
int rv;
diff --git a/driver/tcpm/tcpci.h b/driver/tcpm/tcpci.h
index ce1b082fca..cc6fb3c4d1 100644
--- a/driver/tcpm/tcpci.h
+++ b/driver/tcpm/tcpci.h
@@ -122,6 +122,8 @@
extern const struct tcpm_drv tcpci_tcpm_drv;
extern const struct usb_mux_driver tcpci_tcpm_usb_mux_driver;
+void tcpci_tcpc_alert(int port);
+int tcpci_tcpm_init(int port);
int tcpci_tcpm_get_cc(int port, int *cc1, int *cc2);
int tcpci_tcpm_get_vbus_level(int port);
int tcpci_tcpm_select_rp_value(int port, int rp);
@@ -133,6 +135,13 @@ int tcpci_tcpm_set_rx_enable(int port, int enable);
int tcpci_tcpm_get_message(int port, uint32_t *payload, int *head);
int tcpci_tcpm_transmit(int port, enum tcpm_transmit_type type,
uint16_t header, const uint32_t *data);
+int tcpci_tcpm_release(int port);
+#ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE
+int tcpci_tcpc_drp_toggle(int port, int enable);
+#endif
+#ifdef CONFIG_USB_PD_DISCHARGE_TCPC
+void tcpci_tcpc_discharge_vbus(int port, int enable);
+#endif
int tcpci_tcpm_mux_init(int i2c_addr);
int tcpci_tcpm_mux_set(int i2c_addr, mux_state_t mux_state);