24 #include <linux/module.h>
25 #include <linux/kernel.h>
26 #include <linux/sched.h>
28 #include <linux/list.h>
38 #include <mach/cputype.h>
39 #include <mach/hardware.h>
45 #ifdef CONFIG_MACH_DAVINCI_EVM
46 #define GPIO_nVBUS_DRV 160
53 #define USB_PHY_CTRL IO_ADDRESS(USBPHY_CTL_PADDR)
54 #define DM355_DEEPSLEEP IO_ADDRESS(DM355_DEEPSLEEP_PADDR)
68 static inline void phy_on(
void)
82 static inline void phy_off(
void)
94 static void davinci_musb_enable(
struct musb *
musb)
126 static void davinci_musb_disable(
struct musb *musb)
145 #define portstate(stmt) stmt
156 #ifdef CONFIG_MACH_DAVINCI_EVM
158 static int vbus_state = -1;
167 vbus_state = !vbus_state;
172 static void davinci_musb_source_power(
struct musb *musb,
int is_on,
int immediate)
174 #ifdef CONFIG_MACH_DAVINCI_EVM
178 if (vbus_state == is_on)
182 if (machine_is_davinci_evm()) {
183 static DECLARE_WORK(evm_vbus_work, evm_deferred_drvvbus);
195 static void davinci_musb_set_vbus(
struct musb *musb,
int is_on)
198 davinci_musb_source_power(musb, is_on, 0);
202 #define POLL_SECONDS 2
206 static void otg_timer(
unsigned long _musb)
208 struct musb *musb = (
void *)_musb;
221 switch (musb->
xceiv->state) {
260 spin_unlock_irqrestore(&musb->
lock, flags);
263 static irqreturn_t davinci_musb_interrupt(
int irq,
void *__hci)
267 struct musb *musb = __hci;
331 WARNING(
"VBUS error workaround (delay coming)\n");
332 }
else if (drvvbus) {
349 davinci_musb_source_power(musb, drvvbus, 0);
351 drvvbus ?
"on" :
"off",
368 spin_unlock_irqrestore(&musb->
lock, flags);
373 static int davinci_musb_set_mode(
struct musb *musb,
u8 mode)
379 static int davinci_musb_init(
struct musb *musb)
386 if (IS_ERR_OR_NULL(musb->
xceiv))
396 setup_timer(&otg_workaround, otg_timer, (
unsigned long) musb);
398 davinci_musb_source_power(musb, 0, 1);
403 if (machine_is_davinci_dm355_evm()) {
406 phy_ctrl &= ~(3 << 9);
430 pr_debug(
"DaVinci OTG revision %08x phy %03x control %02x\n",
434 musb->
isr = davinci_musb_interrupt;
444 static int davinci_musb_exit(
struct musb *musb)
457 davinci_musb_source_power(musb, 0 , 1);
460 if (musb->
xceiv->otg->default_a) {
471 if ((devctl & MUSB_DEVCTL_VBUS) != warn) {
478 }
while (maxdelay > 0);
481 if (devctl & MUSB_DEVCTL_VBUS)
494 .init = davinci_musb_init,
495 .exit = davinci_musb_exit,
497 .enable = davinci_musb_enable,
498 .disable = davinci_musb_disable,
500 .set_mode = davinci_musb_set_mode,
502 .set_vbus = davinci_musb_set_vbus,
519 dev_err(&pdev->
dev,
"failed to allocate glue context\n");
526 dev_err(&pdev->
dev,
"failed to allocate musb id\n");
533 dev_err(&pdev->
dev,
"failed to allocate musb device\n");
546 dev_err(&pdev->
dev,
"failed to enable clock\n");
551 musb->
dev.parent = &pdev->
dev;
552 musb->
dev.dma_mask = &davinci_dmamask;
553 musb->
dev.coherent_dma_mask = davinci_dmamask;
561 platform_set_drvdata(pdev, glue);
566 dev_err(&pdev->
dev,
"failed to add resources\n");
572 dev_err(&pdev->
dev,
"failed to add platform_data\n");
578 dev_err(&pdev->
dev,
"failed to register musb device\n");
618 .probe = davinci_probe,
621 .name =
"musb-davinci",
629 static int __init davinci_init(
void)
635 static void __exit davinci_exit(
void)