diff options
| author | sakumisu <[email protected]> | 2023-11-21 22:20:57 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2023-11-22 19:28:30 +0800 |
| commit | af1484882ddad8d2f5b2770cc1ea34bea89ac7c9 (patch) | |
| tree | 83badf3dd593ee488628dd64de3ac3586203a5d8 | |
| parent | e3c9fdbb862d731730f28fd8c0d566cb66aefebd (diff) | |
support ehci suspend & resume
| -rw-r--r-- | port/ehci/usb_hc_ehci.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/port/ehci/usb_hc_ehci.c b/port/ehci/usb_hc_ehci.c index a37226c4..8f3e2687 100644 --- a/port/ehci/usb_hc_ehci.c +++ b/port/ehci/usb_hc_ehci.c @@ -961,6 +961,19 @@ int usbh_roothub_control(struct usb_setup_packet *setup, uint8_t *buf) EHCI_HCOR->portsc[port - 1] &= ~EHCI_PORTSC_PE; break; case HUB_PORT_FEATURE_SUSPEND: + EHCI_HCOR->portsc[port - 1] |= EHCI_PORTSC_RESUME; + usb_osal_msleep(20); + EHCI_HCOR->portsc[port - 1] &= ~EHCI_PORTSC_RESUME; + while(EHCI_HCOR->portsc[port - 1] & EHCI_PORTSC_RESUME){} + + temp = EHCI_HCOR->usbcmd; + temp |= EHCI_USBCMD_ASEN; + temp |= EHCI_USBCMD_PSEN; + temp |= EHCI_USBCMD_RUN; + EHCI_HCOR->usbcmd = temp; + + while((EHCI_HCOR->usbcmd & EHCI_USBCMD_RUN) == 0){} + case HUB_PORT_FEATURE_C_SUSPEND: break; case HUB_PORT_FEATURE_POWER: @@ -990,6 +1003,16 @@ int usbh_roothub_control(struct usb_setup_packet *setup, uint8_t *buf) switch (setup->wValue) { case HUB_PORT_FEATURE_SUSPEND: + temp = EHCI_HCOR->usbcmd; + temp &= ~EHCI_USBCMD_ASEN; + temp &= ~EHCI_USBCMD_PSEN; + temp &= ~EHCI_USBCMD_RUN; + EHCI_HCOR->usbcmd = temp; + + while(EHCI_HCOR->usbcmd & EHCI_USBCMD_RUN){} + + EHCI_HCOR->portsc[port - 1] |= EHCI_PORTSC_SUSPEND; + while((EHCI_HCOR->portsc[port - 1] & EHCI_PORTSC_SUSPEND) == 0){} break; case HUB_PORT_FEATURE_POWER: #ifdef CONFIG_USB_EHCI_PORT_POWER |
