Hi, On Fri, Nov 21, 2014 at 06:24:44PM +0100, Robert Jarzmik wrote: > Felipe Balbi <balbi@xxxxxx> writes: > > > On Sun, Nov 09, 2014 at 03:58:14PM +0100, Robert Jarzmik wrote: > >> + if (!enabled) { > >> + ret = regulator_enable(vbus_draw); > >> + if (ret < 0) > >> + return; > >> + nop->vbus_draw_enabled = 1; > > > > do you really need this flag here ? How about: > > > > if (regulator_is_enabled(vbus_draw)) > > foo(); > Good question, I copy-pasted that code from gpio-vbus... > Philipp, do you have an insight here ? > > >> + if (vbus) { > >> + status = USB_EVENT_VBUS; > >> + nop->phy.state = OTG_STATE_B_PERIPHERAL; > >> + nop->phy.last_event = status; > >> + usb_gadget_vbus_connect(otg->gadget); > >> + > >> + /* drawing a "unit load" is *always* OK, except for OTG */ > >> + nop_set_vbus_draw(nop, 100); > > > > right, we need to take into considering the Battery Charging > > specification here, though. We might need to setup a timer for the > > amount of time we can draw 100mA before device enumerates. If the times > > expires we're only allowed to draw 8mA or 2mA, or something like that. > > > > The time gets cancelled as soon as we get enumerated. > > > > Another possibility would be to move this policy into userland, then > > kernel only provides the interfaces. > Ah ok. > Do you know exactly what the spec is telling in here ? I would have to go read the spec again to remember, but... > Is it something such as : > - upon vbus insertion, a UDC can draw 100mA during ??? ms this is, IIRC, a rather long time. Something like 10 minutes or maybe more. It falls into the dead battery provision. > - if during ??? ms, the device is enumerated, it can continue drawing 100mA either 100mA or bMaxPower from chosen configuration. > - if not, it should not draw more than 8mA after ??? ms yeah, something like that. > Is this right ? I can add a timer I think, if the spec if that simple. Now if > there are a lot of special cases then maybe it could be dropped to userland. yeah, there quite a few special cases :-) -- balbi
Attachment:
signature.asc
Description: Digital signature