summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2017-09-07 15:13:18 +0200
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2017-09-11 21:34:16 +0000
commitb31512fe872257a6a34019e9f80d2c0352d3c544 (patch)
tree189df2bb79d4abfd6f6e076fa50b6aa5bf07fb74 /include
parent4f905f82740339fba74f7ef824655e60f951403f (diff)
downloadchrome-ec-b31512fe872257a6a34019e9f80d2c0352d3c544.tar.gz
g: restore DATA PID after USB suspend/resume
In USB FS on a bulk/interrupt endpoint, the transactions normally toggles between DATA0 and DATA1 PIDs. After a USB suspend/resume cycle, we need to restart from the PID we were at before suspend. In our current code, when going to deep-sleep during USB suspend, we are re-initializing everything when the MCU restarts at each resume. So we set implicitly the PID to DATA0. The USB Hardware IP just silently discards the packet when the PID of an incoming OUT packet is not matching the expectation in the endpoint register. In order to preserve DATA PIDS, record the state of the PID toggling on each endpoint when going to deep-sleep and restore it during the USB initialization. Conflicts: include/usb_api.h Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=b:38160821 TEST=manual, plug a HG proto2 on a Linux host machine and enable 'auto-suspend' for this USB device. Let it go to sleep and wake-it up by sending a U2FHID request. Repeat the process several times and see that the key answers every time (while it was failing after the second cycle before). Change-Id: I75e2cfc39f22483d9e9b32c5f8b887dbafc37108 Reviewed-on: https://chromium-review.googlesource.com/655238 Commit-Ready: Marius Schilder <mschilder@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Marius Schilder <mschilder@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> (cherry picked from commit 096ea20ed18095a967e1829b6ae60b13453416be) Reviewed-on: https://chromium-review.googlesource.com/660891 Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/usb_api.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/usb_api.h b/include/usb_api.h
index a251b3f857..726e6df5dc 100644
--- a/include/usb_api.h
+++ b/include/usb_api.h
@@ -50,6 +50,18 @@ void usb_release(void);
*/
void usb_wake(void);
+/*
+ * Preserve in non-volatile memory the state of the USB hardware registers
+ * which cannot be simply re-initialized when powered up again.
+ */
+void usb_save_suspended_state(void);
+
+/*
+ * Restore from non-volatile memory the state of the USB hardware registers
+ * which was lost by powering them down.
+ */
+void usb_restore_suspended_state(void);
+
#ifdef CONFIG_USB_SELECT_PHY
/* Select which PHY to use. */
void usb_select_phy(uint32_t phy);