summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2018-02-01 11:33:25 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-02-02 10:17:30 -0800
commit76927bdc5a17ddbdc9fc601b761c2a4984ecc1e9 (patch)
tree0ef346ffe19b05b9fddeb0320c244705c5686baf /chip
parentc721ad9162b9fe20ce872c1d28cd8b1ad60e2c25 (diff)
downloadchrome-ec-76927bdc5a17ddbdc9fc601b761c2a4984ecc1e9.tar.gz
stm32/usb: Add HOOK_USB_PM_CHANGE, called when USB is resumed/suspended
In particular, this will allow touchpad driver and keyboard matrix scanning to be powered off/disabled when the USB interface is disabled without setting the remote wake feature (USB_REQ_FEATURE_DEVICE_REMOTE_WAKEUP), as events would be ignored anyway. BRANCH=none BUG=b:72683995 TEST=With next CLs, touchpad and keyboard matrix scanning are disabled when lid is closed. Change-Id: I3750bfaf8c31cde075adf9da4fef39753b8981c5 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/897067 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r--chip/stm32/usb.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/chip/stm32/usb.c b/chip/stm32/usb.c
index 57e629a3d1..560ca3da2d 100644
--- a/chip/stm32/usb.c
+++ b/chip/stm32/usb.c
@@ -379,10 +379,16 @@ static void usb_reset(void)
}
#ifdef CONFIG_USB_SUSPEND
+static void usb_pm_change_notify_hooks(void)
+{
+ hook_notify(HOOK_USB_PM_CHANGE);
+}
+DECLARE_DEFERRED(usb_pm_change_notify_hooks);
+
/* See RM0091 Reference Manual 30.5.5 Suspend/Resume events */
static void usb_suspend(void)
{
- CPRINTF("SUS\n");
+ CPRINTF("SUS%d\n", remote_wakeup_enabled);
/*
* usb_suspend can be called from hook task, make sure no interrupt is
@@ -400,6 +406,8 @@ static void usb_suspend(void)
/* USB is not in use anymore, we can (hopefully) sleep now. */
enable_sleep(SLEEP_MASK_USB_DEVICE);
+
+ hook_call_deferred(&usb_pm_change_notify_hooks_data, 0);
}
static void usb_resume_deferred(void)
@@ -410,6 +418,8 @@ static void usb_resume_deferred(void)
CPRINTF("RSMd %d %04x\n", state, STM32_USB_CNTR);
if (state == 2 || state == 3)
usb_suspend();
+ else
+ hook_call_deferred(&usb_pm_change_notify_hooks_data, 0);
}
DECLARE_DEFERRED(usb_resume_deferred);
@@ -440,6 +450,8 @@ static void usb_resume(void)
*/
if (state == 2 || state == 3)
hook_call_deferred(&usb_resume_deferred_data, 3 * MSEC);
+ else
+ hook_call_deferred(&usb_pm_change_notify_hooks_data, 0);
}
#ifdef CONFIG_USB_REMOTE_WAKEUP
@@ -536,6 +548,15 @@ int usb_is_suspended(void)
return 0;
}
+
+int usb_is_remote_wakeup_enabled(void)
+{
+#ifdef CONFIG_USB_REMOTE_WAKEUP
+ return remote_wakeup_enabled;
+#else
+ return 0;
+#endif
+}
#endif /* CONFIG_USB_SUSPEND */
#if defined(CONFIG_USB_SUSPEND) && defined(CONFIG_USB_REMOTE_WAKEUP)