All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Mats Karrman <mats.dev.list@gmail.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Rob Herring <robh+dt@kernel.org>,
	linux-usb@vger.kernel.org
Subject: [RFC,1/7] usb: typec: Generalize mux mode names
Date: Wed, 2 May 2018 11:23:35 +0300	[thread overview]
Message-ID: <20180502082335.GF12870@kuha.fi.intel.com> (raw)

Hi Mats,

On Wed, May 02, 2018 at 12:21:07AM +0200, Mats Karrman wrote:
> The current naming used for tcpc_mux_mode constants makes
> too much assumptioms about the usage of the signals.
> This patch replaces the names with generic names more closely
> tied to the Type-C specifications and also adds some new ones.
> At the same time TCPC_MUX_* defines are removed as they do not
> fit the new concept and currently have no in-tree users.

I'm afraid trying to generalize the modal connector states even like
this is not going to work. We can't make any assumptions about how the
alternate modes configure the pins, or the connector in general.

The only way this will work is that every alternate mode has its own
configurations defined separately, and I'm talking about the actual
pin configurations that the specifications for each alternate mode
defines, so something like TYPEC_MUX_DP and TYPEC_MUX_DOCK will not
work for sure.

The connector states that are defined in USB Type-C specification (so
basically USB Operation and USB Safe State) can be generalized, but
those states just should not be defined in tcpm.h. We need to use
them in other drivers as well.

I'm in the middle of preparing more complete support for alternate
modes. If you check the RFC [1] I send previously, in the first patch
of the series I'm adding documentation that should explain the
plan.

> Signed-off-by: Mats Karrman <mats.dev.list@gmail.com>
> ---
>  drivers/usb/typec/mux/pi3usb30532.c |  7 ++++---
>  drivers/usb/typec/tcpm.c            |  2 +-
>  include/linux/usb/tcpm.h            | 21 ++++++++++-----------
>  3 files changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/usb/typec/mux/pi3usb30532.c b/drivers/usb/typec/mux/pi3usb30532.c
> index b0e88db..279f3c3 100644
> --- a/drivers/usb/typec/mux/pi3usb30532.c
> +++ b/drivers/usb/typec/mux/pi3usb30532.c
> @@ -83,18 +83,19 @@ static int pi3usb30532_mux_set(struct typec_mux *mux, int state)
>  	new_conf = pi->conf;
>  
>  	switch (state) {
> +	default:
>  	case TYPEC_MUX_NONE:
>  		new_conf = PI3USB30532_CONF_OPEN;
>  		break;
> -	case TYPEC_MUX_USB:
> +	case TYPEC_MUX_2CH_USBSS:
>  		new_conf = (new_conf & PI3USB30532_CONF_SWAP) |
>  			   PI3USB30532_CONF_USB3;
>  		break;
> -	case TYPEC_MUX_DP:
> +	case TYPEC_MUX_4CH_AM:
>  		new_conf = (new_conf & PI3USB30532_CONF_SWAP) |
>  			   PI3USB30532_CONF_4LANE_DP;
>  		break;
> -	case TYPEC_MUX_DOCK:
> +	case TYPEC_MUX_2CH_USBSS_2CH_AM:
>  		new_conf = (new_conf & PI3USB30532_CONF_SWAP) |
>  			   PI3USB30532_CONF_USB3_AND_2LANE_DP;
>  		break;
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index 7ee417a..0451ea0 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -790,7 +790,7 @@ static int tcpm_set_roles(struct tcpm_port *port, bool attached,
>  	else
>  		usb_role = USB_ROLE_DEVICE;
>  
> -	ret = tcpm_mux_set(port, TYPEC_MUX_USB, usb_role, orientation);
> +	ret = tcpm_mux_set(port, TYPEC_MUX_2CH_USBSS, usb_role, orientation);
>  	if (ret < 0)
>  		return ret;
>  
> diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
> index b231b93..3518965 100644
> --- a/include/linux/usb/tcpm.h
> +++ b/include/linux/usb/tcpm.h
> @@ -93,20 +93,19 @@ struct tcpc_config {
>  	const struct typec_altmode_desc *alt_modes;
>  };
>  
> -/* Mux state attributes */
> -#define TCPC_MUX_USB_ENABLED		BIT(0)	/* USB enabled */
> -#define TCPC_MUX_DP_ENABLED		BIT(1)	/* DP enabled */
> -#define TCPC_MUX_POLARITY_INVERTED	BIT(2)	/* Polarity inverted */
> -
> -/* Mux modes, decoded to attributes */
> +/* Mux modes */
>  enum tcpc_mux_mode {
> -	TYPEC_MUX_NONE	= 0,				/* Open switch */
> -	TYPEC_MUX_USB	= TCPC_MUX_USB_ENABLED,		/* USB only */
> -	TYPEC_MUX_DP	= TCPC_MUX_DP_ENABLED,		/* DP only */
> -	TYPEC_MUX_DOCK	= TCPC_MUX_USB_ENABLED |	/* Both USB and DP */
> -			  TCPC_MUX_DP_ENABLED,
> +	TYPEC_MUX_NONE,				/* Open switch */
> +	TYPEC_MUX_2CH_USBSS,			/* 2ch USB SS */
> +	TYPEC_MUX_4CH_AM,			/* 4ch Alt Mode */
> +	TYPEC_MUX_2CH_USBSS_2CH_AM,		/* 2ch USB SS + 2ch Alt Mode */
> +
> +	// Example of additional modes that may be needed in future:
> +	TYPEC_MUX_4CH_USBSS,			/* 4ch USB SS */
> +	TYPEC_MUX_2CH_USBSS_2CH_AM_B,		/* 2ch USB SS + 2ch Alt Mode (e.g. DP GPU2) */
>  };
>  
> +
>  /**
>   * struct tcpc_dev - Port configuration and callback functions
>   * @config:	Pointer to port configuration


Thanks,

             reply	other threads:[~2018-05-02  8:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-02  8:23 Heikki Krogerus [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-05-21 13:04 [RFC,1/7] usb: typec: Generalize mux mode names Heikki Krogerus
2018-05-18  5:26 Mats Karrman
2018-05-17 11:50 Heikki Krogerus
2018-05-16 21:11 Mats Karrman
2018-05-16 11:43 Heikki Krogerus
2018-05-15 21:24 Mats Karrman
2018-05-15  7:30 Heikki Krogerus
2018-05-11 19:28 Mats Karrman
2018-05-09 12:49 Heikki Krogerus
2018-05-08 19:10 Mats Karrman
2018-05-08 14:25 Heikki Krogerus
2018-05-07 21:19 Mats Karrman
2018-05-07 13:39 Heikki Krogerus
2018-05-04 16:57 Mats Karrman
2018-05-04 14:56 Heikki Krogerus
2018-05-02 13:13 Mats Karrman
2018-05-02  8:25 Heikki Krogerus
2018-05-01 22:21 Mats Karrman

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=20180502082335.GF12870@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mats.dev.list@gmail.com \
    --cc=robh+dt@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.