From: John Youn <johnyoun@synopsys.com>
To: linux-usb@vger.kernel.org
To: Doug Anderson <dianders@chromium.org>
Cc: johnyoun@synopsys.com
Cc: Felipe Balbi <balbi@ti.com>
Cc: Stefan Wahren <stefan.wahren@i2se.com>
Cc: Michael Niewoehner <linux@mniewoehner.de>
Cc: Tao Huang <huangtao@rock-chips.com>
Cc: Julius Werner <jwerner@chromium.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Caesar Wang <caesar.upstream@gmail.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Remi Pommarel <repk@triplefau.lt>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Przemek Rudy <prudy1@o2.pl>
Subject: [RFT PATCH 1/4] usb: dwc2: do not override forced dr_mode in gadget setup
Date: Mon, 28 Mar 2016 19:36:29 -0700 [thread overview]
Message-ID: <019279685dfc8cec902e33e7b7418873c5a98def.1459211397.git.johnyoun@synopsys.com> (raw)
In-Reply-To: <cover.1459211397.git.johnyoun@synopsys.com>
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
next prev parent reply other threads:[~2016-03-29 2:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-29 2:36 [RFT PATCH 0/4] usb: dwc2: Fix core reset and force mode delay problems John Youn
2016-03-29 2:36 ` John Youn [this message]
2016-03-29 2:36 ` [RFT PATCH 2/4] usb: dwc2: gadget: Only initialize device if in device mode John Youn
2016-03-29 2:36 ` [RFT PATCH 3/4] usb: dwc2: Add delay to core soft reset John Youn
2016-03-29 2:36 ` [RFT PATCH 4/4] usb: dwc2: Properly account for the force mode delays John Youn
2016-03-31 8:52 ` [RFT PATCH 0/4] usb: dwc2: Fix core reset and force mode delay problems Stefan Wahren
2016-03-31 20:45 ` Michael Niewoehner
2016-03-31 21:43 ` Michael Niewoehner
2016-04-07 18:41 ` John Youn
2016-04-07 20:36 ` Michael Niewoehner
2016-04-07 22:12 ` John Youn
2016-04-08 10:25 ` Michael Niewoehner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=019279685dfc8cec902e33e7b7418873c5a98def.1459211397.git.johnyoun@synopsys.com \
--to=johnyoun@synopsys.com \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®