summaryrefslogtreecommitdiff
path: root/drivers/platform/chrome
diff options
context:
space:
mode:
authorPrashant Malani <pmalani@chromium.org>2022-12-28 03:45:13 +0300
committerPrashant Malani <pmalani@chromium.org>2023-01-09 23:32:54 +0300
commit40a9b13a09ef2ec207fec1b328ed796d08e20e54 (patch)
treeb0d0a555a389eff093a9ed340927e6198791bcd5 /drivers/platform/chrome
parent50ed638bbc47ba68ccc90d81118fe030cf39b6b5 (diff)
downloadlinux-40a9b13a09ef2ec207fec1b328ed796d08e20e54.tar.xz
platform/chrome: cros_typec_vdm: Add VDM send support
Add support to send generic VDM messages from the alt mode driver to the partner (via the ChromeOS EC). The function introduced here is intended to be called by the alt mode driver (via the Type-C bus logic). Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Prashant Malani <pmalani@chromium.org> Reviewed-by: Benson Leung <bleung@chromium.org> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20221228004648.793339-11-pmalani@chromium.org
Diffstat (limited to 'drivers/platform/chrome')
-rw-r--r--drivers/platform/chrome/cros_typec_vdm.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/platform/chrome/cros_typec_vdm.c b/drivers/platform/chrome/cros_typec_vdm.c
index fc7b602ceb37..aca9d337118e 100644
--- a/drivers/platform/chrome/cros_typec_vdm.c
+++ b/drivers/platform/chrome/cros_typec_vdm.c
@@ -77,6 +77,30 @@ static int cros_typec_port_amode_enter(struct typec_altmode *amode, u32 *vdo)
sizeof(req), NULL, 0);
}
+static int cros_typec_port_amode_vdm(struct typec_altmode *amode, const u32 hdr,
+ const u32 *vdo, int cnt)
+{
+ struct cros_typec_port *port = typec_altmode_get_drvdata(amode);
+ struct ec_params_typec_control req = {
+ .port = port->port_num,
+ .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
+ };
+ struct typec_vdm_req vdm_req = {};
+
+ vdm_req.vdm_data[0] = hdr;
+ vdm_req.vdm_data_objects = cnt;
+ memcpy(&vdm_req.vdm_data[1], vdo, cnt - 1);
+ vdm_req.partner_type = TYPEC_PARTNER_SOP;
+ req.vdm_req_params = vdm_req;
+
+ dev_dbg(port->typec_data->dev, "Sending VDM, hdr: %x, num_objects: %d, port: %d\n",
+ hdr, cnt, port->port_num);
+
+ return cros_ec_cmd(port->typec_data->ec, 0, EC_CMD_TYPEC_CONTROL, &req,
+ sizeof(req), NULL, 0);
+}
+
struct typec_altmode_ops port_amode_ops = {
.enter = cros_typec_port_amode_enter,
+ .vdm = cros_typec_port_amode_vdm,
};