drivers: usb: dwc2: refactor to use MMIO macros#103779
drivers: usb: dwc2: refactor to use MMIO macros#103779nashif merged 1 commit intozephyrproject-rtos:mainfrom
Conversation
jfischer-no
left a comment
There was a problem hiding this comment.
Please use git log to view examples at how to write commit message in this area. No idea what warning do you mean. I am not aware of any. Type conversion to mem_addr_t do not seem to be correct.
I apologize for the poorly written commit message, these log should help. |
jfischer-no
left a comment
There was a problem hiding this comment.
Again, "Please use git log to view examples at how to write commit message in this area."
| } | ||
|
|
||
| sys_write32((uint32_t)buf->data, | ||
| sys_write32((mem_addr_t)buf->data, |
There was a problem hiding this comment.
/home/waleed-badar/workspace/zephyrproject/zephyr/drivers/usb/udc/udc_dwc2.c: In function 'dwc2_tx_fifo_write':
/home/waleed-badar/workspace/zephyrproject/zephyr/drivers/usb/udc/udc_dwc2.c:598:29: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
598 | sys_write32((uint32_t)buf->data,
I do not think it is right way to fix it. As its name suggests, it writes (or reads) a 32-bit value. Same below L:797 and L:2894 (where the change is just wrong).
a890c34 to
fb14b75
Compare
a3f1049 to
6434c0c
Compare
|
@jfischer-no Could you please provide more details on what needs to be updated in the commit message? I reviewed the log history but didn’t see anything specific for this area. |
|
Rebased to fix CI failures. |
|
Hi @jfischer-no, sorry to bother you again, could you please take a look? |
carlocaione
left a comment
There was a problem hiding this comment.
Also having This PR migrates... in a commit message doesn't make any sense when (if) the PR is merged
| #include <zephyr/logging/log.h> | ||
| LOG_MODULE_REGISTER(udc_dwc2, CONFIG_UDC_DRIVER_LOG_LEVEL); |
| uint8_t setup[8]; | ||
| }; | ||
|
|
||
| #include "udc_dwc2.h" |
There was a problem hiding this comment.
please add a comment explaining why now this header is here. This sucks but now udc_dwc2.h cannot be included anymore anywhere else, so add a comment there as well.
|
Needed a rebase due to zephyr-sdk changes. |
I have updated the commit message. |
The DWC2 USB driver was accessing hardware registers through a raw dev->config->base pointer, which breaks on MMU-enabled platforms where physical addresses need to be mapped to virtual ones before use. Use Zephyr's standard MMIO abstraction API by introducing DEVICE_MMIO_NAMED_RAM/ROM(core) in the driver's data and config structs, mapping the region at initialization time with DEVICE_MMIO_NAMED_MAP, and routing all register accesses through a dwc2_get_base() helper that calls DEVICE_MMIO_NAMED_GET. These changes allows the driver to be useful on MMU-based platforms like Broadcom BCM2711 SoC. Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
jfischer-no
left a comment
There was a problem hiding this comment.
Thank you.
Tested on nRF54LM20A.
Thank you for approving and also tested on Espressif ESP32S3 and Broadcom BCM2711. |
|
I hope there will be a follow-up PR to add vendor quirks to support Broadcom BCM2711 in the tree. |



The DWC2 USB driver was accessing hardware registers through a raw dev->config->base pointer, which breaks on MMU-enabled platforms where physical addresses need to be mapped to virtual ones before use.
Use Zephyr's standard MMIO abstraction API by introducing DEVICE_MMIO_NAMED_RAM/ROM(core) in the driver's data and config structs, mapping the region at initialization time with DEVICE_MMIO_NAMED_MAP, and routing all register accesses through a dwc2_get_base() helper that calls DEVICE_MMIO_NAMED_GET. These changes allows the driver to be useful on MMU-based platforms like Broadcom BCM2711 SoC.