summaryrefslogtreecommitdiff
path: root/drivers/usb/musb/am35x.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2010-12-02 09:06:51 +0200
committerFelipe Balbi <balbi@ti.com>2010-12-10 10:21:13 +0200
commitce40c5767a0ea1e77ca5d0b73269cb86301a35cf (patch)
treea57a74a1a12596f50df2e3ecbe70f5d5253a03cf /drivers/usb/musb/am35x.c
parentdc09886bfa781e2b442301116c18199519e36f0f (diff)
usb: musb: split am35x to its own platform_driver
Just adding its own platform_driver, not really using it yet. When all HW glue layers are converted, more patches will come to split power management code from musb_core and move it completely to HW glue layer. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb/am35x.c')
-rw-r--r--drivers/usb/musb/am35x.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index be17610d7fc2..0ae01f57b3df 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -29,6 +29,8 @@
#include <linux/init.h>
#include <linux/clk.h>
#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
#include <plat/control.h>
#include <plat/usb.h>
@@ -535,3 +537,85 @@ const struct musb_platform_ops musb_ops = {
.set_vbus = am35x_musb_set_vbus,
};
+
+static u64 am35x_dmamask = DMA_BIT_MASK(32);
+
+static int __init am35x_probe(struct platform_device *pdev)
+{
+ struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
+ struct platform_device *musb;
+
+ int ret = -ENOMEM;
+
+ musb = platform_device_alloc("musb-hdrc", -1);
+ if (!musb) {
+ dev_err(&pdev->dev, "failed to allocate musb device\n");
+ goto err0;
+ }
+
+ musb->dev.parent = &pdev->dev;
+ musb->dev.dma_mask = &am35x_dmamask;
+ musb->dev.coherent_dma_mask = am35x_dmamask;
+
+ platform_set_drvdata(pdev, musb);
+
+ ret = platform_device_add_resources(musb, pdev->resource,
+ pdev->num_resources);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to add resources\n");
+ goto err1;
+ }
+
+ ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
+ if (ret) {
+ dev_err(&pdev->dev, "failed to add platform_data\n");
+ goto err1;
+ }
+
+ ret = platform_device_add(musb);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to register musb device\n");
+ goto err1;
+ }
+
+ return 0;
+
+err1:
+ platform_device_put(musb);
+
+err0:
+ return ret;
+}
+
+static int __exit am35x_remove(struct platform_device *pdev)
+{
+ struct platform_device *musb = platform_get_drvdata(pdev);
+
+ platform_device_del(musb);
+ platform_device_put(musb);
+
+ return 0;
+}
+
+static struct platform_driver am35x_driver = {
+ .remove = __exit_p(am35x_remove),
+ .driver = {
+ .name = "musb-am35x",
+ },
+};
+
+MODULE_DESCRIPTION("AM35x MUSB Glue Layer");
+MODULE_AUTHOR("Ajay Kumar Gupta <ajay.gupta@ti.com>");
+MODULE_LICENSE("GPL v2");
+
+static int __init am35x_init(void)
+{
+ return platform_driver_probe(&am35x_driver, am35x_probe);
+}
+subsys_initcall(am35x_init);
+
+static void __exit am35x_exit(void)
+{
+ platform_driver_unregister(&am35x_driver);
+}
+module_exit(am35x_exit);