From: Andrei Kuchynski <akuchynski@chromium.org>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Abhishek Pandit-Subedi <abhishekpandit@chromium.org>,
Benson Leung <bleung@chromium.org>,
Jameson Thies <jthies@google.com>,
Tzung-Bi Shih <tzungbi@kernel.org>,
linux-usb@vger.kernel.org, chrome-platform@lists.linux.dev
Cc: Guenter Roeck <groeck@chromium.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
"Christian A. Ehrhardt" <lk@c--e.de>,
Venkat Jayaraman <venkat.jayaraman@intel.com>,
linux-kernel@vger.kernel.org,
Andrei Kuchynski <akuchynski@chromium.org>
Subject: [PATCH v3 08/10] platform/chrome: cros_ec_typec: Propagate altmode entry result
Date: Mon, 4 Aug 2025 09:03:37 +0000 [thread overview]
Message-ID: <20250804090340.3062182-9-akuchynski@chromium.org> (raw)
In-Reply-To: <20250804090340.3062182-1-akuchynski@chromium.org>
In the `cros_typec_configure_mux` function, which concludes the DP/TBT
alternate mode entry, the error code should be reported back to the Type-C
mode selection logic. This ensures a detailed result is conveyed to user
space. To inform partner drivers about the result, the VDM mechanism is
used: DP_CMD_STATUS_UPDATE for DP altmode and TBT_CMD_STATUS_UPDATE for
TBT altmode.
Signed-off-by: Andrei Kuchynski <akuchynski@chromium.org>
---
drivers/platform/chrome/cros_ec_typec.c | 9 ++++++
drivers/platform/chrome/cros_typec_altmode.c | 32 ++++++++++++++++++--
drivers/platform/chrome/cros_typec_altmode.h | 6 ++++
include/linux/usb/typec_dp.h | 2 ++
4 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 99f549263c37..73aa25433a50 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -693,6 +693,7 @@ static int cros_typec_enable_dp(struct cros_typec_data *typec,
if (!ret)
ret = typec_mux_set(port->mux, &port->state);
+ dp_data.error = 0;
if (!ret)
ret = cros_typec_displayport_status_update(port->state.alt,
port->state.data);
@@ -782,8 +783,16 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
ret = cros_typec_enable_usb4(typec, port_num, pd_ctrl);
} else if (port->mux_flags & USB_PD_MUX_TBT_COMPAT_ENABLED) {
ret = cros_typec_enable_tbt(typec, port_num, pd_ctrl);
+ cros_typec_tbt_status_update(
+ port->port_altmode[CROS_EC_ALTMODE_TBT], ret);
} else if (port->mux_flags & USB_PD_MUX_DP_ENABLED) {
ret = cros_typec_enable_dp(typec, port_num, pd_ctrl);
+ if (ret) {
+ struct typec_displayport_data dp_data = {.error = ret};
+
+ cros_typec_displayport_status_update(
+ port->port_altmode[CROS_EC_ALTMODE_DP], &dp_data);
+ }
} else if (port->mux_flags & USB_PD_MUX_SAFE_MODE) {
ret = cros_typec_usb_safe_state(port);
} else if (port->mux_flags & USB_PD_MUX_USB_ENABLED) {
diff --git a/drivers/platform/chrome/cros_typec_altmode.c b/drivers/platform/chrome/cros_typec_altmode.c
index 557340b53af0..7ee295cf0c02 100644
--- a/drivers/platform/chrome/cros_typec_altmode.c
+++ b/drivers/platform/chrome/cros_typec_altmode.c
@@ -28,6 +28,7 @@ struct cros_typec_altmode_data {
u16 sid;
u8 mode;
+ int error;
};
struct cros_typec_dp_data {
@@ -295,9 +296,16 @@ int cros_typec_displayport_status_update(struct typec_altmode *altmode,
dp_data->data = *data;
dp_data->pending_status_update = false;
- adata->header |= VDO_CMDT(CMDT_RSP_ACK);
- adata->vdo_data = &dp_data->data.status;
- adata->vdo_size = 2;
+ if (data->error) {
+ adata->header |= VDO_CMDT(CMDT_RSP_NAK);
+ adata->error = dp_data->data.error;
+ adata->vdo_data = &adata->error;
+ adata->vdo_size = 1;
+ } else {
+ adata->header |= VDO_CMDT(CMDT_RSP_ACK);
+ adata->vdo_data = &dp_data->data.status;
+ adata->vdo_size = 2;
+ }
schedule_work(&adata->work);
mutex_unlock(&adata->lock);
@@ -370,4 +378,22 @@ cros_typec_register_thunderbolt(struct cros_typec_port *port,
return alt;
}
+
+int cros_typec_tbt_status_update(struct typec_altmode *alt, int error)
+{
+ struct cros_typec_altmode_data *adata = typec_altmode_get_drvdata(alt);
+
+ mutex_lock(&adata->lock);
+
+ adata->header = VDO(adata->sid, 1, SVDM_VER_2_0, TBT_CMD_STATUS_UPDATE);
+ adata->header |= VDO_CMDT(error ? CMDT_RSP_NAK : CMDT_RSP_ACK);
+ adata->error = error;
+ adata->vdo_data = &adata->error;
+ adata->vdo_size = 1;
+ schedule_work(&adata->work);
+
+ mutex_unlock(&adata->lock);
+
+ return 0;
+}
#endif
diff --git a/drivers/platform/chrome/cros_typec_altmode.h b/drivers/platform/chrome/cros_typec_altmode.h
index 3f2aa95d065a..848a2b194b34 100644
--- a/drivers/platform/chrome/cros_typec_altmode.h
+++ b/drivers/platform/chrome/cros_typec_altmode.h
@@ -39,6 +39,7 @@ static inline int cros_typec_displayport_status_update(struct typec_altmode *alt
struct typec_altmode *
cros_typec_register_thunderbolt(struct cros_typec_port *port,
struct typec_altmode_desc *desc);
+int cros_typec_tbt_status_update(struct typec_altmode *alt, int error);
#else
static inline struct typec_altmode *
cros_typec_register_thunderbolt(struct cros_typec_port *port,
@@ -46,6 +47,11 @@ cros_typec_register_thunderbolt(struct cros_typec_port *port,
{
return typec_port_register_altmode(port->port, desc);
}
+static inline int cros_typec_tbt_status_update(struct typec_altmode *alt,
+ int error)
+{
+ return 0;
+}
#endif
#endif /* __CROS_TYPEC_ALTMODE_H__ */
diff --git a/include/linux/usb/typec_dp.h b/include/linux/usb/typec_dp.h
index acb0ad03bdac..c9fa68cd1265 100644
--- a/include/linux/usb/typec_dp.h
+++ b/include/linux/usb/typec_dp.h
@@ -44,10 +44,12 @@ enum {
* commands: Status Update and Configure.
*
* @status will show for example the status of the HPD signal.
+ * @error will contain the error code, if applicable.
*/
struct typec_displayport_data {
u32 status;
u32 conf;
+ int error;
};
enum {
--
2.50.1.565.gc32cd1483b-goog
next prev parent reply other threads:[~2025-08-04 9:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-04 9:03 [PATCH v3 00/10] USB Type-C mode selection Andrei Kuchynski
2025-08-04 9:03 ` [PATCH v3 01/10] usb: typec: Add alt_mode_override field to port property Andrei Kuchynski
2025-08-04 9:03 ` [PATCH v3 02/10] platform/chrome: cros_ec_typec: Set alt_mode_override flag Andrei Kuchynski
2025-08-04 9:03 ` [PATCH v3 03/10] usb: typec: ucsi: " Andrei Kuchynski
2025-08-04 9:03 ` [PATCH v3 04/10] usb: typec: Expose mode priorities via sysfs Andrei Kuchynski
2025-08-11 14:25 ` Heikki Krogerus
2025-08-11 18:22 ` Abhishek Pandit-Subedi
2025-08-12 11:40 ` Heikki Krogerus
2025-08-12 20:33 ` Abhishek Pandit-Subedi
2025-08-14 8:22 ` Andrei Kuchynski
2025-08-04 9:03 ` [PATCH v3 05/10] usb: typec: Implement automated mode selection Andrei Kuchynski
2025-08-04 13:00 ` kernel test robot
2025-08-11 15:31 ` Heikki Krogerus
2025-08-04 9:03 ` [PATCH v3 06/10] usb: typec: Report altmode entry status via callback Andrei Kuchynski
2025-08-04 9:03 ` [PATCH v3 07/10] usb: typec: ucsi: displayport: Propagate DP altmode entry result Andrei Kuchynski
2025-08-04 9:03 ` Andrei Kuchynski [this message]
2025-08-04 9:03 ` [PATCH v3 09/10] platform/chrome: cros_ec_typec: Report USB4 entry status via callback Andrei Kuchynski
2025-08-04 9:03 ` [PATCH v3 10/10] platform/chrome: cros_ec_typec: Add default_usb_mode_set support Andrei Kuchynski
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=20250804090340.3062182-9-akuchynski@chromium.org \
--to=akuchynski@chromium.org \
--cc=abhishekpandit@chromium.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=groeck@chromium.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=jthies@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=lk@c--e.de \
--cc=tzungbi@kernel.org \
--cc=venkat.jayaraman@intel.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
all inboxes | Powered by JetHome®