summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Broch <tbroch@chromium.org>2015-02-11 15:15:40 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-02-12 23:08:37 +0000
commit7c1f189edc3d3a937746ccae01012868398f70ef (patch)
tree409720e6270631aa4c00ec3e973f6e9eb623fe88
parent80778ad0eb0f2a7a156f02b68eb7103687c245fb (diff)
downloadchrome-ec-7c1f189edc3d3a937746ccae01012868398f70ef.tar.gz
pd: DRP: VCONN should be off at start of pd task.
VCONN should be off at the start of pd task. This is handled initially by the defaults in gpio.inc. However in the case of a sysjump after a RW only firmware update the previous state would be preserved. This in turn would allow us to evaluate polarity incorrectly if an accessory was connected in the CC2 polarity and subsequently enable both VCONNs which would leave the port with both CCx lines at 3.3V. This change adds a new function, pd_config_init, which initializes VCONN(s) to off. Future CLs will evaluate other PD related GPIOs that may be left unitialized as a result of sysjump. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:36481 TEST=manual, 1. Boot samus w/ samus_pd in RO 2. connect hoho | dingdong in CC2 polarity to type-C port 3. sysjump to RW 4. unplug / plug hoho | dingdongs No longer see both VCONNs enabled. Change-Id: Ia53c06ea8face4da6829f9667f4f44a9034183be Reviewed-on: https://chromium-review.googlesource.com/248831 Trybot-Ready: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org>
-rw-r--r--board/fruitpie/usb_pd_config.h14
-rw-r--r--board/plankton/usb_pd_config.h14
-rw-r--r--board/ryu/usb_pd_config.h14
-rw-r--r--board/samus_pd/usb_pd_config.h19
-rw-r--r--common/usb_pd_protocol.c4
5 files changed, 65 insertions, 0 deletions
diff --git a/board/fruitpie/usb_pd_config.h b/board/fruitpie/usb_pd_config.h
index 759ca21212..acf0f6f6ca 100644
--- a/board/fruitpie/usb_pd_config.h
+++ b/board/fruitpie/usb_pd_config.h
@@ -132,6 +132,20 @@ static inline void pd_set_host_mode(int port, int enable)
gpio_set_level(GPIO_CC_HOST, enable);
}
+/**
+ * Initialize various GPIOs and interfaces to safe state at start of pd_task.
+ *
+ * These include:
+ * VCONNs disabled.
+ *
+ * @param port USB-C port number
+ */
+static inline void pd_config_init(int port)
+{
+ gpio_set_level(GPIO_VCONN1_EN, 0);
+ gpio_set_level(GPIO_VCONN2_EN, 0);
+}
+
static inline int pd_adc_read(int port, int cc)
{
if (cc == 0)
diff --git a/board/plankton/usb_pd_config.h b/board/plankton/usb_pd_config.h
index 6fd5b9c48a..c1fefbcf7e 100644
--- a/board/plankton/usb_pd_config.h
+++ b/board/plankton/usb_pd_config.h
@@ -129,6 +129,20 @@ static inline void pd_set_host_mode(int port, int enable)
board_pd_set_host_mode(enable);
}
+/**
+ * Initialize various GPIOs and interfaces to safe state at start of pd_task.
+ *
+ * These include:
+ * VCONNs disabled.
+ *
+ * @param port USB-C port number
+ */
+static inline void pd_config_init(int port)
+{
+ gpio_set_level(GPIO_USB_CC1_VCONN_EN_L, 1);
+ gpio_set_level(GPIO_USB_CC2_VCONN_EN_L, 1);
+}
+
static inline int pd_adc_read(int port, int cc)
{
if (board_pd_fake_disconnected())
diff --git a/board/ryu/usb_pd_config.h b/board/ryu/usb_pd_config.h
index d5992e3335..f64f27b882 100644
--- a/board/ryu/usb_pd_config.h
+++ b/board/ryu/usb_pd_config.h
@@ -147,6 +147,20 @@ static inline void pd_set_host_mode(int port, int enable)
}
+/**
+ * Initialize various GPIOs and interfaces to safe state at start of pd_task.
+ *
+ * These include:
+ * VCONNs disabled.
+ *
+ * @param port USB-C port number
+ */
+static inline void pd_config_init(int port)
+{
+ gpio_set_level(GPIO_USBC_VCONN1_EN_L, 1);
+ gpio_set_level(GPIO_USBC_VCONN2_EN_L, 1);
+}
+
static inline int pd_adc_read(int port, int cc)
{
if (cc == 0)
diff --git a/board/samus_pd/usb_pd_config.h b/board/samus_pd/usb_pd_config.h
index a2e80aaabd..3fede784e2 100644
--- a/board/samus_pd/usb_pd_config.h
+++ b/board/samus_pd/usb_pd_config.h
@@ -224,6 +224,25 @@ static inline void pd_set_host_mode(int port, int enable)
}
}
+/**
+ * Initialize various GPIOs and interfaces to safe state at start of pd_task.
+ *
+ * These include:
+ * VCONNs disabled.
+ *
+ * @param port USB-C port number
+ */
+static inline void pd_config_init(int port)
+{
+ if (port == 0) {
+ gpio_set_level(GPIO_USB_C0_CC1_VCONN1_EN_L, 1);
+ gpio_set_level(GPIO_USB_C0_CC2_VCONN1_EN_L, 1);
+ } else {
+ gpio_set_level(GPIO_USB_C1_CC1_VCONN1_EN_L, 1);
+ gpio_set_level(GPIO_USB_C1_CC2_VCONN1_EN_L, 1);
+ }
+}
+
static inline int pd_adc_read(int port, int cc)
{
if (port == 0)
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 18a217528b..40126aa8fe 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -1775,6 +1775,10 @@ void pd_task(void)
/* Initialize TX pins and put them in Hi-Z */
pd_tx_init();
+#if defined(CONFIG_USB_PD_DUAL_ROLE) && defined(CONFIG_USB_PD_ALT_MODE_DFP)
+ pd_config_init(port);
+#endif
+
/* Initialize PD protocol state variables for each port. */
pd[port].power_role = PD_ROLE_DEFAULT;
pd_set_data_role(port, PD_ROLE_DEFAULT);