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 3075 Build 3107: arc lint + arc unit
Event Timeline
sys/arm/allwinner/a10_clk.c | ||
---|---|---|
153 ↗ | (On Diff #13840) | 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 ↗ | (On Diff #13840) | I think these should be sorted by bit number. |
sys/arm/allwinner/aw_ohci.c | ||
30 ↗ | (On Diff #13840) | Is this needed? |
sys/dev/usb/controller/generic_ohci.c | ||
36 | Is this needed? | |
42 | condvar.h might be unnecessary as well | |
190 | 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 | ||
---|---|---|
148 ↗ | (On Diff #13851) | 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 | ||
---|---|---|
160 ↗ | (On Diff #13863) | You need to call this before dropping the lock, and pass in sc for convenience. |
185 ↗ | (On Diff #13863) | Call this before dropping the lock. |
218 ↗ | (On Diff #13863) | Call this before dropping the lock. |
250 ↗ | (On Diff #13863) | Call this before dropping the lock. |
258 ↗ | (On Diff #13863) | This can be simplified if you add softc as a parameter. |
264 ↗ | (On Diff #13863) | Instead of acquiring the lock here, assert that it is held. |
284 ↗ | (On Diff #13863) | Pass sc as parameter to simplify. |
290 ↗ | (On Diff #13863) | Same as activate -- assert that the lock is held instead. |
sys/conf/files | ||
---|---|---|
2580 | 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 | ||
---|---|---|
2580 | 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 ↗ | (On Diff #13976) | 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 | ||
---|---|---|
2580 | 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 | ||
116 ↗ | (On Diff #14098) | Here, and on may other places. |
220 ↗ | (On Diff #14098) | static ? |
See aw_ohci.c for subclassed driver.
sys/conf/files | ||
---|---|---|
2580 | 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 | ||
116 ↗ | (On Diff #14098) | Thanks, I'll look again at style(9) for this. |
220 ↗ | (On Diff #14098) | 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 | 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.