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.
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.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 #include <linux/module.h>
20 #include <linux/platform_device.h>
21 #include <linux/pm_runtime.h>
22 #include <linux/usb/msm_hsusb_hw.h>
23 #include <linux/usb/ulpi.h>
25 #include "ci13xxx_udc.c"
27 #define MSM_USB_BASE (udc->regs)
29 static irqreturn_t
msm_udc_irq(int irq
, void *data
)
34 static void ci13xxx_msm_notify_event(struct ci13xxx
*udc
, unsigned event
)
36 struct device
*dev
= udc
->gadget
.dev
.parent
;
40 case CI13XXX_CONTROLLER_RESET_EVENT
:
41 dev_dbg(dev
, "CI13XXX_CONTROLLER_RESET_EVENT received\n");
42 writel(0, USB_AHBBURST
);
43 writel(0, USB_AHBMODE
);
45 case CI13XXX_CONTROLLER_STOPPED_EVENT
:
46 dev_dbg(dev
, "CI13XXX_CONTROLLER_STOPPED_EVENT received\n");
48 * Put the transceiver in non-driving mode. Otherwise host
49 * may not detect soft-disconnection.
51 val
= otg_io_read(udc
->transceiver
, ULPI_FUNC_CTRL
);
52 val
&= ~ULPI_FUNC_CTRL_OPMODE_MASK
;
53 val
|= ULPI_FUNC_CTRL_OPMODE_NONDRIVING
;
54 otg_io_write(udc
->transceiver
, val
, ULPI_FUNC_CTRL
);
57 dev_dbg(dev
, "unknown ci13xxx_udc event\n");
62 static struct ci13xxx_udc_driver ci13xxx_msm_udc_driver
= {
63 .name
= "ci13xxx_msm",
64 .flags
= CI13XXX_REGS_SHARED
|
65 CI13XXX_REQUIRE_TRANSCEIVER
|
66 CI13XXX_PULLUP_ON_VBUS
|
67 CI13XXX_DISABLE_STREAMING
,
69 .notify_event
= ci13xxx_msm_notify_event
,
72 static int ci13xxx_msm_probe(struct platform_device
*pdev
)
79 dev_dbg(&pdev
->dev
, "ci13xxx_msm_probe\n");
81 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
83 dev_err(&pdev
->dev
, "failed to get platform resource mem\n");
87 regs
= ioremap(res
->start
, resource_size(res
));
89 dev_err(&pdev
->dev
, "ioremap failed\n");
93 ret
= udc_probe(&ci13xxx_msm_udc_driver
, &pdev
->dev
, regs
);
95 dev_err(&pdev
->dev
, "udc_probe failed\n");
99 irq
= platform_get_irq(pdev
, 0);
101 dev_err(&pdev
->dev
, "IRQ not found\n");
106 ret
= request_irq(irq
, msm_udc_irq
, IRQF_SHARED
, pdev
->name
, pdev
);
108 dev_err(&pdev
->dev
, "request_irq failed\n");
112 pm_runtime_no_callbacks(&pdev
->dev
);
113 pm_runtime_enable(&pdev
->dev
);
125 static struct platform_driver ci13xxx_msm_driver
= {
126 .probe
= ci13xxx_msm_probe
,
127 .driver
= { .name
= "msm_hsusb", },
130 static int __init
ci13xxx_msm_init(void)
132 return platform_driver_register(&ci13xxx_msm_driver
);
134 module_init(ci13xxx_msm_init
);