Message ID | 20190416200754.2826-2-hdegoede@redhat.com (mailing list archive) |
---|---|
State | Mainlined |
Commit | 6258db14d78c6991bcdd56f576788b3b2e16cc3f |
Headers | show |
Series | [v2,1/3] usb: typec: tcpm: Notify the tcpc to start connection-detection for SRPs | expand |
On 4/16/19 1:07 PM, Hans de Goede wrote: > When in single-role port mode, we must start single-role toggling to > get an interrupt when a device / cable gets plugged into the port. > > This commit modifies the fusb302 start_toggling implementation to > start toggling for all port-types, so that connection-detection works > on single-role ports too. > > Fixes: ea3b4d5523bc("usb: typec: fusb302: Resolve fixed power role ...") > Cc: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> > Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> > --- > Changes in v2: > -Adjust for the tcpm core renaming start_drp_toggling to start_toggling, > instead of adding a new start_srp_connection_detect callback > --- > drivers/usb/typec/tcpm/fusb302.c | 16 +++++++++++++--- > 1 file changed, 13 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c > index 6d83891cc895..ba030b03d156 100644 > --- a/drivers/usb/typec/tcpm/fusb302.c > +++ b/drivers/usb/typec/tcpm/fusb302.c > @@ -882,10 +882,20 @@ static int tcpm_start_toggling(struct tcpc_dev *dev, > { > struct fusb302_chip *chip = container_of(dev, struct fusb302_chip, > tcpc_dev); > + enum toggling_mode mode = TOGGLING_MODE_OFF; > int ret = 0; > > - if (port_type != TYPEC_PORT_DRP) > - return -EOPNOTSUPP; > + switch (port_type) { > + case TYPEC_PORT_SRC: > + mode = TOGGLING_MODE_SRC; > + break; > + case TYPEC_PORT_SNK: > + mode = TOGGLING_MODE_SNK; > + break; > + case TYPEC_PORT_DRP: > + mode = TOGGLING_MODE_DRP; > + break; > + } > > mutex_lock(&chip->lock); > ret = fusb302_set_src_current(chip, cc_src_current[cc]); > @@ -894,7 +904,7 @@ static int tcpm_start_toggling(struct tcpc_dev *dev, > typec_cc_status_name[cc], ret); > goto done; > } > - ret = fusb302_set_toggling(chip, TOGGLING_MODE_DRP); > + ret = fusb302_set_toggling(chip, mode); > if (ret < 0) { > fusb302_log(chip, > "unable to start drp toggling, ret=%d", ret); >
On Tue, Apr 16, 2019 at 10:07:53PM +0200, Hans de Goede wrote: > When in single-role port mode, we must start single-role toggling to > get an interrupt when a device / cable gets plugged into the port. > > This commit modifies the fusb302 start_toggling implementation to > start toggling for all port-types, so that connection-detection works > on single-role ports too. > > Fixes: ea3b4d5523bc("usb: typec: fusb302: Resolve fixed power role ...") > Cc: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> > Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by Heikki Krogerus <heikki.krogerus@linux.intel.com> > --- > Changes in v2: > -Adjust for the tcpm core renaming start_drp_toggling to start_toggling, > instead of adding a new start_srp_connection_detect callback > --- > drivers/usb/typec/tcpm/fusb302.c | 16 +++++++++++++--- > 1 file changed, 13 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c > index 6d83891cc895..ba030b03d156 100644 > --- a/drivers/usb/typec/tcpm/fusb302.c > +++ b/drivers/usb/typec/tcpm/fusb302.c > @@ -882,10 +882,20 @@ static int tcpm_start_toggling(struct tcpc_dev *dev, > { > struct fusb302_chip *chip = container_of(dev, struct fusb302_chip, > tcpc_dev); > + enum toggling_mode mode = TOGGLING_MODE_OFF; > int ret = 0; > > - if (port_type != TYPEC_PORT_DRP) > - return -EOPNOTSUPP; > + switch (port_type) { > + case TYPEC_PORT_SRC: > + mode = TOGGLING_MODE_SRC; > + break; > + case TYPEC_PORT_SNK: > + mode = TOGGLING_MODE_SNK; > + break; > + case TYPEC_PORT_DRP: > + mode = TOGGLING_MODE_DRP; > + break; > + } > > mutex_lock(&chip->lock); > ret = fusb302_set_src_current(chip, cc_src_current[cc]); > @@ -894,7 +904,7 @@ static int tcpm_start_toggling(struct tcpc_dev *dev, > typec_cc_status_name[cc], ret); > goto done; > } > - ret = fusb302_set_toggling(chip, TOGGLING_MODE_DRP); > + ret = fusb302_set_toggling(chip, mode); > if (ret < 0) { > fusb302_log(chip, > "unable to start drp toggling, ret=%d", ret); > -- > 2.21.0 thanks,
On 16 April 2019 21:08, Hans de Goede wrote: > When in single-role port mode, we must start single-role toggling to > get an interrupt when a device / cable gets plugged into the port. > > This commit modifies the fusb302 start_toggling implementation to > start toggling for all port-types, so that connection-detection works > on single-role ports too. > > Fixes: ea3b4d5523bc("usb: typec: fusb302: Resolve fixed power role ...") > Cc: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> > Signed-off-by: Hans de Goede <hdegoede@redhat.com> For DRP & Sink only toggling scenarios, with FUSB302 TCPC: Tested-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> > --- > Changes in v2: > -Adjust for the tcpm core renaming start_drp_toggling to start_toggling, > instead of adding a new start_srp_connection_detect callback > --- > drivers/usb/typec/tcpm/fusb302.c | 16 +++++++++++++--- > 1 file changed, 13 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/typec/tcpm/fusb302.c > b/drivers/usb/typec/tcpm/fusb302.c > index 6d83891cc895..ba030b03d156 100644 > --- a/drivers/usb/typec/tcpm/fusb302.c > +++ b/drivers/usb/typec/tcpm/fusb302.c > @@ -882,10 +882,20 @@ static int tcpm_start_toggling(struct tcpc_dev *dev, > { > struct fusb302_chip *chip = container_of(dev, struct fusb302_chip, > tcpc_dev); > + enum toggling_mode mode = TOGGLING_MODE_OFF; > int ret = 0; > > - if (port_type != TYPEC_PORT_DRP) > - return -EOPNOTSUPP; > + switch (port_type) { > + case TYPEC_PORT_SRC: > + mode = TOGGLING_MODE_SRC; > + break; > + case TYPEC_PORT_SNK: > + mode = TOGGLING_MODE_SNK; > + break; > + case TYPEC_PORT_DRP: > + mode = TOGGLING_MODE_DRP; > + break; > + } > > mutex_lock(&chip->lock); > ret = fusb302_set_src_current(chip, cc_src_current[cc]); > @@ -894,7 +904,7 @@ static int tcpm_start_toggling(struct tcpc_dev *dev, > typec_cc_status_name[cc], ret); > goto done; > } > - ret = fusb302_set_toggling(chip, TOGGLING_MODE_DRP); > + ret = fusb302_set_toggling(chip, mode); > if (ret < 0) { > fusb302_log(chip, > "unable to start drp toggling, ret=%d", ret); > -- > 2.21.0
diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c index 6d83891cc895..ba030b03d156 100644 --- a/drivers/usb/typec/tcpm/fusb302.c +++ b/drivers/usb/typec/tcpm/fusb302.c @@ -882,10 +882,20 @@ static int tcpm_start_toggling(struct tcpc_dev *dev, { struct fusb302_chip *chip = container_of(dev, struct fusb302_chip, tcpc_dev); + enum toggling_mode mode = TOGGLING_MODE_OFF; int ret = 0; - if (port_type != TYPEC_PORT_DRP) - return -EOPNOTSUPP; + switch (port_type) { + case TYPEC_PORT_SRC: + mode = TOGGLING_MODE_SRC; + break; + case TYPEC_PORT_SNK: + mode = TOGGLING_MODE_SNK; + break; + case TYPEC_PORT_DRP: + mode = TOGGLING_MODE_DRP; + break; + } mutex_lock(&chip->lock); ret = fusb302_set_src_current(chip, cc_src_current[cc]); @@ -894,7 +904,7 @@ static int tcpm_start_toggling(struct tcpc_dev *dev, typec_cc_status_name[cc], ret); goto done; } - ret = fusb302_set_toggling(chip, TOGGLING_MODE_DRP); + ret = fusb302_set_toggling(chip, mode); if (ret < 0) { fusb302_log(chip, "unable to start drp toggling, ret=%d", ret);
When in single-role port mode, we must start single-role toggling to get an interrupt when a device / cable gets plugged into the port. This commit modifies the fusb302 start_toggling implementation to start toggling for all port-types, so that connection-detection works on single-role ports too. Fixes: ea3b4d5523bc("usb: typec: fusb302: Resolve fixed power role ...") Cc: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> --- Changes in v2: -Adjust for the tcpm core renaming start_drp_toggling to start_toggling, instead of adding a new start_srp_connection_detect callback --- drivers/usb/typec/tcpm/fusb302.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)