From: Peter Chen <peter.chen@freescale.com>
To: Roger Quadros <rogerq@ti.com>
Cc: <stern@rowland.harvard.edu>, <balbi@ti.com>,
<gregkh@linuxfoundation.org>, <dan.j.williams@intel.com>,
<jun.li@freescale.com>, <mathias.nyman@linux.intel.com>,
<tony@atomide.com>, <Joao.Pinto@synopsys.com>,
<abrestic@chromium.org>, <linux-usb@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-omap@vger.kernel.org>
Subject: Re: [PATCH v4 00/13] USB: OTG/DRD Core functionality
Date: Sun, 6 Sep 2015 15:06:32 +0800 [thread overview]
Message-ID: <20150906070631.GE4914@shlinux2> (raw)
In-Reply-To: <1440422484-4737-1-git-send-email-rogerq@ti.com>
On Mon, Aug 24, 2015 at 04:21:11PM +0300, Roger Quadros wrote:
> Hi,
>
> This series centralizes OTG/Dual-role functionality in the kernel.
> As of now I've got Dual-role functionality working pretty reliably on
> dra7-evm and am437x-gp-evm.
>
> DWC3 controller and platform related patches will be sent separately.
>
> Series is based on Greg's usb-next tree.
>
> Changelog:
> ---------
> v4:
> - Added DT support for tying otg-controller to host and gadget
> controllers. For DT we no longer have the constraint that
> OTG controller needs to be parent of host and gadget. They can be
> tied together using the "otg-controller" property.
> - Relax the requirement for DT case that otg controller must register before
> host/gadget. We maintain a wait list of host/gadget devices
> waiting on the otg controller.
> - Use a single struct usb_otg for otg data.
> - Don't override host/gadget start/stop APIs. Let the controller
> drivers do what they want as they know best. Helper API is provided
> for controller start/stop that controller driver can use.
> - Introduce struct usb_otg_config to pass the otg capabilities,
> otg ops and otg timer timeouts during otg controller registration.
> - rebased on Greg's usb.git/usb-next
Roger, thanks for your hard work. Since it is complicated, and can't
know its correctness and scalable well just reading code. I will run
it for chipidea driver, wait some time please.
Peter
>
> v3:
> - all otg related definations now in otg.h
> - single kernel config USB_OTG to enable OTG core and FSM.
> - resolved symbol dependency issues.
> - use dev_vdbg instead of VDBG() in usb-otg-fsm.c
> - rebased on v4.2-rc1
>
> v2:
> - Use add/remove_hcd() instead of start/stop_hcd() to enable/disable
> the host controller
> - added dual-role-device (DRD) state machine which is a much simpler
> mode of operation when compared to OTG. Here we don't support fancy
> OTG features like HNP, SRP, on the fly role-swap. The mode of operation
> is determined based on ID pin (cable type) and the role doesn't change
> till the cable type changes.
>
> Why?:
> ----
>
> Most of the OTG drivers have been dealing with the OTG state machine
> themselves and there is a scope for code re-use. This has been
> partly addressed by the usb/common/usb-otg-fsm.c but it still
> leaves the instantiation of the state machine and OTG timers
> to the controller drivers. We re-use usb-otg-fsm.c but
> go one step further by instantiating the state machine and timers
> thus making it easier for drivers to implement OTG functionality.
>
> Newer OTG cores support standard host interface (e.g. xHCI) so
> host and gadget functionality are no longer closely knit like older
> cores. There needs to be a way to co-ordinate the operation of the
> host and gadget in OTG mode. i.e. to stop and start them from a
> central location. This central location should be the USB OTG core.
>
> Host and gadget controllers might be sharing resources and can't
> be always running. One has to be stopped for the other to run.
> This can't be done as of now and can be done from the OTG core.
>
> What?:
> -----
>
> The OTG core instantiates the OTG/DRD Finite State Machine
> per OTG controller and manages starting/stopping the
> host and gadget controllers based on the bus state.
>
> It provides APIs for the following
>
> - Registering an OTG capable controller
> struct otg_fsm *usb_otg_register(struct device *dev,
> struct usb_otg_config *config);
>
> int usb_otg_unregister(struct device *dev);
>
> - Registering Host controllers to OTG core (used by hcd-core)
> int usb_otg_register_hcd(struct usb_hcd *hcd, unsigned int irqnum,
> unsigned long irqflags, struct otg_hcd_ops *ops);
> int usb_otg_unregister_hcd(struct usb_hcd *hcd);
>
>
> - Registering Gadget controllers to OTG core (used by udc-core)
> int usb_otg_register_gadget(struct usb_gadget *gadget,
> struct otg_gadget_ops *ops);
> int usb_otg_unregister_gadget(struct usb_gadget *gadget);
>
>
> - Providing inputs to and kicking the OTG state machine
> void usb_otg_sync_inputs(struct otg_fsm *fsm);
> int usb_otg_kick_fsm(struct device *hcd_gcd_device);
>
> - Getting controller device structure from OTG state machine instance
> struct device *usb_otg_fsm_to_dev(struct otg_fsm *fsm);
>
> 'struct otg_fsm' is the interface to the OTG state machine.
> It contains inputs to the fsm, status of the fsm and operations
> for the OTG controller driver.
>
> - Helper APIs for starting/stopping host/gadget controllers
> int usb_otg_start_host(struct otg_fsm *fsm, int on);
> int usb_otg_start_gadget(struct otg_fsm *fsm, int on);
>
> Usage model:
> -----------
>
> - The OTG core needs to know what host and gadget controllers are
> linked to the OTG controller. For DT boots we can provide that
> information by adding "otg-controller" property to the host and
> gadget controller nodes that points to the right otg controller.
> For legacy boot we assume that OTG controller is the parent
> of the host and gadget controllers. For DT if "otg-controller"
> property is not present then parent child relationship constraint
> applies.
>
> - The OTG controller driver must call usb_otg_register() to register
> itself with the OTG core. It must also provide the required
> OTG configuration, fsm operations and timer timeouts (optional)
> via struct usb_otg_config. The fsm operations will be called
> depending on the OTG bus state.
>
> - The host/gadget core stacks are modified to inform the OTG core
> whenever a new host/gadget device is added. The OTG core then
> checks if the host/gadget is part of the OTG controller and if yes
> then prevents the host/gadget from starting till both host and
> gadget are registered, OTG state machine is running and the
> USB bus state is appropriate to start host/gadget.
> For this, APIs have been added to host/gadget stacks to start/stop
> the controllers from the OTG core.
> For DT boots, If the OTG controller hasn't yet been registered
> while the host/gadget are added, the OTG core will hold it in a wait list
> and register them when the OTG controller registers.
>
> - No modification is needed for the host/gadget controller drivers.
> They must ensure that their start/stop methods can be called repeatedly
> and any shared resources between host & gadget are properly managed.
> The OTG core ensures that both are not started simultaneously.
>
> - The OTG core instantiates one OTG state machine per OTG controller
> and the necessary OTG timers to manage OTG state timeouts.
> If none of the otg features are set during usb_otg_register() then it
> instanciates a DRD (dual-role device) state machine instead.
> The state machine is started when both host & gadget register and
> stopped when either of them unregisters. The controllers are started
> and stopped depending on bus state.
>
> - During the lifetime of the OTG state machine, inputs can be
> provided to it by modifying the appropriate members of 'struct otg_fsm'
> and calling usb_otg_sync_inputs(). This is typically done by the
> OTG controller driver that called usb_otg_register().
>
> --
> cheers,
> -roger
>
> Roger Quadros (13):
> usb: otg-fsm: Add documentation for struct otg_fsm
> usb: otg-fsm: support multiple instances
> usb: otg-fsm: Prevent build warning "VDBG" redefined
> otg-fsm: move usb_bus_start_enum into otg-fsm->ops
> usb: hcd.h: Add OTG to HCD interface
> usb: gadget.h: Add OTG to gadget interface
> usb: otg: add OTG core
> usb: doc: dt-binding: Add otg-controller property
> usb: chipidea: move from CONFIG_USB_OTG_FSM to CONFIG_USB_OTG
> usb: hcd: Adapt to OTG core
> usb: core: hub: Notify OTG fsm when A device sets b_hnp_enable
> usb: gadget: udc: adapt to OTG core
> usb: otg: Add dual-role device (DRD) support
>
> Documentation/devicetree/bindings/usb/generic.txt | 5 +
> Documentation/usb/chipidea.txt | 2 +-
> MAINTAINERS | 4 +-
> drivers/usb/Kconfig | 2 +-
> drivers/usb/Makefile | 1 +
> drivers/usb/chipidea/Makefile | 2 +-
> drivers/usb/chipidea/ci.h | 2 +-
> drivers/usb/chipidea/otg_fsm.c | 1 +
> drivers/usb/chipidea/otg_fsm.h | 2 +-
> drivers/usb/common/Makefile | 3 +-
> drivers/usb/common/usb-otg-fsm.c | 26 +-
> drivers/usb/common/usb-otg.c | 1223 +++++++++++++++++++++
> drivers/usb/common/usb-otg.h | 71 ++
> drivers/usb/core/Kconfig | 11 +-
> drivers/usb/core/hcd.c | 55 +-
> drivers/usb/core/hub.c | 10 +-
> drivers/usb/gadget/udc/udc-core.c | 124 ++-
> drivers/usb/phy/Kconfig | 2 +-
> drivers/usb/phy/phy-fsl-usb.c | 3 +
> include/linux/usb/gadget.h | 14 +
> include/linux/usb/hcd.h | 14 +
> include/linux/usb/otg-fsm.h | 116 +-
> include/linux/usb/otg.h | 191 +++-
> 23 files changed, 1808 insertions(+), 76 deletions(-)
> create mode 100644 drivers/usb/common/usb-otg.c
> create mode 100644 drivers/usb/common/usb-otg.h
>
> --
> 2.1.4
>
--
Best Regards,
Peter Chen
next prev parent reply other threads:[~2015-09-06 8:18 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-24 13:21 [PATCH v4 00/13] USB: OTG/DRD Core functionality Roger Quadros
2015-08-24 13:21 ` [PATCH v4 01/13] usb: otg-fsm: Add documentation for struct otg_fsm Roger Quadros
2015-08-24 13:21 ` [PATCH v4 02/13] usb: otg-fsm: support multiple instances Roger Quadros
2015-09-06 5:52 ` Peter Chen
2015-08-24 13:21 ` [PATCH v4 03/13] usb: otg-fsm: Prevent build warning "VDBG" redefined Roger Quadros
2015-08-24 13:21 ` [PATCH v4 04/13] otg-fsm: move usb_bus_start_enum into otg-fsm->ops Roger Quadros
2015-09-07 1:24 ` Peter Chen
2015-09-07 9:57 ` Roger Quadros
2015-09-08 6:54 ` Peter Chen
2015-09-08 8:24 ` Roger Quadros
2015-08-24 13:21 ` [PATCH v4 05/13] usb: hcd.h: Add OTG to HCD interface Roger Quadros
2015-08-24 13:21 ` [PATCH v4 06/13] usb: gadget.h: Add OTG to gadget interface Roger Quadros
2015-08-24 13:21 ` [PATCH v4 07/13] usb: otg: add OTG core Roger Quadros
2015-09-07 1:23 ` Peter Chen
2015-09-07 10:23 ` Roger Quadros
2015-09-08 8:31 ` Peter Chen
2015-09-08 12:25 ` Roger Quadros
2015-09-08 14:34 ` Alan Stern
2015-09-08 17:29 ` Roger Quadros
2015-09-09 2:21 ` Peter Chen
2015-09-09 9:08 ` Roger Quadros
2015-09-09 8:13 ` Peter Chen
2015-09-09 9:33 ` Roger Quadros
2015-09-09 8:45 ` Peter Chen
2015-09-09 10:21 ` Roger Quadros
2015-09-10 5:35 ` Peter Chen
2015-09-10 14:17 ` Roger Quadros
2015-09-11 1:50 ` Peter Chen
2015-09-07 7:40 ` Li Jun
2015-09-07 10:53 ` Roger Quadros
2015-09-09 6:20 ` Li Jun
2015-09-09 10:01 ` Roger Quadros
2015-09-10 9:28 ` Li Jun
2015-09-10 14:14 ` Roger Quadros
2015-08-24 13:21 ` [PATCH v4 08/13] usb: doc: dt-binding: Add otg-controller property Roger Quadros
2015-08-24 13:21 ` [PATCH v4 09/13] usb: chipidea: move from CONFIG_USB_OTG_FSM to CONFIG_USB_OTG Roger Quadros
2015-08-24 13:21 ` [PATCH v4 10/13] usb: hcd: Adapt to OTG core Roger Quadros
2015-09-09 2:23 ` Peter Chen
2015-09-09 9:39 ` Roger Quadros
2015-08-24 13:21 ` [PATCH v4 11/13] usb: core: hub: Notify OTG fsm when A device sets b_hnp_enable Roger Quadros
2015-08-24 13:21 ` [PATCH v4 12/13] usb: gadget: udc: adapt to OTG core Roger Quadros
2015-08-24 13:21 ` [PATCH v4 13/13] usb: otg: Add dual-role device (DRD) support Roger Quadros
2015-09-07 7:53 ` Li Jun
2015-09-07 9:51 ` Roger Quadros
2015-08-26 6:19 ` [PATCH v4 00/13] USB: OTG/DRD Core functionality Peter Chen
2015-09-06 7:06 ` Peter Chen [this message]
2015-09-07 11:42 ` Roger Quadros
2015-12-03 8:19 ` Peter Chen
2015-12-03 8:54 ` Roger Quadros
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150906070631.GE4914@shlinux2 \
--to=peter.chen@freescale.com \
--cc=Joao.Pinto@synopsys.com \
--cc=abrestic@chromium.org \
--cc=balbi@ti.com \
--cc=dan.j.williams@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jun.li@freescale.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@linux.intel.com \
--cc=rogerq@ti.com \
--cc=stern@rowland.harvard.edu \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).