From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: RD Babiera <rdbabiera@google.com>
Cc: gregkh@linuxfoundation.org, badhri@google.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] usb: typec: class: add typec_get_data_role symbol
Date: Wed, 8 Oct 2025 13:32:26 +0300 [thread overview]
Message-ID: <aOY9uk3waQH8wJKr@kuha.fi.intel.com> (raw)
In-Reply-To: <20250923181606.1583584-5-rdbabiera@google.com>
On Tue, Sep 23, 2025 at 06:16:07PM +0000, RD Babiera wrote:
> Alt Mode drivers are responsible for sending Enter Mode through the TCPM,
> but only a DFP is allowed to send Enter Mode. typec_get_data_role gets
> the port's data role, which can then be used in altmode drivers via
> typec_altmode_get_data_role to know if Enter Mode should be sent.
>
> Signed-off-by: RD Babiera <rdbabiera@google.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> Changes from v1:
> * changed typec_altmode_get_data_role documentation format
> ---
> drivers/usb/typec/class.c | 13 +++++++++++++
> include/linux/usb/typec.h | 1 +
> include/linux/usb/typec_altmode.h | 13 +++++++++++++
> 3 files changed, 27 insertions(+)
>
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 67a533e35150..9b2647cb199b 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -2120,6 +2120,19 @@ void typec_set_data_role(struct typec_port *port, enum typec_data_role role)
> }
> EXPORT_SYMBOL_GPL(typec_set_data_role);
>
> +/**
> + * typec_get_data_role - Get port data role
> + * @port: The USB Type-C Port to query
> + *
> + * This routine is used by the altmode drivers to determine if the port is the
> + * DFP before issuing Enter Mode
> + */
> +enum typec_data_role typec_get_data_role(struct typec_port *port)
> +{
> + return port->data_role;
> +}
> +EXPORT_SYMBOL_GPL(typec_get_data_role);
> +
> /**
> * typec_set_pwr_role - Report power role change
> * @port: The USB Type-C Port where the role was changed
> diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
> index 252af3f77039..309251572e2e 100644
> --- a/include/linux/usb/typec.h
> +++ b/include/linux/usb/typec.h
> @@ -337,6 +337,7 @@ struct typec_plug *typec_register_plug(struct typec_cable *cable,
> void typec_unregister_plug(struct typec_plug *plug);
>
> void typec_set_data_role(struct typec_port *port, enum typec_data_role role);
> +enum typec_data_role typec_get_data_role(struct typec_port *port);
> void typec_set_pwr_role(struct typec_port *port, enum typec_role role);
> void typec_set_vconn_role(struct typec_port *port, enum typec_role role);
> void typec_set_pwr_opmode(struct typec_port *port, enum typec_pwr_opmode mode);
> diff --git a/include/linux/usb/typec_altmode.h b/include/linux/usb/typec_altmode.h
> index b3c0866ea70f..f7db3bd4c90e 100644
> --- a/include/linux/usb/typec_altmode.h
> +++ b/include/linux/usb/typec_altmode.h
> @@ -172,6 +172,19 @@ typec_altmode_get_svdm_version(struct typec_altmode *altmode)
> return typec_get_negotiated_svdm_version(typec_altmode2port(altmode));
> }
>
> +/**
> + * typec_altmode_get_data_role - Get port data role
> + * @altmode: Handle to the alternate mode
> + *
> + * Alt Mode drivers should only issue Enter Mode through the port if they are
> + * the DFP.
> + */
> +static inline enum typec_data_role
> +typec_altmode_get_data_role(struct typec_altmode *altmode)
> +{
> + return typec_get_data_role(typec_altmode2port(altmode));
> +}
> +
> /**
> * struct typec_altmode_driver - USB Type-C alternate mode device driver
> * @id_table: Null terminated array of SVIDs
> --
> 2.51.0.534.gc79095c0ca-goog
--
heikki
next prev parent reply other threads:[~2025-10-08 10:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 18:16 [PATCH v2 0/2] usb: typec: altmodes/displayport: add port data role handling support RD Babiera
2025-09-23 18:16 ` [PATCH v2 1/2] usb: typec: class: add typec_get_data_role symbol RD Babiera
2025-10-08 10:32 ` Heikki Krogerus [this message]
2025-09-23 18:16 ` [PATCH v2 2/2] usb: typec: altmodes/displayport: do not enter mode if port is the UFP RD Babiera
2025-10-08 10:33 ` Heikki Krogerus
2026-01-10 7:53 ` Andy Yan
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=aOY9uk3waQH8wJKr@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=badhri@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--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