usb_usb: power saving during suspend without remote wakeup
https://github.com/tmk/tmk_keyboard/issues/769#issuecomment-1864054914
This commit is contained in:
parent
ea27f71701
commit
09664638f8
2 changed files with 26 additions and 0 deletions
|
|
@ -53,4 +53,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define LOCKING_SUPPORT_ENABLE
|
#define LOCKING_SUPPORT_ENABLE
|
||||||
#define LOCKING_RESYNC_ENABLE
|
#define LOCKING_RESYNC_ENABLE
|
||||||
|
|
||||||
|
// power saving during suspended without remote wakeup disabled
|
||||||
|
#define UHS2_POWER_SAVING
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -242,15 +242,38 @@ void hook_usb_suspend_loop(void)
|
||||||
static uint8_t _led_stats = 0;
|
static uint8_t _led_stats = 0;
|
||||||
void hook_usb_suspend_entry(void)
|
void hook_usb_suspend_entry(void)
|
||||||
{
|
{
|
||||||
|
dprintf("[S]");
|
||||||
matrix_clear();
|
matrix_clear();
|
||||||
clear_keyboard();
|
clear_keyboard();
|
||||||
|
|
||||||
usb_host.suspend();
|
usb_host.suspend();
|
||||||
|
|
||||||
|
#ifdef UHS2_POWER_SAVING
|
||||||
|
// power down when remote wake is not enabled
|
||||||
|
if (!USB_Device_RemoteWakeupEnabled) {
|
||||||
|
dprintf("[p]");
|
||||||
|
usb_host.powerDown();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void hook_usb_wakeup(void)
|
void hook_usb_wakeup(void)
|
||||||
{
|
{
|
||||||
|
dprintf("[W]");
|
||||||
suspend_wakeup_init();
|
suspend_wakeup_init();
|
||||||
|
|
||||||
|
#ifdef UHS2_POWER_SAVING
|
||||||
|
// power down when remote wake is not enabled
|
||||||
|
if (!USB_Device_RemoteWakeupEnabled) {
|
||||||
|
dprintf("[P]");
|
||||||
|
usb_host.powerUp();
|
||||||
|
|
||||||
|
// USB state cannot be retained through power down/up cycle
|
||||||
|
// device should be enumerated and initialize from the beginning
|
||||||
|
usb_host.ReleaseAllDevices();
|
||||||
|
usb_host.setUsbTaskState(USB_STATE_DETACHED);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
usb_host.resume();
|
usb_host.resume();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue