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
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, 50 insertions(+), 11 deletions(-)
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
21 obj-$(CONFIG_USB_MON) += mon/
23 +obj-$(CONFIG_USB_PHY) += phy/
25 obj-$(CONFIG_PCI) += host/
26 obj-$(CONFIG_USB_EHCI_HCD) += host/
27 obj-$(CONFIG_USB_ISP116X_HCD) += host/
29 obj-$(CONFIG_USB_STORAGE) += storage/
30 obj-$(CONFIG_USB) += storage/
32 -obj-$(CONFIG_USB_MDC800) += image/
33 obj-$(CONFIG_USB_MICROTEK) += image/
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
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>
50 hcd->rsrc_start = res_mem->start;
51 hcd->rsrc_len = resource_size(res_mem);
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,
58 + usb_phy_init(hcd->phy);
62 hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
63 if (IS_ERR(hcd->regs)) {
64 err = PTR_ERR(hcd->regs);
66 if (pdata == &ehci_platform_defaults)
67 dev->dev.platform_data = NULL;
69 + if (pdata == &ehci_platform_defaults)
70 + dev->dev.platform_data = NULL;
76 #define ehci_platform_resume NULL
77 #endif /* CONFIG_PM */
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", },
89 .name = "ehci-platform",
90 .pm = &ehci_platform_pm_ops,
91 - .of_match_table = vt8500_ehci_ids,
92 + .of_match_table = ralink_ehci_ids,
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
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>
111 #define DRIVER_DESC "OHCI generic platform driver"
113 +static struct usb_ohci_pdata ohci_platform_defaults;
114 static const char hcd_name[] = "ohci-platform";
116 static int ohci_platform_reset(struct usb_hcd *hcd)
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);
123 if (pdata->big_endian_desc)
133 + * use reasonable defaults so platforms don't have to provide these.
134 + * with DT probing on ARM, none of these are set.
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);
143 + pdata = dev->dev.platform_data;
148 hcd->rsrc_start = res_mem->start;
149 hcd->rsrc_len = resource_size(res_mem);
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);
157 hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
158 if (IS_ERR(hcd->regs)) {
159 err = PTR_ERR(hcd->regs);
161 if (pdata->power_off)
162 pdata->power_off(dev);
164 + if (pdata == &ohci_platform_defaults)
165 + dev->dev.platform_data = NULL;
171 #define ohci_platform_resume NULL
172 #endif /* CONFIG_PM */
174 +static const struct of_device_id ralink_ohci_ids[] = {
175 + { .compatible = "ralink,rt3xxx-ohci", },
179 static const struct platform_device_id ohci_platform_table[] = {
180 { "ohci-platform", 0 },
183 .owner = THIS_MODULE,
184 .name = "ohci-platform",
185 .pm = &ohci_platform_pm_ops,
186 + .of_match_table = of_match_ptr(ralink_ohci_ids),