1 /* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
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.
8 #include <linux/module.h>
9 #include <linux/platform_device.h>
10 #include <linux/pm_runtime.h>
11 #include <linux/usb/msm_hsusb_hw.h>
12 #include <linux/usb/ulpi.h>
14 #include "ci13xxx_udc.c"
16 #define MSM_USB_BASE (udc->regs)
18 static irqreturn_t
msm_udc_irq(int irq
, void *data
)
23 static void ci13xxx_msm_notify_event(struct ci13xxx
*udc
, unsigned event
)
25 struct device
*dev
= udc
->gadget
.dev
.parent
;
29 case CI13XXX_CONTROLLER_RESET_EVENT
:
30 dev_dbg(dev
, "CI13XXX_CONTROLLER_RESET_EVENT received\n");
31 writel(0, USB_AHBBURST
);
32 writel(0, USB_AHBMODE
);
34 case CI13XXX_CONTROLLER_STOPPED_EVENT
:
35 dev_dbg(dev
, "CI13XXX_CONTROLLER_STOPPED_EVENT received\n");
37 * Put the transceiver in non-driving mode. Otherwise host
38 * may not detect soft-disconnection.
40 val
= otg_io_read(udc
->transceiver
, ULPI_FUNC_CTRL
);
41 val
&= ~ULPI_FUNC_CTRL_OPMODE_MASK
;
42 val
|= ULPI_FUNC_CTRL_OPMODE_NONDRIVING
;
43 otg_io_write(udc
->transceiver
, val
, ULPI_FUNC_CTRL
);
46 dev_dbg(dev
, "unknown ci13xxx_udc event\n");
51 static struct ci13xxx_udc_driver ci13xxx_msm_udc_driver
= {
52 .name
= "ci13xxx_msm",
53 .flags
= CI13XXX_REGS_SHARED
|
54 CI13XXX_REQUIRE_TRANSCEIVER
|
55 CI13XXX_PULLUP_ON_VBUS
|
56 CI13XXX_DISABLE_STREAMING
,
58 .notify_event
= ci13xxx_msm_notify_event
,
61 static int ci13xxx_msm_probe(struct platform_device
*pdev
)
68 dev_dbg(&pdev
->dev
, "ci13xxx_msm_probe\n");
70 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
72 dev_err(&pdev
->dev
, "failed to get platform resource mem\n");
76 regs
= ioremap(res
->start
, resource_size(res
));
78 dev_err(&pdev
->dev
, "ioremap failed\n");
82 ret
= udc_probe(&ci13xxx_msm_udc_driver
, &pdev
->dev
, regs
);
84 dev_err(&pdev
->dev
, "udc_probe failed\n");
88 irq
= platform_get_irq(pdev
, 0);
90 dev_err(&pdev
->dev
, "IRQ not found\n");
95 ret
= request_irq(irq
, msm_udc_irq
, IRQF_SHARED
, pdev
->name
, pdev
);
97 dev_err(&pdev
->dev
, "request_irq failed\n");
101 pm_runtime_no_callbacks(&pdev
->dev
);
102 pm_runtime_enable(&pdev
->dev
);
114 static struct platform_driver ci13xxx_msm_driver
= {
115 .probe
= ci13xxx_msm_probe
,
116 .driver
= { .name
= "msm_hsusb", },
118 MODULE_ALIAS("platform:msm_hsusb");
120 static int __init
ci13xxx_msm_init(void)
122 return platform_driver_register(&ci13xxx_msm_driver
);
124 module_init(ci13xxx_msm_init
);
126 MODULE_LICENSE("GPL v2");