drivers: usb: add generic ohci host driver#107065
drivers: usb: add generic ohci host driver#107065maass-hamburg wants to merge 6 commits intozephyrproject-rtos:mainfrom
Conversation
|
Thank you for adding support for Qemu testing. I see tests added. I propose these two PRs:
If this makes sense, it is possible to rebase this current PR on top of either. Feedback welcome. |
|
The really working in qemu version is in #107279. I have not yet updated the commits in here. |
b6477fa to
2119cdd
Compare
2119cdd to
a47a180
Compare
a47a180 to
f0f7207
Compare
When zephyr_udc0 or zephyr_uhc0 are enabled, add the more recent usbd and usbh tags meant to replace usb_device and usb_host. Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
Add a simple test that expects a device already connected when the controller initializes, then read its descriptors. Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
f0f7207 to
bb131ca
Compare
|
What is the goal of this? OHCI is limited to full-speed, and is also used as a companion controller to EHCI, which is limited to high-speed. Though there are EHCI/OHCI shim drivers in the tree for the NXP controllers, I doubt that someone will spend time to get this driver working on real hardware. If that is about to get a controller supported in QEMU, then the right way would be to write XHCI driver. See also QEMU/USB emulation. |
USB compliant High-Speed host port must support Low-Speed/Full-Speed/High-Speed devices connected to it. EHCI controller only supports High-Speed devices, you still need companion controller to handle Full-Speed/Low-Speed devices. EHCI Revision 1.0 1. Introduction
If we are talking about modern x86 PCs, then maybe XHCI is the only thing that matters. But I highly doubt that all the embedded SOCs that do have EHCI/OHCI are end-of-life - which is what your comment seems to suggest. |
|
Mainly because of https://spinalhdl.github.io/SpinalDoc-RTD/master/SpinalHDL/Libraries/Com/usb_ohci.html Because OHCI has a Open Source implementation for FPGAs. That it works in qemu is a very nice bonus and that's how i tested it. |
That makes much more sense. |
In my opinion, it should be migrated to this driver. I have never been a big fan of using hals, as can be seen in #108088 |
| default 3 | ||
| help | ||
| Number of concurrently active bulk/interrupt transfer slots. One slot | ||
| is always reserved for control transfers. Each additional slot allows | ||
| one more bulk or interrupt endpoint to stay posted simultaneously | ||
| (e.g. both IN and OUT for CDC-ECM data plus the interrupt notification | ||
| endpoint). Memory cost is one ED plus UHC_OHCI_MAX_TDS transfer | ||
| descriptors per slot. |
There was a problem hiding this comment.
Should the default increase to 4? 4 should allow CDC ECM (or CDC ACM, or any other class that uses 3 endpoints) to operate freely (one is always reserved for control transfers).
There was a problem hiding this comment.
sure why not, imean we could even set it to 8 by default and leave it to the user to reduce it, if the target is that memory constraint
| #define OHCI_RHPS_W1C_MASK (OHCI_RHPS_CSC | OHCI_RHPS_PESC | OHCI_RHPS_PSSC | \ | ||
| OHCI_RHPS_OCIC | OHCI_RHPS_PRSC) |
There was a problem hiding this comment.
What is so special about these bits? CCS, PRS, PPS and LSDA are also W1C according to specification. Other defined fields which do not have corresponding #define statements here are also W1C.
| #define OHCI_ED_FA_SHIFT 0U | ||
| #define OHCI_ED_EN_SHIFT 7U |
There was a problem hiding this comment.
Why no mask for FunctionAddress and EndpointNumber?
| #define OHCI_ED_D_SHIFT 11U | ||
| #define OHCI_ED_D_FROM_TD 0U | ||
| #define OHCI_ED_D_OUT 1U | ||
| #define OHCI_ED_D_IN 2U |
There was a problem hiding this comment.
Why deviate from the style used with OHCI_CONTROL_HCFS_?
| #define OHCI_ED_D_IN 2U | ||
| #define OHCI_ED_SPEED BIT(13) | ||
| #define OHCI_ED_SKIP BIT(14) | ||
| #define OHCI_ED_MPS_SHIFT 16U |
There was a problem hiding this comment.
Why no mask for MaximumPacketSize?
| #define OHCI_RHPS_W1C_MASK (OHCI_RHPS_CSC | OHCI_RHPS_PESC | OHCI_RHPS_PSSC | \ | ||
| OHCI_RHPS_OCIC | OHCI_RHPS_PRSC) | ||
|
|
||
| #define OHCI_ED_FA_SHIFT 0U |
There was a problem hiding this comment.
I would greatly appreciate /* 4.2.2 Endpoint Descriptor Field Definitions */ comment, as this is not so easy to find otherwise.
| #define OHCI_TD_CC_NO_ERROR 0U | ||
| #define OHCI_TD_CC_DATA_UNDERRUN 9U | ||
| #define OHCI_TD_CC_NOT_ACCESSED 15U | ||
| #define OHCI_TD_T_SHIFT 24U | ||
| #define OHCI_TD_T_TOGGLE_ED 0U | ||
| #define OHCI_TD_T_DATA0 2U | ||
| #define OHCI_TD_T_DATA1 3U | ||
| #define OHCI_TD_DI_SHIFT 21U | ||
| #define OHCI_TD_DI_NO_INTERRUPT 7U | ||
| #define OHCI_TD_DP_SHIFT 19U | ||
| #define OHCI_TD_DP_SETUP 0U | ||
| #define OHCI_TD_DP_OUT 1U | ||
| #define OHCI_TD_DP_IN 2U |
There was a problem hiding this comment.
Why deviate from the style used with OHCI_CONTROL_HCFS_?
Why no mask for T, DI and DP?
| uint32_t ed_flags = FIELD_PREP(GENMASK(6, 0), xfer->udev->addr) | | ||
| FIELD_PREP(GENMASK(10, 7), USB_EP_GET_IDX(xfer->ep)) | | ||
| FIELD_PREP(GENMASK(31, 16), xfer->mps) | | ||
| FIELD_PREP(GENMASK(12, 11), OHCI_ED_D_FROM_TD); |
There was a problem hiding this comment.
Why the masks are generated inline here? Aren't there supposed to be defines for these?
| FIELD_PREP(GENMASK(25, 24), toggle) | | ||
| FIELD_PREP(GENMASK(20, 19), dp) | | ||
| FIELD_PREP(GENMASK(23, 21), |
There was a problem hiding this comment.
Why the masks are generated inline here? Aren't there supposed to be defines for these?
| @@ -0,0 +1 @@ | |||
| CONFIG_QEMU_EXTRA_FLAGS="-device usb-ccid" | |||
There was a problem hiding this comment.
Using the smartcard reader because that is unlikely to get driver support in zephyr.
Why is it important that there is no driver support?
There was a problem hiding this comment.
it isn't really, i just wanted to make sure to reduce problems in the future
There was a problem hiding this comment.
In such case, I would rephrase the commit message to indicate that the usb-ccid is just arbitrary choice. Without going into the speculation whether it will get driver support or won't.
add Generic OHCI USB host controller driver support Assisted-by: GitHub Copilot: GPT-5.3-Codex Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
We need to attach a usb device to the usb bus for the test to work, therefore tell qemu to add a usb smartcard reader. Using the smartcard reader because that is unlikely to get driver support in zephyr. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Add usb ohci host controller to the qemu riscv32 board. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
add qemu board config, that way a device on the usb bus is being reported Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
bb131ca to
72b1a71
Compare
|



Introduce support for the Generic OHCI USB host controller driver and add necessary configurations for QEMU boards. Include tests for USB OHCI functionality on QEMU.