Re: [PATCH v10 2/7] usb: mux: add generic code for dual role port mux

From: Peter Chen
Date: Wed Jun 08 2016 - 02:31:04 EST


On Tue, Jun 07, 2016 at 06:05:25PM +0300, Felipe Balbi wrote:
>
> Hi,
>
> Roger Quadros <rogerq@xxxxxx> writes:
> >> I might be able to find some time to implement a proof of concept which
> >> would allow your platforms to get dual-role with code we already have,
> >> but I need DWC3's OTG support which, I'm assuming, you already have :-)
> >>
> >> If you wanna try something offline, just ping me ;-) I'll be happy to
> >> help.
> >
> > What you are proposing is a dwc3 only solution. With the otg/dual-role
> > series we are trying to be generic as much as possible.
>
> Well, if there is a need for that, sure. Take MUSB for instance. It
> makes use of nothing of the sorts, because it doesn't have to.
>

Indeed, some centralized IP drivers like MUSB, chipidea, dwc3 do not
need this framework for role switch. But there are some common stuffs,
like OTG FSM (fully/simplified), manage roles and sysfs for role switch,
these things can be in a framework, the purpose of this framework is
easy for dual-role switch function.

Besides, when the host and device driver are in different folders for
platform, eg host/ and gadget/udc/, a role switch driver is needed if
we need dual role function.

Recently, the dual-role function is more and more common for USB, a
framework can avoid duplicated work and let switch be standardized.

> > Whether controller drivers want to use it or not is upto the driver
> > maintainers but we should at least ensure that user space ABI if any,
> > is consistent across different implementations.
>
> Role decisions should not be exposed to userspace unless as debug
> feature (using e.g. DebugFS). That should be done either by the HW or
> within the kernel.
>
> If we're discussing userspace ABI here, there's something very wrong
> with OTG/DRD layer design.

Currently, there are some use cases which need to switch role on the
fly (will be more for type-c in future), a sysfs for role switch is
necessary.

--

Best Regards,
Peter Chen