[PATCH 1/2] usb: ohci-pxa27x: add regulator support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add regulator support for usb so that it would be possible to turn
it on and off (also for suspend/resume).

Cc: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Nikita Kiryanov <nikita@xxxxxxxxxxxxxx>
Signed-off-by: Igor Grinberg <grinberg@xxxxxxxxxxxxxx>
---
 drivers/usb/host/ohci-pxa27x.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index 93371a2..35e739e 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -28,6 +28,7 @@
 #include <mach/hardware.h>
 #include <linux/platform_data/usb-ohci-pxa27x.h>
 #include <linux/platform_data/usb-pxa3xx-ulpi.h>
+#include <linux/regulator/machine.h>
 
 /*
  * UHC: USB Host Controller (OHCI-like) register definitions
@@ -107,6 +108,7 @@ struct pxa27x_ohci {
 
 	struct device	*dev;
 	struct clk	*clk;
+	struct regulator *usb_regulator;
 	void __iomem	*mmio_base;
 };
 
@@ -221,6 +223,10 @@ static int pxa27x_start_hc(struct pxa27x_ohci *ohci, struct device *dev)
 
 	inf = dev_get_platdata(dev);
 
+	retval = regulator_enable(ohci->usb_regulator);
+	if (retval)
+		return retval;
+
 	clk_prepare_enable(ohci->clk);
 
 	pxa27x_reset_hc(ohci);
@@ -272,6 +278,7 @@ static void pxa27x_stop_hc(struct pxa27x_ohci *ohci, struct device *dev)
 	udelay(10);
 
 	clk_disable_unprepare(ohci->clk);
+	regulator_disable(ohci->usb_regulator);
 }
 
 #ifdef CONFIG_OF
@@ -413,10 +420,16 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device
 	ohci->dev = &pdev->dev;
 	ohci->clk = usb_clk;
 	ohci->mmio_base = (void __iomem *)hcd->regs;
+	ohci->usb_regulator = regulator_get(&pdev->dev, "vcc usb");
+	if (IS_ERR(ohci->usb_regulator)) {
+		pr_err("could not obtain usb regulator");
+		retval = PTR_ERR(ohci->usb_regulator);
+		goto err3;
+	}
 
 	if ((retval = pxa27x_start_hc(ohci, &pdev->dev)) < 0) {
 		pr_debug("pxa27x_start_hc failed");
-		goto err3;
+		goto err4;
 	}
 
 	/* Select Power Management Mode */
@@ -432,6 +445,9 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device
 		return retval;
 
 	pxa27x_stop_hc(ohci, &pdev->dev);
+
+err4:
+	regulator_put(ohci->usb_regulator);
  err3:
 	iounmap(hcd->regs);
  err2:
@@ -467,6 +483,7 @@ void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *pdev)
 	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
 	usb_put_hcd(hcd);
 	clk_put(ohci->clk);
+	regulator_put(ohci->usb_regulator);
 }
 
 /*-------------------------------------------------------------------------*/
-- 
1.8.1.2

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




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux