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)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:47:02 +0000 (14:47 -0500)
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>
(cherry picked from commit eb7c192ce6ce077471dfdcdc4eb6cc9da4a7c01a)

drivers/usb/chipidea/udc.c

index a5f1d03..0612baa 100644 (file)
@@ -2018,8 +2018,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);
 
@@ -2028,11 +2032,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);
 }