On Fri, 29 Aug 2014, Peter Chen wrote:

> > On Thu, 28 Aug 2014, Alan Stern wrote:
> > 
> > > Okay, so we need to add a "vbus_is_on" flag to the usb_gadget
> > > structure.  The gadget driver will set this flag in its connect
> > > callback and clear the flag in its disconnect callback.  If the UDC
> > > driver doesn't have a Vbus handler, it will invoke the connect
> > > callback just once during startup, and it will invoke the disconnect
> > > callback just once during removal.
> > 
> > After more thought, if the vbus_is_on flag is going to be controlled by
> > the gadget driver rather than the UDC driver, then it really belongs in
> > the gadget driver's private data structure and not in struct usb_gadget.
> > Also, a better name for the flag would be "is_connected".
> > 
> 
> Yes, we should have some places to change "is_connected",  that is one of
> thing we are discussing. 
> 
> > > The gadget driver should include an adjust_pullup() routine.  It
> > > should get called whenever a function is activated or deactivated, and
> > > also by the connect and disconnect callbacks.  The logic is simple:
> > >
> > >   If (any functions are deactivated)
> > >           turn off the pullup
> > >   else if (gadget->vbus_is_on)
> > >           turn on the pullup
> > >   else
> > >           turn off the pullup
> > 
> > This logic can be compressed a little:
> > 
> >     if (!is_connected || any functions are deactivated)
> >             turn off the pullup
> >     else
> >             turn on the pullup
> > 
> 
> Thanks, Alan.
> 
> I have a similar implementation at below, 
> 
> http://www.spinics.net/lists/linux-usb/msg111976.html

Yes, that seems to be moving in the right direction.  You still need to 
change the other gadget drivers, and the API should be changed from 
composite_connect(gadget, flag) to composite_connect(gadget) and 
composite_disconnect(gadget).


On Thu, 28 Aug 2014, Felipe Balbi wrote:

> you shouldn't call usb_gadget_disconnect() from ->disconnect(). It's the
> other way around. You get a disconnect IRQ, then you call gadget
> driver's ->disconnect(), but gadget driver doesn't need to ask UDC to
> remove pullup at that time.

It's true that the gadget driver shouldn't have to ask for this, but
doing so doesn't hurt.

On the other hand, the gadget driver definitely _does_ have to tell the 
UDC driver to enable the pullup when a connect occurs.  Otherwise the 
UDC driver won't know if the gadget's userspace components are ready.

Alan Stern

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

Reply via email to