aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/phy/phy-tegra-usb.c
diff options
context:
space:
mode:
authorMikko Perttunen <mperttunen@nvidia.com>2013-07-17 03:37:49 -0400
committerFelipe Balbi <balbi@ti.com>2013-07-29 06:58:18 -0400
commitf5b8c8b6d3b4697f28b818d8784e3e4b2a290022 (patch)
tree085f50f9642745d41ff282b4134a45aafdd6167d /drivers/usb/phy/phy-tegra-usb.c
parent81d5dfe6d8b3ba48ffcaa882783185c07b5d2384 (diff)
usb: tegra: Use regulators instead of GPIOs for USB PHY VBUS
The tegra ehci driver has enabled USB vbus regulators directly using GPIOs and the device tree attribute nvidia,vbus-gpio. This is ugly and causes error messages on boot when both the regulator driver and the ehci driver want access to the same GPIO. After this patch, usb vbus regulators for tegra usb phy devices are specified with the device tree attribute vbus-supply = <&x> where x is a regulator defined in the device tree. The old nvidia,vbus-gpio property is no longer supported. Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com> Reviewed-by: Stephen Warren <swarren@nvidia.com> Tested-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/phy/phy-tegra-usb.c')
-rw-r--r--drivers/usb/phy/phy-tegra-usb.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 3ecd49871b88..d92a63a5b0c9 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -34,6 +34,7 @@
34#include <asm/mach-types.h> 34#include <asm/mach-types.h>
35#include <linux/usb/ehci_def.h> 35#include <linux/usb/ehci_def.h>
36#include <linux/usb/tegra_usb_phy.h> 36#include <linux/usb/tegra_usb_phy.h>
37#include <linux/regulator/consumer.h>
37 38
38#define ULPI_VIEWPORT 0x170 39#define ULPI_VIEWPORT 0x170
39 40
@@ -613,6 +614,9 @@ static void tegra_usb_phy_close(struct usb_phy *x)
613{ 614{
614 struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); 615 struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy);
615 616
617 if (!IS_ERR(phy->vbus))
618 regulator_disable(phy->vbus);
619
616 clk_disable_unprepare(phy->pll_u); 620 clk_disable_unprepare(phy->pll_u);
617} 621}
618 622
@@ -705,6 +709,16 @@ static int tegra_usb_phy_init(struct tegra_usb_phy *phy)
705 goto fail; 709 goto fail;
706 } 710 }
707 711
712 if (!IS_ERR(phy->vbus)) {
713 err = regulator_enable(phy->vbus);
714 if (err) {
715 dev_err(phy->dev,
716 "failed to enable usb vbus regulator: %d\n",
717 err);
718 goto fail;
719 }
720 }
721
708 if (phy->is_ulpi_phy) 722 if (phy->is_ulpi_phy)
709 err = ulpi_open(phy); 723 err = ulpi_open(phy);
710 else 724 else
@@ -896,6 +910,16 @@ static int tegra_usb_phy_probe(struct platform_device *pdev)
896 } else 910 } else
897 tegra_phy->mode = TEGRA_USB_PHY_MODE_OTG; 911 tegra_phy->mode = TEGRA_USB_PHY_MODE_OTG;
898 912
913 /* On some boards, the VBUS regulator doesn't need to be controlled */
914 if (of_find_property(np, "vbus-supply", NULL)) {
915 tegra_phy->vbus = devm_regulator_get(&pdev->dev, "vbus");
916 if (IS_ERR(tegra_phy->vbus))
917 return PTR_ERR(tegra_phy->vbus);
918 } else {
919 dev_notice(&pdev->dev, "no vbus regulator");
920 tegra_phy->vbus = ERR_PTR(-ENODEV);
921 }
922
899 tegra_phy->dev = &pdev->dev; 923 tegra_phy->dev = &pdev->dev;
900 err = tegra_usb_phy_init(tegra_phy); 924 err = tegra_usb_phy_init(tegra_phy);
901 if (err < 0) 925 if (err < 0)