ralink: fix mt7620 ohci 3.14
[openwrt/openwrt.git] / target / linux / ramips / patches-3.14 / 0038-USB-add-OHCI-EHCI-OF-binding.patch
1 From ffb27de4760595c356ef619c97f25722c8db28e7 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sun, 27 Jul 2014 09:49:07 +0100
4 Subject: [PATCH 38/57] USB: add OHCI/EHCI OF binding
5
6 based on f3bc64d6d1f21c1b92d75f233a37b75d77af6963
7
8 Signed-off-by: John Crispin <blogic@openwrt.org>
9 ---
10 drivers/usb/Makefile | 3 ++-
11 drivers/usb/host/ehci-platform.c | 21 +++++++++++++++++----
12 drivers/usb/host/ohci-platform.c | 37 +++++++++++++++++++++++++++++++------
13 3 files changed, 50 insertions(+), 11 deletions(-)
14
15 Index: linux-3.14.16/drivers/usb/Makefile
16 ===================================================================
17 --- linux-3.14.16.orig/drivers/usb/Makefile 2014-08-08 01:50:59.000000000 +0200
18 +++ linux-3.14.16/drivers/usb/Makefile 2014-08-24 14:33:57.590539754 +0200
19 @@ -11,6 +11,8 @@
20
21 obj-$(CONFIG_USB_MON) += mon/
22
23 +obj-$(CONFIG_USB_PHY) += phy/
24 +
25 obj-$(CONFIG_PCI) += host/
26 obj-$(CONFIG_USB_EHCI_HCD) += host/
27 obj-$(CONFIG_USB_ISP116X_HCD) += host/
28 @@ -41,7 +43,6 @@
29 obj-$(CONFIG_USB_STORAGE) += storage/
30 obj-$(CONFIG_USB) += storage/
31
32 -obj-$(CONFIG_USB_MDC800) += image/
33 obj-$(CONFIG_USB_MICROTEK) += image/
34
35 obj-$(CONFIG_USB_SERIAL) += serial/
36 Index: linux-3.14.16/drivers/usb/host/ehci-platform.c
37 ===================================================================
38 --- linux-3.14.16.orig/drivers/usb/host/ehci-platform.c 2014-08-24 12:39:18.806371411 +0200
39 +++ linux-3.14.16/drivers/usb/host/ehci-platform.c 2014-08-24 12:39:21.102371467 +0200
40 @@ -29,6 +29,8 @@
41 #include <linux/usb.h>
42 #include <linux/usb/hcd.h>
43 #include <linux/usb/ehci_pdriver.h>
44 +#include <linux/usb/phy.h>
45 +#include <linux/usb/otg.h>
46
47 #include "ehci.h"
48
49 @@ -124,6 +126,15 @@
50 hcd->rsrc_start = res_mem->start;
51 hcd->rsrc_len = resource_size(res_mem);
52
53 +#ifdef CONFIG_USB_PHY
54 + hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
55 + if (!IS_ERR_OR_NULL(hcd->phy)) {
56 + otg_set_host(hcd->phy->otg,
57 + &hcd->self);
58 + usb_phy_init(hcd->phy);
59 + }
60 +#endif
61 +
62 hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
63 if (IS_ERR(hcd->regs)) {
64 err = PTR_ERR(hcd->regs);
65 @@ -161,6 +172,9 @@
66 if (pdata == &ehci_platform_defaults)
67 dev->dev.platform_data = NULL;
68
69 + if (pdata == &ehci_platform_defaults)
70 + dev->dev.platform_data = NULL;
71 +
72 return 0;
73 }
74
75 @@ -205,9 +219,8 @@
76 #define ehci_platform_resume NULL
77 #endif /* CONFIG_PM */
78
79 -static const struct of_device_id vt8500_ehci_ids[] = {
80 - { .compatible = "via,vt8500-ehci", },
81 - { .compatible = "wm,prizm-ehci", },
82 +static const struct of_device_id ralink_ehci_ids[] = {
83 + { .compatible = "ralink,rt3xxx-ehci", },
84 {}
85 };
86
87 @@ -231,7 +244,7 @@
88 .owner = THIS_MODULE,
89 .name = "ehci-platform",
90 .pm = &ehci_platform_pm_ops,
91 - .of_match_table = vt8500_ehci_ids,
92 + .of_match_table = ralink_ehci_ids,
93 }
94 };
95
96 Index: linux-3.14.16/drivers/usb/host/ohci-platform.c
97 ===================================================================
98 --- linux-3.14.16.orig/drivers/usb/host/ohci-platform.c 2014-08-08 01:50:59.000000000 +0200
99 +++ linux-3.14.16/drivers/usb/host/ohci-platform.c 2014-08-24 12:41:51.422375146 +0200
100 @@ -22,18 +22,22 @@
101 #include <linux/platform_device.h>
102 #include <linux/usb/ohci_pdriver.h>
103 #include <linux/usb.h>
104 +#include <linux/usb/phy.h>
105 #include <linux/usb/hcd.h>
106 +#include <linux/dma-mapping.h>
107 +#include <linux/of.h>
108
109 #include "ohci.h"
110
111 #define DRIVER_DESC "OHCI generic platform driver"
112
113 +static struct usb_ohci_pdata ohci_platform_defaults;
114 static const char hcd_name[] = "ohci-platform";
115
116 static int ohci_platform_reset(struct usb_hcd *hcd)
117 {
118 struct platform_device *pdev = to_platform_device(hcd->self.controller);
119 - struct usb_ohci_pdata *pdata = dev_get_platdata(&pdev->dev);
120 + struct usb_ohci_pdata *pdata = dev_get_platdata(&pdev->dev);;
121 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
122
123 if (pdata->big_endian_desc)
124 @@ -63,11 +67,18 @@
125 int irq;
126 int err = -ENOMEM;
127
128 - if (!pdata) {
129 - WARN_ON(1);
130 - return -ENODEV;
131 - }
132 + /*
133 + * use reasonable defaults so platforms don't have to provide these.
134 + * with DT probing on ARM, none of these are set.
135 + */
136 + if (!dev->dev.platform_data)
137 + dev->dev.platform_data = &ohci_platform_defaults;
138 + if (!dev->dev.dma_mask)
139 + dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
140 + if (!dev->dev.coherent_dma_mask)
141 + dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
142
143 + pdata = dev->dev.platform_data;
144 if (usb_disabled())
145 return -ENODEV;
146
147 @@ -99,6 +110,12 @@
148 hcd->rsrc_start = res_mem->start;
149 hcd->rsrc_len = resource_size(res_mem);
150
151 +#ifdef CONFIG_USB_PHY
152 + hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
153 + if (!IS_ERR_OR_NULL(hcd->phy))
154 + usb_phy_init(hcd->phy);
155 +#endif
156 +
157 hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
158 if (IS_ERR(hcd->regs)) {
159 err = PTR_ERR(hcd->regs);
160 @@ -134,6 +151,9 @@
161 if (pdata->power_off)
162 pdata->power_off(dev);
163
164 + if (pdata == &ohci_platform_defaults)
165 + dev->dev.platform_data = NULL;
166 +
167 return 0;
168 }
169
170 @@ -180,6 +200,11 @@
171 #define ohci_platform_resume NULL
172 #endif /* CONFIG_PM */
173
174 +static const struct of_device_id ralink_ohci_ids[] = {
175 + { .compatible = "ralink,rt3xxx-ohci", },
176 + {}
177 +};
178 +
179 static const struct platform_device_id ohci_platform_table[] = {
180 { "ohci-platform", 0 },
181 { }
182 @@ -200,6 +225,7 @@
183 .owner = THIS_MODULE,
184 .name = "ohci-platform",
185 .pm = &ohci_platform_pm_ops,
186 + .of_match_table = of_match_ptr(ralink_ohci_ids),
187 }
188 };
189