All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: felipe.balbi@nokia.com
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Anton Vorontsov <avorontsov@ru.mvista.com>,
	Grazvydas Ignotas <notasas@gmail.com>,
	Madhusudhan Chikkature <madhu.cr@ti.com>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
	"Greg Kroah-Hartman" <gregkh@suse.de>
Subject: Re: [RFC/PATCH 1/5] usb: otg: add notifier support
Date: Tue, 26 Jan 2010 07:07:22 -0800	[thread overview]
Message-ID: <201001260707.23339.david-b@pacbell.net> (raw)
In-Reply-To: <20100126141016.GD10690@nokia.com>

On Tuesday 26 January 2010, Felipe Balbi wrote:
> >> +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".

There are thousands of events that could be issued.
I'd rather start with one specific problem, which
can really benefit from being solved.

If necessary, other events can be added later.


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

It's the only transceiver interface we have; and it
works for OTG transceivers in peripheral-only mode,
as well as host-only and dual-role modes.  So it's
not especially wrong.


However, "you can consume N milliAmperes now" doesn't
need to be coupled to a transceiver at all.  In fact,
it works just fine with any pure peripheral interface.
The gadget stack uses such calls ... and doesn't need
to be coupled to any transceiver.  (But obviously it
can hook up to an OTG transceiver.)


 
> >> +    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 ?

That's why I said what I did about the separate charger spec (and 
you quoted it below):  it's not going to be less than those two
ops, which your events don't really capture.

That's "bonus" functionality though ... among other reasons, it's
not all that common yet.  The basic "charge battery over USB"
scenario needs to work without that stuff.

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

So you're presuming some separate component will do charger
detection by listening for events?  If it's mucking with the
pullups, that seems very much like what an OTG transciever
needs to be managing.  And thus, perhaps, transceiver code.

If there's such a separate component, I'd like to see some
detail about how it'd work.  But ... at first glance, it'd
have thought it'd be simplest inside a transceiver driver.


> >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 
> configuration.

Needs to be part of the event spec...

 
> >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".

We could take a vote to see how many folk have even seen
one, much less own one.  They're not very common, and not
part of the USB 2.0 spec.  That's why I say "not 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.

As you say:  transceiver stuff.  What I'm used to seeing is
what the OTG spec says:  ID grounding is an event, which
triggers state machine transitions.  One such transition
involves sourcing VBUS power and making sure it ramps up
properly.  Activating that, and monitoring it, depend on
hardware details which are tightly coupled to transceiver
logic and implementation.


> >>  #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" ?

Iff the IRQ has a thread context, it can block.

But a SET_CONFIGURATION request is mostly going to
be delivered to a hard IRQ context, and that is what
will pass the host's vbus_draw configuration to the
hardware.  (Same for most of the other events you
sketched.)


WARNING: multiple messages have this Message-ID (diff)
From: David Brownell <david-b@pacbell.net>
To: felipe.balbi@nokia.com
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Anton Vorontsov <avorontsov@ru.mvista.com>,
	Grazvydas Ignotas <notasas@gmail.com>,
	Madhusudhan Chikkature <madhu.cr@ti.com>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@suse.de>
Subject: Re: [RFC/PATCH 1/5] usb: otg: add notifier support
Date: Tue, 26 Jan 2010 07:07:22 -0800	[thread overview]
Message-ID: <201001260707.23339.david-b@pacbell.net> (raw)
In-Reply-To: <20100126141016.GD10690@nokia.com>

On Tuesday 26 January 2010, Felipe Balbi wrote:
> >> +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".

There are thousands of events that could be issued.
I'd rather start with one specific problem, which
can really benefit from being solved.

If necessary, other events can be added later.


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

It's the only transceiver interface we have; and it
works for OTG transceivers in peripheral-only mode,
as well as host-only and dual-role modes.  So it's
not especially wrong.


However, "you can consume N milliAmperes now" doesn't
need to be coupled to a transceiver at all.  In fact,
it works just fine with any pure peripheral interface.
The gadget stack uses such calls ... and doesn't need
to be coupled to any transceiver.  (But obviously it
can hook up to an OTG transceiver.)


 
> >> +    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 ?

That's why I said what I did about the separate charger spec (and 
you quoted it below):  it's not going to be less than those two
ops, which your events don't really capture.

That's "bonus" functionality though ... among other reasons, it's
not all that common yet.  The basic "charge battery over USB"
scenario needs to work without that stuff.

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

So you're presuming some separate component will do charger
detection by listening for events?  If it's mucking with the
pullups, that seems very much like what an OTG transciever
needs to be managing.  And thus, perhaps, transceiver code.

If there's such a separate component, I'd like to see some
detail about how it'd work.  But ... at first glance, it'd
have thought it'd be simplest inside a transceiver driver.


> >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 
> configuration.

Needs to be part of the event spec...

 
> >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".

We could take a vote to see how many folk have even seen
one, much less own one.  They're not very common, and not
part of the USB 2.0 spec.  That's why I say "not 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.

As you say:  transceiver stuff.  What I'm used to seeing is
what the OTG spec says:  ID grounding is an event, which
triggers state machine transitions.  One such transition
involves sourcing VBUS power and making sure it ramps up
properly.  Activating that, and monitoring it, depend on
hardware details which are tightly coupled to transceiver
logic and implementation.


> >>  #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" ?

Iff the IRQ has a thread context, it can block.

But a SET_CONFIGURATION request is mostly going to
be delivered to a hard IRQ context, and that is what
will pass the host's vbus_draw configuration to the
hardware.  (Same for most of the other events you
sketched.)

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

  parent reply	other threads:[~2010-01-26 15:07 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-27 14:44 [PATCH] power_supply: Add driver for TWL4030/TPS65950 BCI charger Grazvydas Ignotas
2009-11-27 14:44 ` Grazvydas Ignotas
2009-11-27 14:54 ` Anton Vorontsov
2009-11-27 15:47   ` Grazvydas Ignotas
2009-11-27 16:23     ` Mark Brown
2009-11-30 18:45 ` Madhusudhan
2009-11-30 18:45   ` Madhusudhan
2009-11-30 18:58   ` Anton Vorontsov
2009-12-02 20:38     ` Grazvydas Ignotas
2009-12-02 20:38       ` Grazvydas Ignotas
2009-12-02 21:27       ` Anton Vorontsov
2009-12-02 21:27         ` Anton Vorontsov
2009-12-02 21:32         ` Grazvydas Ignotas
2009-11-30 21:33   ` Grazvydas Ignotas
2009-12-02 16:59     ` Madhusudhan
2009-12-02 16:59       ` Madhusudhan
2009-12-02 17:33 ` Felipe Balbi
2009-12-02 20:34   ` Grazvydas Ignotas
2009-12-02 20:49     ` Felipe Balbi
2009-12-02 20:49       ` Felipe Balbi
2009-12-02 21:29       ` Grazvydas Ignotas
2009-12-02 21:29         ` Grazvydas Ignotas
2009-12-02 21:54         ` Anton Vorontsov
2009-12-02 22:31           ` Felipe Balbi
2009-12-02 22:59             ` Anton Vorontsov
2009-12-03  8:39               ` Felipe Balbi
2009-12-03 10:55                 ` Grazvydas Ignotas
2009-12-03 11:03                   ` Felipe Balbi
2009-12-10 14:09                     ` Grazvydas Ignotas
2009-12-10 14:18                       ` Anton Vorontsov
2009-12-10 14:21                         ` Felipe Balbi
2009-12-10 14:44                           ` Anton Vorontsov
2009-12-10 16:51                             ` Felipe Balbi
2009-12-10 20:51                               ` Grazvydas Ignotas
2009-12-11 11:31                                 ` [RFC/PATCH 0/5] usb transceiver notifier Felipe Balbi
2009-12-11 11:31                                   ` Felipe Balbi
2009-12-11 11:31                                 ` [RFC/PATCH 1/5] usb: otg: add notifier support Felipe Balbi
2009-12-11 11:55                                   ` Mark Brown
2009-12-11 11:55                                     ` Mark Brown
2009-12-11 11:58                                     ` Felipe Balbi
2010-01-26 11:16                                   ` David Brownell
2010-01-26 13:11                                     ` Mark Brown
2010-01-26 13:35                                       ` David Brownell
2010-01-26 14:14                                         ` Felipe Balbi
2010-01-26 14:24                                           ` Oliver Neukum
2010-01-26 14:30                                             ` Felipe Balbi
2010-01-26 14:30                                               ` Felipe Balbi
2010-01-26 15:16                                               ` David Brownell
2010-01-26 15:21                                           ` David Brownell
2010-01-26 18:50                                             ` Felipe Balbi
2010-01-26 14:21                                         ` Mark Brown
2010-01-26 14:21                                           ` Mark Brown
2010-01-26 15:44                                           ` David Brownell
2010-01-26 16:13                                             ` Mark Brown
2010-01-26 14:10                                     ` Felipe Balbi
2010-01-26 14:19                                       ` Felipe Balbi
2010-01-26 15:33                                         ` David Brownell
2010-01-26 15:33                                           ` David Brownell
2010-01-26 15:07                                       ` David Brownell [this message]
2010-01-26 15:07                                         ` David Brownell
2010-01-26 19:09                                         ` Felipe Balbi
2010-01-26 19:15                                           ` Felipe Balbi
2010-01-26 19:15                                             ` Felipe Balbi
2009-12-11 11:31                                 ` [RFC/PATCH 2/5] usb: otg: twl4030: add support for notifier Felipe Balbi
2009-12-11 17:22                                   ` sai pavan
2009-12-11 17:22                                     ` sai pavan
2009-12-11 20:40                                     ` Felipe Balbi
2009-12-11 20:40                                       ` Felipe Balbi
2009-12-12 18:34                                       ` Mark Brown
2009-12-14 10:30                                         ` [RFC/PATCH 0/4] twl4030 threaded_irq support Felipe Balbi
2010-01-26  7:06                                           ` David Brownell
2010-01-26  7:06                                             ` David Brownell
2010-01-26  7:36                                             ` David Brownell
2010-01-26  7:36                                               ` David Brownell
2010-01-26 10:07                                             ` Mark Brown
2010-01-26 11:02                                             ` Felipe Balbi
2010-01-26 12:18                                               ` David Brownell
2010-01-26 12:18                                                 ` David Brownell
2009-12-14 10:30                                         ` [RFC/PATCH 1/4] input: keyboard: twl4030: move to request_threaded_irq Felipe Balbi
2009-12-14 10:30                                           ` Felipe Balbi
2009-12-14 10:30                                         ` [RFC/PATCH 2/4] input: misc: " Felipe Balbi
2009-12-14 10:30                                           ` Felipe Balbi
2009-12-14 11:31                                           ` Shilimkar, Santosh
2009-12-14 11:40                                             ` Felipe Balbi
2009-12-14 13:16                                               ` Shilimkar, Santosh
2009-12-14 10:30                                         ` [RFC/PATCH 3/4] rtc: " Felipe Balbi
2009-12-14 10:30                                         ` [RFC/PATCH 4/4] usb: otg: " Felipe Balbi
2009-12-14 10:30                                           ` Felipe Balbi
2009-12-11 11:31                                 ` [RFC/PATCH 3/5] usb: musb: add support for ulpi block Felipe Balbi
2009-12-11 11:31                                   ` Felipe Balbi
2009-12-11 11:31                                 ` [RFC/PATCH 4/5] usb: musb: isp1704: add registers from isp1704 Felipe Balbi
2009-12-11 11:31                                   ` Felipe Balbi
2009-12-11 12:35                                   ` Krogerus Heikki (EXT-Teleca/Helsinki)
2009-12-11 12:35                                     ` Krogerus Heikki (EXT-Teleca/Helsinki)
2009-12-11 12:57                                     ` Felipe Balbi
2009-12-11 12:57                                       ` Felipe Balbi
2009-12-11 11:31                                 ` [RFC/PATCH 5/5] usb: musb: musb supports otg notifier Felipe Balbi
2009-12-11 11:40                                   ` Felipe Balbi
2009-12-11 11:40                                     ` Felipe Balbi
2009-12-30 19:07                             ` [PATCH] power_supply: Add driver for TWL4030/TPS65950 BCI charger Madhusudhan
2009-12-30 19:07                               ` Madhusudhan
2009-12-10 14:19                       ` Felipe Balbi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201001260707.23339.david-b@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=avorontsov@ru.mvista.com \
    --cc=felipe.balbi@nokia.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=madhu.cr@ti.com \
    --cc=notasas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.