tools: install a fake empty ldconfig script to prevent the system ldconfig from messi...
[openwrt.git] / target / linux / ramips / patches-3.10 / 0120-USB-add-OHCI-EHCI-OF-binding.patch
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
5
6 based on f3bc64d6d1f21c1b92d75f233a37b75d77af6963
7
8 Signed-off-by: John Crispin <blogic@openwrt.org>
9 ---
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(-)
14
15 --- a/drivers/usb/Makefile
16 +++ b/drivers/usb/Makefile
17 @@ -10,6 +10,8 @@ obj-$(CONFIG_USB_DWC3)                += dwc3/
18  
19  obj-$(CONFIG_USB_MON)          += mon/
20  
21 +obj-$(CONFIG_USB_PHY)          += phy/
22 +
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/
28  
29  obj-$(CONFIG_USB)              += misc/
30 -obj-$(CONFIG_USB_PHY)          += phy/
31  obj-$(CONFIG_EARLY_PRINTK_DBGP)        += early/
32  
33  obj-$(CONFIG_USB_ATM)          += atm/
34 --- a/drivers/usb/host/ehci-platform.c
35 +++ b/drivers/usb/host/ehci-platform.c
36 @@ -29,6 +29,8 @@
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>
42  
43  #include "ehci.h"
44  
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);
48  
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,
53 +                               &hcd->self);
54 +               usb_phy_init(hcd->phy);
55 +       }
56 +#endif
57 +
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;
64  
65 +       if (pdata == &ehci_platform_defaults)
66 +               dev->dev.platform_data = NULL;
67 +
68         return 0;
69  }
70  
71 @@ -199,9 +213,8 @@ static int ehci_platform_resume(struct d
72  #define ehci_platform_resume   NULL
73  #endif /* CONFIG_PM */
74  
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", },
80         {}
81  };
82  
83 @@ -225,7 +238,7 @@ static struct platform_driver ehci_platf
84                 .owner  = THIS_MODULE,
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),
89         }
90  };
91  
92 --- a/drivers/usb/host/ohci-platform.c
93 +++ b/drivers/usb/host/ohci-platform.c
94 @@ -16,6 +16,10 @@
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>
100 +
101 +static struct usb_ohci_pdata ohci_platform_defaults;
102  
103  static int ohci_platform_reset(struct usb_hcd *hcd)
104  {
105 @@ -88,14 +92,22 @@ static int ohci_platform_probe(struct pl
106  {
107         struct usb_hcd *hcd;
108         struct resource *res_mem;
109 -       struct usb_ohci_pdata *pdata = dev->dev.platform_data;
110 +       struct usb_ohci_pdata *pdata;
111         int irq;
112         int err = -ENOMEM;
113  
114 -       if (!pdata) {
115 -               WARN_ON(1);
116 -               return -ENODEV;
117 -       }
118 +       /*
119 +        * use reasonable defaults so platforms don't have to provide these.
120 +        * with DT probing on ARM, none of these are set.
121 +        */
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);
128 +
129 +       pdata = dev->dev.platform_data;
130  
131         if (usb_disabled())
132                 return -ENODEV;
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);
136  
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);
141 +#endif
142 +
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);
149  
150 +       if (pdata == &ohci_platform_defaults)
151 +               dev->dev.platform_data = NULL;
152 +
153         return 0;
154  }
155  
156 @@ -201,6 +222,11 @@ static int ohci_platform_resume(struct d
157  #define ohci_platform_resume   NULL
158  #endif /* CONFIG_PM */
159  
160 +static const struct of_device_id ralink_ohci_ids[] = {
161 +       { .compatible = "ralink,rt3xxx-ohci", },
162 +       {}
163 +};
164 +
165  static const struct platform_device_id ohci_platform_table[] = {
166         { "ohci-platform", 0 },
167         { }
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),
173         }
174  };