Looking at our different embedded ohci driver they are almost the same except for the SoC clocks bits.
In the allwinner DTS the ohci controller have an additional compatible string set to "generic-ohci".
I've added a generic_ohci driver with an interface for init and deinit function that are responsible for enable/disable the clocks or others SoC bits.
We still can't use the "generic-ohci" driver directly because of clocks so method is disabled for now.
This also bring the driver for allwinner A10 and A20.
Details
- Reviewers
jmcneill • hselasky - Group Reviewers
ARM - Commits
- rS300068: Add driver for "generic-ohci" as defined by FDT.
Apply patch and test that ohci is working.
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 2779 Build 2800: arc lint + arc unit
Event Timeline
sys/arm/allwinner/a10_clk.c | ||
---|---|---|
166 | Instead of on/off you should use a counter here. Otherwise detaching a single instance of ehci/ohci will deactivate the others. | |
sys/arm/allwinner/a10_clk.h | ||
114 | I think these should be sorted by bit number. | |
sys/arm/allwinner/aw_ohci.c | ||
31 | Is this needed? | |
sys/dev/usb/controller/generic_ohci.c | ||
35 ↗ | (On Diff #13840) | Is this needed? |
41 ↗ | (On Diff #13840) | condvar.h might be unnecessary as well |
189 ↗ | (On Diff #13840) | ohci_detach writes to some registers, I don't think you want to be doing that after you've disabled clocks |
sys/arm/allwinner/a10_clk.c | ||
---|---|---|
156 | It looks like some of the clock gate and resets are shared between EHCI and OHCI. You'll need to track references to those separately. |
sys/arm/allwinner/a10_clk.c | ||
---|---|---|
168 | You need to call this before dropping the lock, and pass in sc for convenience. | |
182 | Call this before dropping the lock. | |
215 | Call this before dropping the lock. | |
247 | Call this before dropping the lock. | |
255 | This can be simplified if you add softc as a parameter. | |
261 | Instead of acquiring the lock here, assert that it is held. | |
281 | Pass sc as parameter to simplify. | |
287 | Same as activate -- assert that the lock is held instead. |
sys/conf/files | ||
---|---|---|
2572 | Thinking these should be named ohci_fdt.c / ohci_fdt_if.m for consistency as the rest of the FDT specific drivers in that directory are also named <foo>_fdt.c |
sys/conf/files | ||
---|---|---|
2572 | And rename generic_ohci to ohci_fdt too ? |
Rename generic_ohci to ohci_fdt.
Merge last head and rename a10_clk_usb_activate to a10_clk_ehci_activate in a10_ehci.
sys/arm/allwinner/a10_clk.h | ||
---|---|---|
135–136 | Sorting |
Remove clocking bits as they have been commited to HEAD.
Fix a few style(9) issues.
Remove ohci_fdt device and use "ohci fdt" in sys/conf/files
Looks good to me. Did you resolve all the style issues?
Do you think the device init and deinit methods you're adding should be more generic, like covering XHCI/EHCI/UHCI and so on aswell?
All the style issues are resolved.
For EHCI/XHCI etc ... I want to do the same, add a generic driver + interface so yeah I guess that the interface could be more generic. I'll look at it soon.
Might be you want to put the additional interface methods inside the existing usb_if.m or maybe a new usb_controller_if.m
--HPS
Do you have any usage pattern for subclassing of ohci_fdt.c? I'm not able to get any way how to do it.
sys/conf/files | ||
---|---|---|
2572 | I cannot agree. This is driver for single device named 'generic ohci', not a generic driver for all FDT based OHCI devices. | |
sys/dev/usb/controller/ohci_fdt.c | ||
117 | Here, and on may other places. | |
221 | static ? |
See aw_ohci.c for subclassed driver.
sys/conf/files | ||
---|---|---|
2572 | I understand your point. The thing is that this driver could also be subclassed for SoC who doesn't have generic_ohci, (If you look at the one for at91 or lpc for example switching to generic_ohci will be easy). but yeah this could be done even is the driver is renamed to generic_ohci. I'll change that. | |
sys/dev/usb/controller/ohci_fdt.c | ||
117 | Thanks, I'll look again at style(9) for this. | |
221 | Because I need this struct when subclassing, if there is another method please let me know. |
Rename driver generic_ohci_fdt
Rename the interface generic_usb_fdt_if as it could be use for an upcoming generic_ehci.
Fix a few style(9) issues.
sys/dev/usb/controller/generic_ohci_fdt.c | ||
---|---|---|
64–81 ↗ | (On Diff #14170) | This should be removed as it's unused. |
I've tested this on arm64 with some busdma fixes, it seems to work.
sys/dev/usb/controller/generic_ohci_fdt.c | ||
---|---|---|
64–81 ↗ | (On Diff #14170) | I've tested this on arm64. Could you implement this, even if the clock are not handled correctly. It would be useful there on at least one platform with fixed clocks. |
136 ↗ | (On Diff #14170) | I don't think this is FDT specific, it should move to be a generic USB controller interface. |
219 ↗ | (On Diff #14170) | This should be .name = "ohci", |
sys/dev/usb/controller/generic_ohci_fdt.c | ||
---|---|---|
64–81 ↗ | (On Diff #14170) | I'm waiting for D5752 to implement the clocks. |
136 ↗ | (On Diff #14170) | So rename the driver from generic_ohci_fdt to generic_ohci and interface from GENERIC_USB_FDT to GENERIC_USB ? |
Rename to generic_ohci
Add support for clocks/reset if compiled with EXT_RESOURCES
Remove subclassed driver aw_ohci as this work with D5752
sys/dev/usb/controller/generic_ohci.c | ||
---|---|---|
143 ↗ | (On Diff #14746) | You should capture the clk and hwreset handles at attach time, otherwise you will leak the references on detach. |
Add generic_ohci.c and generic_usb_if.m in files.allwinner instead of sys/conf/files
Make them depend on ohci instead of generic_ohci.