@@ -108,13 +108,11 @@ DT_INST_FOREACH_STATUS_OKAY(QUIRK_STM32F4_FSOTG_DEFINE)
108108
109109#endif /*DT_HAS_COMPAT_STATUS_OKAY(st_stm32f4_fsotg) */
110110
111- #if DT_HAS_COMPAT_STATUS_OKAY (nordic_nrf_usbhs )
111+ #if DT_HAS_COMPAT_STATUS_OKAY (nordic_nrf_usbhs ) || \
112+ DT_HAS_COMPAT_STATUS_OKAY (nordic_nrf_usbhs_nrf54l )
112113
113114#define DT_DRV_COMPAT snps_dwc2
114115
115- #include <nrfs_backend_ipc_service.h>
116- #include <nrfs_usb.h>
117-
118116#define USBHS_DT_WRAPPER_REG_ADDR (n ) UINT_TO_POINTER(DT_INST_REG_ADDR_BY_NAME(n, wrapper))
119117
120118/*
@@ -125,7 +123,72 @@ DT_INST_FOREACH_STATUS_OKAY(QUIRK_STM32F4_FSOTG_DEFINE)
125123 * CONFIG_UDC_DWC2_USBHS_VBUS_READY_TIMEOUT timeout expires.
126124 */
127125static K_EVENT_DEFINE (usbhs_events );
128- #define USBHS_VBUS_READY BIT(0)
126+ #define USBHS_VBUS_READY BIT(0)
127+
128+ static inline int usbhs_enable_core (const struct device * dev )
129+ {
130+ NRF_USBHS_Type * wrapper = USBHS_DT_WRAPPER_REG_ADDR (0 );
131+ k_timeout_t timeout = K_FOREVER ;
132+
133+ #if CONFIG_NRFS_HAS_VBUS_DETECTOR_SERVICE
134+ if (CONFIG_UDC_DWC2_USBHS_VBUS_READY_TIMEOUT ) {
135+ timeout = K_MSEC (CONFIG_UDC_DWC2_USBHS_VBUS_READY_TIMEOUT );
136+ }
137+ #endif
138+
139+ if (!k_event_wait (& usbhs_events , USBHS_VBUS_READY , false, K_NO_WAIT )) {
140+ LOG_WRN ("VBUS is not ready, block udc_enable()" );
141+ if (!k_event_wait (& usbhs_events , USBHS_VBUS_READY , false, timeout )) {
142+ return - ETIMEDOUT ;
143+ }
144+ }
145+
146+ wrapper -> ENABLE = USBHS_ENABLE_PHY_Msk | USBHS_ENABLE_CORE_Msk ;
147+ wrapper -> TASKS_START = 1UL ;
148+
149+ /* Wait for clock to start to avoid hang on too early register read */
150+ k_busy_wait (1 );
151+
152+ /* Enable interrupts */
153+ wrapper -> INTENSET = 1UL ;
154+
155+ return 0 ;
156+ }
157+
158+ static inline int usbhs_disable_core (const struct device * dev )
159+ {
160+ NRF_USBHS_Type * wrapper = USBHS_DT_WRAPPER_REG_ADDR (0 );
161+
162+ /* Disable interrupts */
163+ wrapper -> INTENCLR = 1UL ;
164+
165+ wrapper -> ENABLE = 0UL ;
166+ wrapper -> TASKS_START = 1UL ;
167+
168+ return 0 ;
169+ }
170+
171+ static inline int usbhs_init_caps (const struct device * dev )
172+ {
173+ struct udc_data * data = dev -> data ;
174+
175+ data -> caps .can_detect_vbus = true;
176+ data -> caps .hs = true;
177+
178+ return 0 ;
179+ }
180+
181+ static inline int usbhs_is_phy_clk_off (const struct device * dev )
182+ {
183+ return !k_event_test (& usbhs_events , USBHS_VBUS_READY );
184+ }
185+
186+ #endif /* nordic_nrf_usbhs || nordic_nrf_usbhs_nrf54l */
187+
188+ #if DT_HAS_COMPAT_STATUS_OKAY (nordic_nrf_usbhs )
189+
190+ #include <nrfs_backend_ipc_service.h>
191+ #include <nrfs_usb.h>
129192
130193static void usbhs_vbus_handler (nrfs_usb_evt_t const * p_evt , void * const context )
131194{
@@ -180,49 +243,6 @@ static inline int usbhs_enable_nrfs_service(const struct device *dev)
180243 return 0 ;
181244}
182245
183- static inline int usbhs_enable_core (const struct device * dev )
184- {
185- NRF_USBHS_Type * wrapper = USBHS_DT_WRAPPER_REG_ADDR (0 );
186- k_timeout_t timeout = K_FOREVER ;
187-
188- #if CONFIG_NRFS_HAS_VBUS_DETECTOR_SERVICE
189- if (CONFIG_UDC_DWC2_USBHS_VBUS_READY_TIMEOUT ) {
190- timeout = K_MSEC (CONFIG_UDC_DWC2_USBHS_VBUS_READY_TIMEOUT );
191- }
192- #endif
193-
194- if (!k_event_wait (& usbhs_events , USBHS_VBUS_READY , false, K_NO_WAIT )) {
195- LOG_WRN ("VBUS is not ready, block udc_enable()" );
196- if (!k_event_wait (& usbhs_events , USBHS_VBUS_READY , false, timeout )) {
197- return - ETIMEDOUT ;
198- }
199- }
200-
201- wrapper -> ENABLE = USBHS_ENABLE_PHY_Msk | USBHS_ENABLE_CORE_Msk ;
202- wrapper -> TASKS_START = 1UL ;
203-
204- /* Wait for clock to start to avoid hang on too early register read */
205- k_busy_wait (1 );
206-
207- /* Enable interrupts */
208- wrapper -> INTENSET = 1UL ;
209-
210- return 0 ;
211- }
212-
213- static inline int usbhs_disable_core (const struct device * dev )
214- {
215- NRF_USBHS_Type * wrapper = USBHS_DT_WRAPPER_REG_ADDR (0 );
216-
217- /* Disable interrupts */
218- wrapper -> INTENCLR = 1UL ;
219-
220- wrapper -> ENABLE = 0UL ;
221- wrapper -> TASKS_START = 1UL ;
222-
223- return 0 ;
224- }
225-
226246static inline int usbhs_disable_nrfs_service (const struct device * dev )
227247{
228248 nrfs_err_t nrfs_err ;
@@ -247,21 +267,6 @@ static inline int usbhs_irq_clear(const struct device *dev)
247267 return 0 ;
248268}
249269
250- static inline int usbhs_init_caps (const struct device * dev )
251- {
252- struct udc_data * data = dev -> data ;
253-
254- data -> caps .can_detect_vbus = true;
255- data -> caps .hs = true;
256-
257- return 0 ;
258- }
259-
260- static inline int usbhs_is_phy_clk_off (const struct device * dev )
261- {
262- return !k_event_test (& usbhs_events , USBHS_VBUS_READY );
263- }
264-
265270static inline int usbhs_post_hibernation_entry (const struct device * dev )
266271{
267272 const struct udc_dwc2_config * const config = dev -> config ;
@@ -311,6 +316,34 @@ DT_INST_FOREACH_STATUS_OKAY(QUIRK_NRF_USBHS_DEFINE)
311316
312317#endif /*DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_usbhs) */
313318
319+ #if DT_HAS_COMPAT_STATUS_OKAY (nordic_nrf_usbhs_nrf54l )
320+
321+ static inline int usbhs_enable_usbreg (const struct device * dev )
322+ {
323+ LOG_WRN ("VBUS detection not implemented." );
324+ k_event_post (& usbhs_events , USBHS_VBUS_READY );
325+ udc_submit_event (dev , UDC_EVT_VBUS_READY , 0 );
326+
327+ return 0 ;
328+ }
329+
330+ #define QUIRK_NRF_USBHS_DEFINE (n ) \
331+ struct dwc2_vendor_quirks dwc2_vendor_quirks_##n = { \
332+ .init = usbhs_enable_usbreg, \
333+ .pre_enable = usbhs_enable_core, \
334+ .disable = usbhs_disable_core, \
335+ .shutdown = NULL, \
336+ .irq_clear = NULL, \
337+ .caps = usbhs_init_caps, \
338+ .is_phy_clk_off = usbhs_is_phy_clk_off, \
339+ .post_hibernation_entry = NULL, \
340+ .pre_hibernation_exit = NULL, \
341+ };
342+
343+ DT_INST_FOREACH_STATUS_OKAY (QUIRK_NRF_USBHS_DEFINE )
344+
345+ #endif /*DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_usbhs_nrf54l) */
346+
314347/* Add next vendor quirks definition above this line */
315348
316349#endif /* ZEPHYR_DRIVERS_USB_UDC_DWC2_VENDOR_QUIRKS_H */
0 commit comments