usb: improve the usb performance of adb push/pull file
authorwu xia <xia.wu@intel.com>
Sun, 1 Apr 2012 10:35:14 +0000 (18:35 +0800)
committerbuildbot <buildbot@intel.com>
Thu, 5 Apr 2012 07:07:44 +0000 (00:07 -0700)
BZ: 24941

The usb performance is low when adb push/pull files to/from PR3 phone.

The reason is that USB interrupt is delayed by OTG device controller.
USB interrupt interval is controlled by USBCMD.ITC. The default value
of ITC is a little high. Set ITC to low value to shorten interrupt
interval.

Change-Id: I85577648e5d0844aaf05ed343c393cad5619f375
Signed-off-by: wu xia <xia.wu@intel.com>
Reviewed-on: http://android.intel.com:8080/39931
Reviewed-by: Gross, Mark <mark.gross@intel.com>
Tested-by: Sun, Jianhua <jianhua.sun@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
drivers/usb/gadget/langwell_udc.c
include/linux/usb/langwell_udc.h

index a09cf0d..9ffa322 100644 (file)
@@ -1618,6 +1618,17 @@ static int langwell_udc_reset(struct langwell_udc *dev)
                udelay(10);
        }
 
+       /* change ITC value. ITC field is used to set the maximum rate at which
+          the device controller will issue interrupts. ITC contain the maximum
+          interrupt interval measured in micro-frames. ITC=2 is the smallest
+          available value. The USB network gadget become instability if ITC is
+          set to 1 or 0.
+       */
+       usbcmd = readl(&dev->op_regs->usbcmd);
+       usbcmd &= ~CMD_SET_ITC(0xff);   /* clear ITC field */
+       usbcmd |= CMD_SET_ITC(0x02);    /* set ITC field */
+       writel(usbcmd, &dev->op_regs->usbcmd);
+
        /* set controller to device mode */
        usbmode = readl(&dev->op_regs->usbmode);
        usbmode |= MODE_DEVICE;
index 15ec232..4748458 100644 (file)
@@ -87,6 +87,8 @@ struct langwell_op_regs {
        (((u)>>24)&0xf)         /* bits 27:24, host init resume duration */
 #define        CMD_ITC(u)      \
        (((u)>>16)&0xff)        /* bits 23:16, interrupt threshold control */
+#define CMD_SET_ITC(u)  \
+       (((u)&0xff)<<16)        /* set value to ITC field */
 #define        CMD_PPE         BIT(15) /* per-port change events enable */
 #define        CMD_ATDTW       BIT(14) /* add dTD tripwire */
 #define        CMD_SUTW        BIT(13) /* setup tripwire */