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
6 based on f3bc64d6d1f21c1b92d75f233a37b75d77af6963
8 Signed-off-by: John Crispin <blogic@openwrt.org>
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(-)
16 Index: linux-3.10.1/arch/mips/ralink/Kconfig
17 ===================================================================
18 --- linux-3.10.1.orig/arch/mips/ralink/Kconfig 2013-07-15 17:35:28.021178556 +0200
19 +++ linux-3.10.1/arch/mips/ralink/Kconfig 2013-07-15 20:00:19.501385660 +0200
24 + select USB_ARCH_HAS_OHCI
25 + select USB_ARCH_HAS_EHCI
29 Index: linux-3.10.1/drivers/usb/Makefile
30 ===================================================================
31 --- linux-3.10.1.orig/drivers/usb/Makefile 2013-07-13 20:42:41.000000000 +0200
32 +++ linux-3.10.1/drivers/usb/Makefile 2013-07-15 19:47:26.725367249 +0200
35 obj-$(CONFIG_USB_MON) += mon/
37 +obj-$(CONFIG_USB_PHY) += phy/
39 obj-$(CONFIG_PCI) += host/
40 obj-$(CONFIG_USB_EHCI_HCD) += host/
41 obj-$(CONFIG_USB_ISP116X_HCD) += host/
43 obj-$(CONFIG_USB_SERIAL) += serial/
45 obj-$(CONFIG_USB) += misc/
46 -obj-$(CONFIG_USB_PHY) += phy/
47 obj-$(CONFIG_EARLY_PRINTK_DBGP) += early/
49 obj-$(CONFIG_USB_ATM) += atm/
50 Index: linux-3.10.1/drivers/usb/host/ehci-platform.c
51 ===================================================================
52 --- linux-3.10.1.orig/drivers/usb/host/ehci-platform.c 2013-07-15 17:35:22.761178428 +0200
53 +++ linux-3.10.1/drivers/usb/host/ehci-platform.c 2013-07-15 19:47:14.525366961 +0200
55 #include <linux/usb.h>
56 #include <linux/usb/hcd.h>
57 #include <linux/usb/ehci_pdriver.h>
58 +#include <linux/usb/phy.h>
59 +#include <linux/usb/otg.h>
64 hcd->rsrc_start = res_mem->start;
65 hcd->rsrc_len = resource_size(res_mem);
67 +#ifdef CONFIG_USB_PHY
68 + hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
69 + if (!IS_ERR_OR_NULL(hcd->phy)) {
70 + otg_set_host(hcd->phy->otg,
72 + usb_phy_init(hcd->phy);
76 hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
77 if (IS_ERR(hcd->regs)) {
78 err = PTR_ERR(hcd->regs);
80 if (pdata == &ehci_platform_defaults)
81 dev->dev.platform_data = NULL;
83 + if (pdata == &ehci_platform_defaults)
84 + dev->dev.platform_data = NULL;
90 #define ehci_platform_resume NULL
91 #endif /* CONFIG_PM */
93 -static const struct of_device_id vt8500_ehci_ids[] = {
94 - { .compatible = "via,vt8500-ehci", },
95 - { .compatible = "wm,prizm-ehci", },
96 +static const struct of_device_id ralink_ehci_ids[] = {
97 + { .compatible = "ralink,rt3xxx-ehci", },
102 .owner = THIS_MODULE,
103 .name = "ehci-platform",
104 .pm = &ehci_platform_pm_ops,
105 - .of_match_table = of_match_ptr(vt8500_ehci_ids),
106 + .of_match_table = of_match_ptr(ralink_ehci_ids),
110 Index: linux-3.10.1/drivers/usb/host/ohci-platform.c
111 ===================================================================
112 --- linux-3.10.1.orig/drivers/usb/host/ohci-platform.c 2013-07-13 20:42:41.000000000 +0200
113 +++ linux-3.10.1/drivers/usb/host/ohci-platform.c 2013-07-15 19:55:15.913378428 +0200
115 #include <linux/err.h>
116 #include <linux/platform_device.h>
117 #include <linux/usb/ohci_pdriver.h>
118 +#include <linux/dma-mapping.h>
119 +#include <linux/of.h>
121 +static struct usb_ohci_pdata ohci_platform_defaults;
123 static int ohci_platform_reset(struct usb_hcd *hcd)
128 struct resource *res_mem;
129 - struct usb_ohci_pdata *pdata = dev->dev.platform_data;
130 + struct usb_ohci_pdata *pdata;
139 + * use reasonable defaults so platforms don't have to provide these.
140 + * with DT probing on ARM, none of these are set.
142 + if (!dev->dev.platform_data)
143 + dev->dev.platform_data = &ohci_platform_defaults;
144 + if (!dev->dev.dma_mask)
145 + dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
146 + if (!dev->dev.coherent_dma_mask)
147 + dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
149 + pdata = dev->dev.platform_data;
154 hcd->rsrc_start = res_mem->start;
155 hcd->rsrc_len = resource_size(res_mem);
157 +#ifdef CONFIG_USB_PHY
158 + hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
159 + if (!IS_ERR_OR_NULL(hcd->phy))
160 + usb_phy_init(hcd->phy);
163 hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
164 if (IS_ERR(hcd->regs)) {
165 err = PTR_ERR(hcd->regs);
167 if (pdata->power_off)
168 pdata->power_off(dev);
170 + if (pdata == &ohci_platform_defaults)
171 + dev->dev.platform_data = NULL;
177 #define ohci_platform_resume NULL
178 #endif /* CONFIG_PM */
180 +static const struct of_device_id ralink_ohci_ids[] = {
181 + { .compatible = "ralink,rt3xxx-ohci", },
185 static const struct platform_device_id ohci_platform_table[] = {
186 { "ohci-platform", 0 },
189 .owner = THIS_MODULE,
190 .name = "ohci-platform",
191 .pm = &ohci_platform_pm_ops,
192 + .of_match_table = of_match_ptr(ralink_ohci_ids),