* [PATCH v2 1/2] platform/chrome: cros_ec: Import Type C control command
@ 2021-02-03 2:15 Prashant Malani
2021-02-03 2:15 ` [PATCH v2 2/2] platform/chrome: cros_ec_typec: Clear Type C disc events Prashant Malani
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Prashant Malani @ 2021-02-03 2:15 UTC (permalink / raw)
To: linux-kernel
Cc: bleung, Prashant Malani, Enric Balletbo i Serra, Guenter Roeck,
Gustavo A. R. Silva, Mark Brown, Pi-Hsun Shih, Utkarsh Patel
This command is used to communicate with the Chrome Embedded Controller
(EC) regarding USB Type C events and state.
These header updates are included in the latest Chrome OS EC headers [1]
[1]
https://chromium.googlesource.com/chromiumos/platform/ec/+/refs/heads/main/include/ec_commands.h
Signed-off-by: Prashant Malani <pmalani@chromium.org>
---
Changes in v2:
- Fixed new line errors.
.../linux/platform_data/cros_ec_commands.h | 26 +++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/include/linux/platform_data/cros_ec_commands.h b/include/linux/platform_data/cros_ec_commands.h
index d3c40220b281..5a967c9f8aca 100644
--- a/include/linux/platform_data/cros_ec_commands.h
+++ b/include/linux/platform_data/cros_ec_commands.h
@@ -5578,6 +5578,32 @@ struct ec_response_typec_discovery {
struct svid_mode_info svids[0];
} __ec_align1;
+/* USB Type-C commands for AP-controlled device policy. */
+#define EC_CMD_TYPEC_CONTROL 0x0132
+
+enum typec_control_command {
+ TYPEC_CONTROL_COMMAND_EXIT_MODES,
+ TYPEC_CONTROL_COMMAND_CLEAR_EVENTS,
+ TYPEC_CONTROL_COMMAND_ENTER_MODE,
+};
+
+struct ec_params_typec_control {
+ uint8_t port;
+ uint8_t command; /* enum typec_control_command */
+ uint16_t reserved;
+
+ /*
+ * This section will be interpreted based on |command|. Define a
+ * placeholder structure to avoid having to increase the size and bump
+ * the command version when adding new sub-commands.
+ */
+ union {
+ uint32_t clear_events_mask;
+ uint8_t mode_to_enter; /* enum typec_mode */
+ uint8_t placeholder[128];
+ };
+} __ec_align1;
+
/*
* Gather all status information for a port.
*
--
2.30.0.365.g02bc693789-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] platform/chrome: cros_ec_typec: Clear Type C disc events
2021-02-03 2:15 [PATCH v2 1/2] platform/chrome: cros_ec: Import Type C control command Prashant Malani
@ 2021-02-03 2:15 ` Prashant Malani
2021-02-04 7:18 ` [PATCH v2 1/2] platform/chrome: cros_ec: Import Type C control command Benson Leung
2021-02-04 18:37 ` Benson Leung
2 siblings, 0 replies; 5+ messages in thread
From: Prashant Malani @ 2021-02-03 2:15 UTC (permalink / raw)
To: linux-kernel
Cc: bleung, Prashant Malani, Enric Balletbo i Serra, Guenter Roeck,
Gustavo A. R. Silva, Mark Brown, Pi-Hsun Shih, Utkarsh Patel
Clear USB Type C discovery events from the Chrome EC once they've been
successfully handled.
Signed-off-by: Prashant Malani <pmalani@chromium.org>
---
Changes in v2:
- No changes.
drivers/platform/chrome/cros_ec_typec.c | 28 +++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index e724a5eaef1c..f3bdb87d6dce 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -867,6 +867,18 @@ static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_nu
return ret;
}
+static int cros_typec_send_clear_event(struct cros_typec_data *typec, int port_num, u32 events_mask)
+{
+ struct ec_params_typec_control req = {
+ .port = port_num,
+ .command = TYPEC_CONTROL_COMMAND_CLEAR_EVENTS,
+ .clear_events_mask = events_mask,
+ };
+
+ return cros_typec_ec_command(typec, 0, EC_CMD_TYPEC_CONTROL, &req,
+ sizeof(req), NULL, 0);
+}
+
static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num)
{
struct ec_response_typec_status resp;
@@ -887,8 +899,14 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num
ret = cros_typec_handle_sop_disc(typec, port_num);
if (ret < 0)
dev_err(typec->dev, "Couldn't parse SOP Disc data, port: %d\n", port_num);
- else
+ else {
typec->ports[port_num]->sop_disc_done = true;
+ ret = cros_typec_send_clear_event(typec, port_num,
+ PD_STATUS_EVENT_SOP_DISC_DONE);
+ if (ret < 0)
+ dev_warn(typec->dev,
+ "Failed SOP Disc event clear, port: %d\n", port_num);
+ }
}
if (resp.events & PD_STATUS_EVENT_SOP_PRIME_DISC_DONE &&
@@ -896,8 +914,14 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num
ret = cros_typec_handle_sop_prime_disc(typec, port_num);
if (ret < 0)
dev_err(typec->dev, "Couldn't parse SOP' Disc data, port: %d\n", port_num);
- else
+ else {
typec->ports[port_num]->sop_prime_disc_done = true;
+ ret = cros_typec_send_clear_event(typec, port_num,
+ PD_STATUS_EVENT_SOP_PRIME_DISC_DONE);
+ if (ret < 0)
+ dev_warn(typec->dev,
+ "Failed SOP Disc event clear, port: %d\n", port_num);
+ }
}
}
--
2.30.0.365.g02bc693789-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] platform/chrome: cros_ec: Import Type C control command
2021-02-03 2:15 [PATCH v2 1/2] platform/chrome: cros_ec: Import Type C control command Prashant Malani
2021-02-03 2:15 ` [PATCH v2 2/2] platform/chrome: cros_ec_typec: Clear Type C disc events Prashant Malani
@ 2021-02-04 7:18 ` Benson Leung
2021-02-04 9:16 ` Prashant Malani
2021-02-04 18:37 ` Benson Leung
2 siblings, 1 reply; 5+ messages in thread
From: Benson Leung @ 2021-02-04 7:18 UTC (permalink / raw)
To: linux-kernel, Prashant Malani
Cc: Pi-Hsun Shih, Gustavo A. R. Silva, Utkarsh Patel,
Enric Balletbo i Serra, Guenter Roeck, Mark Brown, bleung
[-- Attachment #1: Type: text/plain, Size: 802 bytes --]
Hi Prashant,
On Tue, 2 Feb 2021 18:15:37 -0800, Prashant Malani wrote:
> This command is used to communicate with the Chrome Embedded Controller
> (EC) regarding USB Type C events and state.
>
> These header updates are included in the latest Chrome OS EC headers [1]
>
> [1]
> https://chromium.googlesource.com/chromiumos/platform/ec/+/refs/heads/main/include/ec_commands.h
Applied, thanks!
[1/2] platform/chrome: cros_ec: Import Type C control command
commit: 3ec28d3673362076444e290bdb0d94ec6432dc09
[2/2] platform/chrome: cros_ec_typec: Clear Type C disc events
commit: d521119c8b0d70b91971d632430ec1143e5d2e26
Best regards,
--
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 --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] platform/chrome: cros_ec: Import Type C control command
2021-02-04 7:18 ` [PATCH v2 1/2] platform/chrome: cros_ec: Import Type C control command Benson Leung
@ 2021-02-04 9:16 ` Prashant Malani
0 siblings, 0 replies; 5+ messages in thread
From: Prashant Malani @ 2021-02-04 9:16 UTC (permalink / raw)
To: Benson Leung
Cc: Linux Kernel Mailing List, Pi-Hsun Shih, Gustavo A. R. Silva,
Utkarsh Patel, Enric Balletbo i Serra, Guenter Roeck, Mark Brown,
Benson Leung
Thanks Benson,
On Wed, Feb 3, 2021 at 11:18 PM Benson Leung <bleung@google.com> wrote:
>
> Hi Prashant,
>
> On Tue, 2 Feb 2021 18:15:37 -0800, Prashant Malani wrote:
> > This command is used to communicate with the Chrome Embedded Controller
> > (EC) regarding USB Type C events and state.
> >
> > These header updates are included in the latest Chrome OS EC headers [1]
> >
> > [1]
> > https://chromium.googlesource.com/chromiumos/platform/ec/+/refs/heads/main/include/ec_commands.h
>
> Applied, thanks!
>
> [1/2] platform/chrome: cros_ec: Import Type C control command
> commit: 3ec28d3673362076444e290bdb0d94ec6432dc09
> [2/2] platform/chrome: cros_ec_typec: Clear Type C disc events
> commit: d521119c8b0d70b91971d632430ec1143e5d2e26
This (patch 2/2) now looks like it will lead to a conflict with the
following patch which went into Greg's usb tree:
cefc011f8daf ("platform/chrome: cros_ec_typec: Set Partner PD revision
from status")
If we want to submit stuff to for-next, perhaps the immutable branch
should be merged into for-next?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] platform/chrome: cros_ec: Import Type C control command
2021-02-03 2:15 [PATCH v2 1/2] platform/chrome: cros_ec: Import Type C control command Prashant Malani
2021-02-03 2:15 ` [PATCH v2 2/2] platform/chrome: cros_ec_typec: Clear Type C disc events Prashant Malani
2021-02-04 7:18 ` [PATCH v2 1/2] platform/chrome: cros_ec: Import Type C control command Benson Leung
@ 2021-02-04 18:37 ` Benson Leung
2 siblings, 0 replies; 5+ messages in thread
From: Benson Leung @ 2021-02-04 18:37 UTC (permalink / raw)
To: Prashant Malani, linux-kernel
Cc: Enric Balletbo i Serra, Pi-Hsun Shih, Guenter Roeck, Mark Brown,
Gustavo A. R. Silva, Utkarsh Patel
[-- Attachment #1: Type: text/plain, Size: 1134 bytes --]
Hi Prashant,
On Tue, 2 Feb 2021 18:15:37 -0800, Prashant Malani wrote:
> This command is used to communicate with the Chrome Embedded Controller
> (EC) regarding USB Type C events and state.
>
> These header updates are included in the latest Chrome OS EC headers [1]
>
> [1]
> https://chromium.googlesource.com/chromiumos/platform/ec/+/refs/heads/main/include/ec_commands.h
Applied, thanks!
[1/2] platform/chrome: cros_ec: Import Type C control command
commit: b64afd949ee3a61e180813859b50aced26023c55
[2/2] platform/chrome: cros_ec_typec: Clear Type C disc events
commit: c8ec21c6d25c2a8895614ea38575dadb8570c2f9
I rebased these changes so that it clears a merge conflict with changes in
greg's usb-next branch.
These two are in the chrome-platform repo as:
https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git/log/?h=cros_ec_typec-clear-pd-discovery-events-after-handled
I will send a PR to Greg for these too.
Best regards,
--
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 --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-02-04 19:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 2:15 [PATCH v2 1/2] platform/chrome: cros_ec: Import Type C control command Prashant Malani
2021-02-03 2:15 ` [PATCH v2 2/2] platform/chrome: cros_ec_typec: Clear Type C disc events Prashant Malani
2021-02-04 7:18 ` [PATCH v2 1/2] platform/chrome: cros_ec: Import Type C control command Benson Leung
2021-02-04 9:16 ` Prashant Malani
2021-02-04 18:37 ` Benson Leung
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).