mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: ehci: s5p: Power-off VBUS during suspend.
@ 2013-01-29 10:52 Vivek Gautam
  2013-01-29 11:37 ` Oliver Neukum
  2013-01-29 15:21 ` Alan Stern
  0 siblings, 2 replies; 4+ messages in thread
From: Vivek Gautam @ 2013-01-29 10:52 UTC (permalink / raw)
  To: linux-usb
  Cc: linux-kernel, linux-samsung-soc, gregkh, stern, jg1.han, Doug Anderson

This change de-asserts vbus_gpio on suspend and
re-asserts on resume in order to save power.
NOTE, this change means no USB charging in suspend
mode.

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
CC: Doug Anderson <dianders@chromium.org>
---

Based on 'usb-next'.

 drivers/usb/host/ehci-s5p.c |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
index 20ebf6a..297f6f2 100644
--- a/drivers/usb/host/ehci-s5p.c
+++ b/drivers/usb/host/ehci-s5p.c
@@ -37,6 +37,7 @@ struct s5p_ehci_hcd {
 	struct usb_phy *phy;
 	struct usb_otg *otg;
 	struct s5p_ehci_platdata *pdata;
+	int vbus_gpio;
 };
 
 static const struct hc_driver s5p_ehci_hc_driver = {
@@ -90,22 +91,28 @@ static void s5p_ehci_phy_disable(struct s5p_ehci_hcd *s5p_ehci)
 		s5p_ehci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST);
 }
 
-static void s5p_setup_vbus_gpio(struct platform_device *pdev)
+static int s5p_setup_vbus_gpio(struct platform_device *pdev)
 {
 	int err;
 	int gpio;
 
-	if (!pdev->dev.of_node)
-		return;
+	if (!pdev->dev.of_node) {
+		dev_err(&pdev->dev, "No device node present\n");
+		return -ENODEV;
+	}
 
 	gpio = of_get_named_gpio(pdev->dev.of_node,
 			"samsung,vbus-gpio", 0);
 	if (!gpio_is_valid(gpio))
-		return;
+		return -EINVAL;
 
 	err = gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, "ehci_vbus_gpio");
-	if (err)
+	if (err) {
 		dev_err(&pdev->dev, "can't request ehci vbus gpio %d", gpio);
+		return err;
+	}
+
+	return gpio;
 }
 
 static u64 ehci_s5p_dma_mask = DMA_BIT_MASK(32);
@@ -131,8 +138,6 @@ static int s5p_ehci_probe(struct platform_device *pdev)
 	if (!pdev->dev.coherent_dma_mask)
 		pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
 
-	s5p_setup_vbus_gpio(pdev);
-
 	s5p_ehci = devm_kzalloc(&pdev->dev, sizeof(struct s5p_ehci_hcd),
 				GFP_KERNEL);
 	if (!s5p_ehci)
@@ -154,6 +159,10 @@ static int s5p_ehci_probe(struct platform_device *pdev)
 
 	s5p_ehci->dev = &pdev->dev;
 
+	s5p_ehci->vbus_gpio = s5p_setup_vbus_gpio(pdev);
+	if (!gpio_is_valid(s5p_ehci->vbus_gpio))
+		dev_warn(&pdev->dev, "Failed to setup vbus gpio\n");
+
 	hcd = usb_create_hcd(&s5p_ehci_hc_driver, &pdev->dev,
 					dev_name(&pdev->dev));
 	if (!hcd) {
@@ -270,6 +279,9 @@ static int s5p_ehci_suspend(struct device *dev)
 
 	s5p_ehci_phy_disable(s5p_ehci);
 
+	if (gpio_is_valid(s5p_ehci->vbus_gpio))
+		gpio_set_value(s5p_ehci->vbus_gpio, 0);
+
 	clk_disable_unprepare(s5p_ehci->clk);
 
 	return rc;
@@ -282,6 +294,9 @@ static int s5p_ehci_resume(struct device *dev)
 
 	clk_prepare_enable(s5p_ehci->clk);
 
+	if (gpio_is_valid(s5p_ehci->vbus_gpio))
+		gpio_set_value(s5p_ehci->vbus_gpio, 1);
+
 	if (s5p_ehci->otg)
 		s5p_ehci->otg->set_host(s5p_ehci->otg, &s5p_ehci->hcd->self);
 
-- 
1.7.6.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: ehci: s5p: Power-off VBUS during suspend.
  2013-01-29 10:52 [PATCH] usb: ehci: s5p: Power-off VBUS during suspend Vivek Gautam
@ 2013-01-29 11:37 ` Oliver Neukum
  2013-01-29 12:01   ` Vivek Gautam
  2013-01-29 15:21 ` Alan Stern
  1 sibling, 1 reply; 4+ messages in thread
From: Oliver Neukum @ 2013-01-29 11:37 UTC (permalink / raw)
  To: Vivek Gautam
  Cc: linux-usb, linux-kernel, linux-samsung-soc, gregkh, stern,
	jg1.han, Doug Anderson

On Tuesday 29 January 2013 16:22:45 Vivek Gautam wrote:
> This change de-asserts vbus_gpio on suspend and
> re-asserts on resume in order to save power.
> NOTE, this change means no USB charging in suspend
> mode.

What happens if a device on the bus is a source of wakeups?

	Regards
		Oliver


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: ehci: s5p: Power-off VBUS during suspend.
  2013-01-29 11:37 ` Oliver Neukum
@ 2013-01-29 12:01   ` Vivek Gautam
  0 siblings, 0 replies; 4+ messages in thread
From: Vivek Gautam @ 2013-01-29 12:01 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Vivek Gautam, linux-usb, linux-kernel, linux-samsung-soc, gregkh,
	stern, jg1.han, Doug Anderson

Hi Oliver,


On Tue, Jan 29, 2013 at 5:07 PM, Oliver Neukum <oneukum@suse.de> wrote:
> On Tuesday 29 January 2013 16:22:45 Vivek Gautam wrote:
>> This change de-asserts vbus_gpio on suspend and
>> re-asserts on resume in order to save power.
>> NOTE, this change means no USB charging in suspend
>> mode.
>
> What happens if a device on the bus is a source of wakeups?
>

The device will not be powered in suspend state,
so the corresponding wakeup will get missed ?


>         Regards
>                 Oliver
>



-- 
Thanks & Regards
Vivek

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: ehci: s5p: Power-off VBUS during suspend.
  2013-01-29 10:52 [PATCH] usb: ehci: s5p: Power-off VBUS during suspend Vivek Gautam
  2013-01-29 11:37 ` Oliver Neukum
@ 2013-01-29 15:21 ` Alan Stern
  1 sibling, 0 replies; 4+ messages in thread
From: Alan Stern @ 2013-01-29 15:21 UTC (permalink / raw)
  To: Vivek Gautam
  Cc: linux-usb, linux-kernel, linux-samsung-soc, gregkh, jg1.han,
	Doug Anderson

On Tue, 29 Jan 2013, Vivek Gautam wrote:

> This change de-asserts vbus_gpio on suspend and
> re-asserts on resume in order to save power.
> NOTE, this change means no USB charging in suspend
> mode.

Doing this would mean USB devices could not wake up the system.  This 
would be unacceptable.

However, turning off VBUS power is okay provided:

	no root-hub ports are enabled, and

	the root hub is not enabled for wakeup.

Under those circumstances there can't be any wakeup-enabled USB devices 
on the bus, and the root hub itself would not need to detect new 
connections and disconnections.

Alan Stern


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-01-29 15:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-29 10:52 [PATCH] usb: ehci: s5p: Power-off VBUS during suspend Vivek Gautam
2013-01-29 11:37 ` Oliver Neukum
2013-01-29 12:01   ` Vivek Gautam
2013-01-29 15:21 ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®