-
Notifications
You must be signed in to change notification settings - Fork 717
USB cherry pick series for NCS 2.7.99-CS2 #2038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add UDC driver for IT82xx2 SoC. This commit passes tests with 1. samples/subsys/usb/cdc_acm/ 2. samples/subsys/usb/console/ 3. The extend endpoint test with CDC ACM tool 4. USB suspend/resume detection Signed-off-by: Ren Chen <[email protected]> (cherry picked from commit 766a5ea) Signed-off-by: Tomasz Moń <[email protected]>
udc_mcux_ehci is based on the MCUX USB controller driver (usb_device_ehci.c); udc_mcux_ip3511 is based on the MCUX USB controller driver (usb_device_lpcip3511.c); add related Kconfig and CMake; include the usb_phy.h path in modules/hal_nxp/usb/CMakeLists.txt because udc_mcux.c use it; add related macros to usb_device_config.h; update CMakeLists for udc_mcux_ehci and udc_mcux_ip3511. Signed-off-by: Mark Wang <[email protected]> (cherry picked from commit b6b43c3) Signed-off-by: Tomasz Moń <[email protected]>
…iption Rework new USB device support overview description. Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit 9e80d4f) Signed-off-by: Tomasz Moń <[email protected]>
… class instances Add helper to register/unregister all available class instances. Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit 4191602) Signed-off-by: Tomasz Moń <[email protected]>
…all_classes() Rework common USB samples code to use usbd_register_all_classes(). Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit cf2113e) Signed-off-by: Tomasz Moń <[email protected]>
Add initial documentation how to configure and enable new USB device support. Use literalinclude to pull code snippets from the samples. Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit 8739efe) Signed-off-by: Tomasz Moń <[email protected]>
Add register bit defines for registers needed for DMA operation. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit 2c9371e) Signed-off-by: Tomasz Moń <[email protected]>
Do not use sys_clear_bits() followed by sys_set_bits() on DCTL register to avoid writing to DCTL register twice - first with zeroed out address, and then with the new address. Change the code to write the address in one DCTL register write. Do not use sys_set_bits() to set test mode, but rather prepare the correct value first. Set DCFG and GUSBCFG registers in one go. There is no point in reading back the value or doing multiple subsequent writes to these registers. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit 59702c7) Signed-off-by: Tomasz Moń <[email protected]>
Implement absolute minimum necessary to get Buffer DMA working. Require Data Cache to be disabled if DWC2 OTG has DMA enabled because the stack does not currently guarantee cache line alignment for allocated buffers. Set EPENA bit before disabling IN endpoints because it seems to be necessary in Buffer DMA mode (without EPENA the wait for INEPNAKEFF does time out). Setting EPENA should have no impact on Completer mode operation (where EPENA is not necessary for INEPNAKEFF to trigger). Programming Guide recommends programming SUPCnt to 3, but the only advantage would be to be able to tell how many back-to-back SETUP packets were received if there was no more than 3 back-to-back SETUPs. This information doesn't seem to be useful. The disadvantage is that the buffer needed for receiving SETUP packet must be able to hold SUPCnt multiple of 8 bytes. Use SUPCnt 1 so the 8 bytes buffer is enough. Make sure to clear StsPhseRcvd interrupt bit in Buffer DMA mode because the DMA seems to prevent the SETUP Phase Done interrupt from triggering if StsPhseRcvd is set. Clearing this bit doesn't seem to be necessary in Completer mode. This bit is set on control transfers with data stage from host to device. Both Buffer DMA and Completer mode operation on nRF54H20DK was verified using USB2CV Chapter 9 Tests and MSC Tests with Mass Storage sample. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit e1b95eb) Signed-off-by: Tomasz Moń <[email protected]>
Add documentation about USB message notifications. Use literalinclude to pull code snippets from the samples. Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit 7e12308) Signed-off-by: Tomasz Moń <[email protected]>
…ABLED remove CONFIG_DT_HAS_NXP_USBPHY_ENABLED to make codes more simple Signed-off-by: Mark Wang <[email protected]> (cherry picked from commit e2ec54b) Signed-off-by: Tomasz Moń <[email protected]>
Rename uhc_dev parameter of USBD_DEVICE_DEFINE macro to udc_dev to reflect that this is a USB Device Controller device and not a USB Host Controller device. Signed-off-by: Abe Kohandel <[email protected]> (cherry picked from commit de69ebd) Signed-off-by: Tomasz Moń <[email protected]>
Use the message queue to pass the new report from the input callback, and use a semaphore to protect the report buffer until it is transferred to the host. Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit 67a31ef) Signed-off-by: Tomasz Moń <[email protected]>
Add missing documentation to USBD_DEVICE_DEFINE, USBD_CONFIGURATION_DEFINE and USBD_DEFINE_CLASS macros. Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit 1248e26) Signed-off-by: Tomasz Moń <[email protected]>
Fix "designator order for field 'usbd_desc_node::ptr' does not match declaration order in 'usbd_desc_node'" error when building applications with CONFIG_CPP enabled. Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit 18c624e) Signed-off-by: Tomasz Moń <[email protected]>
Remove unnecessary usbd_device_unlock() in usbd_add_configuration(). Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit 1540ba1) Signed-off-by: Tomasz Moń <[email protected]>
… descriptor Change USBD_CONFIGURATION_DEFINE macro to take the address of a string descriptor node as an argument. This is a breaking change for macro users, but quite convenient and easy to implement. Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit 28b2051) Signed-off-by: Tomasz Moń <[email protected]>
When dynamic fifo sizing is enabled the driver can assign fifo size lower or equal to the reset value. Software must respect the maximum sizes because fifo width registers are optimized during synthesis and the larger values simply get discarded. Use 16-bit values for FIFO depths because maximum FIFO depth the vendor can configure the DWC2 otg is 32768. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit f0677e5) Signed-off-by: Tomasz Moń <[email protected]>
Introduce UDC_BUF_POOL_*_DEFINE macros based on NET_BUF_POOL_*_DEFINE macros but use our own version of alloc and unref callbacks to get buffers with specific alignment and granularity. Also, do not use ref callback because it breaks alignment. Also introduces helper macros for defining and checking UDC driver-compliant static buffers. Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit 67caae3) Signed-off-by: Tomasz Moń <[email protected]>
UDC_BUF_POOL_*_DEFINE macro will place buffer pool in __nocache section if NOCACHE_MEMORY is enabled. Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit 9bf3232) Signed-off-by: Tomasz Moń <[email protected]>
Remove BUILD_ASSERT for Internal DMA and DCACHE if both are enabled, and enable Internal DMA support by default. Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit 76fadf9) Signed-off-by: Tomasz Moń <[email protected]>
…_enable() Driver includes wrong header zephyr/usb/usb_device.h and uses defines from include/zephyr/drivers/usb/usb_dc.h. Also fix udc_ep_enable() implementation in general. HAL_PCD_EP_Open() takes the ep_type parameter as uint8_t integer type and the shim driver should not just pass int type. It is recommended that drivers use ep_cfg or cfg for struct udc_ep_config, fix this as well. Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit 043aa83) Signed-off-by: Tomasz Moń <[email protected]>
Add a void *user_data pointer to the input callback structure. This is useful for driver to get back the driver data structure and avoid defining wrapper functions. Signed-off-by: Fabio Baltieri <[email protected]> (cherry picked from commit 716fa26) Signed-off-by: Tomasz Moń <[email protected]>
Enable the MCUX USB controller driver sof, then convert it to zephyr UDC_EVT_SOF event. Signed-off-by: Mark Wang <[email protected]> (cherry picked from commit 564f348) Signed-off-by: Tomasz Moń <[email protected]>
…fication Notify only if the device configuration has changed. Pass only the configuration value as the message status, the actual device speed can be obtained with usbd_bus_speed(). Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit f851cad) Signed-off-by: Tomasz Moń <[email protected]>
wMaxPacketSize in endpoint descriptor is stored in little-endian order, but the mps parameter passed to functions is in host order. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit 60835aa) Signed-off-by: Tomasz Moń <[email protected]>
…tion Use COND_CODE_1() instead of UTIL_AND() to make it possible to only define the HID_MPS_LESS_65_ macros up to value 64. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit e333739) Signed-off-by: Tomasz Moń <[email protected]>
Add macros for converting between Max Packet Size and total payload length. Allow drivers specify whether endpoint supports high-bandwidth interrupt and high-bandwidth isochronous transfers. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit b7664f2) Signed-off-by: Tomasz Moń <[email protected]>
DMA is capable of packetizing transfers on its own and the driver doesn't need to check available TxFIFO size when scheduling DMA transfer. Split packets on DWORD boundary when writing more than one packet to TxFIFO in completer mode. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit 07ea4aa) Signed-off-by: Tomasz Moń <[email protected]>
Make driver aware of High-Bandwidth endpoints both in Completer and Buffer DMA mode. In Completer mode TxFIFO must be able to hold all packets for microframe, while in Buffer DMA mode space enough for two packets is sufficient. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit 07bd625) Signed-off-by: Tomasz Moń <[email protected]>
…e endpoint size Instead, use the helper to get the size field from the MPS value. MPS value may contain information about additional transaction per microframe (bits 12..11). Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit 8617e46) Signed-off-by: Tomasz Moń <[email protected]>
Add all register bit defines necessary for isochronous transfers. Clean up the endpoint transfer size register defines clearly separating IN and OUT registers because they do use different bit fields. Add alternate bit names for bits that do have different meaning based on configured endpoint transfer type. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit 9f98ee8) Signed-off-by: Tomasz Moń <[email protected]>
Function dwc2_set_dedicated_fifo() calls dwc2_flush_tx_fifo() before the diepctl register is written. The register will be only written after the dwc2_set_dedicated_fifo() finishes. Solve the problem by passing fifo number directly instead of endpoint address to dwc2_flush_tx_fifo(). Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit 31ee5d9) Signed-off-by: Tomasz Moń <[email protected]>
…d DMA mode RxFLvl interrupt should only handle the actual data movement from RxFIFO to the buffer. OUT transfers are completed in XferCompl handler both in DMA and Completer mode. This reduces code size by avoiding having separate code paths based on operating mode. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit de28a82) Signed-off-by: Tomasz Moń <[email protected]>
Store SOF frame number and use the information to set the Even/Odd microframe bit when enabling isochronous endpoints. Reject received isochronous data if number of packets received does not align with received PID. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit c3daf6f) Signed-off-by: Tomasz Moń <[email protected]>
Fail TxFIFO write if the endpoint is not activated, because there is essentially no fifo assigned. Writing to not activated endpoint is possible, but it does tend to corrupt fifo number 0 which is used for control transfers. USB stack should not really be attempting to write to endpoints that have not been activated (ep_enable called). Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit 0b242de) Signed-off-by: Tomasz Moń <[email protected]>
…mode Remove the early max packet size check on endpoint activation, because there are valid use cases where the max packet size is not multiple of 4 and the stack won't perform multi-transaction transfers. Example use case is UAC2 explicit feedback endpoint that has Max Packet Size equal 3 when device is operating at Full-Speed. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit debc744) Signed-off-by: Tomasz Moń <[email protected]>
…define Round up buffer size used in UDC_BUF_POOL_DEFINE() to respect the required buffer granularity. The issue was observed with UAC2 explicit feedback data, but the problem applies to any UDC_BUF_POOL_DEFINE() use. In order for every buffer returned by UDC_BUF_POOL_DEFINE() to be both aligned and to have required granurality, it is required to allocate the buffers for ROUND_UP(size, LCM(UDC_BUF_GRANULARITY, UDC_BUF_ALIGN)). Because we do not have Least Common Multiple nor Greatest Common Divisor compile time macros, assume that granularity is multiple of alignment. Validate the assumption with a build time assert. When we get a target where this assumption fails we would have to come up with a solution to compute LCM and/or GCD at compile time. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit 0f41950) Signed-off-by: Tomasz Moń <[email protected]>
Do not allocate TxFIFO in a way that could corrupt Endpoint Information Controller data (stored at DFIFO Depth address) or access locations outside the SPRAM. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit 6582529) Signed-off-by: Tomasz Moń <[email protected]>
|
Descoped due to issues that are not present in upmerge branch. No point in trying to figure out the root cause which most likely is fixed in upstream Zephyr (and hence it does not reproduce in upmerge). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bring the features that are supposed to be in NCS 2.7.99-CS2