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
188 188
189 switch (dp->state) {189 switch (dp->state) {
190 case DP_STATE_ENTER:190 case DP_STATE_ENTER:
191 ret = typec_altmode_enter(dp->alt);191 ret = typec_altmode_enter(dp->alt, NULL);
192 if (ret)192 if (ret)
193 dev_err(&dp->alt->dev, "failed to enter mode\n");193 dev_err(&dp->alt->dev, "failed to enter mode\n");
194 break;194 break;
@@ -306,7 +306,8 @@ err_unlock: · 111 unmodified lines
306 306
307static int dp_altmode_activate(struct typec_altmode *alt, int activate)307static int dp_altmode_activate(struct typec_altmode *alt, int activate)
308{308{
309 return activate ? typec_altmode_enter(alt) : typec_altmode_exit(alt);309 return activate ? typec_altmode_enter(alt, NULL) :
310 typec_altmode_exit(alt);
310}311}
311 312
312static const struct typec_altmode_ops dp_altmode_ops = {313static 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
84/**84/**
85 * typec_altmode_enter - Enter Mode85 * typec_altmode_enter - Enter Mode
86 * @adev: The alternate mode86 * @adev: The alternate mode
87 * @vdo: VDO for the Enter Mode command
87 *88 *
88 * The alternate mode drivers use this function to enter mode. The port drivers89 * The alternate mode drivers use this function to enter mode. The port drivers
89 * use this to inform the alternate mode drivers that the partner has initiated90 * 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.
91 */93 */
92int typec_altmode_enter(struct typec_altmode *adev)94int typec_altmode_enter(struct typec_altmode *adev, u32 *vdo)
93{95{
94 struct altmode *partner = to_altmode(adev)->partner;96 struct altmode *partner = to_altmode(adev)->partner;
95 struct typec_altmode *pdev = &partner->adev;97 struct typec_altmode *pdev = &partner->adev;
@@ -110,7 +112,7 @@ int typec_altmode_enter(struct typec_altmode *adev) · 14 unmodified lines
110 return ret;112 return ret;
111 113
112 /* Enter Mode */114 /* Enter Mode */
113 return pdev->ops->enter(pdev);115 return pdev->ops->enter(pdev, vdo);
114}116}
115EXPORT_SYMBOL_GPL(typec_altmode_enter);117EXPORT_SYMBOL_GPL(typec_altmode_enter);
116 118
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
1475 return 0;1475 return 0;
1476}1476}
1477 1477
1478static int tcpm_altmode_enter(struct typec_altmode *altmode)1478static int tcpm_altmode_enter(struct typec_altmode *altmode, u32 *vdo)
1479{1479{
1480 struct tcpm_port *port = typec_altmode_get_drvdata(altmode);1480 struct tcpm_port *port = typec_altmode_get_drvdata(altmode);
1481 u32 header;1481 u32 header;
1482 1482
1483 mutex_lock(&port->lock);1483 mutex_lock(&port->lock);
1484 header = VDO(altmode->svid, 1, CMD_ENTER_MODE);1484 header = VDO(altmode->svid, vdo ? 2 : 1, CMD_ENTER_MODE);
1485 header |= VDO_OPOS(altmode->mode);1485 header |= VDO_OPOS(altmode->mode);
1486 1486
1487 tcpm_queue_vdm(port, header, NULL, 0);1487 tcpm_queue_vdm(port, header, vdo, vdo ? 1 : 0);
1488 mod_delayed_work(port->wq, &port->vdm_state_machine, 0);1488 mod_delayed_work(port->wq, &port->vdm_state_machine, 0);
1489 mutex_unlock(&port->lock);1489 mutex_unlock(&port->lock);
1490 1490
drivers/usb/typec/ucsi/displayport.c+1−1
@@ -45,7 +45,7 @@ struct ucsi_dp { · 44 unmodified lines
45 * -EOPNOTSUPP.45 * -EOPNOTSUPP.
46 */46 */
47 47
48static int ucsi_displayport_enter(struct typec_altmode *alt)48static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)
49{49{
50 struct ucsi_dp *dp = typec_altmode_get_drvdata(alt);50 struct ucsi_dp *dp = typec_altmode_get_drvdata(alt);
51 struct ucsi *ucsi = dp->con->ucsi;51 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
55 * @activate: User callback for Enter/Exit Mode55 * @activate: User callback for Enter/Exit Mode
56 */56 */
57struct typec_altmode_ops {57struct typec_altmode_ops {
58 int (*enter)(struct typec_altmode *altmode);58 int (*enter)(struct typec_altmode *altmode, u32 *vdo);
59 int (*exit)(struct typec_altmode *altmode);59 int (*exit)(struct typec_altmode *altmode);
60 void (*attention)(struct typec_altmode *altmode, u32 vdo);60 void (*attention)(struct typec_altmode *altmode, u32 vdo);
61 int (*vdm)(struct typec_altmode *altmode, const u32 hdr,61 int (*vdm)(struct typec_altmode *altmode, const u32 hdr,
@@ -65,7 +65,7 @@ struct typec_altmode_ops { · 3 unmodified lines
65 int (*activate)(struct typec_altmode *altmode, int activate);65 int (*activate)(struct typec_altmode *altmode, int activate);
66};66};
67 67
68int typec_altmode_enter(struct typec_altmode *altmode);68int typec_altmode_enter(struct typec_altmode *altmode, u32 *vdo);
69int typec_altmode_exit(struct typec_altmode *altmode);69int typec_altmode_exit(struct typec_altmode *altmode);
70void typec_altmode_attention(struct typec_altmode *altmode, u32 vdo);70void typec_altmode_attention(struct typec_altmode *altmode, u32 vdo);
71int typec_altmode_vdm(struct typec_altmode *altmode,71int typec_altmode_vdm(struct typec_altmode *altmode,