Skip to contentSkip to conversation

usb: typec: fusb302: Implement start_srp_connection_detect

PATCH New Hans de Goede 1 participant 1 message Apr 16, 2019 USB

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 usb: typec: fusb302: Implement start_srp_connection_detect

Hi,

Thank you for the review.

Quoted 7 lines · Sergei Shtylyov

Hello!

Quoted 1 line · Hans de Goede

When in single role port mode, we most start single-role toggling to

   Must, perhaps?

Right, fixed for the upcoming v2 of the patch-set.

Quoted 10 lines
Quoted 10 lines

get an interrupt when a device / cable gets plugged into the port.

This commit implements the tcpc_dev start_srp_connection_detect callback for this.

---
  drivers/usb/typec/tcpm/fusb302.c | 30 ++++++++++++++++++++++++++++++

  1 file changed, 30 insertions(+)
Quoted 15 lines

drivers/usb/typec/tcpm/fusb302.c static int tcpm_set_roles(struct tcpc_dev *dev, bool attached, · line 883

Quoted 13 lines
drivers/usb/typec/tcpm/fusb302.c +6 -0
index 6ea6199caafa..30413a45104f 100644
@@ -876,6 +876,34 @@ static int tcpm_set_roles(struct tcpc_dev *dev, bool attached,
       return ret;
   }
+static int tcpm_start_srp_connection_detect(struct tcpc_dev *dev,
+                        enum typec_cc_status cc)
+{
+    struct fusb302_chip *chip = container_of(dev, struct fusb302_chip,
+                         tcpc_dev);
+    int ret = 0;

   This initializer is useless.

Ack, this part is gone for v2 of the patch though.

Regards,

Hans

Quoted 29 lines
Quoted 16 lines
drivers/usb/typec/tcpm/fusb302.c +15 -0
+
+    mutex_lock(&chip->lock);
+    ret = fusb302_set_src_current(chip, cc_src_current[cc]);
+    if (ret < 0) {
+        fusb302_log(chip, "unable to set src current %s, ret=%d",
+                typec_cc_status_name[cc], ret);
+        goto done;
+    }
+    ret = fusb302_set_toggling(chip, (cc == TYPEC_CC_RD) ?
+                     TOGGLING_MODE_SNK : TOGGLING_MODE_SRC);
+    if (ret < 0) {
+        fusb302_log(chip,
+                "unable to start srp toggling, ret=%d", ret);
+        goto done;
+    }

drivers/usb/typec/tcpm/fusb302.c static int tcpm_set_roles(struct tcpc_dev *dev, bool attached, · line 908

Quoted 10 lines
drivers/usb/typec/tcpm/fusb302.c +7 -0
+    fusb302_log(chip, "start srp toggling");
+done:
+    mutex_unlock(&chip->lock);
+
+    return ret;
+}
+
   static int tcpm_start_drp_toggling(struct tcpc_dev *dev,
                      enum typec_cc_status cc)
   {

[...]

MBR, Sergei