[lkml]   [2010]   [Jan]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [RFC/PATCH 1/5] usb: otg: add notifier support

On Tue, Jan 26, 2010 at 12:16:20PM +0100, ext David Brownell wrote:
>On Friday 11 December 2009, Felipe Balbi wrote:
>> The notifier will be used to communicate usb events
>> to other drivers like the charger chip.
>Good idea ... but not OTG-specific. It doesn't seem to me


>that charging hookups belong in that header at all.

I noticed that when started actually using it :-)

>In fact, usb_gadget_vbus_draw() might better be implemented
>as such a notifier call, removing that configuration mess
>from the usb gadget drivers ("how can I know what charger
>to use??"). That would be the most common situation: a
>peripheral-only device.
>And in fact, OTG can be treated as a trivial superset of
>peripheral-only USB. (In terms of charger support, only!!)
>I'd vote to convert all the USB-to-charger interfaces so
>they use notifiers. After fixing the events ... see
>comments below. :)

makes sense

>> @@ -9,6 +9,8 @@
>> #ifndef __LINUX_USB_OTG_H
>> #define __LINUX_USB_OTG_H
>> +#include <linux/notifier.h>
>> +
>> /* OTG defines lots of enumeration states before device reset */
>> enum usb_otg_state {
>> @@ -33,6 +35,14 @@ enum usb_otg_state {
>> };
>> +enum usb_xceiv_events {
>Let's keep charger events separate from anything else,
>like "enter host mode" or "enter peripheral mode" (or
>even "disconnect"). The audiences for any other types
>of event would be entirely different.

the idea was to notify USB events to interested drivers, not only "usb
charger events".

>Right now there's a mess in terms of charger hookup,
>so getting that straight is IMO a priority over any
>other type of event. Using events will decouple a
>bunch of drivers, and simplify driver configuration.

well, if you consider that this transceiver isn't really otg specific,
then this is already wrong.

>> + USB_EVENT_NONE, /* no events or cable disconnected */
>> + USB_EVENT_VBUS, /* vbus valid event */
>> + USB_EVENT_ID, /* id was grounded */
>> + USB_EVENT_CHARGER, /* usb dedicated charger */
>> + USB_EVENT_ENUMERATED, /* gadget driver enumerated */
>Those seem like the wrong events. The right events for a charger
>would be more along the lines of:
> - For peripheral: "you may use N milliAmperes now".
> - General: "Don't Charge" (a.k.a. "use 0 mA").

I have to disagree, which information would you used to kick the usb
dedicated charger detection other than VBUS irq from transceiver ?

So we need at least that, and also need to notify when the charger
detection is finished, so we can enable data pullups on the link.
Remember we might be connected to a charging downstream port.

>I don't see how "N" would be passed with those events ...

there's a void * we can use to pass bMaxPower field of the selected

>Haven't looked at the details of the charger spec, but
>those two events are the *basics* from the USB 2.0 spec,
>so "official" charger hardware wouldn't be less capable.

I believe the dedicated charger is also "basic".

>Thing like different levels of VBUS validity, ID grounding,
>and so forth ... wouldn't be very relevant. An OTG driver
>will do various things, internally, when ID grounds; but
>anything else is a function of what role eventually gets
>negotiated. And for the charger, they all add up to "Don't
>Charge" (since ID grounded means A-role, sourcing power).

ID grounding event is necessary if you have an external charge pump.
At least the boards I've been working use an external chip as the USB
Charger and Charge pump, iow, the transceiver doesn't source VBUS on ID
ground, but the charger chip is put into "boost" mode for that role.

>> #define USB_OTG_PULLUP_ID (1 << 0)
>> #define USB_OTG_PULLDOWN_DP (1 << 1)
>> #define USB_OTG_PULLDOWN_DM (1 << 2)
>> @@ -70,6 +80,9 @@ struct otg_transceiver {
>> struct otg_io_access_ops *io_ops;
>> void __iomem *io_priv;
>> + /* for notification of usb_xceiv_events */
>> + struct blocking_notifier_head notifier;
>Why "blocking"? That seems kind of unnatural; for example,
>the main users -- like usb_gadget_vbus_draw() -- would be
>called in IRQ context (blocking not allowed).

what about irqs running in thread, wouldn't we "BUG sleeping in irq
context" ?


 \ /
  Last update: 2010-01-26 15:15    [W:0.073 / U:8.448 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site