History

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

Enter Mode Command may contain one VDO.

Heikki Krogerus committed 6 years ago

Commit 8face9a1 parent cf2f58f5 files · +14 −11Browse files

Unified · Split

5 files
  1. drivers/usb/typec/altmodes/displayport.c +3 −2
  2. drivers/usb/typec/bus.c +5 −3
  3. drivers/usb/typec/tcpm/tcpm.c +3 −3
  4. drivers/usb/typec/ucsi/displayport.c +1 −1
  5. include/linux/usb/typec_altmode.h +2 −2
drivers/usb/typec/altmodes/displayport.c+3−2
@@ -188,7 +188,7 @@ static void dp_altmode_work(struct work_struct *work) · 187 unmodified lines
188188
189189 switch (dp->state) {
190190 case DP_STATE_ENTER:
191− ret = typec_altmode_enter(dp->alt);
191+ ret = typec_altmode_enter(dp->alt, NULL);
192192 if (ret)
193193 dev_err(&dp->alt->dev, "failed to enter mode\n");
194194 break;
@@ -306,7 +306,8 @@ err_unlock: · 111 unmodified lines
306306
307307 static int dp_altmode_activate(struct typec_altmode *alt, int activate)
308308 {
309− return activate ? typec_altmode_enter(alt) : typec_altmode_exit(alt);
309+ return activate ? typec_altmode_enter(alt, NULL) :
310+ typec_altmode_exit(alt);
310311 }
311312
312313 static const struct typec_altmode_ops dp_altmode_ops = {
drivers/usb/typec/bus.c+5−3
@@ -84,12 +84,14 @@ EXPORT_SYMBOL_GPL(typec_altmode_notify); · 83 unmodified lines
8484 /**
8585 * typec_altmode_enter - Enter Mode
8686 * @adev: The alternate mode
87+ * @vdo: VDO for the Enter Mode command
8788 *
8889 * The alternate mode drivers use this function to enter mode. The port drivers
8990 * use this to inform the alternate mode drivers that the partner has initiated
90− * Enter Mode command.
91+ * Enter Mode command. If the alternate mode does not require VDO, @vdo must be
92+ * NULL.
9193 */
92−int typec_altmode_enter(struct typec_altmode *adev)
94+int typec_altmode_enter(struct typec_altmode *adev, u32 *vdo)
9395 {
9496 struct altmode *partner = to_altmode(adev)->partner;
9597 struct typec_altmode *pdev = &partner->adev;
@@ -110,7 +112,7 @@ int typec_altmode_enter(struct typec_altmode *adev) · 14 unmodified lines
110112 return ret;
111113
112114 /* Enter Mode */
113− return pdev->ops->enter(pdev);
115+ return pdev->ops->enter(pdev, vdo);
114116 }
115117 EXPORT_SYMBOL_GPL(typec_altmode_enter);
116118
drivers/usb/typec/tcpm/tcpm.c+3−3
@@ -1475,16 +1475,16 @@ static int tcpm_validate_caps(struct tcpm_port *port, const u32 *pdo, · 1474 unmodified lines
14751475 return 0;
14761476 }
14771477
1478−static int tcpm_altmode_enter(struct typec_altmode *altmode)
1478+static int tcpm_altmode_enter(struct typec_altmode *altmode, u32 *vdo)
14791479 {
14801480 struct tcpm_port *port = typec_altmode_get_drvdata(altmode);
14811481 u32 header;
14821482
14831483 mutex_lock(&port->lock);
1484− header = VDO(altmode->svid, 1, CMD_ENTER_MODE);
1484+ header = VDO(altmode->svid, vdo ? 2 : 1, CMD_ENTER_MODE);
14851485 header |= VDO_OPOS(altmode->mode);
14861486
1487− tcpm_queue_vdm(port, header, NULL, 0);
1487+ tcpm_queue_vdm(port, header, vdo, vdo ? 1 : 0);
14881488 mod_delayed_work(port->wq, &port->vdm_state_machine, 0);
14891489 mutex_unlock(&port->lock);
14901490
drivers/usb/typec/ucsi/displayport.c+1−1
@@ -45,7 +45,7 @@ struct ucsi_dp { · 44 unmodified lines
4545 * -EOPNOTSUPP.
4646 */
4747
48−static int ucsi_displayport_enter(struct typec_altmode *alt)
48+static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)
4949 {
5050 struct ucsi_dp *dp = typec_altmode_get_drvdata(alt);
5151 struct ucsi *ucsi = dp->con->ucsi;
include/linux/usb/typec_altmode.h+2−2
@@ -55,7 +55,7 @@ static inline void *typec_altmode_get_drvdata(struct typec_altmode *altmode) · 54 unmodified lines
5555 * @activate: User callback for Enter/Exit Mode
5656 */
5757 struct typec_altmode_ops {
58− int (*enter)(struct typec_altmode *altmode);
58+ int (*enter)(struct typec_altmode *altmode, u32 *vdo);
5959 int (*exit)(struct typec_altmode *altmode);
6060 void (*attention)(struct typec_altmode *altmode, u32 vdo);
6161 int (*vdm)(struct typec_altmode *altmode, const u32 hdr,
@@ -65,7 +65,7 @@ struct typec_altmode_ops { · 3 unmodified lines
6565 int (*activate)(struct typec_altmode *altmode, int activate);
6666 };
6767
68−int typec_altmode_enter(struct typec_altmode *altmode);
68+int typec_altmode_enter(struct typec_altmode *altmode, u32 *vdo);
6969 int typec_altmode_exit(struct typec_altmode *altmode);
7070 void typec_altmode_attention(struct typec_altmode *altmode, u32 vdo);
7171 int typec_altmode_vdm(struct typec_altmode *altmode,