The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: RD Babiera <rdbabiera@google.com>
Cc: linux@roeck-us.net, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	badhri@google.com, bryan.odonoghue@linaro.org, agross@kernel.org,
	andersson@kernel.org, konrad.dybcio@linaro.org
Subject: Re: [PATCH v2 02/12] usb: typec: altmodes: add svdm version info for typec cables
Date: Tue, 19 Dec 2023 15:54:33 +0200	[thread overview]
Message-ID: <ZYGgmTr+7bbrjl1T@kuha.fi.intel.com> (raw)
In-Reply-To: <20231214230850.379863-16-rdbabiera@google.com>

On Thu, Dec 14, 2023 at 11:08:46PM +0000, RD Babiera wrote:
> Add typec_cable_set_svdm_version and typec_get_cable_svdm version symbols.
> Cables can operate under a lower PD revision than the port partner, and the
> max SVDM version is tied to the PD revision. So, typec_cable maintains its
> own svdm_version.
> 
> Add typec_altmode_get_cable_svdm_version to return the cable's negotiated
> svdm_version for altmode drivers to use.
> 
> Signed-off-by: RD Babiera <rdbabiera@google.com>

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

> ---
>  drivers/usb/typec/class.c         | 40 +++++++++++++++++++++++++++++++
>  drivers/usb/typec/class.h         |  1 +
>  include/linux/usb/typec.h         |  3 +++
>  include/linux/usb/typec_altmode.h | 10 ++++++++
>  4 files changed, 54 insertions(+)
> 
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 86b5a8414b89..038c6498e683 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -2129,6 +2129,46 @@ int typec_get_negotiated_svdm_version(struct typec_port *port)
>  }
>  EXPORT_SYMBOL_GPL(typec_get_negotiated_svdm_version);
>  
> +/**
> + * typec_get_cable_svdm_version - Get cable negotiated SVDM Version
> + * @port: USB Type-C Port.
> + *
> + * Get the negotiated SVDM Version for the cable. The Version is set to the port
> + * default value based on the PD Revision during cable registration, and updated
> + * after a successful Discover Identity if the negotiated value is less than the
> + * default.
> + *
> + * Returns usb_pd_svdm_ver if the cable has been registered otherwise -ENODEV.
> + */
> +int typec_get_cable_svdm_version(struct typec_port *port)
> +{
> +	enum usb_pd_svdm_ver svdm_version;
> +	struct device *cable_dev;
> +
> +	cable_dev = device_find_child(&port->dev, NULL, cable_match);
> +	if (!cable_dev)
> +		return -ENODEV;
> +
> +	svdm_version = to_typec_cable(cable_dev)->svdm_version;
> +	put_device(cable_dev);
> +
> +	return svdm_version;
> +}
> +EXPORT_SYMBOL_GPL(typec_get_cable_svdm_version);
> +
> +/**
> + * typec_cable_set_svdm_version - Set negotiated Structured VDM (SVDM) Version
> + * @cable: USB Type-C Active Cable that supports SVDM
> + * @svdm_version: Negotiated SVDM Version
> + *
> + * This routine is used to save the negotiated SVDM Version.
> + */
> +void typec_cable_set_svdm_version(struct typec_cable *cable, enum usb_pd_svdm_ver svdm_version)
> +{
> +	cable->svdm_version = svdm_version;
> +}
> +EXPORT_SYMBOL_GPL(typec_cable_set_svdm_version);
> +
>  /**
>   * typec_get_drvdata - Return private driver data pointer
>   * @port: USB Type-C port
> diff --git a/drivers/usb/typec/class.h b/drivers/usb/typec/class.h
> index c36761ba3f59..759b98355eeb 100644
> --- a/drivers/usb/typec/class.h
> +++ b/drivers/usb/typec/class.h
> @@ -23,6 +23,7 @@ struct typec_cable {
>  	struct usb_pd_identity		*identity;
>  	unsigned int			active:1;
>  	u16				pd_revision; /* 0300H = "3.0" */
> +	enum usb_pd_svdm_ver		svdm_version;
>  };
>  
>  struct typec_partner {
> diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
> index 38f93d72fd1b..b35b427561ab 100644
> --- a/include/linux/usb/typec.h
> +++ b/include/linux/usb/typec.h
> @@ -337,6 +337,9 @@ void typec_partner_set_svdm_version(struct typec_partner *partner,
>  				    enum usb_pd_svdm_ver svdm_version);
>  int typec_get_negotiated_svdm_version(struct typec_port *port);
>  
> +int typec_get_cable_svdm_version(struct typec_port *port);
> +void typec_cable_set_svdm_version(struct typec_cable *cable, enum usb_pd_svdm_ver svdm_version);
> +
>  struct usb_power_delivery *typec_partner_usb_power_delivery_register(struct typec_partner *partner,
>  							struct usb_power_delivery_desc *desc);
>  
> diff --git a/include/linux/usb/typec_altmode.h b/include/linux/usb/typec_altmode.h
> index 72ec8058543a..b3c0866ea70f 100644
> --- a/include/linux/usb/typec_altmode.h
> +++ b/include/linux/usb/typec_altmode.h
> @@ -95,6 +95,16 @@ int typec_cable_altmode_exit(struct typec_altmode *altmode, enum typec_plug_inde
>  int typec_cable_altmode_vdm(struct typec_altmode *altmode, enum typec_plug_index sop,
>  			    const u32 header, const u32 *vdo, int count);
>  
> +/**
> + * typec_altmode_get_cable_svdm_version - Get negotiated SVDM version for cable plug
> + * @altmode: Handle to the alternate mode
> + */
> +static inline int
> +typec_altmode_get_cable_svdm_version(struct typec_altmode *altmode)
> +{
> +	return typec_get_cable_svdm_version(typec_altmode2port(altmode));
> +}
> +
>  /*
>   * These are the connector states (USB, Safe and Alt Mode) defined in USB Type-C
>   * Specification. SVID specific connector states are expected to follow and
> -- 
> 2.43.0.472.g3155946c3a-goog

-- 
heikki

  reply	other threads:[~2023-12-19 13:54 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-14 23:08 [PATCH v2 00/12] usb: typec: add SOP' support to the tcpm and alt mode drivers RD Babiera
2023-12-14 23:08 ` [PATCH v2 01/12] usb: typec: altmodes: add typec_cable_ops to typec_altmode RD Babiera
2023-12-16  2:21   ` kernel test robot
2023-12-17 15:11   ` kernel test robot
2023-12-14 23:08 ` [PATCH v2 02/12] usb: typec: altmodes: add svdm version info for typec cables RD Babiera
2023-12-19 13:54   ` Heikki Krogerus [this message]
2023-12-14 23:08 ` [PATCH v2 03/12] usb: typec: tcpci: add cable_comm_capable attribute RD Babiera
2023-12-19 13:55   ` Heikki Krogerus
2023-12-14 23:08 ` [PATCH v2 04/12] usb: typec: tcpci: add tcpm_transmit_type to tcpm_pd_receive RD Babiera
2023-12-19 13:59   ` Heikki Krogerus
2023-12-14 23:08 ` [PATCH v2 05/12] usb: typec: tcpm: process receive and transmission of sop' messages RD Babiera
2023-12-19 14:07   ` Heikki Krogerus
2024-01-08 19:13     ` RD Babiera
2023-12-14 23:08 ` [PATCH v2 06/12] usb: typec: tcpm: add control message support to sop' RD Babiera
2023-12-19 14:12   ` Heikki Krogerus
2023-12-14 23:08 ` [PATCH v2 07/12] usb: typec: tcpci: add attempt_vconn_swap_discovery callback RD Babiera
2023-12-19 14:17   ` Heikki Krogerus
2023-12-14 23:08 ` [PATCH v2 08/12] usb: typec: tcpm: add discover identity support for SOP' RD Babiera
2023-12-19 14:26   ` Heikki Krogerus
2023-12-14 23:08 ` [PATCH v2 09/12] usb: typec: tcpm: add state machine support for SRC_VDM_IDENTITY_REQUEST RD Babiera
2023-12-19 14:26   ` Heikki Krogerus
2023-12-14 23:08 ` [PATCH v2 10/12] usb: typec: tcpm: add discover svids and discover modes support for sop' RD Babiera
2023-12-19 14:32   ` Heikki Krogerus
2024-01-08 19:02     ` RD Babiera
2023-12-14 23:08 ` [PATCH v2 11/12] usb: typec: tcpm: add alt mode enter/exit/vdm " RD Babiera
2023-12-14 23:08 ` [PATCH v2 12/12] usb: typec: altmodes/displayport: add SOP' support RD Babiera
2024-01-02 14:02   ` Dan Carpenter

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=ZYGgmTr+7bbrjl1T@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.org \
    --cc=badhri@google.com \
    --cc=bryan.odonoghue@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=rdbabiera@google.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