linux-ti33x-psp 3.2: backport PM and USB fixes from PSP
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / psp / 0018-usb-musb-ti81xx-fix-role-switching-issue.patch
1 From f2ddff7377332c9e18878aaa84456d01fcf1d39e Mon Sep 17 00:00:00 2001
2 From: Ajay Kumar Gupta <ajay.gupta@ti.com>
3 Date: Fri, 25 May 2012 11:59:20 +0530
4 Subject: [PATCH 18/18] usb: musb: ti81xx: fix role switching issue
6 Fixing the role switching issue seen when followed steps below:
8 a) Configure port in OTG mode
9 b) Connect MSC device through micro-A-plug to std-A-receptacle
10 c) MSC enumerated and works fine.
11 d) Disconnect MSC device and let cable be connected to port
12 e) Now disconnect cable also
13 f) Connect port to host PC using micro-B plug to std-A plug.
14 e) PC doesn't recognise the gadget driver.
15 ---
16  drivers/usb/musb/ti81xx.c |   26 +++++++++++++++++++++-----
17  1 files changed, 21 insertions(+), 5 deletions(-)
19 diff --git a/drivers/usb/musb/ti81xx.c b/drivers/usb/musb/ti81xx.c
20 index 7e21c25..6b0eb9e 100644
21 --- a/drivers/usb/musb/ti81xx.c
22 +++ b/drivers/usb/musb/ti81xx.c
23 @@ -708,6 +708,12 @@ static void otg_timer(unsigned long _musb)
24                 devctl = musb_readb(mregs, MUSB_DEVCTL);
25                 if (devctl & MUSB_DEVCTL_HM) {
26                         musb->xceiv->state = OTG_STATE_A_IDLE;
27 +               } else if ((devctl & MUSB_DEVCTL_SESSION) &&
28 +                               !(devctl & MUSB_DEVCTL_BDEVICE)) {
29 +                       mod_timer(&musb->otg_workaround,
30 +                                       jiffies + POLL_SECONDS * HZ);
31 +                       musb_writeb(musb->mregs, MUSB_DEVCTL, devctl &
32 +                               ~MUSB_DEVCTL_SESSION);
33                 } else {
34                         mod_timer(&musb->otg_workaround,
35                                         jiffies + POLL_SECONDS * HZ);
36 @@ -976,11 +982,21 @@ static irqreturn_t ti81xx_interrupt(int irq, void *hci)
37                                                 jiffies + POLL_SECONDS * HZ);
38                         WARNING("VBUS error workaround (delay coming)\n");
39                 } else if (is_host_enabled(musb) && drvvbus) {
40 -                       musb->is_active = 1;
41 -                       MUSB_HST_MODE(musb);
42 -                       musb->xceiv->default_a = 1;
43 -                       musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
44 -                       del_timer(&musb->otg_workaround);
45 +                       if ((devctl & MUSB_DEVCTL_SESSION) &&
46 +                               !(devctl & MUSB_DEVCTL_BDEVICE) &&
47 +                               !(devctl & MUSB_DEVCTL_HM)) {
48 +                               dev_dbg(musb->controller,
49 +                                       "Only micro-A plug is connected\n");
50 +                       } else {
51 +                               if (musb->is_active)
52 +                                       del_timer(&musb->otg_workaround);
53 +                               else
54 +                                       musb->is_active = 1;
55 +
56 +                               MUSB_HST_MODE(musb);
57 +                               musb->xceiv->default_a = 1;
58 +                               musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
59 +                       }
60                 } else {
61                         musb->is_active = 0;
62                         MUSB_DEV_MODE(musb);
63 -- 
64 1.7.7.6