2
* Copyright (C) 2010 ST-Ericsson AB
3
* Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
#include <linux/module.h>
23
#include <linux/kernel.h>
24
#include <linux/init.h>
25
#include <linux/clk.h>
27
#include <linux/platform_device.h>
29
#include "musb_core.h"
33
struct platform_device *musb;
36
#define glue_to_musb(g) platform_get_drvdata(g->musb)
38
static int ux500_musb_init(struct musb *musb)
40
musb->xceiv = otg_get_transceiver();
42
pr_err("HS USB OTG: no transceiver configured\n");
49
static int ux500_musb_exit(struct musb *musb)
51
otg_put_transceiver(musb->xceiv);
56
static const struct musb_platform_ops ux500_ops = {
57
.init = ux500_musb_init,
58
.exit = ux500_musb_exit,
61
static int __init ux500_probe(struct platform_device *pdev)
63
struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
64
struct platform_device *musb;
65
struct ux500_glue *glue;
70
glue = kzalloc(sizeof(*glue), GFP_KERNEL);
72
dev_err(&pdev->dev, "failed to allocate glue context\n");
76
musb = platform_device_alloc("musb-hdrc", -1);
78
dev_err(&pdev->dev, "failed to allocate musb device\n");
82
clk = clk_get(&pdev->dev, "usb");
84
dev_err(&pdev->dev, "failed to get clock\n");
89
ret = clk_enable(clk);
91
dev_err(&pdev->dev, "failed to enable clock\n");
95
musb->dev.parent = &pdev->dev;
97
glue->dev = &pdev->dev;
101
pdata->platform_ops = &ux500_ops;
103
platform_set_drvdata(pdev, glue);
105
ret = platform_device_add_resources(musb, pdev->resource,
106
pdev->num_resources);
108
dev_err(&pdev->dev, "failed to add resources\n");
112
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
114
dev_err(&pdev->dev, "failed to add platform_data\n");
118
ret = platform_device_add(musb);
120
dev_err(&pdev->dev, "failed to register musb device\n");
133
platform_device_put(musb);
142
static int __exit ux500_remove(struct platform_device *pdev)
144
struct ux500_glue *glue = platform_get_drvdata(pdev);
146
platform_device_del(glue->musb);
147
platform_device_put(glue->musb);
148
clk_disable(glue->clk);
156
static int ux500_suspend(struct device *dev)
158
struct ux500_glue *glue = dev_get_drvdata(dev);
159
struct musb *musb = glue_to_musb(glue);
161
otg_set_suspend(musb->xceiv, 1);
162
clk_disable(glue->clk);
167
static int ux500_resume(struct device *dev)
169
struct ux500_glue *glue = dev_get_drvdata(dev);
170
struct musb *musb = glue_to_musb(glue);
173
ret = clk_enable(glue->clk);
175
dev_err(dev, "failed to enable clock\n");
179
otg_set_suspend(musb->xceiv, 0);
184
static const struct dev_pm_ops ux500_pm_ops = {
185
.suspend = ux500_suspend,
186
.resume = ux500_resume,
189
#define DEV_PM_OPS (&ux500_pm_ops)
191
#define DEV_PM_OPS NULL
194
static struct platform_driver ux500_driver = {
195
.remove = __exit_p(ux500_remove),
197
.name = "musb-ux500",
202
MODULE_DESCRIPTION("UX500 MUSB Glue Layer");
203
MODULE_AUTHOR("Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>");
204
MODULE_LICENSE("GPL v2");
206
static int __init ux500_init(void)
208
return platform_driver_probe(&ux500_driver, ux500_probe);
210
subsys_initcall(ux500_init);
212
static void __exit ux500_exit(void)
214
platform_driver_unregister(&ux500_driver);
216
module_exit(ux500_exit);