diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2011-10-31 17:25:41 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2011-12-12 04:48:27 -0500 |
commit | 4878a02898bab1a988206341e529997cb46e5f29 (patch) | |
tree | f6340ba066d32aeaf7c7499614d4cb6496b9a359 /drivers/usb/dwc3 | |
parent | 3140e8cbfec18ecb9c9ef856933fdb98c09af1e8 (diff) |
usb: dwc3: move generic dwc3 code from gadget into core
A few inits like the scale value or the removal of the DISSCRAMBLE is
done in the gadget code however it touches a general register.
Move this piece to the core.c file since it is likely to be requied by
both, parts of the core (device and host).
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/dwc3')
-rw-r--r-- | drivers/usb/dwc3/core.c | 23 | ||||
-rw-r--r-- | drivers/usb/dwc3/gadget.c | 24 |
2 files changed, 23 insertions, 24 deletions
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 217547514faa..6910a2d14d93 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -349,6 +349,29 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc) | |||
349 | 349 | ||
350 | dwc3_cache_hwparams(dwc); | 350 | dwc3_cache_hwparams(dwc); |
351 | 351 | ||
352 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); | ||
353 | reg &= ~DWC3_GCTL_SCALEDOWN(3); | ||
354 | reg &= ~DWC3_GCTL_DISSCRAMBLE; | ||
355 | |||
356 | switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams0)) { | ||
357 | case DWC3_GHWPARAMS1_EN_PWROPT_CLK: | ||
358 | reg &= ~DWC3_GCTL_DSBLCLKGTNG; | ||
359 | break; | ||
360 | default: | ||
361 | dev_dbg(dwc->dev, "No power optimization available\n"); | ||
362 | } | ||
363 | |||
364 | /* | ||
365 | * WORKAROUND: DWC3 revisions <1.90a have a bug | ||
366 | * when The device fails to connect at SuperSpeed | ||
367 | * and falls back to high-speed mode which causes | ||
368 | * the device to enter in a Connect/Disconnect loop | ||
369 | */ | ||
370 | if (dwc->revision < DWC3_REVISION_190A) | ||
371 | reg |= DWC3_GCTL_U2RSTECN; | ||
372 | |||
373 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); | ||
374 | |||
352 | ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); | 375 | ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); |
353 | if (ret) { | 376 | if (ret) { |
354 | dev_err(dwc->dev, "failed to allocate event buffers\n"); | 377 | dev_err(dwc->dev, "failed to allocate event buffers\n"); |
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index fab4ee0082e2..8aff490a1ae1 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
@@ -1155,30 +1155,6 @@ static int dwc3_gadget_start(struct usb_gadget *g, | |||
1155 | dwc->gadget_driver = driver; | 1155 | dwc->gadget_driver = driver; |
1156 | dwc->gadget.dev.driver = &driver->driver; | 1156 | dwc->gadget.dev.driver = &driver->driver; |
1157 | 1157 | ||
1158 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); | ||
1159 | |||
1160 | reg &= ~DWC3_GCTL_SCALEDOWN(3); | ||
1161 | reg &= ~DWC3_GCTL_DISSCRAMBLE; | ||
1162 | |||
1163 | switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams0)) { | ||
1164 | case DWC3_GHWPARAMS1_EN_PWROPT_CLK: | ||
1165 | reg &= ~DWC3_GCTL_DSBLCLKGTNG; | ||
1166 | break; | ||
1167 | default: | ||
1168 | dev_dbg(dwc->dev, "No power optimization available\n"); | ||
1169 | } | ||
1170 | |||
1171 | /* | ||
1172 | * WORKAROUND: DWC3 revisions <1.90a have a bug | ||
1173 | * when The device fails to connect at SuperSpeed | ||
1174 | * and falls back to high-speed mode which causes | ||
1175 | * the device to enter in a Connect/Disconnect loop | ||
1176 | */ | ||
1177 | if (dwc->revision < DWC3_REVISION_190A) | ||
1178 | reg |= DWC3_GCTL_U2RSTECN; | ||
1179 | |||
1180 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); | ||
1181 | |||
1182 | reg = dwc3_readl(dwc->regs, DWC3_DCFG); | 1158 | reg = dwc3_readl(dwc->regs, DWC3_DCFG); |
1183 | reg &= ~(DWC3_DCFG_SPEED_MASK); | 1159 | reg &= ~(DWC3_DCFG_SPEED_MASK); |
1184 | reg |= dwc->maximum_speed; | 1160 | reg |= dwc->maximum_speed; |