linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
Cc: gregkh@linuxfoundation.org, pmalani@chromium.org,
	jthies@google.com, neil.armstrong@linaro.org,
	abhishekpandit@chromium.org, fabrice.gasnier@foss.st.com,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: typec: ucsi: Only enable supported notifications
Date: Tue, 2 Apr 2024 13:10:16 +0300	[thread overview]
Message-ID: <ZgvZiOSbT3c8gibQ@kuha.fi.intel.com> (raw)
In-Reply-To: <yhz7nq622mbg3rqsyvqz632pc756niagpfbnzayfswhzo7esho@vrdtx5c3hjgx>

On Wed, Mar 27, 2024 at 12:11:42PM +0000, Diogo Ivo wrote:
> The UCSI specification defines some notifications to be optional for the
> PPM to support. From these only enable the ones the PPM informs us are
> actually supported.
> 
> Signed-off-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>

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

> ---
>  drivers/usb/typec/ucsi/ucsi.c | 25 +++++++++++++++++++++++--
>  1 file changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index cf52cb34d285..0c8f3b3a99d6 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -1626,6 +1626,27 @@ static int ucsi_register_port(struct ucsi *ucsi, struct ucsi_connector *con)
>  	return ret;
>  }
>  
> +static u64 ucsi_get_supported_notifications(struct ucsi *ucsi)
> +{
> +	u8 features = ucsi->cap.features;
> +	u64 ntfy = UCSI_ENABLE_NTFY_ALL;
> +
> +	if (!(features & UCSI_CAP_ALT_MODE_DETAILS))
> +		ntfy &= ~UCSI_ENABLE_NTFY_CAM_CHANGE;
> +
> +	if (!(features & UCSI_CAP_PDO_DETAILS))
> +		ntfy &= ~(UCSI_ENABLE_NTFY_PWR_LEVEL_CHANGE |
> +			  UCSI_ENABLE_NTFY_CAP_CHANGE);
> +
> +	if (!(features & UCSI_CAP_EXT_SUPPLY_NOTIFICATIONS))
> +		ntfy &= ~UCSI_ENABLE_NTFY_EXT_PWR_SRC_CHANGE;
> +
> +	if (!(features & UCSI_CAP_PD_RESET))
> +		ntfy &= ~UCSI_ENABLE_NTFY_PD_RESET_COMPLETE;
> +
> +	return ntfy;
> +}
> +
>  /**
>   * ucsi_init - Initialize UCSI interface
>   * @ucsi: UCSI to be initialized
> @@ -1679,8 +1700,8 @@ static int ucsi_init(struct ucsi *ucsi)
>  			goto err_unregister;
>  	}
>  
> -	/* Enable all notifications */
> -	ntfy = UCSI_ENABLE_NTFY_ALL;
> +	/* Enable all supported notifications */
> +	ntfy = ucsi_get_supported_notifications(ucsi);
>  	command = UCSI_SET_NOTIFICATION_ENABLE | ntfy;
>  	ret = ucsi_send_command(ucsi, command, NULL, 0);
>  	if (ret < 0)
> -- 
> 2.44.0

-- 
heikki

      reply	other threads:[~2024-04-02 10:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-27 12:11 [PATCH] usb: typec: ucsi: Only enable supported notifications Diogo Ivo
2024-04-02 10:10 ` Heikki Krogerus [this message]

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=ZgvZiOSbT3c8gibQ@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=abhishekpandit@chromium.org \
    --cc=diogo.ivo@tecnico.ulisboa.pt \
    --cc=fabrice.gasnier@foss.st.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jthies@google.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=neil.armstrong@linaro.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;
as well as URLs for NNTP newsgroup(s).