summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-05-17 16:08:05 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-05-21 20:35:47 +0000
commitf52b23e96423fa0447013d58da1c6677ac8ae9f8 (patch)
tree83dc601edaa46e9310dff542eaf7784b3aadcddc
parentffac23c0ea1bd4ff4568f5bd709a98f912b833a7 (diff)
downloadchrome-ec-f52b23e96423fa0447013d58da1c6677ac8ae9f8.tar.gz
samus_pd: when sinking power detect loss of VBUS and disconnect
Detect loss of VBUS when acting as PD sink and go to the disconnected state. This allows us to renegotiate power when power supply drops and switches to 5V. BUG=none BRANCH=none TEST=On a samus, tested by running for a couple of hours, and verifying that occasionally when zinger drops from 20V to 5V, we detect it and go to the disconnected state. Note, this only happens a couple times every hour. Change-Id: I237d267824ff564662c9c02e525ce2613ed229e6 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200365 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--board/firefly/usb_pd_config.h5
-rw-r--r--board/fruitpie/usb_pd_config.h5
-rw-r--r--board/samus_pd/usb_pd_config.h5
-rw-r--r--common/usb_pd_protocol.c8
4 files changed, 23 insertions, 0 deletions
diff --git a/board/firefly/usb_pd_config.h b/board/firefly/usb_pd_config.h
index 8e3a3a4af7..595b977d48 100644
--- a/board/firefly/usb_pd_config.h
+++ b/board/firefly/usb_pd_config.h
@@ -96,6 +96,11 @@ static inline int pd_adc_read(int cc)
return adc_read_channel(ADC_CH_CC2_PD);
}
+static inline int pd_snk_is_vbus_provided(void)
+{
+ return 1;
+}
+
/* Standard-current DFP : no-connect voltage is 1.55V */
#define PD_SRC_VNC 1550 /* mV */
diff --git a/board/fruitpie/usb_pd_config.h b/board/fruitpie/usb_pd_config.h
index 3c53d5e923..75d3b112c3 100644
--- a/board/fruitpie/usb_pd_config.h
+++ b/board/fruitpie/usb_pd_config.h
@@ -84,6 +84,11 @@ static inline int pd_adc_read(int cc)
return adc_read_channel(ADC_CH_CC2_PD);
}
+static inline int pd_snk_is_vbus_provided(void)
+{
+ return 1;
+}
+
/* Standard-current DFP : no-connect voltage is 1.55V */
#define PD_SRC_VNC 1550 /* mV */
diff --git a/board/samus_pd/usb_pd_config.h b/board/samus_pd/usb_pd_config.h
index 9606913e06..016394e8bb 100644
--- a/board/samus_pd/usb_pd_config.h
+++ b/board/samus_pd/usb_pd_config.h
@@ -108,6 +108,11 @@ static inline int pd_adc_read(int cc)
return adc_read_channel(ADC_C0_CC2_PD);
}
+static inline int pd_snk_is_vbus_provided(void)
+{
+ return gpio_get_level(GPIO_USB_C0_VBUS_WAKE);
+}
+
/* Standard-current DFP : no-connect voltage is 1.55V */
#define PD_SRC_VNC 1550 /* mV */
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index d15f9bcc0e..48e2763712 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -778,6 +778,14 @@ void pd_task(void)
break;
case PD_STATE_SNK_READY:
/* we have power and we are happy */
+
+ /* if we have lost vbus, go back to disconnected */
+ if (!pd_snk_is_vbus_provided()) {
+ pd_task_state = PD_STATE_SNK_DISCONNECTED;
+ /* set timeout small to reconnect fast */
+ timeout = 5*MSEC;
+ }
+
/* check vital parameters from time to time */
timeout = 100*MSEC;
break;