Message ID | 20221228004648.793339-11-pmalani@chromium.org (mailing list archive) |
---|---|
State | Accepted |
Commit | 40a9b13a09ef2ec207fec1b328ed796d08e20e54 |
Headers | show |
Series | platform/chrome: cros_ec_typec: VDM support | expand |
On Wed, Dec 28, 2022 at 12:45:13AM +0000, Prashant Malani wrote: > 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> > --- > drivers/platform/chrome/cros_typec_vdm.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > 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, > }; > -- > 2.39.0.314.g84b9a713c41-goog > >
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, };
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> --- drivers/platform/chrome/cros_typec_vdm.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)