MLK-9617-4 usb: common: otg: test: do HNP for legacy otg test device
authorLi Jun <B47624@freescale.com>
Mon, 29 Sep 2014 02:47:41 +0000 (10:47 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:47:12 +0000 (14:47 -0500)
Since legacy OTG test device which is only compliant with OTG supplement version
1.3 or earlier, cannot support HNP polling, so directly start role switch.

Signed-off-by: Li Jun <b47624@freescale.com>
(cherry picked from commit 688bbca155159978cd520923f2c3029c7778fa9c)
(cherry picked from commit 6f9edab20e2dd8794e46a0b9129c8694e81d064b)

drivers/usb/common/usb-otg-fsm.c

index 279cb8f..0f34224 100644 (file)
@@ -135,6 +135,7 @@ static void otg_hnp_polling_work(struct work_struct *work)
        enum usb_otg_state state = fsm->otg->state;
        u8 flag;
        int retval;
+       struct usb_otg_descriptor *desc = NULL;
 
        if (state != OTG_STATE_A_HOST && state != OTG_STATE_B_HOST)
                return;
@@ -146,6 +147,24 @@ static void otg_hnp_polling_work(struct work_struct *work)
                return;
        }
 
+       /*
+        * Legacy otg test device does not support HNP polling,
+        * start HNP directly for legacy otg test device.
+        */
+       if (fsm->tst_maint &&
+               (__usb_get_extra_descriptor(udev->rawdescriptors[0],
+               le16_to_cpu(udev->config[0].desc.wTotalLength),
+                               USB_DT_OTG, (void **) &desc) == 0)) {
+               /* shorter bLength of OTG 1.3 or earlier */
+               if (desc->bLength < 5) {
+                       fsm->a_bus_req = 0;
+                       fsm->tst_maint = 0;
+                       otg_del_timer(fsm, A_TST_MAINT);
+                       *fsm->host_req_flag = HOST_REQUEST_FLAG;
+                       return;
+               }
+       }
+
        *fsm->host_req_flag = 0;
        /* Get host request flag from connected USB device */
        retval = usb_control_msg(udev,