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/clk.h>
26 struct platform_device
*dwc3
;
32 static int __devinit
dwc3_exynos_probe(struct platform_device
*pdev
)
34 struct dwc3_exynos_data
*pdata
= pdev
->dev
.platform_data
;
35 struct platform_device
*dwc3
;
36 struct dwc3_exynos
*exynos
;
42 exynos
= kzalloc(sizeof(*exynos
), GFP_KERNEL
);
44 dev_err(&pdev
->dev
, "not enough memory\n");
48 platform_set_drvdata(pdev
, exynos
);
50 devid
= dwc3_get_device_id();
54 dwc3
= platform_device_alloc("dwc3", devid
);
56 dev_err(&pdev
->dev
, "couldn't allocate dwc3 device\n");
60 clk
= clk_get(&pdev
->dev
, "usbdrd30");
62 dev_err(&pdev
->dev
, "couldn't get clock\n");
67 dma_set_coherent_mask(&dwc3
->dev
, pdev
->dev
.coherent_dma_mask
);
69 dwc3
->dev
.parent
= &pdev
->dev
;
70 dwc3
->dev
.dma_mask
= pdev
->dev
.dma_mask
;
71 dwc3
->dev
.dma_parms
= pdev
->dev
.dma_parms
;
73 exynos
->dev
= &pdev
->dev
;
76 clk_enable(exynos
->clk
);
78 /* PHY initialization */
80 dev_dbg(&pdev
->dev
, "missing platform data\n");
83 pdata
->phy_init(pdev
, pdata
->phy_type
);
86 ret
= platform_device_add_resources(dwc3
, pdev
->resource
,
89 dev_err(&pdev
->dev
, "couldn't add resources to dwc3 device\n");
93 ret
= platform_device_add(dwc3
);
95 dev_err(&pdev
->dev
, "failed to register dwc3 device\n");
102 if (pdata
&& pdata
->phy_exit
)
103 pdata
->phy_exit(pdev
, pdata
->phy_type
);
108 platform_device_put(dwc3
);
110 dwc3_put_device_id(devid
);
117 static int __devexit
dwc3_exynos_remove(struct platform_device
*pdev
)
119 struct dwc3_exynos
*exynos
= platform_get_drvdata(pdev
);
120 struct dwc3_exynos_data
*pdata
= pdev
->dev
.platform_data
;
122 platform_device_unregister(exynos
->dwc3
);
124 dwc3_put_device_id(exynos
->dwc3
->id
);
126 if (pdata
&& pdata
->phy_exit
)
127 pdata
->phy_exit(pdev
, pdata
->phy_type
);
129 clk_disable(exynos
->clk
);
130 clk_put(exynos
->clk
);
137 static struct platform_driver dwc3_exynos_driver
= {
138 .probe
= dwc3_exynos_probe
,
139 .remove
= __devexit_p(dwc3_exynos_remove
),
141 .name
= "exynos-dwc3",
145 module_platform_driver(dwc3_exynos_driver
);
147 MODULE_ALIAS("platform:exynos-dwc3");
148 MODULE_AUTHOR("Anton Tikhomirov <av.tikhomirov@samsung.com>");
149 MODULE_LICENSE("GPL");
150 MODULE_DESCRIPTION("DesignWare USB3 EXYNOS Glue Layer");