Commit 8face9aa authored by Heikki Krogerus's avatar Heikki Krogerus Committed by Greg Kroah-Hartman

usb: typec: Add parameter for the VDO to typec_altmode_enter()

Enter Mode Command may contain one VDO.
Signed-off-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20191230142611.24921-3-heikki.krogerus@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cf2f58fb
...@@ -188,7 +188,7 @@ static void dp_altmode_work(struct work_struct *work) ...@@ -188,7 +188,7 @@ static void dp_altmode_work(struct work_struct *work)
switch (dp->state) { switch (dp->state) {
case DP_STATE_ENTER: case DP_STATE_ENTER:
ret = typec_altmode_enter(dp->alt); ret = typec_altmode_enter(dp->alt, NULL);
if (ret) if (ret)
dev_err(&dp->alt->dev, "failed to enter mode\n"); dev_err(&dp->alt->dev, "failed to enter mode\n");
break; break;
...@@ -306,7 +306,8 @@ static int dp_altmode_vdm(struct typec_altmode *alt, ...@@ -306,7 +306,8 @@ static int dp_altmode_vdm(struct typec_altmode *alt,
static int dp_altmode_activate(struct typec_altmode *alt, int activate) static int dp_altmode_activate(struct typec_altmode *alt, int activate)
{ {
return activate ? typec_altmode_enter(alt) : typec_altmode_exit(alt); return activate ? typec_altmode_enter(alt, NULL) :
typec_altmode_exit(alt);
} }
static const struct typec_altmode_ops dp_altmode_ops = { static const struct typec_altmode_ops dp_altmode_ops = {
......
...@@ -84,12 +84,14 @@ EXPORT_SYMBOL_GPL(typec_altmode_notify); ...@@ -84,12 +84,14 @@ EXPORT_SYMBOL_GPL(typec_altmode_notify);
/** /**
* typec_altmode_enter - Enter Mode * typec_altmode_enter - Enter Mode
* @adev: The alternate mode * @adev: The alternate mode
* @vdo: VDO for the Enter Mode command
* *
* The alternate mode drivers use this function to enter mode. The port drivers * The alternate mode drivers use this function to enter mode. The port drivers
* use this to inform the alternate mode drivers that the partner has initiated * use this to inform the alternate mode drivers that the partner has initiated
* Enter Mode command. * Enter Mode command. If the alternate mode does not require VDO, @vdo must be
* NULL.
*/ */
int typec_altmode_enter(struct typec_altmode *adev) int typec_altmode_enter(struct typec_altmode *adev, u32 *vdo)
{ {
struct altmode *partner = to_altmode(adev)->partner; struct altmode *partner = to_altmode(adev)->partner;
struct typec_altmode *pdev = &partner->adev; struct typec_altmode *pdev = &partner->adev;
...@@ -110,7 +112,7 @@ int typec_altmode_enter(struct typec_altmode *adev) ...@@ -110,7 +112,7 @@ int typec_altmode_enter(struct typec_altmode *adev)
return ret; return ret;
/* Enter Mode */ /* Enter Mode */
return pdev->ops->enter(pdev); return pdev->ops->enter(pdev, vdo);
} }
EXPORT_SYMBOL_GPL(typec_altmode_enter); EXPORT_SYMBOL_GPL(typec_altmode_enter);
......
...@@ -1475,16 +1475,16 @@ static int tcpm_validate_caps(struct tcpm_port *port, const u32 *pdo, ...@@ -1475,16 +1475,16 @@ static int tcpm_validate_caps(struct tcpm_port *port, const u32 *pdo,
return 0; return 0;
} }
static int tcpm_altmode_enter(struct typec_altmode *altmode) static int tcpm_altmode_enter(struct typec_altmode *altmode, u32 *vdo)
{ {
struct tcpm_port *port = typec_altmode_get_drvdata(altmode); struct tcpm_port *port = typec_altmode_get_drvdata(altmode);
u32 header; u32 header;
mutex_lock(&port->lock); mutex_lock(&port->lock);
header = VDO(altmode->svid, 1, CMD_ENTER_MODE); header = VDO(altmode->svid, vdo ? 2 : 1, CMD_ENTER_MODE);
header |= VDO_OPOS(altmode->mode); header |= VDO_OPOS(altmode->mode);
tcpm_queue_vdm(port, header, NULL, 0); tcpm_queue_vdm(port, header, vdo, vdo ? 1 : 0);
mod_delayed_work(port->wq, &port->vdm_state_machine, 0); mod_delayed_work(port->wq, &port->vdm_state_machine, 0);
mutex_unlock(&port->lock); mutex_unlock(&port->lock);
......
...@@ -45,7 +45,7 @@ struct ucsi_dp { ...@@ -45,7 +45,7 @@ struct ucsi_dp {
* -EOPNOTSUPP. * -EOPNOTSUPP.
*/ */
static int ucsi_displayport_enter(struct typec_altmode *alt) static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)
{ {
struct ucsi_dp *dp = typec_altmode_get_drvdata(alt); struct ucsi_dp *dp = typec_altmode_get_drvdata(alt);
struct ucsi *ucsi = dp->con->ucsi; struct ucsi *ucsi = dp->con->ucsi;
......
...@@ -55,7 +55,7 @@ static inline void *typec_altmode_get_drvdata(struct typec_altmode *altmode) ...@@ -55,7 +55,7 @@ static inline void *typec_altmode_get_drvdata(struct typec_altmode *altmode)
* @activate: User callback for Enter/Exit Mode * @activate: User callback for Enter/Exit Mode
*/ */
struct typec_altmode_ops { struct typec_altmode_ops {
int (*enter)(struct typec_altmode *altmode); int (*enter)(struct typec_altmode *altmode, u32 *vdo);
int (*exit)(struct typec_altmode *altmode); int (*exit)(struct typec_altmode *altmode);
void (*attention)(struct typec_altmode *altmode, u32 vdo); void (*attention)(struct typec_altmode *altmode, u32 vdo);
int (*vdm)(struct typec_altmode *altmode, const u32 hdr, int (*vdm)(struct typec_altmode *altmode, const u32 hdr,
...@@ -65,7 +65,7 @@ struct typec_altmode_ops { ...@@ -65,7 +65,7 @@ struct typec_altmode_ops {
int (*activate)(struct typec_altmode *altmode, int activate); int (*activate)(struct typec_altmode *altmode, int activate);
}; };
int typec_altmode_enter(struct typec_altmode *altmode); int typec_altmode_enter(struct typec_altmode *altmode, u32 *vdo);
int typec_altmode_exit(struct typec_altmode *altmode); int typec_altmode_exit(struct typec_altmode *altmode);
void typec_altmode_attention(struct typec_altmode *altmode, u32 vdo); void typec_altmode_attention(struct typec_altmode *altmode, u32 vdo);
int typec_altmode_vdm(struct typec_altmode *altmode, int typec_altmode_vdm(struct typec_altmode *altmode,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment