]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
MLK-10101-3 usb: chipidea: otg: enable BSV irq when OTG B-device in host mode
authorLi Jun <jun.li@freescale.com>
Tue, 27 Jan 2015 07:01:57 +0000 (15:01 +0800)
committerLi Jun <jun.li@freescale.com>
Wed, 28 Jan 2015 03:08:36 +0000 (11:08 +0800)
When B-device in host mode, if Vbus is off by A-device or A-device is removed,
B-device should update charger status correctly. This patch enables BSV irq
for B-device in all states, so the charger connection and removal can be early
handled by BSV change irq.

Signed-off-by: Li Jun <jun.li@freescale.com>
drivers/usb/chipidea/udc.c

index 1f46ba09f0bb6bbdf4539f1dab878605846037fb..68fe3bf356a52f223322f79c03e9d201a027089a 100644 (file)
@@ -1938,8 +1938,12 @@ void ci_hdrc_gadget_connect(struct usb_gadget *gadget, int is_active)
 
 static int udc_id_switch_for_device(struct ci_hdrc *ci)
 {
-       if (ci->is_otg)
-               /* Clear and enable BSV irq */
+       if (!ci->is_otg)
+               return 0;
+
+       /* Clear and enable BSV irq for peripheral or OTG B-device */
+       if (!ci_otg_is_fsm_mode(ci) ||
+                       ci->fsm.otg->state <= OTG_STATE_B_HOST)
                hw_write_otgsc(ci, OTGSC_BSVIS | OTGSC_BSVIE,
                                        OTGSC_BSVIS | OTGSC_BSVIE);
 
@@ -1948,11 +1952,14 @@ static int udc_id_switch_for_device(struct ci_hdrc *ci)
 
 static void udc_id_switch_for_host(struct ci_hdrc *ci)
 {
+       if (!ci->is_otg)
+               return;
        /*
-        * host doesn't care B_SESSION_VALID event
+        * Host or OTG A-device doesn't care B_SESSION_VALID event
         * so clear and disbale BSV irq
         */
-       if (ci->is_otg)
+       if (!ci_otg_is_fsm_mode(ci) ||
+                       ci->fsm.otg->state > OTG_STATE_B_HOST)
                hw_write_otgsc(ci, OTGSC_BSVIE | OTGSC_BSVIS, OTGSC_BSVIS);
 }