2 * dwc3-exynos.c - Samsung EXYNOS DWC3 Specific Glue layer
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com
7 * Author: Anton Tikhomirov <av.tikhomirov@samsung.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
15 #include <linux/module.h>
16 #include <linux/kernel.h>
17 #include <linux/slab.h>
18 #include <linux/platform_device.h>
19 #include <linux/platform_data/dwc3-exynos.h>
20 #include <linux/dma-mapping.h>
21 #include <linux/module.h>
22 #include <linux/clk.h>
27 struct platform_device *dwc3;
33 static int __devinit dwc3_exynos_probe(struct platform_device *pdev)
35 struct dwc3_exynos_data *pdata = pdev->dev.platform_data;
36 struct platform_device *dwc3;
37 struct dwc3_exynos *exynos;
43 exynos = kzalloc(sizeof(*exynos), GFP_KERNEL);
45 dev_err(&pdev->dev, "not enough memory\n");
49 platform_set_drvdata(pdev, exynos);
51 devid = dwc3_get_device_id();
55 dwc3 = platform_device_alloc("dwc3", devid);
57 dev_err(&pdev->dev, "couldn't allocate dwc3 device\n");
61 clk = clk_get(&pdev->dev, "usbdrd30");
63 dev_err(&pdev->dev, "couldn't get clock\n");
68 dma_set_coherent_mask(&dwc3->dev, pdev->dev.coherent_dma_mask);
70 dwc3->dev.parent = &pdev->dev;
71 dwc3->dev.dma_mask = pdev->dev.dma_mask;
72 dwc3->dev.dma_parms = pdev->dev.dma_parms;
74 exynos->dev = &pdev->dev;
77 clk_enable(exynos->clk);
79 /* PHY initialization */
81 dev_dbg(&pdev->dev, "missing platform data\n");
84 pdata->phy_init(pdev, pdata->phy_type);
87 ret = platform_device_add_resources(dwc3, pdev->resource,
90 dev_err(&pdev->dev, "couldn't add resources to dwc3 device\n");
94 ret = platform_device_add(dwc3);
96 dev_err(&pdev->dev, "failed to register dwc3 device\n");
103 if (pdata && pdata->phy_exit)
104 pdata->phy_exit(pdev, pdata->phy_type);
109 platform_device_put(dwc3);
111 dwc3_put_device_id(devid);
118 static int __devexit dwc3_exynos_remove(struct platform_device *pdev)
120 struct dwc3_exynos *exynos = platform_get_drvdata(pdev);
121 struct dwc3_exynos_data *pdata = pdev->dev.platform_data;
123 platform_device_unregister(exynos->dwc3);
125 dwc3_put_device_id(exynos->dwc3->id);
127 if (pdata && pdata->phy_exit)
128 pdata->phy_exit(pdev, pdata->phy_type);
130 clk_disable(exynos->clk);
131 clk_put(exynos->clk);
138 static struct platform_driver dwc3_exynos_driver = {
139 .probe = dwc3_exynos_probe,
140 .remove = __devexit_p(dwc3_exynos_remove),
142 .name = "exynos-dwc3",
146 module_platform_driver(dwc3_exynos_driver);
148 MODULE_ALIAS("platform:exynos-dwc3");
149 MODULE_AUTHOR("Anton Tikhomirov <av.tikhomirov@samsung.com>");
150 MODULE_LICENSE("GPL");
151 MODULE_DESCRIPTION("DesignWare USB3 EXYNOS Glue Layer");