aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ehci-omap.c
diff options
context:
space:
mode:
authorAjay Kumar Gupta <ajay.gupta@ti.com>2009-12-28 06:40:46 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-02 17:53:49 -0500
commit881142660697bba0f3ef44f070d80632082c978f (patch)
treee2c6cd69cd0331523e74ed95a385ca2a0c405fcf /drivers/usb/host/ehci-omap.c
parentd3ae8562d43fe2b97d605dd67dc67bf8fa9b956a (diff)
usb: host: ehci: adding regulator framework in ehci-omap.c driver.
OMAP3 has three HS USB ports so it can have three different regulator for each PHY connected to each port. Currently these regulators are assumed to be optional and driver doesn't fail but continue with the initialization if it doesn't get any regulators. Regulator supply names has to be mapped in board files as 'hsusbN' where 'N' is port number and can be {0, 1 ,2}. Signed-off-by: Ajay Kumar Gupta <ajay.gupta@ti.com> Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host/ehci-omap.c')
-rw-r--r--drivers/usb/host/ehci-omap.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 2460f0d82990..17e4ceb5014d 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -37,6 +37,7 @@
37#include <linux/platform_device.h> 37#include <linux/platform_device.h>
38#include <linux/clk.h> 38#include <linux/clk.h>
39#include <linux/gpio.h> 39#include <linux/gpio.h>
40#include <linux/regulator/consumer.h>
40#include <plat/usb.h> 41#include <plat/usb.h>
41 42
42/* 43/*
@@ -178,6 +179,11 @@ struct ehci_hcd_omap {
178 void __iomem *uhh_base; 179 void __iomem *uhh_base;
179 void __iomem *tll_base; 180 void __iomem *tll_base;
180 void __iomem *ehci_base; 181 void __iomem *ehci_base;
182
183 /* Regulators for USB PHYs.
184 * Each PHY can have a seperate regulator.
185 */
186 struct regulator *regulator[OMAP3_HS_USB_PORTS];
181}; 187};
182 188
183/*-------------------------------------------------------------------------*/ 189/*-------------------------------------------------------------------------*/
@@ -546,6 +552,8 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
546 552
547 int irq = platform_get_irq(pdev, 0); 553 int irq = platform_get_irq(pdev, 0);
548 int ret = -ENODEV; 554 int ret = -ENODEV;
555 int i;
556 char supply[7];
549 557
550 if (!pdata) { 558 if (!pdata) {
551 dev_dbg(&pdev->dev, "missing platform_data\n"); 559 dev_dbg(&pdev->dev, "missing platform_data\n");
@@ -613,6 +621,21 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
613 goto err_tll_ioremap; 621 goto err_tll_ioremap;
614 } 622 }
615 623
624 /* get ehci regulator and enable */
625 for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) {
626 if (omap->port_mode[i] != EHCI_HCD_OMAP_MODE_PHY) {
627 omap->regulator[i] = NULL;
628 continue;
629 }
630 snprintf(supply, sizeof(supply), "hsusb%d", i);
631 omap->regulator[i] = regulator_get(omap->dev, supply);
632 if (IS_ERR(omap->regulator[i]))
633 dev_dbg(&pdev->dev,
634 "failed to get ehci port%d regulator\n", i);
635 else
636 regulator_enable(omap->regulator[i]);
637 }
638
616 ret = omap_start_ehc(omap, hcd); 639 ret = omap_start_ehc(omap, hcd);
617 if (ret) { 640 if (ret) {
618 dev_dbg(&pdev->dev, "failed to start ehci\n"); 641 dev_dbg(&pdev->dev, "failed to start ehci\n");
@@ -641,6 +664,12 @@ err_add_hcd:
641 omap_stop_ehc(omap, hcd); 664 omap_stop_ehc(omap, hcd);
642 665
643err_start: 666err_start:
667 for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) {
668 if (omap->regulator[i]) {
669 regulator_disable(omap->regulator[i]);
670 regulator_put(omap->regulator[i]);
671 }
672 }
644 iounmap(omap->tll_base); 673 iounmap(omap->tll_base);
645 674
646err_tll_ioremap: 675err_tll_ioremap:
@@ -674,10 +703,17 @@ static int ehci_hcd_omap_remove(struct platform_device *pdev)
674{ 703{
675 struct ehci_hcd_omap *omap = platform_get_drvdata(pdev); 704 struct ehci_hcd_omap *omap = platform_get_drvdata(pdev);
676 struct usb_hcd *hcd = ehci_to_hcd(omap->ehci); 705 struct usb_hcd *hcd = ehci_to_hcd(omap->ehci);
706 int i;
677 707
678 usb_remove_hcd(hcd); 708 usb_remove_hcd(hcd);
679 omap_stop_ehc(omap, hcd); 709 omap_stop_ehc(omap, hcd);
680 iounmap(hcd->regs); 710 iounmap(hcd->regs);
711 for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) {
712 if (omap->regulator[i]) {
713 regulator_disable(omap->regulator[i]);
714 regulator_put(omap->regulator[i]);
715 }
716 }
681 iounmap(omap->tll_base); 717 iounmap(omap->tll_base);
682 iounmap(omap->uhh_base); 718 iounmap(omap->uhh_base);
683 usb_put_hcd(hcd); 719 usb_put_hcd(hcd);