MLK-9606-2 usb: otg: test: start tst_maint timer and set otg_vbus_off flag
authorLi Jun <B47624@freescale.com>
Wed, 24 Sep 2014 06:05:30 +0000 (14:05 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:47:10 +0000 (14:47 -0500)
This patch adds 2 variables: tst_maint and otg_vbus_off, tst_maint is to check if
current session for test device; otg_vbus_off is to notify if A device need turn
off vbus immediately after B device disconnects.
The otg test device handling is added into ehset driver, for that device,
A-device should start a timer for maintain the session, and set otg_vbus_off
flag according to its bcdDevice value.

Acked-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Li Jun <b47624@freescale.com>
(cherry picked from commit 78a2c14bdea4b8e334c7e0afad074b61b71193cb)
(cherry picked from commit b854141cc5a7150751e7f7fd2dfb10a415cfea10)

drivers/usb/misc/ehset.c
include/linux/usb/otg-fsm.h

index c31b4a3..f6236f1 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/usb/ch11.h>
+#include <linux/usb/otg-fsm.h>
 
 #define TEST_SE0_NAK_PID                       0x0101
 #define TEST_J_PID                             0x0102
@@ -25,6 +26,7 @@
 #define TEST_HS_HOST_PORT_SUSPEND_RESUME       0x0106
 #define TEST_SINGLE_STEP_GET_DEV_DESC          0x0107
 #define TEST_SINGLE_STEP_SET_FEATURE           0x0108
+#define TEST_OTG_TEST_DEVICE_SUPPORT           0x0200
 
 static int ehset_probe(struct usb_interface *intf,
                       const struct usb_device_id *id)
@@ -35,6 +37,7 @@ static int ehset_probe(struct usb_interface *intf,
        struct usb_device_descriptor *buf;
        u8 portnum = dev->portnum;
        u16 test_pid = le16_to_cpu(dev->descriptor.idProduct);
+       struct otg_fsm *fsm = dev->bus->otg_fsm;
 
        switch (test_pid) {
        case TEST_SE0_NAK_PID:
@@ -114,6 +117,20 @@ static int ehset_probe(struct usb_interface *intf,
                                        (6 << 8) | portnum,
                                        NULL, 0, 60 * 1000);
 
+               break;
+       case TEST_OTG_TEST_DEVICE_SUPPORT:
+               if (!fsm || dev->bus->is_b_host)
+                       return ret;
+
+               mutex_lock(&fsm->lock);
+               fsm->tst_maint = 1;
+               if (le16_to_cpu(dev->descriptor.bcdDevice) & 0x1)
+                       fsm->otg_vbus_off = 1;
+               else
+                       fsm->otg_vbus_off = 0;
+               mutex_unlock(&fsm->lock);
+               otg_add_timer(fsm, A_TST_MAINT);
+               ret = 0;
                break;
        default:
                dev_err(&intf->dev, "%s: unsupported PID: 0x%x\n",
@@ -135,6 +152,7 @@ static const struct usb_device_id ehset_id_table[] = {
        { USB_DEVICE(0x1a0a, TEST_HS_HOST_PORT_SUSPEND_RESUME) },
        { USB_DEVICE(0x1a0a, TEST_SINGLE_STEP_GET_DEV_DESC) },
        { USB_DEVICE(0x1a0a, TEST_SINGLE_STEP_SET_FEATURE) },
+       { USB_DEVICE(0x1a0a, TEST_OTG_TEST_DEVICE_SUPPORT) },
        { }                     /* Terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, ehset_id_table);
index e9d3a89..df3a60a 100644 (file)
@@ -69,6 +69,7 @@ enum otg_fsm_timer {
        B_DATA_PLS,
        B_SSEND_SRP,
        A_DP_END,
+       A_TST_MAINT,
 
        NUM_OTG_FSM_TIMERS,
 };
@@ -187,6 +188,10 @@ struct otg_fsm {
        int b_hnp_enable;
        int a_clr_err;
 
+       /* OTG test device */
+       int tst_maint;
+       int otg_vbus_off;
+
        /* Informative variables. All unused as of now */
        int a_bus_drop_inf;
        int a_bus_req_inf;