Felipe Balbi <ba...@ti.com> 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 ?

Is it something such as :
 - upon vbus insertion, a UDC can draw 100mA during ??? ms
   - if during ??? ms, the device is enumerated, it can continue drawing 100mA
   - if not, it should not draw more than 8mA after ??? ms

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.

Cheers.

-- 
Robert
--
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