USB: cp210x: allow more baud rates above 1Mbaud
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / usb / gadget / ci13xxx_msm.c
blob1fc612914c52e464ec89a82ec9e39048068c0b27
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.
6 */
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)
20 return udc_irq();
23 static void ci13xxx_msm_notify_event(struct ci13xxx *udc, unsigned event)
25 struct device *dev = udc->gadget.dev.parent;
26 int val;
28 switch (event) {
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);
33 break;
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);
44 break;
45 default:
46 dev_dbg(dev, "unknown ci13xxx_udc event\n");
47 break;
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)
63 struct resource *res;
64 void __iomem *regs;
65 int irq;
66 int ret;
68 dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n");
70 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
71 if (!res) {
72 dev_err(&pdev->dev, "failed to get platform resource mem\n");
73 return -ENXIO;
76 regs = ioremap(res->start, resource_size(res));
77 if (!regs) {
78 dev_err(&pdev->dev, "ioremap failed\n");
79 return -ENOMEM;
82 ret = udc_probe(&ci13xxx_msm_udc_driver, &pdev->dev, regs);
83 if (ret < 0) {
84 dev_err(&pdev->dev, "udc_probe failed\n");
85 goto iounmap;
88 irq = platform_get_irq(pdev, 0);
89 if (irq < 0) {
90 dev_err(&pdev->dev, "IRQ not found\n");
91 ret = -ENXIO;
92 goto udc_remove;
95 ret = request_irq(irq, msm_udc_irq, IRQF_SHARED, pdev->name, pdev);
96 if (ret < 0) {
97 dev_err(&pdev->dev, "request_irq failed\n");
98 goto udc_remove;
101 pm_runtime_no_callbacks(&pdev->dev);
102 pm_runtime_enable(&pdev->dev);
104 return 0;
106 udc_remove:
107 udc_remove();
108 iounmap:
109 iounmap(regs);
111 return ret;
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");