Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756191AbbDWBzL (ORCPT ); Wed, 22 Apr 2015 21:55:11 -0400 Received: from mail-bn1bon0144.outbound.protection.outlook.com ([157.56.111.144]:8930 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755848AbbDWBzI (ORCPT ); Wed, 22 Apr 2015 21:55:08 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; gmail.com; dkim=none (message not signed) header.d=none; Date: Thu, 23 Apr 2015 09:52:12 +0800 From: Peter Chen To: Roger Quadros CC: "gregkh@linuxfoundation.org" , "balbi@ti.com" , "stern@rowland.harvard.edu" , "dan.j.williams@intel.com" , "Jun.Li@freescale.com" , "mathias.nyman@linux.intel.com" , "tony@atomide.com" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-omap@vger.kernel.org" , "macpaul@gmail.com" Subject: Re: [RFC][PATCH v2 00/13] USB: OTG/DRD Core functionality Message-ID: <20150423015206.GA1111@shlinux2> References: <1429008120-5395-1-git-send-email-rogerq@ti.com> <20150420030531.GA30878@shlinux2> <5534AA8C.1070400@ti.com> <5535FD69.6070900@ti.com> <20150422021723.GB2680@shlinux2> <55374EC4.40107@ti.com> <20150422092229.GC2680@shlinux2> <55379738.1090808@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <55379738.1090808@ti.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;BMV:1;SFV:NSPM;SFS:(10019020)(6009001)(339900001)(51704005)(199003)(24454002)(189002)(50466002)(62966003)(105606002)(106466001)(104016003)(77096005)(93886004)(2950100001)(50986999)(87936001)(97756001)(110136001)(54356999)(76176999)(77156002)(33716001)(6806004)(85426001)(86362001)(47776003)(83506001)(23726002)(33656002)(4001350100001)(92566002)(46406003)(46102003);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0301MB1225;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1225; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(5002010);SRVR:CY1PR0301MB1225;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1225; X-Forefront-PRVS: 0555EC8317 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2015 01:55:04.2799 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1225 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2691 Lines: 76 On Wed, Apr 22, 2015 at 03:42:32PM +0300, Roger Quadros wrote: > > So we will have a separate drd fsm file, and the CONFIG_USB_OTG > > and CONFIG_USB_OTG_FSM are not needed to be defined, right? > > > > for drd case CONFIG_USB_OTG_FSM is definitely not needed. > I'm not sure if we can operate dual-role without CONFIG_USB_OTG. > I was thinking of combining the OTG core functionality (drivers/usb/common/usb-otg.c) > with CONFIG_USB_OTG. > Ok, let's choose CONFIG_USB_OTG for both drd and usb fsm case. And we need to patch for hcd that only hnp supported hcd needs to request otg descriptor, etc. For yesterday's back-compatible old otg device, we can add otg features to these drivers, the current behavior for these drivers is: if CONFIG_USB_OTG is defined, it is an otg device, we can just keep the behavior unchanging. If these drivers need to use OTG framework in future, it needs to update its platform data or dts. So, I prefer: - For switching the role through the ID pin devices, we doesn't need any otg features, so no otg dts properties are needed.(expect dr_mode = "otg") - For adp/srp/hnp supported devices, we need (partial) otg features, and the fsm (hardware or software) are needed, we need some otg dts properties we discussed before. > > > > static const struct usb_descriptor_header *otg_desc_20[] = { > > (struct usb_descriptor_header *) &(struct usb_otg_descriptor_20){ > > .bLength = sizeof(struct usb_otg_descriptor_20), > > .bDescriptorType = USB_DT_OTG, > > > > /* > > * REVISIT SRP-only hardware is possible, although > > * it would not be called "OTG" ... > > */ > > .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, > > .bcdOTG = cpu_to_le16(0x0200), > > }, > > NULL, > > }; > > instead of hardcoding bmAttributes field, it must be obtained from the > appropriate data structure that was set by the controller driver > by reading DT and OTG hardware info. > > > > > During bind process: > > > > if (gadget_is_otg_13(c->cdev->gadget)) > > c->descriptors = otg_desc_13; > > else if (gadget_is_otg_20(c->cdev->gadget)) > > c->descriptors = otg_desc_20; > > Probably a helper utitily can do the necessary checks and build the > otg descriptor for us. > usb_otg_get_descriptor(c->descriptors); > > e.g. for OTG3.0 we have a new flag USB_OTG_RSP, and this helper > can be upgraded in the future. ok, it is the implementation detail. -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/