Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1365808
| From | John Youn <johnyoun@synopsys.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [RFT PATCH 1/4] usb: dwc2: do not override forced dr_mode in gadget setup |
| Date | 2016-03-29 04:40 +0200 |
| Message-ID | <rhRJw-809-13@gated-at.bofh.it> (permalink) |
| References | <rhRJv-809-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Przemek Rudy <prudy1@o2.pl>
The host/device mode set with dr_mode should be kept all the time,
not being changed to OTG in gadget setup (by overriding CFGUSB_FORCEDEVMODE
and CFGUSB_FORCEHOSTMODE bits).
Signed-off-by: Przemek Rudy <prudy1@o2.pl>
Signed-off-by: John Youn <johnyoun@synopsys.com>
---
drivers/usb/dwc2/gadget.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index e9940dd..818f158 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2254,6 +2254,7 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,
{
u32 intmsk;
u32 val;
+ u32 usbcfg;
/* Kill any ep0 requests as controller will be reinitialized */
kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET);
@@ -2267,10 +2268,16 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,
* set configuration.
*/
+ /* keep other bits untouched (so e.g. forced modes are not lost) */
+ usbcfg = dwc2_readl(hsotg->regs + GUSBCFG);
+ usbcfg &= ~(GUSBCFG_TOUTCAL_MASK | GUSBCFG_PHYIF16 | GUSBCFG_SRPCAP |
+ GUSBCFG_HNPCAP);
+
/* set the PLL on, remove the HNP/SRP and set the PHY */
val = (hsotg->phyif == GUSBCFG_PHYIF8) ? 9 : 5;
- dwc2_writel(hsotg->phyif | GUSBCFG_TOUTCAL(7) |
- (val << GUSBCFG_USBTRDTIM_SHIFT), hsotg->regs + GUSBCFG);
+ usbcfg |= hsotg->phyif | GUSBCFG_TOUTCAL(7) |
+ (val << GUSBCFG_USBTRDTIM_SHIFT);
+ dwc2_writel(usbcfg, hsotg->regs + GUSBCFG);
dwc2_hsotg_init_fifo(hsotg);
@@ -3031,6 +3038,7 @@ static struct usb_ep_ops dwc2_hsotg_ep_ops = {
static void dwc2_hsotg_init(struct dwc2_hsotg *hsotg)
{
u32 trdtim;
+ u32 usbcfg;
/* unmask subset of endpoint interrupts */
dwc2_writel(DIEPMSK_TIMEOUTMSK | DIEPMSK_AHBERRMSK |
@@ -3054,11 +3062,16 @@ static void dwc2_hsotg_init(struct dwc2_hsotg *hsotg)
dwc2_hsotg_init_fifo(hsotg);
+ /* keep other bits untouched (so e.g. forced modes are not lost) */
+ usbcfg = dwc2_readl(hsotg->regs + GUSBCFG);
+ usbcfg &= ~(GUSBCFG_TOUTCAL_MASK | GUSBCFG_PHYIF16 | GUSBCFG_SRPCAP |
+ GUSBCFG_HNPCAP);
+
/* set the PLL on, remove the HNP/SRP and set the PHY */
trdtim = (hsotg->phyif == GUSBCFG_PHYIF8) ? 9 : 5;
- dwc2_writel(hsotg->phyif | GUSBCFG_TOUTCAL(7) |
- (trdtim << GUSBCFG_USBTRDTIM_SHIFT),
- hsotg->regs + GUSBCFG);
+ usbcfg |= hsotg->phyif | GUSBCFG_TOUTCAL(7) |
+ (trdtim << GUSBCFG_USBTRDTIM_SHIFT);
+ dwc2_writel(usbcfg, hsotg->regs + GUSBCFG);
if (using_dma(hsotg))
__orr32(hsotg->regs + GAHBCFG, GAHBCFG_DMA_EN);
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFT PATCH 0/4] usb: dwc2: Fix core reset and force mode delay problems John Youn <johnyoun@synopsys.com> - 2016-03-29 04:40 +0200 [RFT PATCH 4/4] usb: dwc2: Properly account for the force mode delays John Youn <johnyoun@synopsys.com> - 2016-03-29 04:40 +0200 [RFT PATCH 1/4] usb: dwc2: do not override forced dr_mode in gadget setup John Youn <johnyoun@synopsys.com> - 2016-03-29 04:40 +0200 [RFT PATCH 2/4] usb: dwc2: gadget: Only initialize device if in device mode John Youn <johnyoun@synopsys.com> - 2016-03-29 04:40 +0200 [RFT PATCH 3/4] usb: dwc2: Add delay to core soft reset John Youn <johnyoun@synopsys.com> - 2016-03-29 04:40 +0200 Re: [RFT PATCH 0/4] usb: dwc2: Fix core reset and force mode delay problems Stefan Wahren <stefan.wahren@i2se.com> - 2016-03-31 11:00 +0200 Re: [RFT PATCH 0/4] usb: dwc2: Fix core reset and force mode delay problems Michael Niewoehner <linux@mniewoehner.de> - 2016-03-31 22:50 +0200 Re: [RFT PATCH 0/4] usb: dwc2: Fix core reset and force mode delay problems Michael Niewoehner <linux@mniewoehner.de> - 2016-03-31 23:50 +0200
csiph-web