From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757799AbbGQKLi (ORCPT ); Fri, 17 Jul 2015 06:11:38 -0400 Received: from mail-bl2on0139.outbound.protection.outlook.com ([65.55.169.139]:29854 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757341AbbGQKLf (ORCPT ); Fri, 17 Jul 2015 06:11:35 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none; Date: Fri, 17 Jul 2015 17:02:13 +0800 From: Li Jun To: Roger Quadros CC: , , , , , , , , , , , Subject: Re: [PATCH v3 10/11] usb: otg: Add dual-role device (DRD) support Message-ID: <20150717090212.GC4515@shlinux2> References: <1436350777-28056-1-git-send-email-rogerq@ti.com> <1436350777-28056-11-git-send-email-rogerq@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1436350777-28056-11-git-send-email-rogerq@ti.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD053;1:qnrAl7BPCNvfqoz0PkpxvJb09o2u17hSuZTEJhZpDDJgufaphveZg4RQlNGCXG7sL+7iqKL2h3WON+UKDOJco40yrj/vFBRx+0nleaUhDP4PWiqI2UaadZN722SL+HW26JzYbG99V0CzaAoC8V9BJzdUcP7UROsLYH3rh4Q5GHTA/N3b9bIQm/GtYNae0S8e206+zeQx/e4GG5vOtHqw33Lccjuxl51IKtnpgxf4ia1p/Wk8i9NXnaR+BaYVbdzNhv6YRdruQrUtsQ8s7rL39aa2MiYMmNv5PB4wG/8ff4p2VRWe0PmB6RGwy2N4DVpLiRqJWFRkG9EOqLpK9DQxcyjC/cvWT0mfdxTKnJXuUVZxFvEH61jnvmSEvoREvIjxsvI8JJ3a2pmdTcZuf8uiPvXynbZY01qto+19wXFE0Ex3LkUbER3HcvE/aiSDPOmu X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(24454002)(110136002)(189998001)(97756001)(54356999)(33716001)(5001960100002)(106466001)(47776003)(105606002)(76176999)(33656002)(77156002)(4001350100001)(77096005)(46102003)(46406003)(6806004)(85426001)(50986999)(19580395003)(87936001)(92566002)(83506001)(104016003)(575784001)(23726002)(2950100001)(50466002);DIR:OUT;SFP:1102;SCL:1;SRVR:BN3PR0301MB1219;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB1219;2:1tgPSkaBlGTbKfI9PV+uGS+/HfJzNiR2nIWlUW8ki/WRK0VWJow17YTt10yyy9kY;3:Okd8FtrMhWBwcwH1RAR5hyRHZosDSKI+6XnhwpZ2cdySenqR69gbUqIwSbMmgKj48U/ioSTINzYue5B7sf9emhzdksjs/YRs08Hx6wbH8aeCHKCktm4X0qn7kvzw1mS4F5KqIP4H0uRiCGgIgnFkFd83+/aw3+JjZVDHGYs2Eju1Ry7m/7+Jk1AXNk6/SuifvxEDL+8DbGkZU5RVVHfWniXbsIfZ2IGv11QDXa2Tk9Q=;25:3TRKbhDDd78j/Bz+bGBNk+JdJHwhmO3Bw/dsq7NLIv18DAFMvSUNeGAiWTF269fN/AcphKS46jWmrtBzma4JGf1xl4cRYrmk49FtpduufYxdaHNXmquUu9ty5fsa1bwMLOIe8anZM1U9xNOLAOYPsM90/6T/81gD7mYFCU+Ei7dEHxALsnuERm+Vct+KWaN9Pw7rO1nOJD2/w7ZbMCEZ85QK76wH28W9WVQqwHT3hNtK/viAVZJY/k3EhPMY2YIfi94L45/5OnDEDkFp1HXT9g==;20:eSGtkrouw3bNhsXPoVUJL4wvSXLbrJb6dOyMwLU2iwmMMCbZCzOQLfiQ0Zv1cYbpal5NV2xHTnp9JAltB6G29tpYmR71vbSFR71RmUj0cdKAMMWTuc0rk97ziYMc95iZkPkmR16Oax+0DoKqgsPEkoclukDR0wtRGgCwaZZlrKAYUBK3Zov0ug3eOBWNVmwWbChOM5woFxLNltAkG+qD44KjOdXFvIQKyp+D3kODP9it5DcNs4i2cJo45baahvPZVlB2Wz0CsYrqj1P1/kbvF/Bra3fjP6NLQEVEouYFmswObb9XDdaDUQK23jzsaU/oa7xUSnfvshrHnCeoFkjNE0e2WYnaz3wN8wxQJuuQ0qw= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB1219;UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB1300; BN3PR0301MB1219: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BN3PR0301MB1219;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB1219; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB1219;4:apcRvpx5r4ZUymhtn0UnKPCoBJjWSzCWZaUjSAIRRsGvW7MlLaII6Knhu2XgMKMp51h6Aaa8CX/V/7iOMxswcOxLnowDiEjom1orymYxAwBmP6j8tOyZ5QVwCMNiVVR+AkBjag317tcn6WdJNMlXVqZ00gvW+fgWJB68ysS6TL/X5VBuIc970JQWNUKdswlEXrNnjgngjUsH8SJqLDENNEVfxb8N6el5Hhb/8mGqCQPh/kAZSHQkelaMuAlLI1CeJsfyAcTwCtMTjFEle04irXVd78nipJW+kC7MBeZXuOU= X-Forefront-PRVS: 06400060E1 X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB1219;23:duLZStI/3xNzC8FHoYOZlaHIKYeijInejaasCHiT4JegsjrVoRrIfUp+5cfjZrcurNaGwsrfXV1mT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y2rScvWugojU/YiKIZcy0K/alf6Wk8C82C7DC8fq27g9eRQbeAQ9mSsR5+FP2/nxE=;20:GK5QcAw+2Txnx2gRmtiui/+B1WIWHTprcl2AHLXO9iQqDUHhwvcfDP137UsLm4fRE/ZxZPloyImXo12b2pQQOQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2015 10:11:31.6875 (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.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0301MB1219 X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB1300;2:w0WPIlF22nlYCrt/9UH0obHAG7c0+7lI5bSgnXeU+huHwsXA5qfQVatKUJ/1lX+W;3:drCtlolRsWsQ2e5ZemUdMJBXEjfmpiNJDVtUDjWcrEEej9+uQaQf3ges7XcX4PJBe0qKPLH8PyQTDy4iP5fOfQeYoQEnvtjVvO0z9GImYZ13lhs4AcIGNTWWdvsgG68bcAfnEP/DsUV31B1DQG4A0aDsK8x4Oky3roQ9gl26U7z03HslKfmD9pXaFLGO8Sf3vKmMsdrN8QQXQfzy5VQeFu5UcE/lZs7ww9mp08knQo0=;25:ycIDYHul8gUZjhR7j/bYcp2RwojGWaPKqMuKTZDwCUXxbTuitg8v96yEii98YJrDJ6a9ofolM9DKdlLdcgWOmbIXz0lrqq5uGshalo93egfzkfkC5WzARlkei1T84wuB/Gi7JsoDZoHwVRd1+7wlDfljpIjhGwRRoFarIZEwr50B416DKbj3EqDElNCdoN+YbeP9o2VGwytuBru2pNx//SJizQYoRi2eMgVtDNk8O83GF8uKCODRSqb734QZfMoRhpx9FlED5nkkP5RVz7umNQ==;23:/iHxHIZmX0oar6/UVP+FKjtmirBhOeWxDthRM4P0kSsiYxzZO0Y/OFPKIKf7lyhPwkgTZezoXacoCOVJZtroPJELlCcsdBrI7VDO0q9Od1hINWUPBPVuQ4WPeTYz85SGBlsW/6LxIoklE0WLk8qW8lr7m/TY0x12/2wO+2ekSXWuKt36njZVZNDbu+MzS+UopzbbJk4UNU0nqBS3TjsxM2UoxHKuBulx6LvqBbcJwN175dZsyfqN8J3uchda9bBL X-OriginatorOrg: freescale.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 08, 2015 at 01:19:36PM +0300, Roger Quadros wrote: [...] > struct otg_fsm *usb_otg_register(struct device *parent_dev, > - struct otg_fsm_ops *fsm_ops) > + struct otg_fsm_ops *fsm_ops, > + bool drd_only) > { > struct otg_data *otgd; > int ret = 0; > @@ -328,7 +482,15 @@ struct otg_fsm *usb_otg_register(struct device *parent_dev, > goto err_wq; > } > > - usb_otg_init_timers(otgd); > + otgd->drd_only = drd_only; > + /* For DRD mode we don't need OTG timers */ > + if (!drd_only) { > + usb_otg_init_timers(otgd); > + > + /* FIXME: we ignore caller's timer ops */ > + otgd->fsm_ops.add_timer = usb_otg_add_timer; > + otgd->fsm_ops.del_timer = usb_otg_del_timer; > + } > > /* save original start host/gadget ops */ > otgd->start_host = fsm_ops->start_host; > @@ -338,9 +500,6 @@ struct otg_fsm *usb_otg_register(struct device *parent_dev, Your above override will be override back to be fsm_ops's by below copy: /* create copy of original ops */ otgd->fsm_ops = *fsm_ops; So add/del_timer must be override after the copy. > /* override ops */ > otgd->fsm_ops.start_host = usb_otg_start_host; > otgd->fsm_ops.start_gadget = usb_otg_start_gadget; > - /* FIXME: we ignore caller's timer ops */ > - otgd->fsm_ops.add_timer = usb_otg_add_timer; > - otgd->fsm_ops.del_timer = usb_otg_del_timer; > /* set otg ops */ > otgd->fsm.ops = &otgd->fsm_ops; > otgd->fsm.otg = &otgd->otg; > @@ -443,8 +602,10 @@ static void usb_otg_stop_fsm(struct otg_fsm *fsm) > otgd->fsm_running = false; > > /* Stop state machine / timers */ > - for (i = 0; i < ARRAY_SIZE(otgd->timers); i++) > - hrtimer_cancel(&otgd->timers[i].timer); > + if (!otgd->drd_only) { > + for (i = 0; i < ARRAY_SIZE(otgd->timers); i++) > + hrtimer_cancel(&otgd->timers[i].timer); > + } > > flush_workqueue(otgd->wq); > fsm->otg->state = OTG_STATE_UNDEFINED; > diff --git a/include/linux/usb/otg-fsm.h b/include/linux/usb/otg-fsm.h > index 22d8baa..ae9c30a 100644 > --- a/include/linux/usb/otg-fsm.h > +++ b/include/linux/usb/otg-fsm.h > @@ -48,6 +48,11 @@ enum otg_fsm_timer { > /** > * struct otg_fsm - OTG state machine according to the OTG spec > * > + * DRD mode hardware Inputs > + * > + * @id: TRUE for B-device, FALSE for A-device. > + * @vbus: VBUS voltage in regulation. > + * > * OTG hardware Inputs > * > * Common inputs for A and B device > @@ -122,7 +127,8 @@ enum otg_fsm_timer { > */ > struct otg_fsm { > /* Input */ > - int id; > + int id; /* DRD + OTG */ > + int vbus; /* DRD only */ Existing b_sess_vld can be also used for drd only case, no need create a new flag. > int adp_change; > int power_up; > int a_srp_det; > diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h > index ce6f8d8..1086a0b 100644 > --- a/include/linux/usb/otg.h > +++ b/include/linux/usb/otg.h > @@ -58,7 +58,7 @@ enum usb_dr_mode { > > #if IS_ENABLED(CONFIG_USB_OTG) > struct otg_fsm *usb_otg_register(struct device *parent_dev, > - struct otg_fsm_ops *fsm_ops); > + struct otg_fsm_ops *fsm_ops, bool drd_only); > int usb_otg_unregister(struct device *parent_dev); > int usb_otg_register_hcd(struct usb_hcd *hcd, unsigned int irqnum, > unsigned long irqflags, struct otg_hcd_ops *ops); > @@ -73,7 +73,8 @@ struct device *usb_otg_fsm_to_dev(struct otg_fsm *fsm); > #else /* CONFIG_USB_OTG */ > > static inline struct otg_fsm *usb_otg_register(struct device *parent_dev, > - struct otg_fsm_ops *fsm_ops) > + struct otg_fsm_ops *fsm_ops, > + bool drd_only) > { > return ERR_PTR(-ENOSYS); > } > -- > 2.1.4 > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Li Jun Subject: Re: [PATCH v3 10/11] usb: otg: Add dual-role device (DRD) support Date: Fri, 17 Jul 2015 17:02:13 +0800 Message-ID: <20150717090212.GC4515@shlinux2> References: <1436350777-28056-1-git-send-email-rogerq@ti.com> <1436350777-28056-11-git-send-email-rogerq@ti.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Return-path: Content-Disposition: inline In-Reply-To: <1436350777-28056-11-git-send-email-rogerq@ti.com> Sender: linux-kernel-owner@vger.kernel.org To: Roger Quadros Cc: stern@rowland.harvard.edu, balbi@ti.com, gregkh@linuxfoundation.org, peter.chen@freescale.com, dan.j.williams@intel.com, jun.li@freescale.com, mathias.nyman@linux.intel.com, tony@atomide.com, Joao.Pinto@synopsys.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org List-Id: linux-omap@vger.kernel.org On Wed, Jul 08, 2015 at 01:19:36PM +0300, Roger Quadros wrote: [...] > struct otg_fsm *usb_otg_register(struct device *parent_dev, > - struct otg_fsm_ops *fsm_ops) > + struct otg_fsm_ops *fsm_ops, > + bool drd_only) > { > struct otg_data *otgd; > int ret = 0; > @@ -328,7 +482,15 @@ struct otg_fsm *usb_otg_register(struct device *parent_dev, > goto err_wq; > } > > - usb_otg_init_timers(otgd); > + otgd->drd_only = drd_only; > + /* For DRD mode we don't need OTG timers */ > + if (!drd_only) { > + usb_otg_init_timers(otgd); > + > + /* FIXME: we ignore caller's timer ops */ > + otgd->fsm_ops.add_timer = usb_otg_add_timer; > + otgd->fsm_ops.del_timer = usb_otg_del_timer; > + } > > /* save original start host/gadget ops */ > otgd->start_host = fsm_ops->start_host; > @@ -338,9 +500,6 @@ struct otg_fsm *usb_otg_register(struct device *parent_dev, Your above override will be override back to be fsm_ops's by below copy: /* create copy of original ops */ otgd->fsm_ops = *fsm_ops; So add/del_timer must be override after the copy. > /* override ops */ > otgd->fsm_ops.start_host = usb_otg_start_host; > otgd->fsm_ops.start_gadget = usb_otg_start_gadget; > - /* FIXME: we ignore caller's timer ops */ > - otgd->fsm_ops.add_timer = usb_otg_add_timer; > - otgd->fsm_ops.del_timer = usb_otg_del_timer; > /* set otg ops */ > otgd->fsm.ops = &otgd->fsm_ops; > otgd->fsm.otg = &otgd->otg; > @@ -443,8 +602,10 @@ static void usb_otg_stop_fsm(struct otg_fsm *fsm) > otgd->fsm_running = false; > > /* Stop state machine / timers */ > - for (i = 0; i < ARRAY_SIZE(otgd->timers); i++) > - hrtimer_cancel(&otgd->timers[i].timer); > + if (!otgd->drd_only) { > + for (i = 0; i < ARRAY_SIZE(otgd->timers); i++) > + hrtimer_cancel(&otgd->timers[i].timer); > + } > > flush_workqueue(otgd->wq); > fsm->otg->state = OTG_STATE_UNDEFINED; > diff --git a/include/linux/usb/otg-fsm.h b/include/linux/usb/otg-fsm.h > index 22d8baa..ae9c30a 100644 > --- a/include/linux/usb/otg-fsm.h > +++ b/include/linux/usb/otg-fsm.h > @@ -48,6 +48,11 @@ enum otg_fsm_timer { > /** > * struct otg_fsm - OTG state machine according to the OTG spec > * > + * DRD mode hardware Inputs > + * > + * @id: TRUE for B-device, FALSE for A-device. > + * @vbus: VBUS voltage in regulation. > + * > * OTG hardware Inputs > * > * Common inputs for A and B device > @@ -122,7 +127,8 @@ enum otg_fsm_timer { > */ > struct otg_fsm { > /* Input */ > - int id; > + int id; /* DRD + OTG */ > + int vbus; /* DRD only */ Existing b_sess_vld can be also used for drd only case, no need create a new flag. > int adp_change; > int power_up; > int a_srp_det; > diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h > index ce6f8d8..1086a0b 100644 > --- a/include/linux/usb/otg.h > +++ b/include/linux/usb/otg.h > @@ -58,7 +58,7 @@ enum usb_dr_mode { > > #if IS_ENABLED(CONFIG_USB_OTG) > struct otg_fsm *usb_otg_register(struct device *parent_dev, > - struct otg_fsm_ops *fsm_ops); > + struct otg_fsm_ops *fsm_ops, bool drd_only); > int usb_otg_unregister(struct device *parent_dev); > int usb_otg_register_hcd(struct usb_hcd *hcd, unsigned int irqnum, > unsigned long irqflags, struct otg_hcd_ops *ops); > @@ -73,7 +73,8 @@ struct device *usb_otg_fsm_to_dev(struct otg_fsm *fsm); > #else /* CONFIG_USB_OTG */ > > static inline struct otg_fsm *usb_otg_register(struct device *parent_dev, > - struct otg_fsm_ops *fsm_ops) > + struct otg_fsm_ops *fsm_ops, > + bool drd_only) > { > return ERR_PTR(-ENOSYS); > } > -- > 2.1.4 >