From: Andreas Kemnade <andreas@kemnade.info>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-omap@vger.kernel.org, rogerq@ti.com,
Discussions about the Letux Kernel <letux-kernel@openphoenux.org>
Subject: [RFC] ehci-omap: simple suspend implementation
Date: Fri, 16 Feb 2018 19:35:57 +0100 [thread overview]
Message-ID: <20180216193557.2a7dbda4@aktux> (raw)
On Fri, 16 Feb 2018 13:13:11 -0500 (EST)
Alan Stern <stern@rowland.harvard.edu> wrote:
> On Fri, 16 Feb 2018, Andreas Kemnade wrote:
>
> > This powers down the phy and on a gta04 it reduces
> > suspend current by 13 mA.
> > For unknown reasons usb does not power on properly.
> > Also calling usb_phy_shutdown() here feels wrong
> > apparently the reset line has to be activated.
> > usb_phy_set_suspend is not enough here. The power
> > consumption still stays approximately the same as
> > without any patch.
> >
> > With a device connected the device does not enumerate
> > after resume. A rmmod ehci-omap ; modprobe ehci-omap
> > does not make it reenumerade.
> > So there is still something wrong here.
> >
> > Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> > ---
> > drivers/usb/host/ehci-omap.c | 59 ++++++++++++++++++++++++++++++++++++++++++--
> > 1 file changed, 57 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
> > index 8d8bafc70c1f..0be2ccf8182a 100644
> > --- a/drivers/usb/host/ehci-omap.c
> > +++ b/drivers/usb/host/ehci-omap.c
> > @@ -266,6 +266,58 @@ static int ehci_hcd_omap_remove(struct platform_device *pdev)
> > return 0;
> > }
> >
> > +
> > +static int __maybe_unused ehci_omap_suspend(struct device *dev)
> > +{
> > + struct usb_hcd *hcd = dev_get_drvdata(dev);
> > + struct omap_hcd *omap = (struct omap_hcd *)hcd_to_ehci(hcd)->priv;
> > + int ret;
> > + int i;
> > +
> > + ret = ehci_suspend(hcd, false);
> > + if (ret) {
> > + dev_err(dev, "ehci suspend failed: %d\n", ret);
> > + return ret;
> > + }
> > + for (i = 0; i < omap->nports; i++) {
> > + if (omap->phy[i])
> > + usb_phy_shutdown(omap->phy[i]);
> > + }
> > + pm_runtime_put_sync(dev);
>
> Why do you include a runtime PM call here, given that the driver
> doesn't support runtime suspend or resume?
>
Well, the parent (drivers/mfd/omap-usb-host.c) has, and there are runtime PM
calls here in the _probe/_remove functions, so it seems to be sane to do it
here, too.
> > +
> > + return 0;
> > +}
> > +
> > +static int __maybe_unused ehci_omap_resume(struct device *dev)
> > +{
> > + struct usb_hcd *hcd = dev_get_drvdata(dev);
> > + struct omap_hcd *omap = (struct omap_hcd *)hcd_to_ehci(hcd)->priv;
> > + int i;
> > +
> > + pm_runtime_get_sync(dev);
> > + /*
> > + * An undocumented "feature" in the OMAP3 EHCI controller,
> > + * causes suspended ports to be taken out of suspend when
> > + * the USBCMD.Run/Stop bit is cleared (for example when
> > + * we do ehci_bus_suspend).
> > + * This breaks suspend-resume if the root-hub is allowed
> > + * to suspend. Writing 1 to this undocumented register bit
> > + * disables this feature and restores normal behavior.
> > + */
> > + ehci_write(hcd->regs, EHCI_INSNREG04,
> > + EHCI_INSNREG04_DISABLE_UNSUSPEND);
>
> Doesn't this code belong in ehci_hcd_omap_probe()? I assume you only
> need to set this undocumented bit once, not every time the controller
> is suspended. And in any case, according to the comment, you would
> need to take care of this before the root hub is suspended -- by the
> time the controller is suspended, it is already too late.
>
I am not really sure about this one. It is set in ehci_hcd_omap_probe()
so it is set before suspend. I set it here to ensure it is re-set when
the controller is powered down too much to keep register contents. I
do not know if that is the case. But I thought it would not harm.
Regards,
Andreas
next reply other threads:[~2018-02-16 18:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-16 18:35 Andreas Kemnade [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-02-26 9:14 [RFC] ehci-omap: simple suspend implementation Roger Quadros
2018-02-26 7:04 Andreas Kemnade
2018-02-20 17:05 Andreas Kemnade
2018-02-19 9:41 Roger Quadros
2018-02-16 19:31 Alan Stern
2018-02-16 18:13 Alan Stern
2018-02-16 17:14 Andreas Kemnade
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=20180216193557.2a7dbda4@aktux \
--to=andreas@kemnade.info \
--cc=gregkh@linuxfoundation.org \
--cc=letux-kernel@openphoenux.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=rogerq@ti.com \
--cc=stern@rowland.harvard.edu \
/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).