linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
To: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
Cc: balbi-l0cyMroinI0@public.gmane.org,
	Andy Green <andy.green-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Alan Stern
	<stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>,
	keshava_mgowda-l0cyMroinI0@public.gmane.org,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 16/16] ARM: OMAP: omap4panda: Power down the USB PHY and ETH when not in use
Date: Fri, 23 Nov 2012 12:44:16 +0200	[thread overview]
Message-ID: <20121123104416.GD29585@arwen.pp.htv.fi> (raw)
In-Reply-To: <50AF4EB8.9010800-l0cyMroinI0@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 6571 bytes --]

On Fri, Nov 23, 2012 at 12:23:52PM +0200, Roger Quadros wrote:
> On 11/22/2012 06:12 PM, Felipe Balbi wrote:
> > Hi,
> > 
> > On Thu, Nov 22, 2012 at 05:00:45PM +0200, Roger Quadros wrote:
> >> On 11/22/2012 03:56 PM, Felipe Balbi wrote:
> >>> Hi,
> >>>
> >>> On Thu, Nov 22, 2012 at 09:49:05PM +0800, Andy Green wrote:
> >>>>> Again it sounds like something that should be done at the hub driver
> >>>>> level. I mean using the GPIO (for reset) and Power Regulator.
> >>>>>
> >>>>> not implementing the regulator part itself, but using it.
> >>>>
> >>>> If you mean change the regulator managing code from living in
> >>>> omap-hsusb to ehci-hcd, it sounds like a good idea.
> >>>
> >>> I mean that drivers/usb/core/hub.c should manage it, since that's what
> >>> actually manages the HUB entity.
> >>
> >> Yes. I agree that powering up the on-board hubs should be done
> >> generically and not in ehci-omap.c. I'm not sure how it can be done in
> >> hub.c.
> >>
> >> I'm assuming that such problem is limited to root hub ports where system
> > 
> > an external LAN95xx HUB is not the roothub. LAN95xx is connected to the
> > roothub.
> > 
> 
> I didn't say LAN95xx is the root hub. It is connected to the root hub.
> So it is in theory, the root hub port's responsibility to power the LAN95xx.

no, it's LAN95xx's responsibility to power itself up. What if you had
multiple tiers of LAN95xx ?

> >> designers have the flexibility to provide power to the peripherals
> >> outside the USB Hub specification.
> >>
> >> I can think of two solutions
> >>
> >> 1) Associate the regulators with the root hub _ports_ and enable them as
> >> part of port's power-up routine.
> > 
> > doesn't make sense. We need to figure out a way to attach the regulator
> > to the ports which actually have them. In this case it's the external
> > LAN95xx, right ?
> 
> I think you are confused here. The LAN95xx's ports are compatible with
> USB hub specification and they work using the in-band set_port_feature
> mechanism already. We have a problem powering the LAN95xx itself which
> ideally should have been powered with set_port_feature on the root hub.
> (or ehci_port_power() in this case).

I don't set_port_feature() has anything to do with the problem here.
It's not working because the controller's supply isn't turned on. How
can any port be turned on if the supply isn't turned on ?

I still think, however, the hub needs to know how to power itself up.

> > The patch below is *CLEARLY WRONG* it's just to illustrate how this
> > could be started:
> > 
> > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> > index 1af04bd..662d4cf 100644
> > --- a/drivers/usb/core/hub.c
> > +++ b/drivers/usb/core/hub.c
> > @@ -26,6 +26,7 @@
> >  #include <linux/mutex.h>
> >  #include <linux/freezer.h>
> >  #include <linux/random.h>
> > +#include <linux/regulator/consumer.h>
> >  
> >  #include <asm/uaccess.h>
> >  #include <asm/byteorder.h>
> > @@ -44,6 +45,7 @@ struct usb_port {
> >  	struct device dev;
> >  	struct dev_state *port_owner;
> >  	enum usb_port_connect_type connect_type;
> > +	struct regulator *port_regulator;
> >  };
> >  
> >  struct usb_hub {
> > @@ -847,8 +849,41 @@ static unsigned hub_power_on(struct usb_hub *hub, bool do_delay)
> >  	else
> >  		dev_dbg(hub->intfdev, "trying to enable port power on "
> >  				"non-switchable hub\n");
> > -	for (port1 = 1; port1 <= hub->descriptor->bNbrPorts; port1++)
> > +	for (port1 = 1; port1 <= hub->descriptor->bNbrPorts; port1++) {
> > +		regulator_enable(hub->ports[port1]->port_regulator);
> >  		set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER);
> > +	}
> > +
> > +	/* Wait at least 100 msec for power to become stable */
> > +	delay = max(pgood_delay, (unsigned) 100);
> > +	if (do_delay)
> > +		msleep(delay);
> > +	return delay;
> > +}
> > +
> > +static unsigned hub_power_off(struct usb_hub *hub, bool do_delay)
> > +{
> > +	int port1;
> > +	unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2;
> > +	unsigned delay;
> > +	u16 wHubCharacteristics =
> > +			le16_to_cpu(hub->descriptor->wHubCharacteristics);
> > +
> > +	/* Disable power on each port.  Some hubs have reserved values
> > +	 * of LPSM (> 2) in their descriptors, even though they are
> > +	 * USB 2.0 hubs.  Some hubs do not implement port-power switching
> > +	 * but only emulate it.  In all cases, the ports won't work
> > +	 * unless we send these messages to the hub.
> > +	 */
> > +	if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2)
> > +		dev_dbg(hub->intfdev, "disabling power on all ports\n");
> > +	else
> > +		dev_dbg(hub->intfdev, "trying to disable port power on "
> > +				"non-switchable hub\n");
> > +	for (port1 = 1; port1 <= hub->descriptor->bNbrPorts; port1++) {
> > +		regulator_disable(hub->ports[port1]->port_regulator);
> > +		clear_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER);
> > +	}
> >  
> >  	/* Wait at least 100 msec for power to become stable */
> >  	delay = max(pgood_delay, (unsigned) 100);
> > @@ -1336,6 +1371,9 @@ static int hub_configure(struct usb_hub *hub,
> >  		goto fail;
> >  	}
> >  
> > +	if (hub->has_external_port_regulator) /* maybe implement with a quirk flag ??? */
> > +		regulator_get(hub_dev, "hub_port_supply\n");
> > +
> >  	wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics);
> >  
> >  	/* FIXME for USB 3.0, skip for now */
> > @@ -4205,8 +4243,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
> >  
> >  		/* maybe switch power back on (e.g. root hub was reset) */
> >  		if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2
> > -				&& !port_is_power_on(hub, portstatus))
> > +				&& !port_is_power_on(hub, portstatus)) {
> > +			regulator_enable(hub->ports[port1]->port_regulator);
> >  			set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
> > +		}
> >  
> >  		if (portstatus & USB_PORT_STAT_ENABLE)
> >    			goto done;
> > 
> > Note that if we have a single regulator, than all ports' regulators
> > should point to the same struct regulator so that regulator_get() and
> > regulator_put() can do proper reference counting.
> > 
> > This is just an idea though.
> > 
> 
> Thanks for the example. The only problem is, how do we associate a
> regulator to a specific port in the system.

heh, that's the 1 million dollar question, isn't it ? :-)

that's what we need to figure out now. Luckily we have Alan Stern
helping us out ;-)

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2012-11-23 10:44 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-15 14:33 [PATCH 00/16] OMAP USB Host cleanup Roger Quadros
2012-11-15 14:33 ` [PATCH 01/16] mfd: omap-usb-tll: Avoid creating copy of platform data Roger Quadros
2012-11-21 11:42   ` Felipe Balbi
2012-11-15 14:34 ` [PATCH 02/16] mfd: omap-usb-tll: Clean up clock handling Roger Quadros
2012-11-21 11:55   ` Felipe Balbi
2012-11-21 12:36     ` Roger Quadros
2012-11-21 14:03       ` Felipe Balbi
     [not found]         ` <20121121140354.GR10216-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-11-21 15:39           ` Roger Quadros
     [not found]             ` <50ACF5CD.9010209-l0cyMroinI0@public.gmane.org>
2012-11-21 19:39               ` Felipe Balbi
2012-11-22  8:19                 ` Roger Quadros
2012-11-15 14:34 ` [PATCH 03/16] mfd: omap-usb-tll: introduce and use mode_needs_tll() Roger Quadros
2012-11-21 11:57   ` Felipe Balbi
     [not found]     ` <20121121115705.GE10216-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-11-21 12:37       ` Roger Quadros
     [not found] ` <1352990054-14680-1-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2012-11-15 14:34   ` [PATCH 04/16] mfd: omap-usb-tll: Move port clock handling out of runtime ops Roger Quadros
     [not found]     ` <1352990054-14680-5-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2012-11-21 12:06       ` Felipe Balbi
2012-11-21 12:45         ` Roger Quadros
     [not found]           ` <50ACCCFA.6060605-l0cyMroinI0@public.gmane.org>
2012-11-21 14:07             ` Felipe Balbi
2012-11-15 14:34   ` [PATCH 05/16] mfd: omap-usb-tll: Add OMAP5 revision and HSIC support Roger Quadros
     [not found]     ` <1352990054-14680-6-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2012-11-21 12:12       ` Felipe Balbi
     [not found]         ` <20121121121238.GG10216-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-11-21 12:49           ` Roger Quadros
2012-11-21 14:08             ` Felipe Balbi
2012-11-15 14:34   ` [PATCH 06/16] mfd: omap-usb-host: cleanup clock management code Roger Quadros
     [not found]     ` <1352990054-14680-7-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2012-11-21 13:39       ` Felipe Balbi
2012-11-26 15:14         ` Roger Quadros
     [not found]           ` <50B38765.5070901-l0cyMroinI0@public.gmane.org>
2012-11-26 20:02             ` Felipe Balbi
2012-11-27  9:41               ` Roger Quadros
2012-11-15 14:34   ` [PATCH 11/16] mfd: omap-usb-host: Manage HSIC clocks for HSIC mode Roger Quadros
     [not found]     ` <1352990054-14680-12-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2012-11-21 13:54       ` Felipe Balbi
     [not found]         ` <20121121135451.GM10216-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-11-21 15:49           ` Roger Quadros
2012-11-15 14:34   ` [PATCH 15/16] ARM: OMAP4: omap4panda: Don't enable USB PHY clock from board Roger Quadros
2012-11-21 13:59     ` Felipe Balbi
2012-11-16 20:08   ` [PATCH 00/16] OMAP USB Host cleanup Kevin Hilman
     [not found]     ` <87fw49cnvh.fsf-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
2012-11-19 10:11       ` Roger Quadros
     [not found]         ` <50AA05C3.7010003-l0cyMroinI0@public.gmane.org>
2012-11-19 23:22           ` Kevin Hilman
2012-11-20 23:13             ` Tony Lindgren
2012-11-21 10:05               ` Roger Quadros
2012-11-21 11:41                 ` Felipe Balbi
2012-11-27 14:42             ` Roger Quadros
2012-11-27 16:30               ` Felipe Balbi
     [not found]                 ` <20121127163022.GB24240-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-12-04 14:46                   ` Grazvydas Ignotas
2012-11-15 14:34 ` [PATCH 07/16] mfd: omap_usb_host: Avoid creating copy of platform_data Roger Quadros
2012-11-21 13:40   ` Felipe Balbi
2012-11-15 14:34 ` [PATCH 08/16] mfd: omap-usb-host: know about number of ports from revision register Roger Quadros
2012-11-21 13:43   ` Felipe Balbi
     [not found]     ` <20121121134300.GJ10216-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-11-21 14:45       ` Roger Quadros
2012-11-21 19:44         ` Felipe Balbi
2012-11-15 14:34 ` [PATCH 09/16] mfd: omap-usb-host: override number of ports from platform data Roger Quadros
     [not found]   ` <1352990054-14680-10-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2012-11-21 13:45     ` Felipe Balbi
2012-11-21 14:50       ` Roger Quadros
2012-11-21 19:47         ` Felipe Balbi
2012-11-15 14:34 ` [PATCH 10/16] mfd: omap-usb-host: Intialize all available ports Roger Quadros
2012-11-21 13:52   ` Felipe Balbi
2012-11-21 15:47     ` Roger Quadros
2012-11-21 19:48       ` Felipe Balbi
2012-11-27 12:10     ` Roger Quadros
2012-11-27 13:28       ` Felipe Balbi
     [not found]         ` <20121127132827.GC22556-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-11-27 13:39           ` Roger Quadros
2012-11-15 14:34 ` [PATCH 12/16] ARM: OMAP2+: clock data: Merge utmi_px_gfclk into usb_host_hs_utmi_px_clk Roger Quadros
2012-11-15 14:34 ` [PATCH 13/16] mfd: omap-usb-host: Get rid of unnecessary spinlock Roger Quadros
     [not found]   ` <1352990054-14680-14-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2012-11-21 13:57     ` Felipe Balbi
     [not found]       ` <20121121135732.GN10216-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-11-21 15:55         ` Roger Quadros
2012-11-21 19:50           ` Felipe Balbi
2012-11-15 14:34 ` [PATCH 14/16] mfd: omap-usb-host: Support an auxiliary clock per port Roger Quadros
     [not found]   ` <1352990054-14680-15-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2012-11-21 13:58     ` Felipe Balbi
     [not found]       ` <20121121135841.GO10216-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-11-21 16:00         ` Roger Quadros
2012-11-15 14:34 ` [PATCH 16/16] ARM: OMAP: omap4panda: Power down the USB PHY and ETH when not in use Roger Quadros
2012-11-21 14:00   ` Felipe Balbi
     [not found]     ` <20121121140044.GQ10216-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-11-21 14:52       ` Alan Stern
2012-11-21 15:13         ` Roger Quadros
     [not found]           ` <50ACEFA5.4080104-l0cyMroinI0@public.gmane.org>
2012-11-21 15:32             ` Alan Stern
     [not found]               ` <Pine.LNX.4.44L0.1211211028200.1731-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2012-11-21 16:07                 ` Roger Quadros
2012-11-21 19:54                   ` Felipe Balbi
     [not found]                     ` <20121121195436.GF14290-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-11-22  1:13                       ` Andy Green
2012-11-22 12:21                         ` Felipe Balbi
     [not found]                           ` <20121122121845.GB18022-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-11-22 13:49                             ` Andy Green
2012-11-22 13:56                               ` Felipe Balbi
     [not found]                                 ` <20121122135603.GA20066-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-11-22 15:00                                   ` Roger Quadros
     [not found]                                     ` <50AE3E1D.9000607-l0cyMroinI0@public.gmane.org>
2012-11-22 16:12                                       ` Felipe Balbi
     [not found]                                         ` <20121122161228.GB20665-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-11-23 10:23                                           ` Roger Quadros
     [not found]                                             ` <50AF4EB8.9010800-l0cyMroinI0@public.gmane.org>
2012-11-23 10:44                                               ` Felipe Balbi [this message]
     [not found]                                                 ` <20121123104416.GD29585-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-11-23 16:25                                                   ` Alan Stern
2012-11-23 20:37                                                     ` Andy Green
2012-11-24 15:38                                                       ` Alan Stern
     [not found]                                                         ` <Pine.LNX.4.44L0.1211241032490.4291-100000-pYrvlCTfrz9XsRXLowluHWD2FQJk+8+b@public.gmane.org>
2012-11-24 22:00                                                           ` Andy Green
     [not found]                                                             ` <50B14395.4010404-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-11-25  0:41                                                               ` Alan Stern
2012-11-22 17:36                                 ` Alan Stern
2012-11-22 17:53                                   ` Felipe Balbi
     [not found]                                     ` <20121122175340.GA22614-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-11-22 18:32                                       ` Alan Stern
2012-11-22 20:15                                         ` Felipe Balbi
2012-11-23  2:35                                           ` Alan Stern
2012-11-23 10:38                                             ` Felipe Balbi
     [not found]                                               ` <20121123103817.GC29585-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-11-23 16:27                                                 ` Alan Stern
2012-11-26  8:52                                                   ` Felipe Balbi
     [not found]                                   ` <Pine.LNX.4.44L0.1211221226360.2255-100000-pYrvlCTfrz9XsRXLowluHWD2FQJk+8+b@public.gmane.org>
2012-11-23  0:19                                     ` Andy Green

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=20121123104416.GD29585@arwen.pp.htv.fi \
    --to=balbi-l0cymroini0@public.gmane.org \
    --cc=andy.green-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=keshava_mgowda-l0cyMroinI0@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=rogerq-l0cyMroinI0@public.gmane.org \
    --cc=stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).