[omap]: switch the am335x-evmsk to the new wlcore bindings
[openwrt/svn-archive/archive.git] / target / linux / ramips / patches-3.10 / 0113-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 --- a/drivers/usb/Makefile
17 +++ b/drivers/usb/Makefile
18 @@ -10,6 +10,8 @@ obj-$(CONFIG_USB_DWC3) += dwc3/
19
20 obj-$(CONFIG_USB_MON) += mon/
21
22 +obj-$(CONFIG_USB_PHY) += phy/
23 +
24 obj-$(CONFIG_PCI) += host/
25 obj-$(CONFIG_USB_EHCI_HCD) += host/
26 obj-$(CONFIG_USB_ISP116X_HCD) += host/
27 @@ -44,7 +46,6 @@ obj-$(CONFIG_USB_MICROTEK) += image/
28 obj-$(CONFIG_USB_SERIAL) += serial/
29
30 obj-$(CONFIG_USB) += misc/
31 -obj-$(CONFIG_USB_PHY) += phy/
32 obj-$(CONFIG_EARLY_PRINTK_DBGP) += early/
33
34 obj-$(CONFIG_USB_ATM) += atm/
35 --- a/drivers/usb/host/ehci-platform.c
36 +++ b/drivers/usb/host/ehci-platform.c
37 @@ -29,6 +29,8 @@
38 #include <linux/usb.h>
39 #include <linux/usb/hcd.h>
40 #include <linux/usb/ehci_pdriver.h>
41 +#include <linux/usb/phy.h>
42 +#include <linux/usb/otg.h>
43
44 #include "ehci.h"
45
46 @@ -118,6 +120,15 @@ static int ehci_platform_probe(struct pl
47 hcd->rsrc_start = res_mem->start;
48 hcd->rsrc_len = resource_size(res_mem);
49
50 +#ifdef CONFIG_USB_PHY
51 + hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
52 + if (!IS_ERR_OR_NULL(hcd->phy)) {
53 + otg_set_host(hcd->phy->otg,
54 + &hcd->self);
55 + usb_phy_init(hcd->phy);
56 + }
57 +#endif
58 +
59 hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
60 if (IS_ERR(hcd->regs)) {
61 err = PTR_ERR(hcd->regs);
62 @@ -155,6 +166,9 @@ static int ehci_platform_remove(struct p
63 if (pdata == &ehci_platform_defaults)
64 dev->dev.platform_data = NULL;
65
66 + if (pdata == &ehci_platform_defaults)
67 + dev->dev.platform_data = NULL;
68 +
69 return 0;
70 }
71
72 @@ -199,9 +213,8 @@ static int ehci_platform_resume(struct d
73 #define ehci_platform_resume NULL
74 #endif /* CONFIG_PM */
75
76 -static const struct of_device_id vt8500_ehci_ids[] = {
77 - { .compatible = "via,vt8500-ehci", },
78 - { .compatible = "wm,prizm-ehci", },
79 +static const struct of_device_id ralink_ehci_ids[] = {
80 + { .compatible = "ralink,rt3xxx-ehci", },
81 {}
82 };
83
84 @@ -225,7 +238,7 @@ static struct platform_driver ehci_platf
85 .owner = THIS_MODULE,
86 .name = "ehci-platform",
87 .pm = &ehci_platform_pm_ops,
88 - .of_match_table = of_match_ptr(vt8500_ehci_ids),
89 + .of_match_table = of_match_ptr(ralink_ehci_ids),
90 }
91 };
92
93 --- a/drivers/usb/host/ohci-platform.c
94 +++ b/drivers/usb/host/ohci-platform.c
95 @@ -16,6 +16,10 @@
96 #include <linux/err.h>
97 #include <linux/platform_device.h>
98 #include <linux/usb/ohci_pdriver.h>
99 +#include <linux/dma-mapping.h>
100 +#include <linux/of.h>
101 +
102 +static struct usb_ohci_pdata ohci_platform_defaults;
103
104 static int ohci_platform_reset(struct usb_hcd *hcd)
105 {
106 @@ -88,14 +92,22 @@ static int ohci_platform_probe(struct pl
107 {
108 struct usb_hcd *hcd;
109 struct resource *res_mem;
110 - struct usb_ohci_pdata *pdata = dev->dev.platform_data;
111 + struct usb_ohci_pdata *pdata;
112 int irq;
113 int err = -ENOMEM;
114
115 - if (!pdata) {
116 - WARN_ON(1);
117 - return -ENODEV;
118 - }
119 + /*
120 + * use reasonable defaults so platforms don't have to provide these.
121 + * with DT probing on ARM, none of these are set.
122 + */
123 + if (!dev->dev.platform_data)
124 + dev->dev.platform_data = &ohci_platform_defaults;
125 + if (!dev->dev.dma_mask)
126 + dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
127 + if (!dev->dev.coherent_dma_mask)
128 + dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
129 +
130 + pdata = dev->dev.platform_data;
131
132 if (usb_disabled())
133 return -ENODEV;
134 @@ -128,6 +140,12 @@ static int ohci_platform_probe(struct pl
135 hcd->rsrc_start = res_mem->start;
136 hcd->rsrc_len = resource_size(res_mem);
137
138 +#ifdef CONFIG_USB_PHY
139 + hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
140 + if (!IS_ERR_OR_NULL(hcd->phy))
141 + usb_phy_init(hcd->phy);
142 +#endif
143 +
144 hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
145 if (IS_ERR(hcd->regs)) {
146 err = PTR_ERR(hcd->regs);
147 @@ -162,6 +180,9 @@ static int ohci_platform_remove(struct p
148 if (pdata->power_off)
149 pdata->power_off(dev);
150
151 + if (pdata == &ohci_platform_defaults)
152 + dev->dev.platform_data = NULL;
153 +
154 return 0;
155 }
156
157 @@ -201,6 +222,11 @@ static int ohci_platform_resume(struct d
158 #define ohci_platform_resume NULL
159 #endif /* CONFIG_PM */
160
161 +static const struct of_device_id ralink_ohci_ids[] = {
162 + { .compatible = "ralink,rt3xxx-ohci", },
163 + {}
164 +};
165 +
166 static const struct platform_device_id ohci_platform_table[] = {
167 { "ohci-platform", 0 },
168 { }
169 @@ -221,5 +247,6 @@ static struct platform_driver ohci_platf
170 .owner = THIS_MODULE,
171 .name = "ohci-platform",
172 .pm = &ohci_platform_pm_ops,
173 + .of_match_table = of_match_ptr(ralink_ohci_ids),
174 }
175 };