aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorStefan Roese <sr@denx.de>2012-04-15 23:38:08 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-18 16:55:01 -0400
commit56fafb94f64efaca625206a3876432b96558dcb0 (patch)
tree4c55810a1ce3a05edac9cee2fa27492becc348bd /drivers/usb
parent8b4fc8c7e0ba3022bb6187c809d8d2b955b2d7fd (diff)
USB: Add DT probing support to ehci-spear and ohci-spear
This patch adds support to configure the SPEAr EHCI & OHCI driver via device-tree instead of platform_data. Signed-off-by: Stefan Roese <sr@denx.de> Acked-by: Viresh Kumar <viresh.kumar@st.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/host/ehci-spear.c32
-rw-r--r--drivers/usb/host/ohci-spear.c32
2 files changed, 52 insertions, 12 deletions
diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c
index 6e928559169c..2e3c89a96650 100644
--- a/drivers/usb/host/ehci-spear.c
+++ b/drivers/usb/host/ehci-spear.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/clk.h> 14#include <linux/clk.h>
15#include <linux/jiffies.h> 15#include <linux/jiffies.h>
16#include <linux/of.h>
16#include <linux/platform_device.h> 17#include <linux/platform_device.h>
17#include <linux/pm.h> 18#include <linux/pm.h>
18 19
@@ -168,6 +169,8 @@ static int ehci_spear_drv_resume(struct device *dev)
168static SIMPLE_DEV_PM_OPS(ehci_spear_pm_ops, ehci_spear_drv_suspend, 169static SIMPLE_DEV_PM_OPS(ehci_spear_pm_ops, ehci_spear_drv_suspend,
169 ehci_spear_drv_resume); 170 ehci_spear_drv_resume);
170 171
172static u64 spear_ehci_dma_mask = DMA_BIT_MASK(32);
173
171static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) 174static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
172{ 175{
173 struct usb_hcd *hcd ; 176 struct usb_hcd *hcd ;
@@ -175,12 +178,9 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
175 struct resource *res; 178 struct resource *res;
176 struct clk *usbh_clk; 179 struct clk *usbh_clk;
177 const struct hc_driver *driver = &ehci_spear_hc_driver; 180 const struct hc_driver *driver = &ehci_spear_hc_driver;
178 int *pdata = pdev->dev.platform_data;
179 int irq, retval; 181 int irq, retval;
180 char clk_name[20] = "usbh_clk"; 182 char clk_name[20] = "usbh_clk";
181 183 static int instance = -1;
182 if (pdata == NULL)
183 return -EFAULT;
184 184
185 if (usb_disabled()) 185 if (usb_disabled())
186 return -ENODEV; 186 return -ENODEV;
@@ -191,8 +191,22 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
191 goto fail_irq_get; 191 goto fail_irq_get;
192 } 192 }
193 193
194 if (*pdata >= 0) 194 /*
195 sprintf(clk_name, "usbh.%01d_clk", *pdata); 195 * Right now device-tree probed devices don't get dma_mask set.
196 * Since shared usb code relies on it, set it here for now.
197 * Once we have dma capability bindings this can go away.
198 */
199 if (!pdev->dev.dma_mask)
200 pdev->dev.dma_mask = &spear_ehci_dma_mask;
201
202 /*
203 * Increment the device instance, when probing via device-tree
204 */
205 if (pdev->id < 0)
206 instance++;
207 else
208 instance = pdev->id;
209 sprintf(clk_name, "usbh.%01d_clk", instance);
196 210
197 usbh_clk = clk_get(NULL, clk_name); 211 usbh_clk = clk_get(NULL, clk_name);
198 if (IS_ERR(usbh_clk)) { 212 if (IS_ERR(usbh_clk)) {
@@ -277,6 +291,11 @@ static int spear_ehci_hcd_drv_remove(struct platform_device *pdev)
277 return 0; 291 return 0;
278} 292}
279 293
294static struct of_device_id spear_ehci_id_table[] __devinitdata = {
295 { .compatible = "st,spear600-ehci", },
296 { },
297};
298
280static struct platform_driver spear_ehci_hcd_driver = { 299static struct platform_driver spear_ehci_hcd_driver = {
281 .probe = spear_ehci_hcd_drv_probe, 300 .probe = spear_ehci_hcd_drv_probe,
282 .remove = spear_ehci_hcd_drv_remove, 301 .remove = spear_ehci_hcd_drv_remove,
@@ -285,6 +304,7 @@ static struct platform_driver spear_ehci_hcd_driver = {
285 .name = "spear-ehci", 304 .name = "spear-ehci",
286 .bus = &platform_bus_type, 305 .bus = &platform_bus_type,
287 .pm = &ehci_spear_pm_ops, 306 .pm = &ehci_spear_pm_ops,
307 .of_match_table = of_match_ptr(spear_ehci_id_table),
288 } 308 }
289}; 309};
290 310
diff --git a/drivers/usb/host/ohci-spear.c b/drivers/usb/host/ohci-spear.c
index 95c16489e883..eb4640b1e402 100644
--- a/drivers/usb/host/ohci-spear.c
+++ b/drivers/usb/host/ohci-spear.c
@@ -14,6 +14,7 @@
14#include <linux/signal.h> 14#include <linux/signal.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/clk.h> 16#include <linux/clk.h>
17#include <linux/of.h>
17 18
18struct spear_ohci { 19struct spear_ohci {
19 struct ohci_hcd ohci; 20 struct ohci_hcd ohci;
@@ -90,6 +91,8 @@ static const struct hc_driver ohci_spear_hc_driver = {
90 .start_port_reset = ohci_start_port_reset, 91 .start_port_reset = ohci_start_port_reset,
91}; 92};
92 93
94static u64 spear_ohci_dma_mask = DMA_BIT_MASK(32);
95
93static int spear_ohci_hcd_drv_probe(struct platform_device *pdev) 96static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
94{ 97{
95 const struct hc_driver *driver = &ohci_spear_hc_driver; 98 const struct hc_driver *driver = &ohci_spear_hc_driver;
@@ -98,11 +101,8 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
98 struct spear_ohci *ohci_p; 101 struct spear_ohci *ohci_p;
99 struct resource *res; 102 struct resource *res;
100 int retval, irq; 103 int retval, irq;
101 int *pdata = pdev->dev.platform_data;
102 char clk_name[20] = "usbh_clk"; 104 char clk_name[20] = "usbh_clk";
103 105 static int instance = -1;
104 if (pdata == NULL)
105 return -EFAULT;
106 106
107 irq = platform_get_irq(pdev, 0); 107 irq = platform_get_irq(pdev, 0);
108 if (irq < 0) { 108 if (irq < 0) {
@@ -110,8 +110,22 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
110 goto fail_irq_get; 110 goto fail_irq_get;
111 } 111 }
112 112
113 if (*pdata >= 0) 113 /*
114 sprintf(clk_name, "usbh.%01d_clk", *pdata); 114 * Right now device-tree probed devices don't get dma_mask set.
115 * Since shared usb code relies on it, set it here for now.
116 * Once we have dma capability bindings this can go away.
117 */
118 if (!pdev->dev.dma_mask)
119 pdev->dev.dma_mask = &spear_ohci_dma_mask;
120
121 /*
122 * Increment the device instance, when probing via device-tree
123 */
124 if (pdev->id < 0)
125 instance++;
126 else
127 instance = pdev->id;
128 sprintf(clk_name, "usbh.%01d_clk", instance);
115 129
116 usbh_clk = clk_get(NULL, clk_name); 130 usbh_clk = clk_get(NULL, clk_name);
117 if (IS_ERR(usbh_clk)) { 131 if (IS_ERR(usbh_clk)) {
@@ -222,6 +236,11 @@ static int spear_ohci_hcd_drv_resume(struct platform_device *dev)
222} 236}
223#endif 237#endif
224 238
239static struct of_device_id spear_ohci_id_table[] __devinitdata = {
240 { .compatible = "st,spear600-ohci", },
241 { },
242};
243
225/* Driver definition to register with the platform bus */ 244/* Driver definition to register with the platform bus */
226static struct platform_driver spear_ohci_hcd_driver = { 245static struct platform_driver spear_ohci_hcd_driver = {
227 .probe = spear_ohci_hcd_drv_probe, 246 .probe = spear_ohci_hcd_drv_probe,
@@ -233,6 +252,7 @@ static struct platform_driver spear_ohci_hcd_driver = {
233 .driver = { 252 .driver = {
234 .owner = THIS_MODULE, 253 .owner = THIS_MODULE,
235 .name = "spear-ohci", 254 .name = "spear-ohci",
255 .of_match_table = of_match_ptr(spear_ohci_id_table),
236 }, 256 },
237}; 257};
238 258