mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-24 14:54:49 +08:00
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
This commit is contained in:
parent
50ed638bbc
commit
40a9b13a09
@ -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,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user