@@ -833,7 +833,6 @@ static hcd_port_event_t _intr_hdlr_hprt(port_t *port, usb_dwc_hal_port_event_t h
833833 }
834834 case USB_DWC_HAL_PORT_EVENT_REMOTE_WAKEUP : {
835835 esp_rom_printf ("WAKE\n" );
836- //port->state = HCD_PORT_STATE_ENABLED;
837836 port_event = HCD_PORT_EVENT_REMOTE_WAKEUP ;
838837 break ;
839838 }
@@ -1259,9 +1258,9 @@ static esp_err_t _port_cmd_power_on(port_t *port)
12591258 // Port can only be powered on if it's currently unpowered
12601259 if (port -> state == HCD_PORT_STATE_NOT_POWERED ) {
12611260 port -> state = HCD_PORT_STATE_DISCONNECTED ;
1261+ //assert(_internal_clk_gate(port, false)); // Un-gate the phy clock TODO: Test this
12621262 usb_dwc_hal_port_init (port -> hal );
12631263 usb_dwc_hal_port_toggle_power (port -> hal , true);
1264- //_internal_clk_gate(port, false); // Un-gate the phy clock TODO: Test this
12651264 ret = ESP_OK ;
12661265 } else {
12671266 ret = ESP_ERR_INVALID_STATE ;
@@ -1274,8 +1273,13 @@ static esp_err_t _port_cmd_power_off(port_t *port)
12741273 esp_err_t ret ;
12751274 // Port can only be unpowered if already powered
12761275 if (port -> state != HCD_PORT_STATE_NOT_POWERED ) {
1276+
1277+ if (port -> state == HCD_PORT_STATE_SUSPENDED ) {
1278+ // un-gate internal clock, to be able to toggle power on the port
1279+ assert (_internal_clk_gate (port , false)); // Un-gate the phy clock
1280+ }
12771281 port -> state = HCD_PORT_STATE_NOT_POWERED ;
1278- //_internal_clk_gate(port, false); // Un-gate the phy clock TODO: Test this
1282+ //assert( _internal_clk_gate(port, false)) ; // Gate the phy clock TODO: Test this
12791283 usb_dwc_hal_port_deinit (port -> hal );
12801284 usb_dwc_hal_port_toggle_power (port -> hal , false);
12811285 // If a device is currently connected, this should trigger a disconnect event
@@ -1568,7 +1572,6 @@ esp_err_t hcd_port_deinit(hcd_port_handle_t port_hdl)
15681572 return ESP_OK ;
15691573}
15701574
1571-
15721575esp_err_t hcd_port_command (hcd_port_handle_t port_hdl , hcd_port_cmd_t command )
15731576{
15741577 esp_err_t ret = ESP_ERR_INVALID_STATE ;
@@ -1677,6 +1680,7 @@ esp_err_t hcd_port_recover(hcd_port_handle_t port_hdl)
16771680 ESP_ERR_INVALID_STATE );
16781681
16791682 // We are about to do a soft reset on the peripheral. Disable the peripheral throughout
1683+ //assert(_internal_clk_gate(port, false)); // Gate the phy clock
16801684 esp_intr_disable (port -> isr_hdl );
16811685 usb_dwc_hal_core_soft_reset (port -> hal );
16821686 port -> state = HCD_PORT_STATE_NOT_POWERED ;
@@ -1686,6 +1690,7 @@ esp_err_t hcd_port_recover(hcd_port_handle_t port_hdl)
16861690 // Clear the frame list. We set the frame list register and enable periodic scheduling after a successful reset
16871691 memset (port -> frame_list , 0 , FRAME_LIST_LEN * sizeof (uint32_t ));
16881692 esp_intr_enable (port -> isr_hdl );
1693+ //assert(_internal_clk_gate(port, true)); // Gate the phy clock
16891694 HCD_EXIT_CRITICAL ();
16901695 return ESP_OK ;
16911696}
0 commit comments