From patchwork Thu Jul 26 20:52:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 10546477 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2657714BC for ; Thu, 26 Jul 2018 20:52:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8ACA2BB40 for ; Thu, 26 Jul 2018 20:52:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC5182BB4E; Thu, 26 Jul 2018 20:52:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38A5B2BB40 for ; Thu, 26 Jul 2018 20:52:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730581AbeGZWKt (ORCPT ); Thu, 26 Jul 2018 18:10:49 -0400 Received: from smtprelay.synopsys.com ([198.182.60.111]:37388 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730392AbeGZWKs (ORCPT ); Thu, 26 Jul 2018 18:10:48 -0400 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 0508110C0A70; Thu, 26 Jul 2018 13:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1532638336; bh=QB9BZWeK7EJOZn5gPCSK0oYTkHhceWsnID1mTc1lTLk=; h=Date:From:Subject:To:CC:From; b=RZRDV7WUhaur9gopQcgVLpmfM109Or4KCsWU2bogQq68wWKsk2k4kusB0jyePNiYF CbJdFSr0lJ0wtzAAAybZNCmlJGTOHFp8ISPAKBlASIntIKluYvzp3mESq2NFs6BUss prMmuVLoZgBUzNr5oBE3rGgudpr3Zk7mLpH+TUHdFnrtOqB52YD6FP3N/MDGMvKKLy fOOlGAu0ST6rWqc2WRFbcpnnaFhXSi+W5I4i18ecHa2EOEZzbZv7aZqiHd21gEAeOa BogIvURqfJ0ThMTnR2bfK7AMEZm1vGEt7KEN19szXHTM4e0dp1LvPRoDZ0FSnPOTNn v02Mg+dkkpgXQ== Received: from US01WEHTC2.internal.synopsys.com (us01wehtc2.internal.synopsys.com [10.12.239.237]) by mailhost.synopsys.com (Postfix) with ESMTP id EADF43203; Thu, 26 Jul 2018 13:52:15 -0700 (PDT) Received: from US01WEHTC3.internal.synopsys.com (10.15.84.232) by US01WEHTC2.internal.synopsys.com (10.12.239.237) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 26 Jul 2018 13:52:15 -0700 Received: from te-lab16 (10.13.184.20) by US01WEHTC3.internal.synopsys.com (10.15.84.231) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 26 Jul 2018 13:52:11 -0700 Received: by te-lab16 (sSMTP sendmail emulation); Thu, 26 Jul 2018 13:52:11 -0700 Date: Thu, 26 Jul 2018 13:52:11 -0700 Message-ID: <5fd8c3934df0d740d78616046451f983e07b92eb.1532637584.git.thinhn@synopsys.com> From: Thinh Nguyen Subject: [PATCH] usb: dwc3: Set default mode for dwc_usb31 To: Felipe Balbi , CC: John Youn MIME-Version: 1.0 X-Originating-IP: [10.13.184.20] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP dwc_usb31 does not support OTG mode. If the controller supports DRD but the dr_mode is not specified or set to OTG, then set the mode to peripheral. Signed-off-by: Thinh Nguyen --- drivers/usb/dwc3/core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 21e4931d0cc0..64ba664d467c 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -78,6 +78,14 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc) mode = USB_DR_MODE_HOST; else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET)) mode = USB_DR_MODE_PERIPHERAL; + + /* + * dwc_usb31 does not support OTG mode. If the controller + * supports DRD but the dr_mode is not specified or set to OTG, + * then set the mode to peripheral. + */ + if (mode == USB_DR_MODE_OTG && dwc3_is_usb31(dwc)) + mode = USB_DR_MODE_PERIPHERAL; } if (mode != dwc->dr_mode) {