@@ -186,7 +186,7 @@ static inline int esp32_usb_otg_get_phy_clock(struct phy_context_t *phy_ctx)
186186 \
187187 static int esp32_usb_otg_disable_phy_##n(const struct device *dev) \
188188 { \
189- return esp32_usb_otg_enable_phy (&phy_ctx_##n, false); \
189+ return esp32_usb_otg_disable_phy (&phy_ctx_##n, false); \
190190 } \
191191 static int esp32_usb_int_enable_func_##n(const struct device *dev) \
192192 { \
@@ -258,27 +258,6 @@ static void vregusb_isr(const void *arg)
258258 }
259259}
260260
261- static inline int usbhs_init_vreg_and_clock (const struct device * dev )
262- {
263- IRQ_CONNECT (VREGUSB_IRQn , NRF_DEFAULT_IRQ_PRIORITY ,
264- vregusb_isr , DEVICE_DT_INST_GET (0 ), 0 );
265-
266- NRF_VREGUSB -> INTEN = VREGUSB_INTEN_VBUSDETECTED_Msk |
267- VREGUSB_INTEN_VBUSREMOVED_Msk ;
268- NRF_VREGUSB -> TASKS_START = 1 ;
269-
270- /* TODO: Determine conditions when VBUSDETECTED is not generated */
271- if (sys_read32 ((mem_addr_t )NRF_VREGUSB + 0x400 ) & BIT (2 )) {
272- k_event_post (& usbhs_events , USBHS_VBUS_READY );
273- //uhc_submit_event(dev, UHC_EVT_VBUS_READY, 0);
274- }
275-
276- irq_enable (VREGUSB_IRQn );
277- pclk24m_mgr = z_nrf_clock_control_get_onoff (CLOCK_CONTROL_NRF_SUBSYS_HF24M );
278-
279- return 0 ;
280- }
281-
282261static inline int usbhs_enable_core (const struct device * dev )
283262{
284263 LOG_MODULE_DECLARE (uhc_dwc2 , CONFIG_UHC_DRIVER_LOG_LEVEL );
@@ -345,6 +324,36 @@ static inline int usbhs_disable_core(const struct device *dev)
345324 return 0 ;
346325}
347326
327+ static inline int usbhs_init_vreg_and_clock_and_core (const struct device * dev )
328+ {
329+ /* Init VREG */
330+
331+ IRQ_CONNECT (VREGUSB_IRQn , NRF_DEFAULT_IRQ_PRIORITY ,
332+ vregusb_isr , DEVICE_DT_INST_GET (0 ), 0 );
333+
334+ NRF_VREGUSB -> INTEN = VREGUSB_INTEN_VBUSDETECTED_Msk |
335+ VREGUSB_INTEN_VBUSREMOVED_Msk ;
336+ NRF_VREGUSB -> TASKS_START = 1 ;
337+
338+ /* TODO: Determine conditions when VBUSDETECTED is not generated */
339+ if (sys_read32 ((mem_addr_t )NRF_VREGUSB + 0x400 ) & BIT (2 )) {
340+ k_event_post (& usbhs_events , USBHS_VBUS_READY );
341+ //uhc_submit_event(dev, UHC_EVT_VBUS_READY, 0);
342+ }
343+
344+ irq_enable (VREGUSB_IRQn );
345+
346+ /* Init the clock */
347+
348+ pclk24m_mgr = z_nrf_clock_control_get_onoff (CLOCK_CONTROL_NRF_SUBSYS_HF24M );
349+
350+ /* Enable the core */
351+
352+ return usbhs_enable_core (dev );
353+
354+ /* It is now possible to access the configuration registers */
355+ }
356+
348357static inline int usbhs_disable_vreg (const struct device * dev )
349358{
350359 NRF_VREGUSB -> INTEN = 0 ;
@@ -422,7 +431,7 @@ static inline int usbhs_pre_hibernation_exit(const struct device *dev)
422431 } \
423432 \
424433 struct uhc_dwc2_vendor_quirks uhc_dwc2_vendor_quirks_##n = { \
425- .init = usbhs_init_vreg_and_clock, \
434+ .init = usbhs_init_vreg_and_clock_and_core, \
426435 .pre_enable = usbhs_enable_core, \
427436 .disable = usbhs_disable_core, \
428437 .shutdown = usbhs_disable_vreg, \
0 commit comments