Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755463AbcDGIwg (ORCPT ); Thu, 7 Apr 2016 04:52:36 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:61758 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753938AbcDGIwc convert rfc822-to-8bit (ORCPT ); Thu, 7 Apr 2016 04:52:32 -0400 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'208";a="208654292" From: Yoshihiro Shimoda To: Roger Quadros , "stern@rowland.harvard.edu" , "balbi@kernel.org" , "gregkh@linuxfoundation.org" , "peter.chen@freescale.com" CC: "dan.j.williams@intel.com" , "jun.li@freescale.com" , "mathias.nyman@linux.intel.com" , "tony@atomide.com" , "Joao.Pinto@synopsys.com" , "abrestic@chromium.org" , "r.baldyga@samsung.com" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-omap@vger.kernel.org" Subject: RE: [PATCH v6 07/12] usb: otg: add OTG/dual-role core Thread-Topic: [PATCH v6 07/12] usb: otg: add OTG/dual-role core Thread-Index: AQHRj0Tb371d8JP1IUix4M6r6OgSS59+LbDw Date: Thu, 7 Apr 2016 08:52:26 +0000 Message-ID: References: <1459865117-7032-1-git-send-email-rogerq@ti.com> <1459865117-7032-8-git-send-email-rogerq@ti.com> In-Reply-To: <1459865117-7032-8-git-send-email-rogerq@ti.com> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: ti.com; dkim=none (message not signed) header.d=none;ti.com; dmarc=none action=none header.from=renesas.com; x-originating-ip: [211.11.155.144] x-ms-office365-filtering-correlation-id: ed9198bd-60a5-4095-9b3c-08d35ec1f18c x-microsoft-exchange-diagnostics: 1;SG2PR06MB0918;5:Zb1H4KUBqHSOtJXwz8dQZio1xK8x5MdDcCx2q1UM5MwxvJ6/zo3nCb9LhbyIWPB1OF913k2u98zEREf4sCNi6vU5BORn2wKBvQoOD5YwXt0BbWNcsz0cVLUYbsFe/mFGWCUD21RK7oPV05m5vRGRtQ==;24:Z0ht8Ewm//nl71ZMIpzDcJ6P5yX0smYPmdFDeEJMNXdXT6S3Q/7cNURlViOb1EHp5u0kW+aRXq+F4eCvdT/m1RBbwvmJ1SAufeXZAI6Q+A8=;20:/R0VYphmqGQeJjQQf+EoUoKfk9YM+SY4n7paN6CbX7mAoPMQpuNEsEIFcEULz1h6ZVqQvvHOApvKoyKcDjBvqhQZVBdakQv4jwlVXtZD+AO5vLEtnC3sL+HqwV8MYX0NxDcWA4eZEtBUBtiWAbmSJCvYn1yhoy3o2gUBQa1dQ0M= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB0918; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026);SRVR:SG2PR06MB0918;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB0918; x-forefront-prvs: 0905A6B2C7 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(377454003)(76104003)(3846002)(2501003)(74316001)(106116001)(5008740100001)(122556002)(10400500002)(3280700002)(50986999)(66066001)(3660700001)(5890100001)(1220700001)(2906002)(4326007)(1096002)(102836003)(6116002)(5002640100001)(189998001)(92566002)(586003)(33656002)(5001770100001)(76576001)(19580395003)(76176999)(54356999)(2171001)(86362001)(11100500001)(2201001)(19580405001)(5003600100002)(77096005)(2950100001)(81166005)(7059030);DIR:OUT;SFP:1102;SCL:1;SRVR:SG2PR06MB0918;H:SG2PR06MB0919.apcprd06.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Apr 2016 08:52:26.1875 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB0918 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2718 Lines: 78 Hi, > From: Roger Quadros > Sent: Tuesday, April 05, 2016 11:05 PM > > It provides APIs for the following tasks > > - Registering an OTG/dual-role capable controller > - Registering Host and Gadget controllers to OTG core > - Providing inputs to and kicking the OTG state machine > > Provide a dual-role device (DRD) state machine. > DRD mode is a reduced functionality OTG mode. In this mode > we don't support SRP, HNP and dynamic role-swap. > > In DRD operation, the controller mode (Host or Peripheral) > is decided based on the ID pin status. Once a cable plug (Type-A > or Type-B) is attached the controller selects the state > and doesn't change till the cable in unplugged and a different > cable type is inserted. > > As we don't need most of the complex OTG states and OTG timers > we implement a lean DRD state machine in usb-otg.c. > The DRD state machine is only interested in 2 hardware inputs > 'id' and 'b_sess_vld'. > > Signed-off-by: Roger Quadros > --- I tried to implement this framework on my environment, and it seemed work if I added a local hack to this patch :) < snip > > + /* HCD will be started by OTG fsm when needed */ > + mutex_lock(&otg->fsm.lock); > + if (otg->primary_hcd.hcd) { > + /* probably a shared HCD ? */ > + if (usb_otg_hcd_is_primary_hcd(hcd)) { > + dev_err(otg_dev, "otg: primary host already registered\n"); My environment is arm64 / r8a7795, renesas_usbhs (as a gadget), EHCI and OHCI. In this case, OHCI driver is also a primary_hcd. So, this error happened. To avoid this, I assumes that the OHCI hcd is as shared_hcd like a patch below: diff --git a/drivers/usb/common/usb-otg.c b/drivers/usb/common/usb-otg.c index 41e762a..4d7f043 100644 --- a/drivers/usb/common/usb-otg.c +++ b/drivers/usb/common/usb-otg.c @@ -825,11 +825,16 @@ int usb_otg_register_hcd(struct usb_hcd *hcd, unsigned int irqnum, if (otg->primary_hcd.hcd) { /* probably a shared HCD ? */ if (usb_otg_hcd_is_primary_hcd(hcd)) { + if (hcd->driver->flags & HCD_USB11) { + dev_info(otg_dev, "this assumes usb 1.1 hc is as shared_hcd\n"); + goto check_shared_hcd; + } dev_err(otg_dev, "otg: primary host already registered\n"); goto err; } if (hcd->shared_hcd == otg->primary_hcd.hcd) { +check_shared_hcd: if (otg->shared_hcd.hcd) { dev_err(otg_dev, "otg: shared host already registered\n"); goto err; What do you think this local hack? I also wonder if array of hcd may be good for both xHCI and EHCI/OHCI. For example of xHCI: - otg->hcds[0] = primary_hcd - otg->hcds[1] = shared_hcd For example of EHCI/OHCI: - otg->hcds[0] = primary_hcd of EHCI - otg->hcds[1] = primary_hcd of OHCI Best regards, Yoshihiro Shimoda