usb: gadget: ci13xxx: rename register layouts
[deliverable/linux.git] / drivers / usb / gadget / ci13xxx_msm.c
1 /* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
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
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>
13
14 #include "ci13xxx_udc.c"
15
16 #define MSM_USB_BASE (udc->regs)
17
18 static irqreturn_t msm_udc_irq(int irq, void *data)
19 {
20 return udc_irq();
21 }
22
23 static void ci13xxx_msm_notify_event(struct ci13xxx *udc, unsigned event)
24 {
25 struct device *dev = udc->gadget.dev.parent;
26 int val;
27
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");
36 /*
37 * Put the transceiver in non-driving mode. Otherwise host
38 * may not detect soft-disconnection.
39 */
40 val = usb_phy_io_read(udc->transceiver, ULPI_FUNC_CTRL);
41 val &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
42 val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING;
43 usb_phy_io_write(udc->transceiver, val, ULPI_FUNC_CTRL);
44 break;
45 default:
46 dev_dbg(dev, "unknown ci13xxx_udc event\n");
47 break;
48 }
49 }
50
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,
57
58 .notify_event = ci13xxx_msm_notify_event,
59 };
60
61 static int ci13xxx_msm_probe(struct platform_device *pdev)
62 {
63 struct resource *res;
64 void __iomem *regs;
65 int irq;
66 int ret;
67
68 dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n");
69
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;
74 }
75
76 regs = ioremap(res->start, resource_size(res));
77 if (!regs) {
78 dev_err(&pdev->dev, "ioremap failed\n");
79 return -ENOMEM;
80 }
81
82 ret = udc_probe(&ci13xxx_msm_udc_driver, &pdev->dev, regs,
83 DEF_CAPOFFSET);
84 if (ret < 0) {
85 dev_err(&pdev->dev, "udc_probe failed\n");
86 goto iounmap;
87 }
88
89 irq = platform_get_irq(pdev, 0);
90 if (irq < 0) {
91 dev_err(&pdev->dev, "IRQ not found\n");
92 ret = -ENXIO;
93 goto udc_remove;
94 }
95
96 ret = request_irq(irq, msm_udc_irq, IRQF_SHARED, pdev->name, pdev);
97 if (ret < 0) {
98 dev_err(&pdev->dev, "request_irq failed\n");
99 goto udc_remove;
100 }
101
102 pm_runtime_no_callbacks(&pdev->dev);
103 pm_runtime_enable(&pdev->dev);
104
105 return 0;
106
107 udc_remove:
108 udc_remove();
109 iounmap:
110 iounmap(regs);
111
112 return ret;
113 }
114
115 static struct platform_driver ci13xxx_msm_driver = {
116 .probe = ci13xxx_msm_probe,
117 .driver = { .name = "msm_hsusb", },
118 };
119 MODULE_ALIAS("platform:msm_hsusb");
120
121 static int __init ci13xxx_msm_init(void)
122 {
123 return platform_driver_register(&ci13xxx_msm_driver);
124 }
125 module_init(ci13xxx_msm_init);
126
127 MODULE_LICENSE("GPL v2");
This page took 0.033297 seconds and 5 git commands to generate.