From: Benson Leung <bleung@google.com>
To: Prashant Malani <pmalani@chromium.org>
Cc: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev,
bleung@chromium.org, heikki.krogerus@linux.intel.com,
Daisuke Nojiri <dnojiri@chromium.org>,
"Dustin L. Howett" <dustin@howett.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Guenter Roeck <groeck@chromium.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Lee Jones <lee@kernel.org>,
Tinghan Shen <tinghan.shen@mediatek.com>,
Tzung-Bi Shih <tzungbi@kernel.org>
Subject: Re: [PATCH 2/2] platform/chrome: cros_typec_vdm: Add Attention support
Date: Thu, 26 Jan 2023 13:01:51 -0800 [thread overview]
Message-ID: <Y9LqP72lQpu3Jwmc@google.com> (raw)
In-Reply-To: <20230126205620.3714994-2-pmalani@chromium.org>
[-- Attachment #1: Type: text/plain, Size: 3834 bytes --]
On Thu, Jan 26, 2023 at 08:55:46PM +0000, Prashant Malani wrote:
> Add support to retrieve VDM attention messages and forward them to the
> appropriate alt mode driver.
>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
> ---
> drivers/platform/chrome/cros_ec_typec.c | 8 +++++
> drivers/platform/chrome/cros_typec_vdm.c | 40 ++++++++++++++++++++++++
> drivers/platform/chrome/cros_typec_vdm.h | 1 +
> 3 files changed, 49 insertions(+)
>
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 1abb471840d5..71f5d7d8e055 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -1015,6 +1015,14 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num
> if (ret < 0)
> dev_warn(typec->dev, "Failed VDM Reply event clear, port: %d\n", port_num);
> }
> +
> + if (resp.events & PD_STATUS_EVENT_VDM_ATTENTION) {
> + cros_typec_handle_vdm_attention(typec, port_num);
> + ret = cros_typec_send_clear_event(typec, port_num, PD_STATUS_EVENT_VDM_ATTENTION);
> + if (ret < 0)
> + dev_warn(typec->dev, "Failed VDM Attenetion event clear, port: %d\n",
> + port_num);
> + }
> }
>
> static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)
> diff --git a/drivers/platform/chrome/cros_typec_vdm.c b/drivers/platform/chrome/cros_typec_vdm.c
> index 06f4a55999c5..20515ee0a20e 100644
> --- a/drivers/platform/chrome/cros_typec_vdm.c
> +++ b/drivers/platform/chrome/cros_typec_vdm.c
> @@ -13,6 +13,46 @@
> #include "cros_ec_typec.h"
> #include "cros_typec_vdm.h"
>
> +/*
> + * Retrieves pending VDM attention messages from the EC and forwards them to the altmode driver
> + * based on SVID.
> + */
> +void cros_typec_handle_vdm_attention(struct cros_typec_data *typec, int port_num)
> +{
> + struct ec_response_typec_vdm_response resp;
> + struct ec_params_typec_vdm_response req = {
> + .port = port_num,
> + };
> + struct typec_altmode *amode;
> + u16 svid;
> + u32 hdr;
> + int ret;
> +
> + do {
> + ret = cros_ec_cmd(typec->ec, 0, EC_CMD_TYPEC_VDM_RESPONSE, &req,
> + sizeof(req), &resp, sizeof(resp));
> + if (ret < 0) {
> + dev_warn(typec->dev, "Failed VDM response fetch, port: %d\n", port_num);
> + return;
> + }
> +
> + hdr = resp.vdm_response[0];
> + svid = PD_VDO_VID(hdr);
> + dev_dbg(typec->dev, "Received VDM Attention header: %x, port: %d\n", hdr, port_num);
> +
> + amode = typec_match_altmode(typec->ports[port_num]->port_altmode,
> + CROS_EC_ALTMODE_MAX, svid, PD_VDO_OPOS(hdr));
> + if (!amode) {
> + dev_err(typec->dev,
> + "Received VDM for unregistered altmode (SVID:%x), port: %d\n",
> + svid, port_num);
> + return;
> + }
> +
> + typec_altmode_attention(amode, resp.vdm_attention[1]);
> + } while (resp.vdm_attention_left);
> +}
> +
> /*
> * Retrieves a VDM response from the EC and forwards it to the altmode driver based on SVID.
> */
> diff --git a/drivers/platform/chrome/cros_typec_vdm.h b/drivers/platform/chrome/cros_typec_vdm.h
> index 003587525554..95a6a75d32b6 100644
> --- a/drivers/platform/chrome/cros_typec_vdm.h
> +++ b/drivers/platform/chrome/cros_typec_vdm.h
> @@ -7,6 +7,7 @@
>
> extern struct typec_altmode_ops port_amode_ops;
>
> +void cros_typec_handle_vdm_attention(struct cros_typec_data *typec, int port_num);
> void cros_typec_handle_vdm_response(struct cros_typec_data *typec, int port_num);
>
> #endif /* __CROS_TYPEC_VDM__ */
> --
> 2.39.1.456.gfc5497dd1b-goog
>
>
--
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
bleung@google.com
Chromium OS Project
bleung@chromium.org
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2023-01-26 21:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-26 20:55 [PATCH 1/2] platform/chrome: cros_ec: Add VDM attention headers Prashant Malani
2023-01-26 20:55 ` [PATCH 2/2] platform/chrome: cros_typec_vdm: Add Attention support Prashant Malani
2023-01-26 21:01 ` Benson Leung [this message]
2023-01-27 15:11 ` Heikki Krogerus
2023-01-26 21:00 ` [PATCH 1/2] platform/chrome: cros_ec: Add VDM attention headers Benson Leung
2023-01-31 3:19 ` Tzung-Bi Shih
2023-01-31 18:21 ` Prashant Malani
2023-01-31 18:20 ` patchwork-bot+chrome-platform
2023-02-07 0:10 ` patchwork-bot+chrome-platform
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=Y9LqP72lQpu3Jwmc@google.com \
--to=bleung@google.com \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=dnojiri@chromium.org \
--cc=dustin@howett.net \
--cc=gregkh@linuxfoundation.org \
--cc=groeck@chromium.org \
--cc=gustavoars@kernel.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmalani@chromium.org \
--cc=tinghan.shen@mediatek.com \
--cc=tzungbi@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.