aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-tegra/Makefile1
-rw-r--r--arch/arm/mach-tegra/devices.c2
-rw-r--r--arch/arm/mach-tegra/devices.h2
-rw-r--r--drivers/usb/host/ehci-tegra.c14
-rw-r--r--drivers/usb/phy/Makefile1
-rw-r--r--drivers/usb/phy/tegra_usb_phy.c (renamed from arch/arm/mach-tegra/usb_phy.c)152
-rw-r--r--include/linux/usb/tegra_usb_phy.h (renamed from arch/arm/mach-tegra/include/mach/usb_phy.h)16
7 files changed, 103 insertions, 85 deletions
diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile
index c3d7303b9ac8..0e82b7f34fc1 100644
--- a/arch/arm/mach-tegra/Makefile
+++ b/arch/arm/mach-tegra/Makefile
@@ -21,7 +21,6 @@ obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
21obj-$(CONFIG_TEGRA_SYSTEM_DMA) += dma.o 21obj-$(CONFIG_TEGRA_SYSTEM_DMA) += dma.o
22obj-$(CONFIG_CPU_FREQ) += cpu-tegra.o 22obj-$(CONFIG_CPU_FREQ) += cpu-tegra.o
23obj-$(CONFIG_TEGRA_PCI) += pcie.o 23obj-$(CONFIG_TEGRA_PCI) += pcie.o
24obj-$(CONFIG_USB_SUPPORT) += usb_phy.o
25 24
26obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += board-dt-tegra20.o 25obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += board-dt-tegra20.o
27obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += board-dt-tegra30.o 26obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += board-dt-tegra30.o
diff --git a/arch/arm/mach-tegra/devices.c b/arch/arm/mach-tegra/devices.c
index c70e65ffa36b..d8ab76276397 100644
--- a/arch/arm/mach-tegra/devices.c
+++ b/arch/arm/mach-tegra/devices.c
@@ -27,7 +27,7 @@
27#include <mach/irqs.h> 27#include <mach/irqs.h>
28#include <mach/iomap.h> 28#include <mach/iomap.h>
29#include <mach/dma.h> 29#include <mach/dma.h>
30#include <mach/usb_phy.h> 30#include <linux/usb/tegra_usb_phy.h>
31 31
32#include "gpio-names.h" 32#include "gpio-names.h"
33#include "devices.h" 33#include "devices.h"
diff --git a/arch/arm/mach-tegra/devices.h b/arch/arm/mach-tegra/devices.h
index 4f5052726495..906a61f340c8 100644
--- a/arch/arm/mach-tegra/devices.h
+++ b/arch/arm/mach-tegra/devices.h
@@ -22,7 +22,7 @@
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/platform_data/tegra_usb.h> 23#include <linux/platform_data/tegra_usb.h>
24 24
25#include <mach/usb_phy.h> 25#include <linux/usb/tegra_usb_phy.h>
26 26
27extern struct tegra_ulpi_config tegra_ehci2_ulpi_phy_config; 27extern struct tegra_ulpi_config tegra_ehci2_ulpi_phy_config;
28 28
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 950e95efa381..65408f7ae92b 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -27,7 +27,7 @@
27#include <linux/of_gpio.h> 27#include <linux/of_gpio.h>
28#include <linux/pm_runtime.h> 28#include <linux/pm_runtime.h>
29 29
30#include <mach/usb_phy.h> 30#include <linux/usb/tegra_usb_phy.h>
31#include <mach/iomap.h> 31#include <mach/iomap.h>
32 32
33#define TEGRA_USB_DMA_ALIGN 32 33#define TEGRA_USB_DMA_ALIGN 32
@@ -49,7 +49,7 @@ static void tegra_ehci_power_up(struct usb_hcd *hcd)
49 49
50 clk_prepare_enable(tegra->emc_clk); 50 clk_prepare_enable(tegra->emc_clk);
51 clk_prepare_enable(tegra->clk); 51 clk_prepare_enable(tegra->clk);
52 tegra_usb_phy_power_on(tegra->phy); 52 usb_phy_set_suspend(&tegra->phy->u_phy, 0);
53 tegra->host_resumed = 1; 53 tegra->host_resumed = 1;
54} 54}
55 55
@@ -58,7 +58,7 @@ static void tegra_ehci_power_down(struct usb_hcd *hcd)
58 struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); 58 struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller);
59 59
60 tegra->host_resumed = 0; 60 tegra->host_resumed = 0;
61 tegra_usb_phy_power_off(tegra->phy); 61 usb_phy_set_suspend(&tegra->phy->u_phy, 1);
62 clk_disable_unprepare(tegra->clk); 62 clk_disable_unprepare(tegra->clk);
63 clk_disable_unprepare(tegra->emc_clk); 63 clk_disable_unprepare(tegra->emc_clk);
64} 64}
@@ -715,7 +715,9 @@ static int tegra_ehci_probe(struct platform_device *pdev)
715 goto fail_phy; 715 goto fail_phy;
716 } 716 }
717 717
718 err = tegra_usb_phy_power_on(tegra->phy); 718 usb_phy_init(&tegra->phy->u_phy);
719
720 err = usb_phy_set_suspend(&tegra->phy->u_phy, 0);
719 if (err) { 721 if (err) {
720 dev_err(&pdev->dev, "Failed to power on the phy\n"); 722 dev_err(&pdev->dev, "Failed to power on the phy\n");
721 goto fail; 723 goto fail;
@@ -762,7 +764,7 @@ fail:
762 usb_put_phy(tegra->transceiver); 764 usb_put_phy(tegra->transceiver);
763 } 765 }
764#endif 766#endif
765 tegra_usb_phy_close(tegra->phy); 767 usb_phy_shutdown(&tegra->phy->u_phy);
766fail_phy: 768fail_phy:
767 iounmap(hcd->regs); 769 iounmap(hcd->regs);
768fail_io: 770fail_io:
@@ -801,7 +803,7 @@ static int tegra_ehci_remove(struct platform_device *pdev)
801 usb_remove_hcd(hcd); 803 usb_remove_hcd(hcd);
802 usb_put_hcd(hcd); 804 usb_put_hcd(hcd);
803 805
804 tegra_usb_phy_close(tegra->phy); 806 usb_phy_shutdown(&tegra->phy->u_phy);
805 iounmap(hcd->regs); 807 iounmap(hcd->regs);
806 808
807 clk_disable_unprepare(tegra->clk); 809 clk_disable_unprepare(tegra->clk);
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index cf38f08c818f..bb948fb8654c 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -6,3 +6,4 @@ ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
6 6
7obj-$(CONFIG_USB_ISP1301) += isp1301.o 7obj-$(CONFIG_USB_ISP1301) += isp1301.o
8obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o 8obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o
9obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o
diff --git a/arch/arm/mach-tegra/usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index 022b33a05c3a..4739903245e8 100644
--- a/arch/arm/mach-tegra/usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/arm/mach-tegra/usb_phy.c
3 *
4 * Copyright (C) 2010 Google, Inc. 2 * Copyright (C) 2010 Google, Inc.
5 * 3 *
6 * Author: 4 * Author:
@@ -31,7 +29,7 @@
31#include <linux/usb/ulpi.h> 29#include <linux/usb/ulpi.h>
32#include <asm/mach-types.h> 30#include <asm/mach-types.h>
33#include <mach/gpio-tegra.h> 31#include <mach/gpio-tegra.h>
34#include <mach/usb_phy.h> 32#include <linux/usb/tegra_usb_phy.h>
35#include <mach/iomap.h> 33#include <mach/iomap.h>
36 34
37#define ULPI_VIEWPORT 0x170 35#define ULPI_VIEWPORT 0x170
@@ -482,7 +480,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
482 return 0; 480 return 0;
483} 481}
484 482
485static void utmi_phy_power_off(struct tegra_usb_phy *phy) 483static int utmi_phy_power_off(struct tegra_usb_phy *phy)
486{ 484{
487 unsigned long val; 485 unsigned long val;
488 void __iomem *base = phy->regs; 486 void __iomem *base = phy->regs;
@@ -514,7 +512,7 @@ static void utmi_phy_power_off(struct tegra_usb_phy *phy)
514 UTMIP_FORCE_PDDR_POWERDOWN; 512 UTMIP_FORCE_PDDR_POWERDOWN;
515 writel(val, base + UTMIP_XCVR_CFG1); 513 writel(val, base + UTMIP_XCVR_CFG1);
516 514
517 utmip_pad_power_off(phy); 515 return utmip_pad_power_off(phy);
518} 516}
519 517
520static void utmi_phy_preresume(struct tegra_usb_phy *phy) 518static void utmi_phy_preresume(struct tegra_usb_phy *phy)
@@ -638,7 +636,7 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy)
638 return 0; 636 return 0;
639} 637}
640 638
641static void ulpi_phy_power_off(struct tegra_usb_phy *phy) 639static int ulpi_phy_power_off(struct tegra_usb_phy *phy)
642{ 640{
643 unsigned long val; 641 unsigned long val;
644 void __iomem *base = phy->regs; 642 void __iomem *base = phy->regs;
@@ -651,15 +649,92 @@ static void ulpi_phy_power_off(struct tegra_usb_phy *phy)
651 val &= ~(USB_PORTSC1_WKOC | USB_PORTSC1_WKDS | USB_PORTSC1_WKCN); 649 val &= ~(USB_PORTSC1_WKOC | USB_PORTSC1_WKDS | USB_PORTSC1_WKCN);
652 writel(val, base + USB_PORTSC1); 650 writel(val, base + USB_PORTSC1);
653 651
654 gpio_direction_output(config->reset_gpio, 0);
655 clk_disable(phy->clk); 652 clk_disable(phy->clk);
653 return gpio_direction_output(config->reset_gpio, 0);
654}
655
656static int tegra_phy_init(struct usb_phy *x)
657{
658 struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy);
659 struct tegra_ulpi_config *ulpi_config;
660 int err;
661
662 if (phy_is_ulpi(phy)) {
663 ulpi_config = phy->config;
664 phy->clk = clk_get_sys(NULL, ulpi_config->clk);
665 if (IS_ERR(phy->clk)) {
666 pr_err("%s: can't get ulpi clock\n", __func__);
667 err = -ENXIO;
668 goto err1;
669 }
670 if (!gpio_is_valid(ulpi_config->reset_gpio))
671 ulpi_config->reset_gpio =
672 of_get_named_gpio(phy->dev->of_node,
673 "nvidia,phy-reset-gpio", 0);
674 if (!gpio_is_valid(ulpi_config->reset_gpio)) {
675 pr_err("%s: invalid reset gpio: %d\n", __func__,
676 ulpi_config->reset_gpio);
677 err = -EINVAL;
678 goto err1;
679 }
680 gpio_request(ulpi_config->reset_gpio, "ulpi_phy_reset_b");
681 gpio_direction_output(ulpi_config->reset_gpio, 0);
682 phy->ulpi = otg_ulpi_create(&ulpi_viewport_access_ops, 0);
683 phy->ulpi->io_priv = phy->regs + ULPI_VIEWPORT;
684 } else {
685 err = utmip_pad_open(phy);
686 if (err < 0)
687 goto err1;
688 }
689 return 0;
690err1:
691 clk_disable_unprepare(phy->pll_u);
692 clk_put(phy->pll_u);
693 return err;
694}
695
696static void tegra_usb_phy_close(struct usb_phy *x)
697{
698 struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy);
699
700 if (phy_is_ulpi(phy))
701 clk_put(phy->clk);
702 else
703 utmip_pad_close(phy);
704 clk_disable_unprepare(phy->pll_u);
705 clk_put(phy->pll_u);
706 kfree(phy);
707}
708
709static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy)
710{
711 if (phy_is_ulpi(phy))
712 return ulpi_phy_power_on(phy);
713 else
714 return utmi_phy_power_on(phy);
715}
716
717static int tegra_usb_phy_power_off(struct tegra_usb_phy *phy)
718{
719 if (phy_is_ulpi(phy))
720 return ulpi_phy_power_off(phy);
721 else
722 return utmi_phy_power_off(phy);
723}
724
725static int tegra_usb_phy_suspend(struct usb_phy *x, int suspend)
726{
727 struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy);
728 if (suspend)
729 return tegra_usb_phy_power_off(phy);
730 else
731 return tegra_usb_phy_power_on(phy);
656} 732}
657 733
658struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance, 734struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
659 void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode) 735 void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode)
660{ 736{
661 struct tegra_usb_phy *phy; 737 struct tegra_usb_phy *phy;
662 struct tegra_ulpi_config *ulpi_config;
663 unsigned long parent_rate; 738 unsigned long parent_rate;
664 int i; 739 int i;
665 int err; 740 int err;
@@ -672,6 +747,7 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
672 phy->regs = regs; 747 phy->regs = regs;
673 phy->config = config; 748 phy->config = config;
674 phy->mode = phy_mode; 749 phy->mode = phy_mode;
750 phy->dev = dev;
675 751
676 if (!phy->config) { 752 if (!phy->config) {
677 if (phy_is_ulpi(phy)) { 753 if (phy_is_ulpi(phy)) {
@@ -704,33 +780,9 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
704 goto err1; 780 goto err1;
705 } 781 }
706 782
707 if (phy_is_ulpi(phy)) { 783 phy->u_phy.init = tegra_phy_init;
708 ulpi_config = config; 784 phy->u_phy.shutdown = tegra_usb_phy_close;
709 phy->clk = clk_get_sys(NULL, ulpi_config->clk); 785 phy->u_phy.set_suspend = tegra_usb_phy_suspend;
710 if (IS_ERR(phy->clk)) {
711 pr_err("%s: can't get ulpi clock\n", __func__);
712 err = -ENXIO;
713 goto err1;
714 }
715 if (!gpio_is_valid(ulpi_config->reset_gpio))
716 ulpi_config->reset_gpio =
717 of_get_named_gpio(dev->of_node,
718 "nvidia,phy-reset-gpio", 0);
719 if (!gpio_is_valid(ulpi_config->reset_gpio)) {
720 pr_err("%s: invalid reset gpio: %d\n", __func__,
721 ulpi_config->reset_gpio);
722 err = -EINVAL;
723 goto err1;
724 }
725 gpio_request(ulpi_config->reset_gpio, "ulpi_phy_reset_b");
726 gpio_direction_output(ulpi_config->reset_gpio, 0);
727 phy->ulpi = otg_ulpi_create(&ulpi_viewport_access_ops, 0);
728 phy->ulpi->io_priv = regs + ULPI_VIEWPORT;
729 } else {
730 err = utmip_pad_open(phy);
731 if (err < 0)
732 goto err1;
733 }
734 786
735 return phy; 787 return phy;
736 788
@@ -743,24 +795,6 @@ err0:
743} 795}
744EXPORT_SYMBOL_GPL(tegra_usb_phy_open); 796EXPORT_SYMBOL_GPL(tegra_usb_phy_open);
745 797
746int tegra_usb_phy_power_on(struct tegra_usb_phy *phy)
747{
748 if (phy_is_ulpi(phy))
749 return ulpi_phy_power_on(phy);
750 else
751 return utmi_phy_power_on(phy);
752}
753EXPORT_SYMBOL_GPL(tegra_usb_phy_power_on);
754
755void tegra_usb_phy_power_off(struct tegra_usb_phy *phy)
756{
757 if (phy_is_ulpi(phy))
758 ulpi_phy_power_off(phy);
759 else
760 utmi_phy_power_off(phy);
761}
762EXPORT_SYMBOL_GPL(tegra_usb_phy_power_off);
763
764void tegra_usb_phy_preresume(struct tegra_usb_phy *phy) 798void tegra_usb_phy_preresume(struct tegra_usb_phy *phy)
765{ 799{
766 if (!phy_is_ulpi(phy)) 800 if (!phy_is_ulpi(phy))
@@ -803,15 +837,3 @@ void tegra_usb_phy_clk_enable(struct tegra_usb_phy *phy)
803 utmi_phy_clk_enable(phy); 837 utmi_phy_clk_enable(phy);
804} 838}
805EXPORT_SYMBOL_GPL(tegra_usb_phy_clk_enable); 839EXPORT_SYMBOL_GPL(tegra_usb_phy_clk_enable);
806
807void tegra_usb_phy_close(struct tegra_usb_phy *phy)
808{
809 if (phy_is_ulpi(phy))
810 clk_put(phy->clk);
811 else
812 utmip_pad_close(phy);
813 clk_disable_unprepare(phy->pll_u);
814 clk_put(phy->pll_u);
815 kfree(phy);
816}
817EXPORT_SYMBOL_GPL(tegra_usb_phy_close);
diff --git a/arch/arm/mach-tegra/include/mach/usb_phy.h b/include/linux/usb/tegra_usb_phy.h
index 935ce9f65590..176b1ca06ae4 100644
--- a/arch/arm/mach-tegra/include/mach/usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/arm/mach-tegra/include/mach/usb_phy.h
3 *
4 * Copyright (C) 2010 Google, Inc. 2 * Copyright (C) 2010 Google, Inc.
5 * 3 *
6 * This software is licensed under the terms of the GNU General Public 4 * This software is licensed under the terms of the GNU General Public
@@ -14,8 +12,8 @@
14 * 12 *
15 */ 13 */
16 14
17#ifndef __MACH_USB_PHY_H 15#ifndef __TEGRA_USB_PHY_H
18#define __MACH_USB_PHY_H 16#define __TEGRA_USB_PHY_H
19 17
20#include <linux/clk.h> 18#include <linux/clk.h>
21#include <linux/usb/otg.h> 19#include <linux/usb/otg.h>
@@ -59,19 +57,17 @@ struct tegra_usb_phy {
59 enum tegra_usb_phy_mode mode; 57 enum tegra_usb_phy_mode mode;
60 void *config; 58 void *config;
61 struct usb_phy *ulpi; 59 struct usb_phy *ulpi;
60 struct usb_phy u_phy;
61 struct device *dev;
62}; 62};
63 63
64struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance, 64struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
65 void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode); 65 void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode);
66 66
67int tegra_usb_phy_power_on(struct tegra_usb_phy *phy);
68
69void tegra_usb_phy_clk_disable(struct tegra_usb_phy *phy); 67void tegra_usb_phy_clk_disable(struct tegra_usb_phy *phy);
70 68
71void tegra_usb_phy_clk_enable(struct tegra_usb_phy *phy); 69void tegra_usb_phy_clk_enable(struct tegra_usb_phy *phy);
72 70
73void tegra_usb_phy_power_off(struct tegra_usb_phy *phy);
74
75void tegra_usb_phy_preresume(struct tegra_usb_phy *phy); 71void tegra_usb_phy_preresume(struct tegra_usb_phy *phy);
76 72
77void tegra_usb_phy_postresume(struct tegra_usb_phy *phy); 73void tegra_usb_phy_postresume(struct tegra_usb_phy *phy);
@@ -81,6 +77,4 @@ void tegra_ehci_phy_restore_start(struct tegra_usb_phy *phy,
81 77
82void tegra_ehci_phy_restore_end(struct tegra_usb_phy *phy); 78void tegra_ehci_phy_restore_end(struct tegra_usb_phy *phy);
83 79
84void tegra_usb_phy_close(struct tegra_usb_phy *phy); 80#endif /* __TEGRA_USB_PHY_H */
85
86#endif /* __MACH_USB_PHY_H */