aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc3/gadget.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2012-01-02 11:25:43 -0500
committerFelipe Balbi <balbi@ti.com>2012-02-06 04:48:19 -0500
commit04a9bfcd50dd568a8f1a10194a7f336f6b3ad81c (patch)
tree65ca241b579b0938a1acf6fe512e11c3efeebc2d /drivers/usb/dwc3/gadget.c
parent62aa2b537c6f5957afd98e29f96897419ed5ebab (diff)
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/gadget.c')
-rw-r--r--drivers/usb/dwc3/gadget.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 064b6e2cd41..1dee17e7b77 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -56,6 +56,39 @@
56 56
57#define DMA_ADDR_INVALID (~(dma_addr_t)0) 57#define DMA_ADDR_INVALID (~(dma_addr_t)0)
58 58
59/**
60 * dwc3_gadget_set_test_mode - Enables USB2 Test Modes
61 * @dwc: pointer to our context structure
62 * @mode: the mode to set (J, K SE0 NAK, Force Enable)
63 *
64 * Caller should take care of locking. This function will
65 * return 0 on success or -EINVAL if wrong Test Selector
66 * is passed
67 */
68int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode)
69{
70 u32 reg;
71
72 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
73 reg &= ~DWC3_DCTL_TSTCTRL_MASK;
74
75 switch (mode) {
76 case TEST_J:
77 case TEST_K:
78 case TEST_SE0_NAK:
79 case TEST_PACKET:
80 case TEST_FORCE_EN:
81 reg |= mode << 1;
82 break;
83 default:
84 return -EINVAL;
85 }
86
87 dwc3_writel(dwc->regs, DWC3_DCTL, reg);
88
89 return 0;
90}
91
59void dwc3_map_buffer_to_dma(struct dwc3_request *req) 92void dwc3_map_buffer_to_dma(struct dwc3_request *req)
60{ 93{
61 struct dwc3 *dwc = req->dep->dwc; 94 struct dwc3 *dwc = req->dep->dwc;