aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory Herrero <gregory.herrero@intel.com>2015-01-30 03:09:32 -0500
committerFelipe Balbi <balbi@ti.com>2015-01-30 11:32:41 -0500
commit643cc4dee1ee804b46f8d288babca046cca7e099 (patch)
tree7e421c8125090e712400f06887a613ad68cf27a2
parent7d24c1b5a77c71d885fca047d1f25721f6b366e7 (diff)
usb: dwc2: gadget: add reset flag in init function
Add a flag to request physical reset of the controller when s3c_hsotg_core_init_disconnected is called. During the usb reset, controller must not be fully reconfigured and resetted. Else this leads to shorter chirp-k duration during enumeration. Tested-by: Robert Baldyga <r.baldyga@samsung.com> Acked-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Gregory Herrero <gregory.herrero@intel.com> Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/dwc2/core.h6
-rw-r--r--drivers/usb/dwc2/gadget.c33
-rw-r--r--drivers/usb/dwc2/hcd.c2
3 files changed, 26 insertions, 15 deletions
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 485b195126e7..f74304b12652 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -999,7 +999,8 @@ extern int s3c_hsotg_remove(struct dwc2_hsotg *hsotg);
999extern int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2); 999extern int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2);
1000extern int s3c_hsotg_resume(struct dwc2_hsotg *dwc2); 1000extern int s3c_hsotg_resume(struct dwc2_hsotg *dwc2);
1001extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq); 1001extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq);
1002extern void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2); 1002extern void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2,
1003 bool reset);
1003extern void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg); 1004extern void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg);
1004extern void s3c_hsotg_disconnect(struct dwc2_hsotg *dwc2); 1005extern void s3c_hsotg_disconnect(struct dwc2_hsotg *dwc2);
1005#else 1006#else
@@ -1011,7 +1012,8 @@ static inline int s3c_hsotg_resume(struct dwc2_hsotg *dwc2)
1011{ return 0; } 1012{ return 0; }
1012static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq) 1013static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
1013{ return 0; } 1014{ return 0; }
1014static inline void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2) {} 1015static inline void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2,
1016 bool reset) {}
1015static inline void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg) {} 1017static inline void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg) {}
1016static inline void s3c_hsotg_disconnect(struct dwc2_hsotg *dwc2) {} 1018static inline void s3c_hsotg_disconnect(struct dwc2_hsotg *dwc2) {}
1017#endif 1019#endif
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 5e91cf154bba..3cf9c6a5e2c7 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2271,9 +2271,13 @@ static int s3c_hsotg_corereset(struct dwc2_hsotg *hsotg)
2271 * 2271 *
2272 * Issue a soft reset to the core, and await the core finishing it. 2272 * Issue a soft reset to the core, and await the core finishing it.
2273 */ 2273 */
2274void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg) 2274void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,
2275 bool is_usb_reset)
2275{ 2276{
2276 s3c_hsotg_corereset(hsotg); 2277 u32 val;
2278
2279 if (!is_usb_reset)
2280 s3c_hsotg_corereset(hsotg);
2277 2281
2278 /* 2282 /*
2279 * we must now enable ep0 ready for host detection and then 2283 * we must now enable ep0 ready for host detection and then
@@ -2286,7 +2290,8 @@ void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg)
2286 2290
2287 s3c_hsotg_init_fifo(hsotg); 2291 s3c_hsotg_init_fifo(hsotg);
2288 2292
2289 __orr32(hsotg->regs + DCTL, DCTL_SFTDISCON); 2293 if (!is_usb_reset)
2294 __orr32(hsotg->regs + DCTL, DCTL_SFTDISCON);
2290 2295
2291 writel(1 << 18 | DCFG_DEVSPD_HS, hsotg->regs + DCFG); 2296 writel(1 << 18 | DCFG_DEVSPD_HS, hsotg->regs + DCFG);
2292 2297
@@ -2357,9 +2362,11 @@ void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg)
2357 s3c_hsotg_ctrl_epint(hsotg, 0, 0, 1); 2362 s3c_hsotg_ctrl_epint(hsotg, 0, 0, 1);
2358 s3c_hsotg_ctrl_epint(hsotg, 0, 1, 1); 2363 s3c_hsotg_ctrl_epint(hsotg, 0, 1, 1);
2359 2364
2360 __orr32(hsotg->regs + DCTL, DCTL_PWRONPRGDONE); 2365 if (!is_usb_reset) {
2361 udelay(10); /* see openiboot */ 2366 __orr32(hsotg->regs + DCTL, DCTL_PWRONPRGDONE);
2362 __bic32(hsotg->regs + DCTL, DCTL_PWRONPRGDONE); 2367 udelay(10); /* see openiboot */
2368 __bic32(hsotg->regs + DCTL, DCTL_PWRONPRGDONE);
2369 }
2363 2370
2364 dev_dbg(hsotg->dev, "DCTL=0x%08x\n", readl(hsotg->regs + DCTL)); 2371 dev_dbg(hsotg->dev, "DCTL=0x%08x\n", readl(hsotg->regs + DCTL));
2365 2372
@@ -2388,8 +2395,10 @@ void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg)
2388 readl(hsotg->regs + DOEPCTL0)); 2395 readl(hsotg->regs + DOEPCTL0));
2389 2396
2390 /* clear global NAKs */ 2397 /* clear global NAKs */
2391 writel(DCTL_CGOUTNAK | DCTL_CGNPINNAK | DCTL_SFTDISCON, 2398 val = DCTL_CGOUTNAK | DCTL_CGNPINNAK;
2392 hsotg->regs + DCTL); 2399 if (!is_usb_reset)
2400 val |= DCTL_SFTDISCON;
2401 __orr32(hsotg->regs + DCTL, val);
2393 2402
2394 /* must be at-least 3ms to allow bus to see disconnect */ 2403 /* must be at-least 3ms to allow bus to see disconnect */
2395 mdelay(3); 2404 mdelay(3);
@@ -2482,7 +2491,7 @@ irq_retry:
2482 kill_all_requests(hsotg, hsotg->eps_out[0], 2491 kill_all_requests(hsotg, hsotg->eps_out[0],
2483 -ECONNRESET); 2492 -ECONNRESET);
2484 2493
2485 s3c_hsotg_core_init_disconnected(hsotg); 2494 s3c_hsotg_core_init_disconnected(hsotg, true);
2486 s3c_hsotg_core_connect(hsotg); 2495 s3c_hsotg_core_connect(hsotg);
2487 } 2496 }
2488 } 2497 }
@@ -3052,7 +3061,7 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget,
3052 3061
3053 spin_lock_irqsave(&hsotg->lock, flags); 3062 spin_lock_irqsave(&hsotg->lock, flags);
3054 s3c_hsotg_init(hsotg); 3063 s3c_hsotg_init(hsotg);
3055 s3c_hsotg_core_init_disconnected(hsotg); 3064 s3c_hsotg_core_init_disconnected(hsotg, false);
3056 hsotg->enabled = 0; 3065 hsotg->enabled = 0;
3057 spin_unlock_irqrestore(&hsotg->lock, flags); 3066 spin_unlock_irqrestore(&hsotg->lock, flags);
3058 3067
@@ -3171,7 +3180,7 @@ static int s3c_hsotg_vbus_session(struct usb_gadget *gadget, int is_active)
3171 if (is_active) { 3180 if (is_active) {
3172 /* Kill any ep0 requests as controller will be reinitialized */ 3181 /* Kill any ep0 requests as controller will be reinitialized */
3173 kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET); 3182 kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET);
3174 s3c_hsotg_core_init_disconnected(hsotg); 3183 s3c_hsotg_core_init_disconnected(hsotg, false);
3175 if (hsotg->enabled) 3184 if (hsotg->enabled)
3176 s3c_hsotg_core_connect(hsotg); 3185 s3c_hsotg_core_connect(hsotg);
3177 } else { 3186 } else {
@@ -4097,7 +4106,7 @@ int s3c_hsotg_resume(struct dwc2_hsotg *hsotg)
4097 s3c_hsotg_phy_enable(hsotg); 4106 s3c_hsotg_phy_enable(hsotg);
4098 4107
4099 spin_lock_irqsave(&hsotg->lock, flags); 4108 spin_lock_irqsave(&hsotg->lock, flags);
4100 s3c_hsotg_core_init_disconnected(hsotg); 4109 s3c_hsotg_core_init_disconnected(hsotg, false);
4101 if (hsotg->enabled) 4110 if (hsotg->enabled)
4102 s3c_hsotg_core_connect(hsotg); 4111 s3c_hsotg_core_connect(hsotg);
4103 spin_unlock_irqrestore(&hsotg->lock, flags); 4112 spin_unlock_irqrestore(&hsotg->lock, flags);
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 4a9bcdd5cb23..c78c8740db1d 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -1373,7 +1373,7 @@ static void dwc2_conn_id_status_change(struct work_struct *work)
1373 hsotg->op_state = OTG_STATE_B_PERIPHERAL; 1373 hsotg->op_state = OTG_STATE_B_PERIPHERAL;
1374 dwc2_core_init(hsotg, false, -1); 1374 dwc2_core_init(hsotg, false, -1);
1375 dwc2_enable_global_interrupts(hsotg); 1375 dwc2_enable_global_interrupts(hsotg);
1376 s3c_hsotg_core_init_disconnected(hsotg); 1376 s3c_hsotg_core_init_disconnected(hsotg, false);
1377 s3c_hsotg_core_connect(hsotg); 1377 s3c_hsotg_core_connect(hsotg);
1378 } else { 1378 } else {
1379 /* A-Device connector (Host Mode) */ 1379 /* A-Device connector (Host Mode) */