ramips: add ralink v3.10 support
[openwrt/staging/lynxis/omap.git] / target / linux / ramips / patches-3.10 / 0019-USB-add-OHCI-EHCI-OF-binding.patch
1 From 40b9d3026ed0b3bcd59f90391195df5b2adabad2 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sun, 14 Jul 2013 23:34:53 +0200
4 Subject: [PATCH 19/33] USB: add OHCI/EHCI OF binding
5
6 based on f3bc64d6d1f21c1b92d75f233a37b75d77af6963
7
8 Signed-off-by: John Crispin <blogic@openwrt.org>
9 ---
10 arch/mips/ralink/Kconfig | 2 ++
11 drivers/usb/Makefile | 3 ++-
12 drivers/usb/host/ehci-platform.c | 19 +++++++++++++++----
13 drivers/usb/host/ohci-platform.c | 37 ++++++++++++++++++++++++++++++++-----
14 4 files changed, 51 insertions(+), 10 deletions(-)
15
16 diff --git a/arch/mips/ralink/Kconfig b/arch/mips/ralink/Kconfig
17 index 992e365..8f49ed7 100644
18 --- a/arch/mips/ralink/Kconfig
19 +++ b/arch/mips/ralink/Kconfig
20 @@ -24,6 +24,8 @@ choice
21
22 config SOC_MT7620
23 bool "MT7620"
24 + select USB_ARCH_HAS_OHCI
25 + select USB_ARCH_HAS_EHCI
26 select HW_HAS_PCI
27
28 endchoice
29 diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
30 index c41feba..d155174 100644
31 --- a/drivers/usb/Makefile
32 +++ b/drivers/usb/Makefile
33 @@ -10,6 +10,8 @@ obj-$(CONFIG_USB_DWC3) += dwc3/
34
35 obj-$(CONFIG_USB_MON) += mon/
36
37 +obj-$(CONFIG_USB_OTG_UTILS) += phy/
38 +
39 obj-$(CONFIG_PCI) += host/
40 obj-$(CONFIG_USB_EHCI_HCD) += host/
41 obj-$(CONFIG_USB_ISP116X_HCD) += host/
42 @@ -44,7 +46,6 @@ obj-$(CONFIG_USB_MICROTEK) += image/
43 obj-$(CONFIG_USB_SERIAL) += serial/
44
45 obj-$(CONFIG_USB) += misc/
46 -obj-$(CONFIG_USB_PHY) += phy/
47 obj-$(CONFIG_EARLY_PRINTK_DBGP) += early/
48
49 obj-$(CONFIG_USB_ATM) += atm/
50 diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
51 index f47f259..84d22ff 100644
52 --- a/drivers/usb/host/ehci-platform.c
53 +++ b/drivers/usb/host/ehci-platform.c
54 @@ -117,6 +117,15 @@ static int ehci_platform_probe(struct platform_device *dev)
55 hcd->rsrc_start = res_mem->start;
56 hcd->rsrc_len = resource_size(res_mem);
57
58 +#ifdef CONFIG_USB_OTG_UTILS
59 + hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
60 + if (!IS_ERR_OR_NULL(hcd->phy)) {
61 + otg_set_host(hcd->phy->otg,
62 + &hcd->self);
63 + usb_phy_init(hcd->phy);
64 + }
65 +#endif
66 +
67 hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
68 if (IS_ERR(hcd->regs)) {
69 err = PTR_ERR(hcd->regs);
70 @@ -154,6 +163,9 @@ static int ehci_platform_remove(struct platform_device *dev)
71 if (pdata == &ehci_platform_defaults)
72 dev->dev.platform_data = NULL;
73
74 + if (pdata == &ehci_platform_defaults)
75 + dev->dev.platform_data = NULL;
76 +
77 return 0;
78 }
79
80 @@ -198,9 +210,8 @@ static int ehci_platform_resume(struct device *dev)
81 #define ehci_platform_resume NULL
82 #endif /* CONFIG_PM */
83
84 -static const struct of_device_id vt8500_ehci_ids[] = {
85 - { .compatible = "via,vt8500-ehci", },
86 - { .compatible = "wm,prizm-ehci", },
87 +static const struct of_device_id ralink_ehci_ids[] = {
88 + { .compatible = "ralink,rt3xxx-ehci", },
89 {}
90 };
91
92 @@ -224,7 +235,7 @@ static struct platform_driver ehci_platform_driver = {
93 .owner = THIS_MODULE,
94 .name = "ehci-platform",
95 .pm = &ehci_platform_pm_ops,
96 - .of_match_table = of_match_ptr(vt8500_ehci_ids),
97 + .of_match_table = of_match_ptr(ralink_ehci_ids),
98 }
99 };
100
101 diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
102 index c3e7287..dd9bac6 100644
103 --- a/drivers/usb/host/ohci-platform.c
104 +++ b/drivers/usb/host/ohci-platform.c
105 @@ -16,6 +16,10 @@
106 #include <linux/err.h>
107 #include <linux/platform_device.h>
108 #include <linux/usb/ohci_pdriver.h>
109 +#include <linux/dma-mapping.h>
110 +#include <linux/of.h>
111 +
112 +static struct usb_ohci_pdata ohci_platform_defaults;
113
114 static int ohci_platform_reset(struct usb_hcd *hcd)
115 {
116 @@ -88,14 +92,22 @@ static int ohci_platform_probe(struct platform_device *dev)
117 {
118 struct usb_hcd *hcd;
119 struct resource *res_mem;
120 - struct usb_ohci_pdata *pdata = dev->dev.platform_data;
121 + struct usb_ohci_pdata *pdata;
122 int irq;
123 int err = -ENOMEM;
124
125 - if (!pdata) {
126 - WARN_ON(1);
127 - return -ENODEV;
128 - }
129 + /*
130 + * use reasonable defaults so platforms don't have to provide these.
131 + * with DT probing on ARM, none of these are set.
132 + */
133 + if (!dev->dev.platform_data)
134 + dev->dev.platform_data = &ohci_platform_defaults;
135 + if (!dev->dev.dma_mask)
136 + dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
137 + if (!dev->dev.coherent_dma_mask)
138 + dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
139 +
140 + pdata = dev->dev.platform_data;
141
142 if (usb_disabled())
143 return -ENODEV;
144 @@ -128,6 +140,12 @@ static int ohci_platform_probe(struct platform_device *dev)
145 hcd->rsrc_start = res_mem->start;
146 hcd->rsrc_len = resource_size(res_mem);
147
148 +#ifdef CONFIG_USB_OTG_UTILS
149 + hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
150 + if (!IS_ERR_OR_NULL(hcd->phy))
151 + usb_phy_init(hcd->phy);
152 +#endif
153 +
154 hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
155 if (IS_ERR(hcd->regs)) {
156 err = PTR_ERR(hcd->regs);
157 @@ -162,6 +180,9 @@ static int ohci_platform_remove(struct platform_device *dev)
158 if (pdata->power_off)
159 pdata->power_off(dev);
160
161 + if (pdata == &ohci_platform_defaults)
162 + dev->dev.platform_data = NULL;
163 +
164 return 0;
165 }
166
167 @@ -201,6 +222,11 @@ static int ohci_platform_resume(struct device *dev)
168 #define ohci_platform_resume NULL
169 #endif /* CONFIG_PM */
170
171 +static const struct of_device_id ralink_ohci_ids[] = {
172 + { .compatible = "ralink,rt3xxx-ohci", },
173 + {}
174 +};
175 +
176 static const struct platform_device_id ohci_platform_table[] = {
177 { "ohci-platform", 0 },
178 { }
179 @@ -221,5 +247,6 @@ static struct platform_driver ohci_platform_driver = {
180 .owner = THIS_MODULE,
181 .name = "ohci-platform",
182 .pm = &ohci_platform_pm_ops,
183 + .of_match_table = of_match_ptr(ralink_ohci_ids),
184 }
185 };
186 --
187 1.7.10.4
188