diff options
author | Stefan Roese <sr@denx.de> | 2012-04-15 23:38:08 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-04-18 16:55:01 -0400 |
commit | 56fafb94f64efaca625206a3876432b96558dcb0 (patch) | |
tree | 4c55810a1ce3a05edac9cee2fa27492becc348bd /drivers/usb/host/ehci-spear.c | |
parent | 8b4fc8c7e0ba3022bb6187c809d8d2b955b2d7fd (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/host/ehci-spear.c')
-rw-r--r-- | drivers/usb/host/ehci-spear.c | 32 |
1 files changed, 26 insertions, 6 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) | |||
168 | static SIMPLE_DEV_PM_OPS(ehci_spear_pm_ops, ehci_spear_drv_suspend, | 169 | static SIMPLE_DEV_PM_OPS(ehci_spear_pm_ops, ehci_spear_drv_suspend, |
169 | ehci_spear_drv_resume); | 170 | ehci_spear_drv_resume); |
170 | 171 | ||
172 | static u64 spear_ehci_dma_mask = DMA_BIT_MASK(32); | ||
173 | |||
171 | static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) | 174 | static 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 | ||
294 | static struct of_device_id spear_ehci_id_table[] __devinitdata = { | ||
295 | { .compatible = "st,spear600-ehci", }, | ||
296 | { }, | ||
297 | }; | ||
298 | |||
280 | static struct platform_driver spear_ehci_hcd_driver = { | 299 | static 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 | ||