From: Vivek Gautam <gautam.vivek@samsung.com>
To: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
gregkh@linuxfoundation.org, stern@rowland.harvard.edu,
jg1.han@samsung.com, Doug Anderson <dianders@chromium.org>
Subject: [PATCH] usb: ehci: s5p: Power-off VBUS during suspend.
Date: Tue, 29 Jan 2013 16:22:45 +0530 [thread overview]
Message-ID: <1359456765-7335-1-git-send-email-gautam.vivek@samsung.com> (raw)
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
next reply other threads:[~2013-01-29 10:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-29 10:52 Vivek Gautam [this message]
2013-01-29 11:37 ` Oliver Neukum
2013-01-29 12:01 ` Vivek Gautam
2013-01-29 15:21 ` Alan Stern
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=1359456765-7335-1-git-send-email-gautam.vivek@samsung.com \
--to=gautam.vivek@samsung.com \
--cc=dianders@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=jg1.han@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--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
all inboxes | Powered by JetHome®