aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorVivek Gautam <gautam.vivek@samsung.com>2014-08-05 06:39:08 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-09-08 18:38:21 -0400
commit2f7f41c7a73c7416e72a07baede021ab62bd5ae7 (patch)
tree7a4807dda8552ccb64c004efa78a2c1493d73e30 /drivers/usb/host
parent69e273c0b0a3c337a521d083374c918dc52c666f (diff)
usb: ehci/ohci-exynos: Fix PHY getting sequence
Since we want to keep support for both older usb-phys as well as the newer generic phys, lets first get the generic PHYs and fallback to older USB-PHYs only when we fail to get the former. This should fix the issue with ehci-exynos and ohci-exynos, wherein in the absence of SAMSUNG_USB2PHY config symbol, we end up getting the NOP_USB_XCEIV phy when the same is enabled. And thus the PHYs are not configured properly. Reported-by: Sachin Kamat <sachin.kamat@samsung.com> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com> Cc: Alan Stern <stern@rowland.harvard.edu> Cc: Jingoo Han <jg1.han@samsung.com> Tested-by: Sachin Kamat <sachin.kamat@samsung.com> Acked-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/ehci-exynos.c40
-rw-r--r--drivers/usb/host/ohci-exynos.c47
2 files changed, 42 insertions, 45 deletions
diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index cda0a2f5c467..2eed9a4f89a9 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -62,18 +62,6 @@ static int exynos_ehci_get_phy(struct device *dev,
62 int phy_number; 62 int phy_number;
63 int ret = 0; 63 int ret = 0;
64 64
65 exynos_ehci->phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
66 if (IS_ERR(exynos_ehci->phy)) {
67 ret = PTR_ERR(exynos_ehci->phy);
68 if (ret != -ENXIO && ret != -ENODEV) {
69 dev_err(dev, "no usb2 phy configured\n");
70 return ret;
71 }
72 dev_dbg(dev, "Failed to get usb2 phy\n");
73 } else {
74 exynos_ehci->otg = exynos_ehci->phy->otg;
75 }
76
77 for_each_available_child_of_node(dev->of_node, child) { 65 for_each_available_child_of_node(dev->of_node, child) {
78 ret = of_property_read_u32(child, "reg", &phy_number); 66 ret = of_property_read_u32(child, "reg", &phy_number);
79 if (ret) { 67 if (ret) {
@@ -90,15 +78,27 @@ static int exynos_ehci_get_phy(struct device *dev,
90 78
91 phy = devm_of_phy_get(dev, child, NULL); 79 phy = devm_of_phy_get(dev, child, NULL);
92 of_node_put(child); 80 of_node_put(child);
93 if (IS_ERR(phy)) { 81 if (IS_ERR(phy))
94 ret = PTR_ERR(phy); 82 /* Lets fallback to older USB-PHYs */
95 if (ret != -ENOSYS && ret != -ENODEV) { 83 goto usb_phy_old;
96 dev_err(dev, "no usb2 phy configured\n");
97 return ret;
98 }
99 dev_dbg(dev, "Failed to get usb2 phy\n");
100 }
101 exynos_ehci->phy_g[phy_number] = phy; 84 exynos_ehci->phy_g[phy_number] = phy;
85 /* Make the older PHYs unavailable */
86 exynos_ehci->phy = ERR_PTR(-ENXIO);
87 }
88
89 return 0;
90
91usb_phy_old:
92 exynos_ehci->phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
93 if (IS_ERR(exynos_ehci->phy)) {
94 ret = PTR_ERR(exynos_ehci->phy);
95 if (ret != -ENXIO && ret != -ENODEV) {
96 dev_err(dev, "no usb2 phy configured\n");
97 return ret;
98 }
99 dev_dbg(dev, "Failed to get usb2 phy\n");
100 } else {
101 exynos_ehci->otg = exynos_ehci->phy->otg;
102 } 102 }
103 103
104 return ret; 104 return ret;
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index a72ab8fe8cd3..7c48e3f3146b 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -51,27 +51,12 @@ static int exynos_ohci_get_phy(struct device *dev,
51 int phy_number; 51 int phy_number;
52 int ret = 0; 52 int ret = 0;
53 53
54 exynos_ohci->phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
55 if (IS_ERR(exynos_ohci->phy)) {
56 ret = PTR_ERR(exynos_ohci->phy);
57 if (ret != -ENXIO && ret != -ENODEV) {
58 dev_err(dev, "no usb2 phy configured\n");
59 return ret;
60 }
61 dev_dbg(dev, "Failed to get usb2 phy\n");
62 } else {
63 exynos_ohci->otg = exynos_ohci->phy->otg;
64 }
65
66 /* 54 /*
67 * Getting generic phy: 55 * Getting generic phy:
68 * We are keeping both types of phys as a part of transiting OHCI 56 * We are keeping both types of phys as a part of transiting OHCI
69 * to generic phy framework, so as to maintain backward compatibilty 57 * to generic phy framework, so as to maintain backward compatibilty
70 * with old DTB. 58 * with old DTB too.
71 * If there are existing devices using DTB files built from them, 59 * We fallback to older USB-PHYs when we fail to get generic PHYs.
72 * to remove the support for old bindings in this driver,
73 * we need to make sure that such devices have their DTBs
74 * updated to ones built from new DTS.
75 */ 60 */
76 for_each_available_child_of_node(dev->of_node, child) { 61 for_each_available_child_of_node(dev->of_node, child) {
77 ret = of_property_read_u32(child, "reg", &phy_number); 62 ret = of_property_read_u32(child, "reg", &phy_number);
@@ -89,15 +74,27 @@ static int exynos_ohci_get_phy(struct device *dev,
89 74
90 phy = devm_of_phy_get(dev, child, NULL); 75 phy = devm_of_phy_get(dev, child, NULL);
91 of_node_put(child); 76 of_node_put(child);
92 if (IS_ERR(phy)) { 77 if (IS_ERR(phy))
93 ret = PTR_ERR(phy); 78 /* Lets fallback to older USB-PHYs */
94 if (ret != -ENOSYS && ret != -ENODEV) { 79 goto usb_phy_old;
95 dev_err(dev, "no usb2 phy configured\n");
96 return ret;
97 }
98 dev_dbg(dev, "Failed to get usb2 phy\n");
99 }
100 exynos_ohci->phy_g[phy_number] = phy; 80 exynos_ohci->phy_g[phy_number] = phy;
81 /* Make the older PHYs unavailable */
82 exynos_ohci->phy = ERR_PTR(-ENXIO);
83 }
84
85 return 0;
86
87usb_phy_old:
88 exynos_ohci->phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
89 if (IS_ERR(exynos_ohci->phy)) {
90 ret = PTR_ERR(exynos_ohci->phy);
91 if (ret != -ENXIO && ret != -ENODEV) {
92 dev_err(dev, "no usb2 phy configured\n");
93 return ret;
94 }
95 dev_dbg(dev, "Failed to get usb2 phy\n");
96 } else {
97 exynos_ohci->otg = exynos_ohci->phy->otg;
101 } 98 }
102 99
103 return ret; 100 return ret;