blob: fac777c95609f130bc61c81b5f3c939a97902bcd [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
Pavankumar Kondeti33f82f32010-12-07 17:54:03 +05302 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
Pavankumar Kondeti33f82f32010-12-07 17:54:03 +053012 */
13
14#include <linux/module.h>
15#include <linux/platform_device.h>
Pavankumar Kondeti2d0cdcc2010-12-07 17:54:05 +053016#include <linux/pm_runtime.h>
Pavankumar Kondeti33f82f32010-12-07 17:54:03 +053017#include <linux/usb/msm_hsusb_hw.h>
18#include <linux/usb/ulpi.h>
19
20#include "ci13xxx_udc.c"
21
22#define MSM_USB_BASE (udc->regs)
23
24static irqreturn_t msm_udc_irq(int irq, void *data)
25{
26 return udc_irq();
27}
28
29static void ci13xxx_msm_notify_event(struct ci13xxx *udc, unsigned event)
30{
31 struct device *dev = udc->gadget.dev.parent;
Pavankumar Kondeti33f82f32010-12-07 17:54:03 +053032
33 switch (event) {
34 case CI13XXX_CONTROLLER_RESET_EVENT:
35 dev_dbg(dev, "CI13XXX_CONTROLLER_RESET_EVENT received\n");
36 writel(0, USB_AHBBURST);
37 writel(0, USB_AHBMODE);
38 break;
Pavankumar Kondeti33f82f32010-12-07 17:54:03 +053039 default:
40 dev_dbg(dev, "unknown ci13xxx_udc event\n");
41 break;
42 }
43}
44
45static struct ci13xxx_udc_driver ci13xxx_msm_udc_driver = {
46 .name = "ci13xxx_msm",
47 .flags = CI13XXX_REGS_SHARED |
48 CI13XXX_REQUIRE_TRANSCEIVER |
49 CI13XXX_PULLUP_ON_VBUS |
Vijayavardhan Vennapusad450cb02012-02-25 14:35:26 +053050 CI13XXX_ZERO_ITC |
51 CI13XXX_IS_OTG,
Pavankumar Kondeti33f82f32010-12-07 17:54:03 +053052
53 .notify_event = ci13xxx_msm_notify_event,
54};
55
56static int ci13xxx_msm_probe(struct platform_device *pdev)
57{
58 struct resource *res;
59 void __iomem *regs;
60 int irq;
61 int ret;
62
63 dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n");
64
65 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
66 if (!res) {
67 dev_err(&pdev->dev, "failed to get platform resource mem\n");
68 return -ENXIO;
69 }
70
71 regs = ioremap(res->start, resource_size(res));
72 if (!regs) {
73 dev_err(&pdev->dev, "ioremap failed\n");
74 return -ENOMEM;
75 }
76
77 ret = udc_probe(&ci13xxx_msm_udc_driver, &pdev->dev, regs);
78 if (ret < 0) {
79 dev_err(&pdev->dev, "udc_probe failed\n");
80 goto iounmap;
81 }
82
83 irq = platform_get_irq(pdev, 0);
84 if (irq < 0) {
85 dev_err(&pdev->dev, "IRQ not found\n");
86 ret = -ENXIO;
87 goto udc_remove;
88 }
89
90 ret = request_irq(irq, msm_udc_irq, IRQF_SHARED, pdev->name, pdev);
91 if (ret < 0) {
92 dev_err(&pdev->dev, "request_irq failed\n");
93 goto udc_remove;
94 }
95
Pavankumar Kondeti2d0cdcc2010-12-07 17:54:05 +053096 pm_runtime_no_callbacks(&pdev->dev);
97 pm_runtime_enable(&pdev->dev);
98
Pavankumar Kondeti33f82f32010-12-07 17:54:03 +053099 return 0;
100
101udc_remove:
102 udc_remove();
103iounmap:
104 iounmap(regs);
105
106 return ret;
107}
108
109static struct platform_driver ci13xxx_msm_driver = {
110 .probe = ci13xxx_msm_probe,
111 .driver = { .name = "msm_hsusb", },
112};
113
114static int __init ci13xxx_msm_init(void)
115{
116 return platform_driver_register(&ci13xxx_msm_driver);
117}
118module_init(ci13xxx_msm_init);