From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754768AbbIIJ6K (ORCPT ); Wed, 9 Sep 2015 05:58:10 -0400 Received: from mail-bl2on0141.outbound.protection.outlook.com ([65.55.169.141]:35904 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751886AbbIIJ6E (ORCPT ); Wed, 9 Sep 2015 05:58:04 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=freescale.com; Date: Wed, 9 Sep 2015 16:45:45 +0800 From: Peter Chen To: Roger Quadros CC: , , , , , , , , , , , Subject: Re: [PATCH v4 07/13] usb: otg: add OTG core Message-ID: <20150909084544.GO7802@shlinux2> References: <1440422484-4737-1-git-send-email-rogerq@ti.com> <1440422484-4737-8-git-send-email-rogerq@ti.com> <20150907012327.GG4914@shlinux2> <55ED6585.5050200@ti.com> <20150908083059.GD7802@shlinux2> <55EED3B5.5030806@ti.com> <20150909022116.GF7802@shlinux2> <55EFF6FA.1000705@ti.com> <20150909081304.GM7802@shlinux2> <55EFFCE0.5070109@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <55EFFCE0.5070109@ti.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD007;1:PUpbp+3QNPkMGB7VI61dJow8ozeviCXs9nYiLTVQcoKBIK89nFXETLm7cWxV+CYRHklCFC6cC7ALzE1N94dnI/0E84coW14JmZNrEObDuzPg2sLHprcWAnF8l8BLPbDnrj+P05UGT1BE3RLEyp4vZ3Y6mU+HOf9Nkgj5z2TiSImsHJAO1SWu5e0jWunO0+j4PJPXVqlXM59MQnwfbaxpjvf0mCREA8AL1APM/iRvp4BjXSx69nCk3PhVkRaeF9+vZoAgT8gk9giWliJX+pJ7+5FUq/MRVuNykmzrpig3bW3ADP9u4eNobWwU3Yxvt3RiHPVhlSitb4jwDXbJhWTFNpIQDz1onDATN9LxEpf2KqBfP74/TUrW+UvhAZww68Ruy3Nui+hViOatKtFIBGM+1rqxE4tr5VIJOIfbqJP5/l4= X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(1109001)(1110001)(339900001)(24454002)(479174004)(189002)(199003)(2950100001)(81156007)(106466001)(5001830100001)(85426001)(83506001)(97736004)(4001350100001)(5001960100002)(86362001)(5007970100001)(68736005)(5001860100001)(4001540100001)(104016003)(62966003)(50466002)(23726002)(93886004)(77156002)(189998001)(76176999)(87936001)(33656002)(69596002)(97756001)(64706001)(33716001)(47776003)(11100500001)(54356999)(46406003)(92566002)(110136002)(105606002)(77096005)(46102003)(6806004)(50986999);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR0301MB1229;H:az84smr01.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1229;2:R2q7h9nOsgmg8XA2l/0cufWG/qS0yOp+GYpjZVHrp6MVVTD2tqFcdKjxKnf+7qXEP1wdtkgUUXsvXLeBNZgkwCqlyYQ91TFq+NZTAnLDKmojxb8uFNKeo/NJQAWnh+a5uJ/aBJPWQMT3xFxFL7kFao5GRjZefXlxg4BVyXECc4o=;3:B1/nvjLtLnYid1GUWPgGx7DdDNzJXWHnCmdEdQ7b+QU2e+ZrcqtiQfz2lojH9BJ5iKteZD7tfIL2AukPBTB7I7oYRghU0F+p48DYuJTSdbVQD5gt6qlMbTVlH5pWxjG6A5XFh/cItAiR2fVqYPiQ+UJKezOLkcjk9Gdj7ZU8OQnh1qY55zjPGVyGgv6STNk35vzyaSeU8MQ5GirwVJ1r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q8+4cp+Fr X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(8121501046)(3002001);SRVR:DM2PR0301MB1229;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB1229; X-Forefront-PRVS: 0694C54398 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM2PR0301MB1229;23:GVjWDxeDr5TvIRQuI4ko/7E4RG4YIX9WrRZNILv?= =?us-ascii?Q?q09BDkt4YIjPYq1rRLTG6Sb4WgV12uFlJb6hoev4H4DPTDmuTkbMcR43CjXk?= =?us-ascii?Q?u0bq6oaRZstZMB2IGnsDoiskiVzWpwID+panILD/FAbx0qM/+KNzk9e4Ju52?= =?us-ascii?Q?pJUXppHgHKfrbDNRPlIYlRaXv1bQbhSROX7OmwAWBqC6M2LffCgWmXe6CxGY?= =?us-ascii?Q?41qXGAB4BgOhoFBH7wqDRFSzG9pB6IAnYqSlv87aR+LWjSAtrCnEfADzLZAy?= =?us-ascii?Q?smE4kH5zt2gyvWToInmRj7fiKlE1DK0xT0mDlYHKevyu8dbYr+pXyyP44zXk?= =?us-ascii?Q?dqbBzAIS3Vh2lFlcAhqnBZf5p4zRf94k/tIPYY2YRgMxjp9hmiW7vjjoxCGN?= =?us-ascii?Q?jHch+PThcoya3YLoPz/zKk8XBDxX3P4YNCJkHwJAygnsJBHRkDKq05Uq4SAe?= =?us-ascii?Q?Q1ozmU3V8Clh3ZlojBKnnd9ruYoiv1NAYBRL592eFF+fR5Ok0+Rd1sHgnI/u?= =?us-ascii?Q?4NK0oP0G687OMW5zXv5hpKh9gr77aIvaXEOFuVCxBsABVSXGrIxDJofIsvUM?= =?us-ascii?Q?sZXHEe6gtvU1mEkCnuqlLlB5lcgiocASIgEetLoWGld8dfu7zyYXpLXl3rOJ?= =?us-ascii?Q?3PwCoIo9/UVq+Hgz57G02G7gGdH3nKDcOnWSpYAq8F+Zy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xORo92uAjlgH4EDt8sgqeVL7BwydnlqVnPFSTZrsFXYvCRL/j3A2pu6oPvTZxYuQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2015 09:58:00.1851 (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: DM2PR0301MB1229 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 09, 2015 at 12:33:20PM +0300, Roger Quadros wrote: > On 09/09/15 11:13, Peter Chen wrote: > > On Wed, Sep 09, 2015 at 12:08:10PM +0300, Roger Quadros wrote: > >> On 09/09/15 05:21, Peter Chen wrote: > >>> On Tue, Sep 08, 2015 at 03:25:25PM +0300, Roger Quadros wrote: > >>>> > >>>> > >>>> On 08/09/15 11:31, Peter Chen wrote: > >>>>> On Mon, Sep 07, 2015 at 01:23:01PM +0300, Roger Quadros wrote: > >>>>>> On 07/09/15 04:23, Peter Chen wrote: > >>>>>>> On Mon, Aug 24, 2015 at 04:21:18PM +0300, Roger Quadros wrote: > >>>>>>>> + * This is used by the USB Host stack to register the Host controller > >>>>>>>> + * to the OTG core. Host controller must not be started by the > >>>>>>>> + * caller as it is left upto the OTG state machine to do so. > >>>>>>>> + * > >>>>>>>> + * Returns: 0 on success, error value otherwise. > >>>>>>>> + */ > >>>>>>>> +int usb_otg_register_hcd(struct usb_hcd *hcd, unsigned int irqnum, > >>>>>>>> + unsigned long irqflags, struct otg_hcd_ops *ops) > >>>>>>>> +{ > >>>>>>>> + struct usb_otg *otgd; > >>>>>>>> + struct device *hcd_dev = hcd->self.controller; > >>>>>>>> + struct device *otg_dev = usb_otg_get_device(hcd_dev); > >>>>>>>> + > >>>>>>> > >>>>>>> One big problem here is: there are two designs for current (IP) driver > >>>>>>> code, one creates dedicated hcd device as roothub's parent, like dwc3. > >>>>>>> Another one doesn't do this, roothub's parent is core device (or otg device > >>>>>>> in your patch), like chipidea and dwc2. > >>>>>>> > >>>>>>> Then, otg_dev will be glue layer device for chipidea after that. > >>>>>> > >>>>>> OK. Let's add a way for the otg controller driver to provide the host and gadget > >>>>>> information to the otg core for such devices like chipidea and dwc2. > >>>>>> > >>>>> > >>>>> Roger, not only chipidea and dwc2, I think the musb uses the same > >>>>> hierarchy. If the host, device, and otg share the same register > >>>>> region, host part can't be a platform driver since we don't want > >>>>> to remap the same register region again. > >>>>> > >>>>> So, in the design, we may need to consider both situations, one > >>>>> is otg/host/device has its own register region, and host is a > >>>>> separate platform device (A), the other is three parts share the > >>>>> same register region, there is only one platform driver (B). > >>>>> > >>>>> A: > >>>>> > >>>>> IP core device > >>>>> | > >>>>> | > >>>>> |-----|-----| > >>>>> gadget host platform device > >>>>> | > >>>>> roothub > >>>>> > >>>>> B: > >>>>> > >>>>> IP core device > >>>>> | > >>>>> | > >>>>> |-----|-----| > >>>>> gadget roothub > >>>>> > >>>>> > >>>>>> This API must be called before the hcd/gadget-driver is added so that the otg > >>>>>> core knows it's linked to an OTG controller. > >>>>>> > >>>>>> Any better idea? > >>>>>> > >>>>> > >>>>> A flag stands for this hcd controller is the same with otg controller > >>>>> can be used, this flag can be stored at struct usb_otg_config. > >>>> > >>>> What if there is another architecture like so? > >>>> > >>>> C: > >>>> [Parent] > >>>> | > >>>> | > >>>> |------------------|--------------| > >>>> [OTG core] [gadget] [host] > >>>> > >>>> We need a more flexible mechanism to link the gadget and > >>>> host device to the otg core for non DT case. > >>>> > >>>> How about adding struct usb_otg parameter to usb_otg_register_hcd()? > >>>> > >>>> e.g. > >>>> int usb_otg_register_hcd(struct usb_otg *otg, struct usb_hcd *hcd, ..) > >>>> > >>>> If otg is NULL it will try DT otg-controller property or parent to > >>>> get the otg controller. > >>> > >>> How usb_otg_register_hcd get struct usb_otg, from where? > >> > >> This only works when the parent driver creating the hcd has registered the > >> otg controller too. > >> > > > > Sorry? So we need to find another way to solve this issue, right? > > For existing cases this is sufficient. > The otg device is either the one supplied during usb_otg_register_hcd > (cases B and C) or it is the parent device (case A). How we differentiate case A and case B at usb_otg_register_hcd? Would you show me the sample code? > > It does not work when the 3 devices are totally independent and get registered > at different times. > I don't think there is such a case for non-DT yet, but let's not have this > limitation. So yes, we need to look for better solution :). > Yes, we need to find some places to store gadget/host/otg information, Alan's suggestion to save them at device drvdata may be a direction, but I still doesn't have way to cover all cases. -- Best Regards, Peter Chen