RE: Fwd: RE: [RFC PATCH 1/1] usb: udc-core: redo usb_gadget_probe_driver when the udc is ready

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 
> 
> On Wed, 30 Apr 2014, Felipe Balbi wrote:
> 
> > > > Now say you want to use that gadget driver which is deferred, you
> > > > unload first gadget driver and then nothing happens because you
> > > > have no way to tell that gadget driver that you want it to bind to
> > > > the UDC which is now available.
> > > >
> > > > see the problem ?
> > >
> > > This is the sort of thing that could be fixed by creating a "gadget"
> > > bus type.  The user would be able to force a gadget to bind to a UDC
> > > by writing to the appropriate sysfs file.
> > >
> > > Of course, I suppose you could always implement the same sort of
> > > functionality with a special-purpose sysfs file, without going to
> > > all the effort of adding a new bus type.
> >
> > Maybe the bus type is what we need to do, something along the lines of
> > i2c_bus_type, perhaps ?
> 
> Maybe -- I don't know how the i2c bus type works.  But the general idea
> is simple enough: Each UDC automatically gets a child device
> (representing controller's external interface to the USB bus, as opposed
> to its internal interface to an ordinary bus such as PCI or platform),
> and each each gadget driver gets registered as a driver on the gadget bus.
> 
> Thus, when a UDC driver registers a controller with udc-core, the core
> could dynamically allocate a struct usb_udc_device, which would be little
> more than a wrapper around a struct device.  The core would register this
> device on the gadget bus, on behalf of the UDC driver, as a child of the
> actual UDC device.  Then binding of gadget drivers to UDCs would be
> handled in the same way as binding of any other driver to a device.
> 
> For example, if you had a net2280 card in your computer, the net2280
> driver would bind to the card's PCI device, and udc-core would create a
> corresponding usb_gadget device, with a name like "udc-1" -- the full
> path would be something like
> 
> 	/sys/devices/pci0000:00/0000:00:1e.0/0000:01:00.0/udc-1
> 
> where 0000:01:00.0 is the PCI device corresponding to the net2280 card.
> 
> When a gadget driver registers itself with udc-core, the core would add
> the usb_gadget_driver structure to the gadget bus.  Then the ordinary
> device core mechanism would try to probe each unbound usb_udc_device with
> the new gadget driver.  This automatic binding might not be what you want,
> especially if you have multiple device controllers in the system or
> multiple gadget drivers built into the kernel, but the user could always
> change the bindings by writing to sysfs files.

Can we have multiple gadget drivers build into the kernel? I can't find
that way through kernel configuration.

> 
> > The difficulty will be with matching a gadget driver to a particular
> > UDC. How would we be able to load g_zero to dwc3 and g_mass_storage to
> > dummy ?
> 
> The automatic binding could easily get annoying, but we could disable it
> (perhaps by adding a special flag to the bus_type structure).
> 
> At any rate, let's say the dwc3 UDC is registered as
> /sys/bus/gadget/devices/udc-1 and the dummy UDC is registered as
> /sys/bus/gadget/devices/udc-2.  Then you could set up the bindings you
> want by doing:
> 
> 	echo udc-1 >/sys/bus/gadget/drivers/g_zero/bind
> 	echo udc-2 >/sys/bus/gadget/drivers/g_mass_storage/bind
> 
> > Or maybe we load gadgets to the bus and always bind through configfs ?!?
> 
> Maybe.  That certainly would be more suitable if the gadget driver needs
> to be configured specially for the UDC when it binds.
> 

The most use case is one udc and one gadget, can we take it as default
case and use automatic binding, and with another kernel configuration
or module parameter to disable automatic binding, and use sys/ entry
instead of it?

Peter

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux