Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751282AbcC3KRG (ORCPT ); Wed, 30 Mar 2016 06:17:06 -0400 Received: from mga02.intel.com ([134.134.136.20]:33546 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750744AbcC3KRE (ORCPT ); Wed, 30 Mar 2016 06:17:04 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,415,1455004800"; d="asc'?scan'208";a="921700976" From: Felipe Balbi To: John Youn , Przemek Rudy , "John.Youn\@synopsys.com" Cc: "gregkh\@linuxfoundation.org" , "linux-usb\@vger.kernel.org" , "linux-kernel\@vger.kernel.org" Subject: Re: [PATCH] usb: dwc2: do not override forced dr_mode in gadget setup In-Reply-To: <56F45A61.3060006@synopsys.com> References: <1458166226-14983-1-git-send-email-prudy1@o2.pl> <56F45A61.3060006@synopsys.com> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/25.0.90.3 (x86_64-pc-linux-gnu) Date: Wed, 30 Mar 2016 13:15:10 +0300 Message-ID: <87bn5wqnkh.fsf@intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4009 Lines: 111 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable John Youn writes: > [ text/plain ] > On 3/16/2016 3:10 PM, Przemek Rudy wrote: >> 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_FORCEDEVM= ODE >> and CFGUSB_FORCEHOSTMODE bits). >>=20 >> Signed-off-by: Przemek Rudy >> --- >> drivers/usb/dwc2/gadget.c | 23 ++++++++++++++++++----- >> 1 file changed, 18 insertions(+), 5 deletions(-) >>=20 >> 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; >>=20=20 >> /* 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 dw= c2_hsotg *hsotg, >> * set configuration. >> */ >>=20=20 >> + /* keep other bits untouched (so e.g. forced modes are not lost) */ >> + usbcfg =3D dwc2_readl(hsotg->regs + GUSBCFG); >> + usbcfg &=3D ~(GUSBCFG_TOUTCAL_MASK | GUSBCFG_PHYIF16 | GUSBCFG_SRPCAP | >> + GUSBCFG_HNPCAP); >> + >> /* set the PLL on, remove the HNP/SRP and set the PHY */ >> val =3D (hsotg->phyif =3D=3D GUSBCFG_PHYIF8) ? 9 : 5; >> - dwc2_writel(hsotg->phyif | GUSBCFG_TOUTCAL(7) | >> - (val << GUSBCFG_USBTRDTIM_SHIFT), hsotg->regs + GUSBCFG); >> + usbcfg |=3D hsotg->phyif | GUSBCFG_TOUTCAL(7) | >> + (val << GUSBCFG_USBTRDTIM_SHIFT); >> + dwc2_writel(usbcfg, hsotg->regs + GUSBCFG); >>=20=20 >> dwc2_hsotg_init_fifo(hsotg); >>=20=20 >> @@ -3031,6 +3038,7 @@ static struct usb_ep_ops dwc2_hsotg_ep_ops =3D { >> static void dwc2_hsotg_init(struct dwc2_hsotg *hsotg) >> { >> u32 trdtim; >> + u32 usbcfg; >> /* unmask subset of endpoint interrupts */ >>=20=20 >> dwc2_writel(DIEPMSK_TIMEOUTMSK | DIEPMSK_AHBERRMSK | >> @@ -3054,11 +3062,16 @@ static void dwc2_hsotg_init(struct dwc2_hsotg *h= sotg) >>=20=20 >> dwc2_hsotg_init_fifo(hsotg); >>=20=20 >> + /* keep other bits untouched (so e.g. forced modes are not lost) */ >> + usbcfg =3D dwc2_readl(hsotg->regs + GUSBCFG); >> + usbcfg &=3D ~(GUSBCFG_TOUTCAL_MASK | GUSBCFG_PHYIF16 | GUSBCFG_SRPCAP | >> + GUSBCFG_HNPCAP); >> + >> /* set the PLL on, remove the HNP/SRP and set the PHY */ >> trdtim =3D (hsotg->phyif =3D=3D GUSBCFG_PHYIF8) ? 9 : 5; >> - dwc2_writel(hsotg->phyif | GUSBCFG_TOUTCAL(7) | >> - (trdtim << GUSBCFG_USBTRDTIM_SHIFT), >> - hsotg->regs + GUSBCFG); >> + usbcfg |=3D hsotg->phyif | GUSBCFG_TOUTCAL(7) | >> + (trdtim << GUSBCFG_USBTRDTIM_SHIFT); >> + dwc2_writel(usbcfg, hsotg->regs + GUSBCFG); >>=20=20 >> if (using_dma(hsotg)) >> __orr32(hsotg->regs + GAHBCFG, GAHBCFG_DMA_EN); >>=20 > > > Acked-by: John Youn > Tested-by: John Youn I suppose this is for v4.7 merge window ? =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJW+6cvAAoJEIaOsuA1yqRELfYQAKcd4TiRk45QAtIwvavrknZo jwCvIK1BubQ11sBoFhgxHMYYJJJH8R5DkUZPKPzu2pgvDFkCTG/+8I2+trOU1bgJ TzFnC3HM9l2OgrxXHvARpXn8wAserxLKP8D3iZontUrsMVA+aUSkNIyt+k763Po7 a6lNVKihss846FLe/+uCXMM7jVCoNR27bYtmepbKuFyjHmhdKiu1wWYCH7SosIHv r4i/WaWxDrBVqP2D0zxSOmWlETkKXstfjhPnXuNhtIZ1v5Ng2YH5DzFU8IxrnvB6 lrt8R8IupaiE9zl5lQubvNnNqdaF4SHORIRe+C61Z5EUtnQtdjNU4eUoqcs+6BOq NdJDOmdQo+td+hBRCy95YyiMqncnvk1DNn7GFfEV8hiRtIMiD3t7YJwFo4B3s60e D+yLhKgzUetiEi4PwSfuxoeLG+t5dw6L1JNtoD9Hd6K3EEQGxGrLrmoAbVt3KZTX +gYQczxi4wNBYnhvXNYEMcAQNUetL0XGFBHF4m8djRyN0RSXqgGT54/Jh1LqRRNk Ed36s5Modaihi2R4Vx5Mwqwlu6bWITnxtRxV+7VyOf75SnX2lXQeL8cpYS7by1y+ eqKLRVHWhuWr2Y7XPxQ2qFNiZ1oMxToF0dSEHJAUpZnl+g8bw9eMXRTQ5NZu/N1R 1B83UyRFwLUg5NqYQWHZ =PtlP -----END PGP SIGNATURE----- --=-=-=--