Skip to contentSkip to conversation

usb: typec: ucsi: Add support for SET_PDOS command

PATCH Superseded Pooja Katiyar 2 participants 6 messages Sep 6, 2025

Subsystems (4)

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v3 cover usb: typec: ucsi: Add support for SET_PDOS command

This series implements support for UCSI SET_PDOS command. It provides interface to send message out data structure and update source or sink capabilities PDOs on a connector over debugfs interface.

It also updates UCSI structure to have message in and message out fields instead of handling them as separate parameters.

Pooja Katiyar (4):
usb: typec: ucsi: Update UCSI structure to have message in and message
out fields
usb: typec: ucsi: Add support for message out data structure
usb: typec: ucsi: Enable debugfs for message_out data structure
usb: typec: ucsi: Add support for SET_PDOS command

 drivers/usb/typec/ucsi/cros_ec_ucsi.c |   5 +-
 drivers/usb/typec/ucsi/debugfs.c      |  36 +++++++-
 drivers/usb/typec/ucsi/displayport.c  |  11 ++-
 drivers/usb/typec/ucsi/ucsi.c         | 118 ++++++++++++++++++--------
 drivers/usb/typec/ucsi/ucsi.h         |  22 +++--
 drivers/usb/typec/ucsi/ucsi_acpi.c    |  25 ++++--
 drivers/usb/typec/ucsi/ucsi_ccg.c     |  11 ++-
 7 files changed, 165 insertions(+), 63 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v3 1/4 usb: typec: ucsi: Update UCSI structure to have message in and message out fields

Update UCSI structure by adding fields for incoming and outgoing messages. Update .sync_control function and other related functions to use these new fields within the UCSI structure, instead of handling them as separate parameters.

---
 drivers/usb/typec/ucsi/cros_ec_ucsi.c |   5 +-
 drivers/usb/typec/ucsi/debugfs.c      |   9 ++-
 drivers/usb/typec/ucsi/displayport.c  |  11 ++-
 drivers/usb/typec/ucsi/ucsi.c         | 104 +++++++++++++++++---------
 drivers/usb/typec/ucsi/ucsi.h         |  19 +++--
 drivers/usb/typec/ucsi/ucsi_acpi.c    |   9 +--
 drivers/usb/typec/ucsi/ucsi_ccg.c     |  11 ++-
 7 files changed, 105 insertions(+), 63 deletions(-)
drivers/usb/typec/ucsi/cros_ec_ucsi.c +2 -3
index eed2a7d0ebc6..d753f2188e25 100644
@@ -105,13 +105,12 @@ static int cros_ucsi_async_control(struct ucsi *ucsi, u64 cmd)
 	return 0;
 }
 
-static int cros_ucsi_sync_control(struct ucsi *ucsi, u64 cmd, u32 *cci,
-				  void *data, size_t size)
+static int cros_ucsi_sync_control(struct ucsi *ucsi, u64 cmd, u32 *cci)
 {
 	struct cros_ucsi_data *udata = ucsi_get_drvdata(ucsi);
 	int ret;
 
-	ret = ucsi_sync_control_common(ucsi, cmd, cci, data, size);
+	ret = ucsi_sync_control_common(ucsi, cmd, cci);
 	switch (ret) {
 	case -EBUSY:
 		/* EC may return -EBUSY if CCI.busy is set.
drivers/usb/typec/ucsi/debugfs.c +5 -4
index 92ebf1a2defd..0a20b966578c 100644
@@ -35,7 +35,8 @@ static int ucsi_cmd(void *data, u64 val)
 	case UCSI_SET_SINK_PATH:
 	case UCSI_SET_NEW_CAM:
 	case UCSI_SET_USB:
-		ret = ucsi_send_command(ucsi, val, NULL, 0);
+		ucsi->message_in_size = 0;
+		ret = ucsi_send_command(ucsi, val);
 		break;
 	case UCSI_GET_CAPABILITY:
 	case UCSI_GET_CONNECTOR_CAPABILITY:
@@ -50,9 +51,9 @@ static int ucsi_cmd(void *data, u64 val)
 	case UCSI_GET_ATTENTION_VDO:
 	case UCSI_GET_CAM_CS:
 	case UCSI_GET_LPM_PPM_INFO:
-		ret = ucsi_send_command(ucsi, val,
-					&ucsi->debugfs->response,
-					sizeof(ucsi->debugfs->response));
+		ucsi->message_in_size = sizeof(ucsi->debugfs->response);
+		ret = ucsi_send_command(ucsi, val);
+		memcpy(&ucsi->debugfs->response, ucsi->message_in, sizeof(ucsi->debugfs->response));
 		break;
 	default:
 		ret = -EOPNOTSUPP;
drivers/usb/typec/ucsi/displayport.c +8 -3
index 8aae80b457d7..a09b4900ec76 100644
@@ -67,11 +67,14 @@ static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)
 	}
 
 	command = UCSI_GET_CURRENT_CAM | UCSI_CONNECTOR_NUMBER(dp->con->num);
-	ret = ucsi_send_command(ucsi, command, &cur, sizeof(cur));
+	ucsi->message_in_size = sizeof(cur);
+	ret = ucsi_send_command(ucsi, command);
 	if (ret < 0) {
 		if (ucsi->version > 0x0100)
 			goto err_unlock;
 		cur = 0xff;
+	} else {
+		memcpy(&cur, ucsi->message_in, ucsi->message_in_size);
 	}
 
 	if (cur != 0xff) {
@@ -126,7 +129,8 @@ static int ucsi_displayport_exit(struct typec_altmode *alt)
 	}
 
 	command = UCSI_CMD_SET_NEW_CAM(dp->con->num, 0, dp->offset, 0);
-	ret = ucsi_send_command(dp->con->ucsi, command, NULL, 0);
+	dp->con->ucsi->message_in_size = 0;
+	ret = ucsi_send_command(dp->con->ucsi, command);
 	if (ret < 0)
 		goto out_unlock;
 
@@ -193,7 +197,8 @@ static int ucsi_displayport_configure(struct ucsi_dp *dp)
 
 	command = UCSI_CMD_SET_NEW_CAM(dp->con->num, 1, dp->offset, pins);
 
-	return ucsi_send_command(dp->con->ucsi, command, NULL, 0);
+	dp->con->ucsi->message_in_size = 0;
+	return ucsi_send_command(dp->con->ucsi, command);
 }
 
 static int ucsi_displayport_vdm(struct typec_altmode *alt,
drivers/usb/typec/ucsi/ucsi.c +68 -36

279 lines not on this page · raw message

drivers/usb/typec/ucsi/ucsi.h +13 -6
index ebd7c27c2cc7..673f57eb7842 100644
@@ -29,6 +29,10 @@ struct dentry;
 #define UCSI_MESSAGE_OUT		32
 #define UCSIv2_MESSAGE_OUT		272
 
+/* Define maximum lengths for message buffers */
+#define UCSI_MAX_MESSAGE_IN_LENGTH	256
+#define UCSI_MAX_MESSAGE_OUT_LENGTH	256
+
 /* UCSI versions */
 #define UCSI_VERSION_1_0	0x0100
 #define UCSI_VERSION_1_1	0x0110
@@ -80,8 +84,7 @@ struct ucsi_operations {
 	int (*read_cci)(struct ucsi *ucsi, u32 *cci);
 	int (*poll_cci)(struct ucsi *ucsi, u32 *cci);
 	int (*read_message_in)(struct ucsi *ucsi, void *val, size_t val_len);
-	int (*sync_control)(struct ucsi *ucsi, u64 command, u32 *cci,
-			    void *data, size_t size);
+	int (*sync_control)(struct ucsi *ucsi, u64 command, u32 *cci);
 	int (*async_control)(struct ucsi *ucsi, u64 command);
 	bool (*update_altmodes)(struct ucsi *ucsi, u8 recipient,
 				struct ucsi_altmode *orig,
@@ -476,6 +479,12 @@ struct ucsi {
 	unsigned long quirks;
 #define UCSI_NO_PARTNER_PDOS	BIT(0)	/* Don't read partner's PDOs */
 #define UCSI_DELAY_DEVICE_PDOS	BIT(1)	/* Reading PDOs fails until the parter is in PD mode */
+
+	/* Fixed-size buffers for incoming and outgoing messages */
+	u8 message_in[UCSI_MAX_MESSAGE_IN_LENGTH];
+	size_t message_in_size;
+	u8 message_out[UCSI_MAX_MESSAGE_OUT_LENGTH];
+	size_t message_out_size;
 };
 
 #define UCSI_MAX_DATA_LENGTH(u) (((u)->version < UCSI_VERSION_2_0) ? 0x10 : 0xff)
@@ -534,15 +543,13 @@ struct ucsi_connector {
 	struct usb_pd_identity cable_identity;
 };
 
-int ucsi_send_command(struct ucsi *ucsi, u64 command,
-		      void *retval, size_t size);
+int ucsi_send_command(struct ucsi *ucsi, u64 command);
 
 void ucsi_altmode_update_active(struct ucsi_connector *con);
 int ucsi_resume(struct ucsi *ucsi);
 
 void ucsi_notify_common(struct ucsi *ucsi, u32 cci);
-int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci,
-			     void *data, size_t size);
+int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci);
 
 #if IS_ENABLED(CONFIG_POWER_SUPPLY)
 int ucsi_register_port_psy(struct ucsi_connector *con);
drivers/usb/typec/ucsi/ucsi_acpi.c +4 -5
index 6b92f296e985..f1d1f6917b09 100644
@@ -105,15 +105,14 @@ static const struct ucsi_operations ucsi_acpi_ops = {
 	.async_control = ucsi_acpi_async_control
 };
 
-static int ucsi_gram_sync_control(struct ucsi *ucsi, u64 command, u32 *cci,
-				  void *val, size_t len)
+static int ucsi_gram_sync_control(struct ucsi *ucsi, u64 command, u32 *cci)
 {
 	u16 bogus_change = UCSI_CONSTAT_POWER_LEVEL_CHANGE |
 			   UCSI_CONSTAT_PDOS_CHANGE;
 	struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi);
 	int ret;
 
-	ret = ucsi_sync_control_common(ucsi, command, cci, val, len);
+	ret = ucsi_sync_control_common(ucsi, command, cci);
 	if (ret < 0)
 		return ret;
 
@@ -125,8 +124,8 @@ static int ucsi_gram_sync_control(struct ucsi *ucsi, u64 command, u32 *cci,
 	if (UCSI_COMMAND(ua->cmd) == UCSI_GET_CONNECTOR_STATUS &&
 	    ua->check_bogus_event) {
 		/* Clear the bogus change */
-		if (*(u16 *)val == bogus_change)
-			*(u16 *)val = 0;
+		if (*(u16 *)ucsi->message_in == bogus_change)
+			*(u16 *)ucsi->message_in = 0;
 
 		ua->check_bogus_event = false;
 	}
drivers/usb/typec/ucsi/ucsi_ccg.c +5 -6
index d83a0051c737..ead1b2a25c79 100644
@@ -606,8 +606,7 @@ static int ucsi_ccg_async_control(struct ucsi *ucsi, u64 command)
 	return ccg_write(uc, reg, (u8 *)&command, sizeof(command));
 }
 
-static int ucsi_ccg_sync_control(struct ucsi *ucsi, u64 command, u32 *cci,
-				 void *data, size_t size)
+static int ucsi_ccg_sync_control(struct ucsi *ucsi, u64 command, u32 *cci)
 {
 	struct ucsi_ccg *uc = ucsi_get_drvdata(ucsi);
 	struct ucsi_connector *con;
@@ -629,16 +628,16 @@ static int ucsi_ccg_sync_control(struct ucsi *ucsi, u64 command, u32 *cci,
 		ucsi_ccg_update_set_new_cam_cmd(uc, con, &command);
 	}
 
-	ret = ucsi_sync_control_common(ucsi, command, cci, data, size);
+	ret = ucsi_sync_control_common(ucsi, command, cci);
 
 	switch (UCSI_COMMAND(command)) {
 	case UCSI_GET_CURRENT_CAM:
 		if (uc->has_multiple_dp)
-			ucsi_ccg_update_get_current_cam_cmd(uc, (u8 *)data);
+			ucsi_ccg_update_get_current_cam_cmd(uc, (u8 *)ucsi->message_in);
 		break;
 	case UCSI_GET_ALTERNATE_MODES:
 		if (UCSI_ALTMODE_RECIPIENT(command) == UCSI_RECIPIENT_SOP) {
-			struct ucsi_altmode *alt = data;
+			struct ucsi_altmode *alt = (struct ucsi_altmode *)ucsi->message_in;
 
 			if (alt[0].svid == USB_TYPEC_NVIDIA_VLINK_SID)
 				ucsi_ccg_nvidia_altmode(uc, alt, command);
@@ -646,7 +645,7 @@ static int ucsi_ccg_sync_control(struct ucsi *ucsi, u64 command, u32 *cci,
 		break;
 	case UCSI_GET_CAPABILITY:
 		if (uc->fw_build == CCG_FW_BUILD_NVIDIA_TEGRA) {
-			struct ucsi_capability *cap = data;
+			struct ucsi_capability *cap = (struct ucsi_capability *)ucsi->message_in;
 
 			cap->features &= ~UCSI_CAP_ALT_MODE_DETAILS;
 		}
Signature · 1 line
2.43.0
#3 lore raw

PATCH v3 2/4 usb: typec: ucsi: Add support for message out data structure

In reply to Pooja Katiyar

Add support for updating message out data structure for UCSI ACPI interface for UCSI 2.1 and UCSI 3.0 commands such as Set PDOs and LPM Firmware Update.

---
 drivers/usb/typec/ucsi/ucsi.c      | 14 ++++++++++++++
 drivers/usb/typec/ucsi/ucsi.h      |  2 ++
 drivers/usb/typec/ucsi/ucsi_acpi.c | 16 ++++++++++++++++
 3 files changed, 32 insertions(+)
drivers/usb/typec/ucsi/ucsi.c +14 -0
index c953aa7d5283..02e43687c3f6 100644
@@ -67,6 +67,20 @@ int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci)
 
 	reinit_completion(&ucsi->complete);
 
+	if (ucsi->message_out_size > 0) {
+		if (!ucsi->ops->write_message_out) {
+			ucsi->message_out_size = 0;
+			ret = -EOPNOTSUPP;
+			goto out_clear_bit;
+		}
+
+		ret = ucsi->ops->write_message_out(ucsi, ucsi->message_out,
+						   ucsi->message_out_size);
+		ucsi->message_out_size = 0;
+		if (ret)
+			goto out_clear_bit;
+	}
+
 	ret = ucsi->ops->async_control(ucsi, command);
 	if (ret)
 		goto out_clear_bit;
drivers/usb/typec/ucsi/ucsi.h +2 -0
index 673f57eb7842..d932fa1a40b9 100644
@@ -69,6 +69,7 @@ struct dentry;
  * @read_cci: Read CCI register
  * @poll_cci: Read CCI register while polling with notifications disabled
  * @read_message_in: Read message data from UCSI
+ * @write_message_out: Write message data to UCSI
  * @sync_control: Blocking control operation
  * @async_control: Non-blocking control operation
  * @update_altmodes: Squashes duplicate DP altmodes
@@ -84,6 +85,7 @@ struct ucsi_operations {
 	int (*read_cci)(struct ucsi *ucsi, u32 *cci);
 	int (*poll_cci)(struct ucsi *ucsi, u32 *cci);
 	int (*read_message_in)(struct ucsi *ucsi, void *val, size_t val_len);
+	int (*write_message_out)(struct ucsi *ucsi, void *data, size_t data_len);
 	int (*sync_control)(struct ucsi *ucsi, u64 command, u32 *cci);
 	int (*async_control)(struct ucsi *ucsi, u64 command);
 	bool (*update_altmodes)(struct ucsi *ucsi, u8 recipient,
drivers/usb/typec/ucsi/ucsi_acpi.c +16 -0
index f1d1f6917b09..f9beeb835238 100644
@@ -86,6 +86,21 @@ static int ucsi_acpi_read_message_in(struct ucsi *ucsi, void *val, size_t val_le
 	return 0;
 }
 
+static int ucsi_acpi_write_message_out(struct ucsi *ucsi, void *data, size_t data_len)
+{
+	struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi);
+
+	if (!data || !data_len)
+		return -EINVAL;
+
+	if (ucsi->version <= UCSI_VERSION_1_2)
+		memcpy(ua->base + UCSI_MESSAGE_OUT, data, data_len);
+	else
+		memcpy(ua->base + UCSIv2_MESSAGE_OUT, data, data_len);
+
+	return 0;
+}
+
 static int ucsi_acpi_async_control(struct ucsi *ucsi, u64 command)
 {
 	struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi);
@@ -101,6 +116,7 @@ static const struct ucsi_operations ucsi_acpi_ops = {
 	.read_cci = ucsi_acpi_read_cci,
 	.poll_cci = ucsi_acpi_poll_cci,
 	.read_message_in = ucsi_acpi_read_message_in,
+	.write_message_out = ucsi_acpi_write_message_out,
 	.sync_control = ucsi_sync_control_common,
 	.async_control = ucsi_acpi_async_control
 };
Signature · 1 line
2.43.0
#4 lore raw

PATCH v3 3/4 usb: typec: ucsi: Enable debugfs for message_out data structure

In reply to Pooja Katiyar

Add debugfs entry for writing message_out data structure to handle UCSI 2.1 and 3.0 commands through debugfs interface.

Users writing to the message_out debugfs file should ensure the input data adheres to the following format:
1. Input must be a non-empty valid hexadecimal string.
2. Input length of hexadecimal string must not exceed 256 bytes of length to be in alignment with the message out data structure size as per the UCSI specification v2.1.
3. If the input string length is odd, then user needs to prepend a '0' to the first character for proper hex conversion.

Below are examples of valid hex strings. Note that these values are just examples. The exact values depend on specific command use case.

	#echo 1A2B3C4D > message_out
	#echo 01234567 > message_out
---
 drivers/usb/typec/ucsi/debugfs.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/usb/typec/ucsi/debugfs.c +26 -0
index 0a20b966578c..6904722790ba 100644
@@ -81,6 +81,30 @@ static int ucsi_resp_show(struct seq_file *s, void *not_used)
 }
 DEFINE_SHOW_ATTRIBUTE(ucsi_resp);
 
+static ssize_t ucsi_message_out_write(struct file *file,
+				      const char __user *data, size_t count, loff_t *ppos)
+{
+	struct ucsi *ucsi = file->private_data;
+	int ret;
+
+	char *buf __free(kfree) = memdup_user_nul(data, count);
+	if (IS_ERR(buf))
+		return PTR_ERR(buf);
+
+	ucsi->message_out_size = min(count / 2, UCSI_MAX_MESSAGE_OUT_LENGTH);
+	ret = hex2bin(ucsi->message_out, buf, ucsi->message_out_size);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
+static const struct file_operations ucsi_message_out_fops = {
+	.open = simple_open,
+	.write = ucsi_message_out_write,
+	.llseek = generic_file_llseek,
+};
+
 void ucsi_debugfs_register(struct ucsi *ucsi)
 {
 	ucsi->debugfs = kzalloc(sizeof(*ucsi->debugfs), GFP_KERNEL);
@@ -90,6 +114,8 @@ void ucsi_debugfs_register(struct ucsi *ucsi)
 	ucsi->debugfs->dentry = debugfs_create_dir(dev_name(ucsi->dev), ucsi_debugfs_root);
 	debugfs_create_file("command", 0200, ucsi->debugfs->dentry, ucsi, &ucsi_cmd_fops);
 	debugfs_create_file("response", 0400, ucsi->debugfs->dentry, ucsi, &ucsi_resp_fops);
+	debugfs_create_file("message_out", 0200, ucsi->debugfs->dentry, ucsi,
+			    &ucsi_message_out_fops);
 }
 
 void ucsi_debugfs_unregister(struct ucsi *ucsi)
Signature · 1 line
2.43.0
#5 lore raw

PATCH v3 4/4 usb: typec: ucsi: Add support for SET_PDOS command

In reply to Pooja Katiyar

Add support for UCSI SET_PDOS command as per UCSI specification v2.1 and above to debugfs.

---
 drivers/usb/typec/ucsi/debugfs.c | 1 +
 drivers/usb/typec/ucsi/ucsi.h    | 1 +
 2 files changed, 2 insertions(+)
drivers/usb/typec/ucsi/debugfs.c +1 -0
index 6904722790ba..ecc453ec8218 100644
@@ -35,6 +35,7 @@ static int ucsi_cmd(void *data, u64 val)
 	case UCSI_SET_SINK_PATH:
 	case UCSI_SET_NEW_CAM:
 	case UCSI_SET_USB:
+	case UCSI_SET_PDOS:
 		ucsi->message_in_size = 0;
 		ret = ucsi_send_command(ucsi, val);
 		break;
drivers/usb/typec/ucsi/ucsi.h +1 -0
index d932fa1a40b9..b1273a394bc9 100644
@@ -136,6 +136,7 @@ void ucsi_connector_change(struct ucsi *ucsi, u8 num);
 #define UCSI_GET_PD_MESSAGE			0x15
 #define UCSI_GET_CAM_CS			0x18
 #define UCSI_SET_SINK_PATH			0x1c
+#define UCSI_SET_PDOS				0x1d
 #define UCSI_SET_USB				0x21
 #define UCSI_GET_LPM_PPM_INFO			0x22
 
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH v3 1/4] usb: typec: ucsi: Update UCSI structure to have message in and message out fields

In reply to Pooja Katiyar
kernel test robot noticed the following build errors:

Hi Pooja,

kernel test robot noticed the following build errors:

[auto build test ERROR on usb/usb-linus]
[also build test ERROR on westeri-thunderbolt/next linus/master v6.17-rc4] [cannot apply to usb/usb-testing usb/usb-next next-20250905] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Pooja-Katiyar/usb-typec-ucsi-Update-UCSI-structure-to-have-message-in-and-message-out-fields/20250906-123240
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-linus
patch link:    https://lore.kernel.org/r/109c631547b41ce7af26a7c3e9bfd5ab87fa4587.1757024530.git.pooja.katiyar%40intel.com
patch subject: [PATCH v3 1/4] usb: typec: ucsi: Update UCSI structure to have message in and message out fields
config: x86_64-buildonly-randconfig-004-20250906 (https://download.01.org/0day-ci/archive/20250906/[email protected]/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250906/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/usb/typec/ucsi/ucsi_yoga_c630.c:129:53: error: too many arguments to function call, expected 3, have 5
     129 |         ret = ucsi_sync_control_common(ucsi, command, cci, data, size);
         |               ~~~~~~~~~~~~~~~~~~~~~~~~                     ^~~~~~~~~~
   drivers/usb/typec/ucsi/ucsi.h:552:5: note: 'ucsi_sync_control_common' declared here
     552 | int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci);
         |     ^                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/usb/typec/ucsi/ucsi_yoga_c630.c:173:18: error: incompatible function pointer types initializing 'int (*)(struct ucsi *, u64, u32 *)' (aka 'int (*)(struct ucsi *, unsigned long long, unsigned int *)') with an expression of type 'int (struct ucsi *, u64, u32 *, void *, size_t)' (aka 'int (struct ucsi *, unsigned long long, unsigned int *, void *, unsigned long)') [-Wincompatible-function-pointer-types]
     173 |         .sync_control = yoga_c630_ucsi_sync_control,
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~

2 errors generated.

vim +173 drivers/usb/typec/ucsi/ucsi_yoga_c630.c

2ea6d07efe5388 Dmitry Baryshkov      2024-06-24   88  
eebd39f8a89985 Dmitry Baryshkov      2025-06-21   89  static int yoga_c630_ucsi_sync_control(struct ucsi *ucsi,
eebd39f8a89985 Dmitry Baryshkov      2025-06-21   90  				       u64 command,
eebd39f8a89985 Dmitry Baryshkov      2025-06-21   91  				       u32 *cci,
eebd39f8a89985 Dmitry Baryshkov      2025-06-21   92  				       void *data, size_t size)
eebd39f8a89985 Dmitry Baryshkov      2025-06-21   93  {
442392f98d20c5 Dmitry Baryshkov      2025-06-21   94  	int ret;
442392f98d20c5 Dmitry Baryshkov      2025-06-21   95  
442392f98d20c5 Dmitry Baryshkov      2025-06-21   96  	/*
442392f98d20c5 Dmitry Baryshkov      2025-06-21   97  	 * EC doesn't return connector's DP mode even though it is supported.
442392f98d20c5 Dmitry Baryshkov      2025-06-21   98  	 * Fake it.
442392f98d20c5 Dmitry Baryshkov      2025-06-21   99  	 */
442392f98d20c5 Dmitry Baryshkov      2025-06-21  100  	if (UCSI_COMMAND(command) == UCSI_GET_ALTERNATE_MODES &&
442392f98d20c5 Dmitry Baryshkov      2025-06-21  101  	    UCSI_GET_ALTMODE_GET_CONNECTOR_NUMBER(command) == 1 &&
442392f98d20c5 Dmitry Baryshkov      2025-06-21  102  	    UCSI_ALTMODE_RECIPIENT(command) == UCSI_RECIPIENT_CON &&
442392f98d20c5 Dmitry Baryshkov      2025-06-21  103  	    UCSI_ALTMODE_OFFSET(command) == 0) {
442392f98d20c5 Dmitry Baryshkov      2025-06-21  104  		static const struct ucsi_altmode alt = {
442392f98d20c5 Dmitry Baryshkov      2025-06-21  105  			.svid = USB_TYPEC_DP_SID,
442392f98d20c5 Dmitry Baryshkov      2025-06-21  106  			.mid = USB_TYPEC_DP_MODE,
442392f98d20c5 Dmitry Baryshkov      2025-06-21  107  		};
442392f98d20c5 Dmitry Baryshkov      2025-06-21  108  
442392f98d20c5 Dmitry Baryshkov      2025-06-21  109  		dev_dbg(ucsi->dev, "faking DP altmode for con1\n");
442392f98d20c5 Dmitry Baryshkov      2025-06-21  110  		memset(data, 0, size);
442392f98d20c5 Dmitry Baryshkov      2025-06-21  111  		memcpy(data, &alt, min(sizeof(alt), size));
442392f98d20c5 Dmitry Baryshkov      2025-06-21  112  		*cci = UCSI_CCI_COMMAND_COMPLETE | UCSI_SET_CCI_LENGTH(sizeof(alt));
442392f98d20c5 Dmitry Baryshkov      2025-06-21  113  		return 0;
442392f98d20c5 Dmitry Baryshkov      2025-06-21  114  	}
442392f98d20c5 Dmitry Baryshkov      2025-06-21  115  
eebd39f8a89985 Dmitry Baryshkov      2025-06-21  116  	/*
eebd39f8a89985 Dmitry Baryshkov      2025-06-21  117  	 * EC can return AltModes present on CON1 (port0, right) for CON2
eebd39f8a89985 Dmitry Baryshkov      2025-06-21  118  	 * (port1, left) too. Ignore all requests going to CON2 (it doesn't
eebd39f8a89985 Dmitry Baryshkov      2025-06-21  119  	 * support DP anyway).
eebd39f8a89985 Dmitry Baryshkov      2025-06-21  120  	 */
eebd39f8a89985 Dmitry Baryshkov      2025-06-21  121  	if (UCSI_COMMAND(command) == UCSI_GET_ALTERNATE_MODES &&
eebd39f8a89985 Dmitry Baryshkov      2025-06-21  122  	    UCSI_GET_ALTMODE_GET_CONNECTOR_NUMBER(command) == 2) {
eebd39f8a89985 Dmitry Baryshkov      2025-06-21  123  		dev_dbg(ucsi->dev, "ignoring altmodes for con2\n");
eebd39f8a89985 Dmitry Baryshkov      2025-06-21  124  		memset(data, 0, size);
eebd39f8a89985 Dmitry Baryshkov      2025-06-21  125  		*cci = UCSI_CCI_COMMAND_COMPLETE;
eebd39f8a89985 Dmitry Baryshkov      2025-06-21  126  		return 0;
eebd39f8a89985 Dmitry Baryshkov      2025-06-21  127  	}
eebd39f8a89985 Dmitry Baryshkov      2025-06-21  128  
e943c93333e305 Dmitry Baryshkov      2025-06-21 @129  	ret = ucsi_sync_control_common(ucsi, command, cci, data, size);
e943c93333e305 Dmitry Baryshkov      2025-06-21  130  	if (ret < 0)
e943c93333e305 Dmitry Baryshkov      2025-06-21  131  		return ret;
e943c93333e305 Dmitry Baryshkov      2025-06-21  132  
e943c93333e305 Dmitry Baryshkov      2025-06-21  133  	/* UCSI_GET_CURRENT_CAM is off-by-one on all ports */
e943c93333e305 Dmitry Baryshkov      2025-06-21  134  	if (UCSI_COMMAND(command) == UCSI_GET_CURRENT_CAM && data)
e943c93333e305 Dmitry Baryshkov      2025-06-21  135  		((u8 *)data)[0]--;
e943c93333e305 Dmitry Baryshkov      2025-06-21  136  
e943c93333e305 Dmitry Baryshkov      2025-06-21  137  	return ret;
eebd39f8a89985 Dmitry Baryshkov      2025-06-21  138  }
eebd39f8a89985 Dmitry Baryshkov      2025-06-21  139  
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  140  static bool yoga_c630_ucsi_update_altmodes(struct ucsi *ucsi,
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  141  					   u8 recipient,
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  142  					   struct ucsi_altmode *orig,
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  143  					   struct ucsi_altmode *updated)
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  144  {
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  145  	int i;
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  146  
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  147  	if (orig[0].svid == 0 || recipient != UCSI_RECIPIENT_SOP)
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  148  		return false;
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  149  
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  150  	/* EC is nice and repeats altmodes again and again. Ignore copies. */
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  151  	for (i = 1; i < UCSI_MAX_ALTMODES; i++) {
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  152  		if (orig[i].svid == orig[0].svid) {
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  153  			dev_dbg(ucsi->dev, "Found duplicate altmodes, starting from %d\n", i);
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  154  			memset(&orig[i], 0, (UCSI_MAX_ALTMODES - i) * sizeof(*orig));
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  155  			break;
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  156  		}
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  157  	}
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  158  
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  159  	return false;
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  160  }
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  161  
49bf6ee89ebadc Dmitry Baryshkov      2025-06-21  162  static void yoga_c630_ucsi_update_connector(struct ucsi_connector *con)
49bf6ee89ebadc Dmitry Baryshkov      2025-06-21  163  {
49bf6ee89ebadc Dmitry Baryshkov      2025-06-21  164  	if (con->num == 1)
49bf6ee89ebadc Dmitry Baryshkov      2025-06-21  165  		con->typec_cap.orientation_aware = true;
49bf6ee89ebadc Dmitry Baryshkov      2025-06-21  166  }
49bf6ee89ebadc Dmitry Baryshkov      2025-06-21  167  
da31486bf23480 Pei Xiao              2024-12-27  168  static const struct ucsi_operations yoga_c630_ucsi_ops = {
467399d989d799 Dmitry Baryshkov      2024-06-27  169  	.read_version = yoga_c630_ucsi_read_version,
467399d989d799 Dmitry Baryshkov      2024-06-27  170  	.read_cci = yoga_c630_ucsi_read_cci,
976e7e9bdc7719 Christian A. Ehrhardt 2025-02-17  171  	.poll_cci = yoga_c630_ucsi_read_cci,
467399d989d799 Dmitry Baryshkov      2024-06-27  172  	.read_message_in = yoga_c630_ucsi_read_message_in,
eebd39f8a89985 Dmitry Baryshkov      2025-06-21 @173  	.sync_control = yoga_c630_ucsi_sync_control,
13f2ec3115c845 Dmitry Baryshkov      2024-06-27  174  	.async_control = yoga_c630_ucsi_async_control,
e0c48e42d818ab Dmitry Baryshkov      2025-06-21  175  	.update_altmodes = yoga_c630_ucsi_update_altmodes,
49bf6ee89ebadc Dmitry Baryshkov      2025-06-21  176  	.update_connector = yoga_c630_ucsi_update_connector,
2ea6d07efe5388 Dmitry Baryshkov      2024-06-24  177  };

2ea6d07efe5388 Dmitry Baryshkov 2024-06-24 178

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki