1 From 08d438b69f3023f16b044b07eebee6b9c2302f60 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 120/133] USB: add OHCI/EHCI OF binding
6 based on f3bc64d6d1f21c1b92d75f233a37b75d77af6963
8 Signed-off-by: John Crispin <blogic@openwrt.org>
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, 51 insertions(+), 10 deletions(-)
15 --- a/drivers/usb/Makefile
16 +++ b/drivers/usb/Makefile
17 @@ -10,6 +10,8 @@ obj-$(CONFIG_USB_DWC3) += dwc3/
19 obj-$(CONFIG_USB_MON) += mon/
21 +obj-$(CONFIG_USB_PHY) += phy/
23 obj-$(CONFIG_PCI) += host/
24 obj-$(CONFIG_USB_EHCI_HCD) += host/
25 obj-$(CONFIG_USB_ISP116X_HCD) += host/
26 @@ -44,7 +46,6 @@ obj-$(CONFIG_USB_MICROTEK) += image/
27 obj-$(CONFIG_USB_SERIAL) += serial/
29 obj-$(CONFIG_USB) += misc/
30 -obj-$(CONFIG_USB_PHY) += phy/
31 obj-$(CONFIG_EARLY_PRINTK_DBGP) += early/
33 obj-$(CONFIG_USB_ATM) += atm/
34 --- a/drivers/usb/host/ehci-platform.c
35 +++ b/drivers/usb/host/ehci-platform.c
37 #include <linux/usb.h>
38 #include <linux/usb/hcd.h>
39 #include <linux/usb/ehci_pdriver.h>
40 +#include <linux/usb/phy.h>
41 +#include <linux/usb/otg.h>
45 @@ -118,6 +120,15 @@ static int ehci_platform_probe(struct pl
46 hcd->rsrc_start = res_mem->start;
47 hcd->rsrc_len = resource_size(res_mem);
49 +#ifdef CONFIG_USB_PHY
50 + hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
51 + if (!IS_ERR_OR_NULL(hcd->phy)) {
52 + otg_set_host(hcd->phy->otg,
54 + usb_phy_init(hcd->phy);
58 hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
59 if (IS_ERR(hcd->regs)) {
60 err = PTR_ERR(hcd->regs);
61 @@ -155,6 +166,9 @@ static int ehci_platform_remove(struct p
62 if (pdata == &ehci_platform_defaults)
63 dev->dev.platform_data = NULL;
65 + if (pdata == &ehci_platform_defaults)
66 + dev->dev.platform_data = NULL;
71 @@ -199,9 +213,8 @@ static int ehci_platform_resume(struct d
72 #define ehci_platform_resume NULL
73 #endif /* CONFIG_PM */
75 -static const struct of_device_id vt8500_ehci_ids[] = {
76 - { .compatible = "via,vt8500-ehci", },
77 - { .compatible = "wm,prizm-ehci", },
78 +static const struct of_device_id ralink_ehci_ids[] = {
79 + { .compatible = "ralink,rt3xxx-ehci", },
83 @@ -225,7 +238,7 @@ static struct platform_driver ehci_platf
85 .name = "ehci-platform",
86 .pm = &ehci_platform_pm_ops,
87 - .of_match_table = of_match_ptr(vt8500_ehci_ids),
88 + .of_match_table = of_match_ptr(ralink_ehci_ids),
92 --- a/drivers/usb/host/ohci-platform.c
93 +++ b/drivers/usb/host/ohci-platform.c
95 #include <linux/err.h>
96 #include <linux/platform_device.h>
97 #include <linux/usb/ohci_pdriver.h>
98 +#include <linux/dma-mapping.h>
99 +#include <linux/of.h>
101 +static struct usb_ohci_pdata ohci_platform_defaults;
103 static int ohci_platform_reset(struct usb_hcd *hcd)
105 @@ -88,14 +92,22 @@ static int ohci_platform_probe(struct pl
108 struct resource *res_mem;
109 - struct usb_ohci_pdata *pdata = dev->dev.platform_data;
110 + struct usb_ohci_pdata *pdata;
119 + * use reasonable defaults so platforms don't have to provide these.
120 + * with DT probing on ARM, none of these are set.
122 + if (!dev->dev.platform_data)
123 + dev->dev.platform_data = &ohci_platform_defaults;
124 + if (!dev->dev.dma_mask)
125 + dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
126 + if (!dev->dev.coherent_dma_mask)
127 + dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
129 + pdata = dev->dev.platform_data;
133 @@ -128,6 +140,12 @@ static int ohci_platform_probe(struct pl
134 hcd->rsrc_start = res_mem->start;
135 hcd->rsrc_len = resource_size(res_mem);
137 +#ifdef CONFIG_USB_PHY
138 + hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
139 + if (!IS_ERR_OR_NULL(hcd->phy))
140 + usb_phy_init(hcd->phy);
143 hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
144 if (IS_ERR(hcd->regs)) {
145 err = PTR_ERR(hcd->regs);
146 @@ -162,6 +180,9 @@ static int ohci_platform_remove(struct p
147 if (pdata->power_off)
148 pdata->power_off(dev);
150 + if (pdata == &ohci_platform_defaults)
151 + dev->dev.platform_data = NULL;
156 @@ -201,6 +222,11 @@ static int ohci_platform_resume(struct d
157 #define ohci_platform_resume NULL
158 #endif /* CONFIG_PM */
160 +static const struct of_device_id ralink_ohci_ids[] = {
161 + { .compatible = "ralink,rt3xxx-ohci", },
165 static const struct platform_device_id ohci_platform_table[] = {
166 { "ohci-platform", 0 },
168 @@ -221,5 +247,6 @@ static struct platform_driver ohci_platf
169 .owner = THIS_MODULE,
170 .name = "ohci-platform",
171 .pm = &ohci_platform_pm_ops,
172 + .of_match_table = of_match_ptr(ralink_ohci_ids),