summaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc3/ep0.c
diff options
context:
space:
mode:
authorFelipe Balbi2012-01-02 17:25:43 +0100
committerFelipe Balbi2012-02-06 10:48:19 +0100
commit04a9bfcd50dd568a8f1a10194a7f336f6b3ad81c (patch)
tree65ca241b579b0938a1acf6fe512e11c3efeebc2d /drivers/usb/dwc3/ep0.c
parentLinux 3.3-rc2 (diff)
downloadkernel-qcow2-linux-04a9bfcd50dd568a8f1a10194a7f336f6b3ad81c.tar.gz
kernel-qcow2-linux-04a9bfcd50dd568a8f1a10194a7f336f6b3ad81c.tar.xz
kernel-qcow2-linux-04a9bfcd50dd568a8f1a10194a7f336f6b3ad81c.zip
usb: dwc3: gadget: re-factor USB2 test mode to a function
There are some situations were we might need to enable USB Test Modes without having access to a Host stack. In such situations we cannot rely solely on USB Control Messages to enable test features. For those cases, we will also allow test mode to be enabled via debugfs and this patch is a preparation for that. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/dwc3/ep0.c')
-rw-r--r--drivers/usb/dwc3/ep0.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index c8df1dd967ef..5eb7095e4005 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -315,7 +315,6 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
u32 recip;
u32 wValue;
u32 wIndex;
- u32 reg;
int ret;
u32 mode;
@@ -357,24 +356,12 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
return -EINVAL;
mode = wIndex >> 8;
- reg = dwc3_readl(dwc->regs, DWC3_DCTL);
- reg &= ~DWC3_DCTL_TSTCTRL_MASK;
-
- switch (mode) {
- case TEST_J:
- case TEST_K:
- case TEST_SE0_NAK:
- case TEST_PACKET:
- case TEST_FORCE_EN:
- reg |= mode << 1;
- break;
- default:
- return -EINVAL;
+ ret = dwc3_gadget_set_test_mode(dwc, mode);
+ if (ret < 0) {
+ dev_dbg(dwc->dev, "Invalid Test #%d\n",
+ mode);
+ return ret;
}
- dwc3_writel(dwc->regs, DWC3_DCTL, reg);
- break;
- default:
- return -EINVAL;
}
break;