mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Prashant Malani <pmalani@chromium.org>
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	gregkh@linuxfoundation.org, enric.balletbo@collabora.com,
	Benson Leung <bleung@chromium.org>,
	Guenter Roeck <groeck@chromium.org>
Subject: Re: [PATCH v3 10/11] platform/chrome: cros_ec_typec: Register SOP' cable plug
Date: Tue, 17 Nov 2020 14:45:10 +0200	[thread overview]
Message-ID: <20201117124510.GJ3437448@kuha.fi.intel.com> (raw)
In-Reply-To: <20201116201150.2919178-11-pmalani@chromium.org>

On Mon, Nov 16, 2020 at 12:11:56PM -0800, Prashant Malani wrote:
> In order to register cable alternate modes, we need to first register a
> plug object. Use the Type C connector class framework to register a SOP'
> plug for this purpose.
> 
> Since a cable and plug go hand in hand, we can handle the registration
> and removal together.
> 
> Signed-off-by: Prashant Malani <pmalani@chromium.org>

FWIW:

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
> 
> Changes in v3:
> - Re-arranged patch order and combined it with related series of
>   patches.
> 
> No version v2.
> 
>  drivers/platform/chrome/cros_ec_typec.c | 35 ++++++++++++++++++-------
>  1 file changed, 26 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index ad5e37bfd45d..d2e154ae2362 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -45,6 +45,8 @@ struct cros_typec_port {
>  	struct typec_capability caps;
>  	struct typec_partner *partner;
>  	struct typec_cable *cable;
> +	/* SOP' plug. */
> +	struct typec_plug *plug;
>  	/* Port partner PD identity info. */
>  	struct usb_pd_identity p_identity;
>  	/* Port cable PD identity info. */
> @@ -222,6 +224,8 @@ static void cros_typec_remove_cable(struct cros_typec_data *typec,
>  {
>  	struct cros_typec_port *port = typec->ports[port_num];
>  
> +	typec_unregister_plug(port->plug);
> +	port->plug = NULL;
>  	typec_unregister_cable(port->cable);
>  	port->cable = NULL;
>  	memset(&port->c_identity, 0, sizeof(port->c_identity));
> @@ -712,7 +716,8 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p
>  {
>  	struct cros_typec_port *port = typec->ports[port_num];
>  	struct ec_response_typec_discovery *disc = port->disc_data;
> -	struct typec_cable_desc desc = {};
> +	struct typec_cable_desc c_desc = {};
> +	struct typec_plug_desc p_desc;
>  	struct ec_params_typec_discovery req = {
>  		.port = port_num,
>  		.partner_type = TYPEC_PARTNER_SOP_PRIME,
> @@ -735,32 +740,44 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p
>  		cable_plug_type = VDO_TYPEC_CABLE_TYPE(port->c_identity.vdo[0]);
>  		switch (cable_plug_type) {
>  		case CABLE_ATYPE:
> -			desc.type = USB_PLUG_TYPE_A;
> +			c_desc.type = USB_PLUG_TYPE_A;
>  			break;
>  		case CABLE_BTYPE:
> -			desc.type = USB_PLUG_TYPE_B;
> +			c_desc.type = USB_PLUG_TYPE_B;
>  			break;
>  		case CABLE_CTYPE:
> -			desc.type = USB_PLUG_TYPE_C;
> +			c_desc.type = USB_PLUG_TYPE_C;
>  			break;
>  		case CABLE_CAPTIVE:
> -			desc.type = USB_PLUG_CAPTIVE;
> +			c_desc.type = USB_PLUG_CAPTIVE;
>  			break;
>  		default:
> -			desc.type = USB_PLUG_NONE;
> +			c_desc.type = USB_PLUG_NONE;
>  		}
> -		desc.active = PD_IDH_PTYPE(port->c_identity.id_header) == IDH_PTYPE_ACABLE;
> +		c_desc.active = PD_IDH_PTYPE(port->c_identity.id_header) == IDH_PTYPE_ACABLE;
>  	}
>  
> -	desc.identity = &port->c_identity;
> +	c_desc.identity = &port->c_identity;
>  
> -	port->cable = typec_register_cable(port->port, &desc);
> +	port->cable = typec_register_cable(port->port, &c_desc);
>  	if (IS_ERR(port->cable)) {
>  		ret = PTR_ERR(port->cable);
>  		port->cable = NULL;
> +		goto sop_prime_disc_exit;
> +	}
> +
> +	p_desc.index = TYPEC_PLUG_SOP_P;
> +	port->plug = typec_register_plug(port->cable, &p_desc);
> +	if (IS_ERR(port->plug)) {
> +		ret = PTR_ERR(port->plug);
> +		port->plug = NULL;
> +		goto sop_prime_disc_exit;
>  	}
>  
> +	return 0;
> +
>  sop_prime_disc_exit:
> +	cros_typec_remove_cable(typec, port_num);
>  	return ret;
>  }
>  
> -- 
> 2.29.2.299.gdc1121823c-goog

-- 
heikki

  reply	other threads:[~2020-11-17 12:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-16 20:11 [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and plug altmodes Prashant Malani
2020-11-16 20:11 ` [PATCH v3 01/11] usb: pd: Add captive Type C cable type Prashant Malani
2020-11-16 20:11 ` [PATCH v3 02/11] usb: typec: Add number of altmodes partner attr Prashant Malani
2020-11-16 20:11 ` [PATCH v3 03/11] usb: typec: Add plug num_altmodes sysfs attr Prashant Malani
2020-11-17 12:41   ` Heikki Krogerus
2020-11-17 17:40     ` Prashant Malani
2020-11-18 12:04       ` Heikki Krogerus
2020-11-16 20:11 ` [PATCH v3 04/11] platform/chrome: cros_ec_typec: Make disc_done flag partner-only Prashant Malani
2020-11-16 20:11 ` [PATCH v3 05/11] platform/chrome: cros_ec_typec: Factor out PD identity parsing Prashant Malani
2020-11-16 20:11 ` [PATCH v3 06/11] platform/chrome: cros_ec_typec: Rename discovery struct Prashant Malani
2020-11-16 20:11 ` [PATCH v3 07/11] platform/chrome: cros_ec_typec: Register cable Prashant Malani
2020-11-16 20:11 ` [PATCH v3 08/11] platform/chrome: cros_ec_typec: Store cable plug type Prashant Malani
2020-11-16 20:11 ` [PATCH v3 09/11] platform/chrome: cros_ec_typec: Set partner num_altmodes Prashant Malani
2020-11-16 20:11 ` [PATCH v3 10/11] platform/chrome: cros_ec_typec: Register SOP' cable plug Prashant Malani
2020-11-17 12:45   ` Heikki Krogerus [this message]
2020-11-16 20:11 ` [PATCH v3 11/11] platform/chrome: cros_ec_typec: Register plug altmodes Prashant Malani
2020-11-17 13:09   ` Heikki Krogerus
2020-11-18 11:59 ` [PATCH v3 00/11] chrome/platform: cros_ec_typec: Register cables, partner altmodes and " Greg KH
2020-11-18 12:16   ` Greg KH
2020-11-19  3:56     ` Prashant Malani
2021-01-05 19:26 ` Benson Leung

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=20201117124510.GJ3437448@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=bleung@chromium.org \
    --cc=enric.balletbo@collabora.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=groeck@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pmalani@chromium.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®