This series adds USB Device Controller (UDC) support for the ASPEED AST1030 and extends the existing ASPEED UDC model with the transfer handling required by the AST1030.
The v1 series included both the usbredir server transport and the ASPEED AST1030 UDC support. Following review feedback, the two parts have been split into separate series. The usbredir server transport is now sent separately, while this series contains the ASPEED AST1030 UDC changes. Dependency ========== The AST1030 UDC implementation itself does not depend on the usbredir server transport series. However, the functional test in this series does depend on it, because the AST1030 has no USB host controller and requires usb-redir-server to export the emulated USB gadget to a USB host controller in another QEMU instance. The functional test therefore depends on: [PATCH v2 0/8] hw/usb: Add a usbredir server transport https://patchwork.kernel.org/project/qemu-devel/cover/[email protected]/ Background ========== This work is part of a larger plan to model USB device-side support on ASPEED BMC/BIC SoCs, which has three goals: 1. Model the ASPEED UDC (AST2600 / AST1030). The AST2600 also has USB host (EHCI) controllers, so that work targets the AST2600 UDC: its gadget can be attached to the SoC's own EHCI bus, letting the guest enumerate its own gadget and exercise the UDC end-to-end. [Done] https://lore.kernel.org/qemu-devel/[email protected]/ 2. AST1030 UDC. The AST1030 has no USB host controller, so testing its UDC needs a second QEMU instance. The UDC gadget is redirected out of the guest with libusbredir and attached to another QEMU that runs a USB host (a VMM, or an AST2600 / AST2700 guest). [this series] 3. ASPEED vHub, as a longer-term goal towards BMC KVM / Virtual Media support in QEMU. [future] This series implements goal 2. AST1030 gadget to an AST2700 host ================================= QEMU #1 -M ast1030-evb QEMU #2 -M ast2700a2-evb +-----------------------------+ +-----------------------------+ | Zephyr usb_dc_aspeed | | Linux ehci-platform | +--------------+--------------+ +--------------+--------------+ | MMIO | MMIO +--------------v--------------+ +--------------v--------------+ | aspeed.udc | | EHCI3 (usb-bus.3) | +--------------+--------------+ +--------------+--------------+ | USBPacket | USBPacket +--------------v--------------+ +--------------v--------------+ | aspeed.udc-gadget | | usb-redir | +--------------+--------------+ +--------------+--------------+ | USBPacket | +--------------v--------------+ | | usb-redir-server | | +--------------+--------------+ | | | +=========== unix socket ============+ usbredir protocol Testing ======= The AST1030 UDC was tested with a Zephyr CDC-ACM gadget. The AST1030 side exports the gadget through usb-redir-server: $ qemu-system-arm -M ast1030-evb -nographic -kernel zephyr.bin -chardev socket,id=u,path=/tmp/usbredir.sock,server=on,wait=off -device usb-redir-server,id=udcredir,chardev=u -device aspeed.udc-gadget,bus=udcredir.0,udc=/machine/soc/udc uart:~$ usb enable uart:~$ usb print 1 The gadget is attached to EHCI3 of an AST2700 guest through the usb-redir client: $ qemu-system-aarch64 -M ast2700a2-evb -nographic -drive file=image-bmc,if=mtd,format=raw -snapshot -net nic -net user -chardev socket,id=r,path=/tmp/usbredir.sock -device usb-redir,chardev=r,bus=usb-bus.3 The AST2700 guest enumerates the AST1030 gadget: root@ast2700-default:~# lsusb Bus 001 Device 001: ID 1d6b:0002 Linux 6.18.36 ehci_hcd EHCI Host Controller Bus 001 Device 002: ID 2245:1030 ZEPHYR Zephyr DFU sample Data transfer was also checked: 2700 -> 1030 echo '1234567890' > /dev/ttyACM0 1030 console: Print Data: 0x31 0x32 ... 0x30 A functional test is added to exercise the AST1030 UDC through this usbredir setup. v1: 1. Make the SETUP buffer byte addressable 2. Support single-stage IN transfers 3. Clear EP_POOL_ACK when no endpoint ack is left 4. Mask the reserved bits on register writes 5. Use the endpoint max packet size for OUT transfers 6. Test the usbredir server transport 7. Add the USB device controller for AST1030 v2: 1. Split the usbredir server transport into a separate series as suggested during review. 2. Keep this series focused on the ASPEED UDC changes and AST1030 UDC support. 3. Add the AST1030 functional test using the usbredir server transport. Jamin Lin (11): hw/usb/aspeed-udc: Make the SETUP buffer byte addressable hw/usb/aspeed-udc: Mask the reserved bits on register writes hw/usb/aspeed-udc: Clear EP_POOL_ACK when no endpoint ack is left hw/usb/aspeed-udc: Rename the transfer helpers after their DMA mode hw/usb/aspeed-udc: Store the EP_DMA_STS write first hw/usb/aspeed-udc: Pick the EP_DMA_STS path by direction hw/usb/aspeed-udc: Support single-stage IN transfers hw/usb/aspeed-udc: Use the endpoint max packet size for OUT transfers hw/usb/aspeed-udc: Add trace events for the transfer paths hw/arm/aspeed_ast10x0: Add the USB device controller tests/functional/arm/test_aspeed_ast1030: Test the usbredir server transport include/hw/arm/aspeed_soc.h | 1 + include/hw/usb/aspeed-udc.h | 13 +- hw/arm/aspeed_ast10x0.c | 17 +- hw/usb/aspeed-udc.c | 290 ++++++++++++++++---- hw/usb/trace-events | 9 + tests/functional/arm/meson.build | 1 + tests/functional/arm/test_aspeed_ast1030.py | 52 ++++ 7 files changed, 330 insertions(+), 53 deletions(-) -- 2.43.0
