aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/phy
diff options
context:
space:
mode:
authorMikko Perttunen <mperttunen@nvidia.com>2013-07-17 02:31:01 -0400
committerFelipe Balbi <balbi@ti.com>2013-07-29 06:58:17 -0400
commit81d5dfe6d8b3ba48ffcaa882783185c07b5d2384 (patch)
treea7d3a8ffffec99f3d794be10e863b0665120a024 /drivers/usb/phy
parentc49667e56fcb5e92efcbe816c34c3e373b33cd01 (diff)
usb: phy: tegra: Read UTMIP parameters from device tree
UTMIP parameters used to be hardcoded into tables in the PHY driver. This patch reads them from the device tree instead in accordance with the phy-tegra-usb DT documentation. 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')
-rw-r--r--drivers/usb/phy/phy-tegra-usb.c129
1 files changed, 87 insertions, 42 deletions
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index cec0855ed248..3ecd49871b88 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -184,27 +184,6 @@ static const struct tegra_xtal_freq tegra_freq_table[] = {
184 }, 184 },
185}; 185};
186 186
187static struct tegra_utmip_config utmip_default[] = {
188 [0] = {
189 .hssync_start_delay = 9,
190 .idle_wait_delay = 17,
191 .elastic_limit = 16,
192 .term_range_adj = 6,
193 .xcvr_setup = 9,
194 .xcvr_lsfslew = 1,
195 .xcvr_lsrslew = 1,
196 },
197 [2] = {
198 .hssync_start_delay = 9,
199 .idle_wait_delay = 17,
200 .elastic_limit = 16,
201 .term_range_adj = 6,
202 .xcvr_setup = 9,
203 .xcvr_lsfslew = 2,
204 .xcvr_lsrslew = 2,
205 },
206};
207
208static void set_pts(struct tegra_usb_phy *phy, u8 pts_val) 187static void set_pts(struct tegra_usb_phy *phy, u8 pts_val)
209{ 188{
210 void __iomem *base = phy->regs; 189 void __iomem *base = phy->regs;
@@ -703,13 +682,6 @@ static int tegra_usb_phy_init(struct tegra_usb_phy *phy)
703 int i; 682 int i;
704 int err; 683 int err;
705 684
706 if (!phy->is_ulpi_phy) {
707 if (phy->is_legacy_phy)
708 phy->config = &utmip_default[0];
709 else
710 phy->config = &utmip_default[2];
711 }
712
713 phy->pll_u = devm_clk_get(phy->dev, "pll_u"); 685 phy->pll_u = devm_clk_get(phy->dev, "pll_u");
714 if (IS_ERR(phy->pll_u)) { 686 if (IS_ERR(phy->pll_u)) {
715 pr_err("Can't get pll_u clock\n"); 687 pr_err("Can't get pll_u clock\n");
@@ -784,6 +756,88 @@ void tegra_ehci_phy_restore_end(struct usb_phy *x)
784} 756}
785EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_end); 757EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_end);
786 758
759static int read_utmi_param(struct platform_device *pdev, const char *param,
760 u8 *dest)
761{
762 u32 value;
763 int err = of_property_read_u32(pdev->dev.of_node, param, &value);
764 *dest = (u8)value;
765 if (err < 0)
766 dev_err(&pdev->dev, "Failed to read USB UTMI parameter %s: %d\n",
767 param, err);
768 return err;
769}
770
771static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy,
772 struct platform_device *pdev)
773{
774 struct resource *res;
775 int err;
776 struct tegra_utmip_config *config;
777
778 tegra_phy->is_ulpi_phy = false;
779
780 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
781 if (!res) {
782 dev_err(&pdev->dev, "Failed to get UTMI Pad regs\n");
783 return -ENXIO;
784 }
785
786 tegra_phy->pad_regs = devm_ioremap(&pdev->dev, res->start,
787 resource_size(res));
788 if (!tegra_phy->regs) {
789 dev_err(&pdev->dev, "Failed to remap UTMI Pad regs\n");
790 return -ENOMEM;
791 }
792
793 tegra_phy->config = devm_kzalloc(&pdev->dev,
794 sizeof(*tegra_phy->config), GFP_KERNEL);
795 if (!tegra_phy->config) {
796 dev_err(&pdev->dev,
797 "unable to allocate memory for USB UTMIP config\n");
798 return -ENOMEM;
799 }
800
801 config = tegra_phy->config;
802
803 err = read_utmi_param(pdev, "nvidia,hssync-start-delay",
804 &config->hssync_start_delay);
805 if (err < 0)
806 return err;
807
808 err = read_utmi_param(pdev, "nvidia,elastic-limit",
809 &config->elastic_limit);
810 if (err < 0)
811 return err;
812
813 err = read_utmi_param(pdev, "nvidia,idle-wait-delay",
814 &config->idle_wait_delay);
815 if (err < 0)
816 return err;
817
818 err = read_utmi_param(pdev, "nvidia,term-range-adj",
819 &config->term_range_adj);
820 if (err < 0)
821 return err;
822
823 err = read_utmi_param(pdev, "nvidia,xcvr-setup",
824 &config->xcvr_setup);
825 if (err < 0)
826 return err;
827
828 err = read_utmi_param(pdev, "nvidia,xcvr-lsfslew",
829 &config->xcvr_lsfslew);
830 if (err < 0)
831 return err;
832
833 err = read_utmi_param(pdev, "nvidia,xcvr-lsrslew",
834 &config->xcvr_lsrslew);
835 if (err < 0)
836 return err;
837
838 return 0;
839}
840
787static int tegra_usb_phy_probe(struct platform_device *pdev) 841static int tegra_usb_phy_probe(struct platform_device *pdev)
788{ 842{
789 struct resource *res; 843 struct resource *res;
@@ -815,20 +869,9 @@ static int tegra_usb_phy_probe(struct platform_device *pdev)
815 869
816 err = of_property_match_string(np, "phy_type", "ulpi"); 870 err = of_property_match_string(np, "phy_type", "ulpi");
817 if (err < 0) { 871 if (err < 0) {
818 tegra_phy->is_ulpi_phy = false; 872 err = utmi_phy_probe(tegra_phy, pdev);
819 873 if (err < 0)
820 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 874 return err;
821 if (!res) {
822 dev_err(&pdev->dev, "Failed to get UTMI Pad regs\n");
823 return -ENXIO;
824 }
825
826 tegra_phy->pad_regs = devm_ioremap(&pdev->dev, res->start,
827 resource_size(res));
828 if (!tegra_phy->regs) {
829 dev_err(&pdev->dev, "Failed to remap UTMI Pad regs\n");
830 return -ENOMEM;
831 }
832 } else { 875 } else {
833 tegra_phy->is_ulpi_phy = true; 876 tegra_phy->is_ulpi_phy = true;
834 877
@@ -839,6 +882,8 @@ static int tegra_usb_phy_probe(struct platform_device *pdev)
839 tegra_phy->reset_gpio); 882 tegra_phy->reset_gpio);
840 return tegra_phy->reset_gpio; 883 return tegra_phy->reset_gpio;
841 } 884 }
885
886 tegra_phy->config = NULL;
842 } 887 }
843 888
844 err = of_property_match_string(np, "dr_mode", "otg"); 889 err = of_property_match_string(np, "dr_mode", "otg");