Hi,
I've been implementing a UDC driver for the on-board UDC of various SuperH devices. I have now got the device to enumerate using Gadget Zero but this has exposed some problems with the gadget driver framework when used with the SuperH UDC.
I always like to hear about more hardware getting Linux support! :)
I'm curious -- are you doing this for 2.4 or 2.6?
The SuperH UDC is less flexible than the other supported UDCs and it also does more in hardware without letting the driver software know.
Yes, some hardware has more automagic than others; and sometimes it will get in the way, so that gadget drivers need to work around the consequent limitations. The gadget driver API has flexibility in this area -- it needs it!
The main issues are:
It only supports one configuration (configuration 1). To handle that I have modified Gadget Zero to compile as either loopback or source sink. This isn't a major problem.
Shouldn't be, though as I mention below, I don't think this controller can implement the loopback device correctly. The source/sink config could be a problem if using patterned I/O, but even that resynchronizes after each short packet rx/tx.
More seriously several control commands are automatically processed by the hardware and the software is not informed (no interrupt is generated). These commands are: Clear Feature, Get Configuration, Set Configuration, Get Interface, Get Status, Set Address, Set Feature, Set Interface.
The feature flag support (set/clear feature, get status) is no problem, it's never exposed in setup() callbacks ... a lot of hardware likes to handle that. Likewise set_address. No worries in those cases, it's all transparent to the gadget drivers.
And handling get_configuration and get_interface in hardware is no problem either ... gadget drivers should never change anything in response to such calls, it doesn't matter if they're hidden. You could even #ifdef gadget drivers to save the bytes of code handling those requests.
That leaves two issues, both of which constrain what the gadget drivers can do:
- set_configuration ... in this case I'd suggest just faking a call (set config 1) soon after each enumeration starts. The hardware seems to be expecting that approach. Gadget drivers don't really need to care about ADDRESS vs CONFIGURED states.
Gadget drivers will have to handle three restrictions, which means that some gadget functions can't use SuperH hardware:
* Device descriptor bNumConfigurations == 1
* Config descriptor bConfigurationValue == 1
* Resets must use class or vendor requestsThose really aren't significant restrictions, unless you need multi-configuration support or need to talk to a host-side driver that relies on config reset working.
- set_interface ... not much you can do here, again there are restrictions:
* Config descriptor bNumInterfaces == 1 ... since most
of the reason to have more than one is to let them be
managed separately, and this hardware won't allow that.
(Implies interface descriptor bInterfaceNumber == 0)
* Interface descriptor bAlternateSetting == 0 ... and
consequently, "can't use ISO" (if you're paying strict
attention to the USB specs).
* Resets must use class or vendor requestsThe reset protocol restrictions will prevent correct functioning of protocols like "loopback", since both config and interface resets need to clear out device state -- specifically, old data on the rx or tx queues should be purged. For example, SuperH could fail this: reset, write data, read data, verify that data. (The data read back might be wrong.)
However, I think other gadget drivers will have more success, since they don't rely on USB-level resets as much. For example the network stack safeguard "g_ether" by dropping packets that seem to be garbled, and "g_file_storage" uses class resets.
The current gadget drivers seem to rely on some of these commands being passed on by the UDC driver, but in the case of the SuperH UDC this is not possible.
Any suggestions for a clean way to get round this problem?
Fake a SET_CONFIGURATION request, and the rest should boil down to gadget driver restrictions that are only troublesome in the case of relying on usb-level reset protocols.
Let us know how this goes!
- Dave
Thanks
Julian Back
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
