From d5e6d028171a38e435ac1ab7c18ae5615f8af5cf Mon Sep 17 00:00:00 2001 From: Ryzee119 Date: Sat, 4 Jun 2022 14:06:23 +0930 Subject: [PATCH] ohci: Leave SMM or bios mode during init --- src/portable/ohci/ohci.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/portable/ohci/ohci.c b/src/portable/ohci/ohci.c index 45600c03b..364f61cf1 100644 --- a/src/portable/ohci/ohci.c +++ b/src/portable/ohci/ohci.c @@ -177,6 +177,22 @@ bool hcd_init(uint8_t rhport) ohci_data.bulk_head_ed.skip = 1; ohci_data.period_head_ed.skip = 1; + //If OHCI hardware is in SMM mode, gain ownership (Ref OHCI spec 5.1.1.3.3) + if (OHCI_REG->control_bit.interrupt_routing == 1) + { + OHCI_REG->command_status_bit.ownership_change_request = 1; + while (OHCI_REG->control_bit.interrupt_routing == 1) {} + } + + //If OHCI hardware has come from warm-boot, signal resume (Ref OHCI spec 5.1.1.3.4) + else if (OHCI_REG->control_bit.hc_functional_state != OHCI_CONTROL_FUNCSTATE_RESET && + OHCI_REG->control_bit.hc_functional_state != OHCI_CONTROL_FUNCSTATE_OPERATIONAL) + { + //Wait 20 ms. (Ref Usb spec 7.1.7.7) + OHCI_REG->control_bit.hc_functional_state = OHCI_CONTROL_FUNCSTATE_RESUME; + osal_task_delay(20); + } + // reset controller OHCI_REG->command_status_bit.controller_reset = 1; while( OHCI_REG->command_status_bit.controller_reset ) {} // should not take longer than 10 us