summaryrefslogtreecommitdiff
path: root/driver/tcpm
diff options
context:
space:
mode:
Diffstat (limited to 'driver/tcpm')
-rw-r--r--driver/tcpm/anx74xx.c6
-rw-r--r--driver/tcpm/anx7688.c7
-rw-r--r--driver/tcpm/fusb302.c6
-rw-r--r--driver/tcpm/fusb302.h1
-rw-r--r--driver/tcpm/it83xx.c6
-rw-r--r--driver/tcpm/tcpci.c33
-rw-r--r--driver/tcpm/tcpm.h5
7 files changed, 62 insertions, 2 deletions
diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c
index 4c3fd41410..461242d79f 100644
--- a/driver/tcpm/anx74xx.c
+++ b/driver/tcpm/anx74xx.c
@@ -1060,8 +1060,14 @@ static int anx74xx_tcpm_init(int port)
return EC_SUCCESS;
}
+static int anx74xx_tcpm_release(int port)
+{
+ return EC_ERROR_UNIMPLEMENTED;
+}
+
const struct tcpm_drv anx74xx_tcpm_drv = {
.init = &anx74xx_tcpm_init,
+ .release = &anx74xx_tcpm_release,
.get_cc = &anx74xx_tcpm_get_cc,
#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC
.get_vbus_level = &anx74xx_tcpm_get_vbus_level,
diff --git a/driver/tcpm/anx7688.c b/driver/tcpm/anx7688.c
index 7dda345302..6b73108739 100644
--- a/driver/tcpm/anx7688.c
+++ b/driver/tcpm/anx7688.c
@@ -61,6 +61,11 @@ static int anx7688_init(int port)
return rv;
}
+static int anx7688_release(int port)
+{
+ return EC_ERROR_UNIMPLEMENTED;
+}
+
static void anx7688_update_hpd_enable(int port)
{
int status, reg, rv;
@@ -178,6 +183,7 @@ static int anx7688_tcpm_get_vbus_level(int port)
/* ANX7688 is a TCPCI compatible port controller */
const struct tcpm_drv anx7688_tcpm_drv = {
.init = &anx7688_init,
+ .release = &anx7688_release,
.get_cc = &tcpci_tcpm_get_cc,
#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC
.get_vbus_level = &anx7688_tcpm_get_vbus_level,
@@ -200,4 +206,3 @@ const struct usb_mux_driver anx7688_usb_mux_driver = {
.get = tcpci_tcpm_mux_get,
};
#endif /* CONFIG_USB_PD_TCPM_MUX */
-
diff --git a/driver/tcpm/fusb302.c b/driver/tcpm/fusb302.c
index 9bdde5e591..3be0288bf1 100644
--- a/driver/tcpm/fusb302.c
+++ b/driver/tcpm/fusb302.c
@@ -428,6 +428,11 @@ static int fusb302_tcpm_init(int port)
return 0;
}
+static int fusb302_tcpm_release(int port)
+{
+ return EC_ERROR_UNIMPLEMENTED;
+}
+
static int fusb302_tcpm_get_cc(int port, int *cc1, int *cc2)
{
if (state[port].pulling_up) {
@@ -926,6 +931,7 @@ void tcpm_set_bist_test_data(int port)
const struct tcpm_drv fusb302_tcpm_drv = {
.init = &fusb302_tcpm_init,
+ .release = &fusb302_tcpm_release,
.get_cc = &fusb302_tcpm_get_cc,
#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC
.get_vbus_level = &fusb302_tcpm_get_vbus_level,
diff --git a/driver/tcpm/fusb302.h b/driver/tcpm/fusb302.h
index dc191bee5a..1773645e91 100644
--- a/driver/tcpm/fusb302.h
+++ b/driver/tcpm/fusb302.h
@@ -206,4 +206,3 @@ enum fusb302_txfifo_tokens {
extern const struct tcpm_drv fusb302_tcpm_drv;
#endif /* __CROS_EC_DRIVER_TCPM_FUSB302_H */
-
diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c
index e30c73bac8..f5e78bbbb9 100644
--- a/driver/tcpm/it83xx.c
+++ b/driver/tcpm/it83xx.c
@@ -351,6 +351,11 @@ static int it83xx_tcpm_init(int port)
return EC_SUCCESS;
}
+static int it83xx_tcpm_release(int port)
+{
+ return EC_ERROR_UNIMPLEMENTED;
+}
+
static int it83xx_tcpm_get_cc(int port, int *cc1, int *cc2)
{
*cc2 = it83xx_get_cc(port, USBPD_CC_PIN_2);
@@ -504,6 +509,7 @@ static int it83xx_tcpm_get_chip_info(int port, int renew,
const struct tcpm_drv it83xx_tcpm_drv = {
.init = &it83xx_tcpm_init,
+ .release = &it83xx_tcpm_release,
.get_cc = &it83xx_tcpm_get_cc,
#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC
.get_vbus_level = NULL,
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index 8da8bdd532..c7cdad4390 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -42,6 +42,11 @@ static int init_alert_mask(int port)
return tcpc_write16(port, TCPC_REG_ALERT_MASK, mask);
}
+static int clear_alert_mask(int port)
+{
+ return tcpc_write16(port, TCPC_REG_ALERT_MASK, 0);
+}
+
static int init_power_status_mask(int port)
{
uint8_t mask;
@@ -57,6 +62,11 @@ static int init_power_status_mask(int port)
return rv;
}
+static int clear_power_status_mask(int port)
+{
+ return tcpc_write(port, TCPC_REG_POWER_STATUS_MASK, 0);
+}
+
int tcpci_tcpm_get_cc(int port, int *cc1, int *cc2)
{
int status;
@@ -436,6 +446,28 @@ int tcpci_tcpm_init(int port)
return EC_SUCCESS;
}
+/*
+ * Dissociate from the TCPC.
+ */
+
+int tcpci_tcpm_release(int port)
+{
+ int error;
+
+ error = clear_alert_mask(port);
+ if (error)
+ return error;
+ error = clear_power_status_mask(port);
+ if (error)
+ return error;
+ /* Clear pending interrupts */
+ error = tcpc_write16(port, TCPC_REG_ALERT, 0xffff);
+ if (error)
+ return error;
+
+ return EC_SUCCESS;
+}
+
#ifdef CONFIG_USB_PD_TCPM_MUX
int tcpci_tcpm_mux_init(int i2c_addr)
@@ -498,6 +530,7 @@ const struct usb_mux_driver tcpci_tcpm_usb_mux_driver = {
const struct tcpm_drv tcpci_tcpm_drv = {
.init = &tcpci_tcpm_init,
+ .release = &tcpci_tcpm_release,
.get_cc = &tcpci_tcpm_get_cc,
#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC
.get_vbus_level = &tcpci_tcpm_get_vbus_level,
diff --git a/driver/tcpm/tcpm.h b/driver/tcpm/tcpm.h
index 71af9361f9..b2d8aef2ea 100644
--- a/driver/tcpm/tcpm.h
+++ b/driver/tcpm/tcpm.h
@@ -75,6 +75,11 @@ static inline int tcpm_init(int port)
return tcpc_config[port].drv->init(port);
}
+static inline int tcpm_release(int port)
+{
+ return tcpc_config[port].drv->release(port);
+}
+
static inline int tcpm_get_cc(int port, int *cc1, int *cc2)
{
return tcpc_config[port].drv->get_cc(port, cc1, cc2);