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

Jun Li
2016-06-08T06:20:25Z

Hi, Baolu

From: Lu Baolu [mailto:baolu.lu@linux.intel.com]
Sent: Wednesday, June 08, 2016 1:11 PM
To: Jun Li <jun.li@nxp.com>; Felipe Balbi <felipe.balbi@linux.intel.com>; Roger Quadros <rogerq@ti.com>; Peter Chen <hzpeterchen@gmail.com>
Cc: Mathias Nyman <mathias.nyman@intel.com>; Greg Kroah-Hartman <gregkh@linuxfoundation.org>; Lee Jones <lee.jones@linaro.org>; Heikki Krogerus <heikki.krogerus@linux.intel.com>; Liam Girdwood <lgirdwood@gmail.com>; Mark Brown <broonie@kernel.org>; linux-usb@vger.kernel.org; linux-kernel@vger.kernel.org
Subject: Re: [PATCH v10 2/7] usb: mux: add generic code for dual role port mux

Hi,

[I have to resend my reply. The previous reply was failed to deliver
to usb mailing list. Sorry for inconvenience.]
On 06/08/2016 11:04 AM, Jun Li wrote:
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.
> In many cases the role decision is made by usersapce, this also should be
> covered.
> This patchset also expose it to userspace but I think it isn't for debug:
> /sys/bus/platform/devices/.../portmux.N/state

> Please don't use this interface for host/gadget role switch, and the
> document doesn't tell you to do so as well. This is only designed to
> put the port mux device to a right direction. Host/gadget dual
> role switch includes other elements, like ID pin detection, type-c
> events, VBUS management and so on.

Confused, then what's the purpose of it? How to use it?
Below is all about it in document, it's seems telling me can do that,
but you say no:)

+What: /sys/bus/platform/devices/.../portmux.N/name
+ /sys/bus/platform/devices/.../portmux.N/state
+Date: April 2016
+Contact: Lu Baolu <baolu.lu@linux.intel.com>
+Description:
+ In some platforms, a single USB port is shared between a USB host
+ controller and a device controller. A USB mux driver is needed to
+ handle the port mux. Read-only attribute "name" shows the name of
+ the port mux device. "state" attribute shows and stores the mux
+ state.
+ For read:
+ 'unknown' - the mux hasn't been set yet;
+ 'peripheral' - mux has been switched to PERIPHERAL controller;
+ 'host' - mux has been switched to HOST controller.
+ For write:
+ 'peripheral' - mux will be switched to PERIPHERAL controller;
+ 'host' - mux will be switched to HOST controller.

> Best regards,
> Lu Baolu