Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755339AbcC3WrZ (ORCPT ); Wed, 30 Mar 2016 18:47:25 -0400 Received: from smtprelay.synopsys.com ([198.182.60.111]:34665 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752977AbcC3WrX (ORCPT ); Wed, 30 Mar 2016 18:47:23 -0400 Subject: Re: [PATCH] usb: dwc2: do not override forced dr_mode in gadget setup To: Przemek Rudy , Felipe Balbi , John Youn References: <1458166226-14983-1-git-send-email-prudy1@o2.pl> <56F45A61.3060006@synopsys.com> <87bn5wqnkh.fsf@intel.com> <56FBEBED.6040008@o2.pl> CC: "gregkh@linuxfoundation.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" From: John Youn Message-ID: <56FC5778.60909@synopsys.com> Date: Wed, 30 Mar 2016 15:47:20 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <56FBEBED.6040008@o2.pl> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.9.139.66] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3370 Lines: 94 On 3/30/2016 8:08 AM, Przemek Rudy wrote: > On 03/30/2016 12:15 PM, Felipe Balbi wrote: >> 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_FORCEDEVMODE >>>> and CFGUSB_FORCEHOSTMODE bits). >>>> >>>> Signed-off-by: Przemek Rudy >>>> --- >>>> 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); >>>> >>> >>> >>> Acked-by: John Youn >>> Tested-by: John Youn >> >> I suppose this is for v4.7 merge window ? >> > Technically - patch was started against 4.5, as there are no conflict changes around the file it fits for 4.6, 4.7. > > > Hi Felipe, Please queue for 4.6-rc. Thanks, John