From: Hans de Goede <hdegoede@redhat.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Guenter Roeck <linux@roeck-us.net>, Heikki Krogerus <heikki.krogerus@linux.intel.com> Cc: Hans de Goede <hdegoede@redhat.com>, Adam Thomson <Adam.Thomson.Opensource@diasemi.com>, Kyle Tso <kyletso@google.com>, linux-usb@vger.kernel.org Subject: [v2,2/3] usb: typec: fusb302: Implement start_toggling for all port-types Date: Tue, 16 Apr 2019 22:07:53 +0200 [thread overview] Message-ID: <20190416200754.2826-2-hdegoede@redhat.com> (raw) 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(-) 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);
WARNING: multiple messages have this Message-ID (diff)
From: Hans de Goede <hdegoede@redhat.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Guenter Roeck <linux@roeck-us.net>, Heikki Krogerus <heikki.krogerus@linux.intel.com> Cc: Hans de Goede <hdegoede@redhat.com>, Adam Thomson <Adam.Thomson.Opensource@diasemi.com>, Kyle Tso <kyletso@google.com>, linux-usb@vger.kernel.org Subject: [PATCH v2 2/3] usb: typec: fusb302: Implement start_toggling for all port-types Date: Tue, 16 Apr 2019 22:07:53 +0200 [thread overview] Message-ID: <20190416200754.2826-2-hdegoede@redhat.com> (raw) Message-ID: <20190416200753.pCUVp__YJtV1EGLejofVfu4O57Iss6nMDUS9hNYYX_8@z> (raw) In-Reply-To: <20190416200754.2826-1-hdegoede@redhat.com> 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(-) 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
next reply other threads:[~2019-04-16 20:07 UTC|newest] Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-04-16 20:07 Hans de Goede [this message] 2019-04-16 20:07 ` [PATCH v2 2/3] usb: typec: fusb302: Implement start_toggling for all port-types Hans de Goede -- strict thread matches above, loose matches on Subject: below -- 2019-04-17 10:53 [v2,3/3] usb: typec: fusb302: Revert "Resolve fixed power role contract setup" Opensource [Adam Thomson] 2019-04-17 10:53 ` [PATCH v2 3/3] " Adam Thomson 2019-04-17 10:50 [v2,2/3] usb: typec: fusb302: Implement start_toggling for all port-types Opensource [Adam Thomson] 2019-04-17 10:50 ` [PATCH v2 2/3] " Adam Thomson 2019-04-17 10:49 [v2,1/3] usb: typec: tcpm: Notify the tcpc to start connection-detection for SRPs Opensource [Adam Thomson] 2019-04-17 10:49 ` [PATCH v2 1/3] " Adam Thomson 2019-04-17 6:24 [v2,3/3] usb: typec: fusb302: Revert "Resolve fixed power role contract setup" Heikki Krogerus 2019-04-17 6:24 ` [PATCH v2 3/3] " Heikki Krogerus 2019-04-17 6:24 [v2,2/3] usb: typec: fusb302: Implement start_toggling for all port-types Heikki Krogerus 2019-04-17 6:24 ` [PATCH v2 2/3] " Heikki Krogerus 2019-04-17 6:23 [v2,1/3] usb: typec: tcpm: Notify the tcpc to start connection-detection for SRPs Heikki Krogerus 2019-04-17 6:23 ` [PATCH v2 1/3] " Heikki Krogerus 2019-04-17 3:44 [v2,3/3] usb: typec: fusb302: Revert "Resolve fixed power role contract setup" Guenter Roeck 2019-04-17 3:44 ` [PATCH v2 3/3] " Guenter Roeck 2019-04-17 3:43 [v2,2/3] usb: typec: fusb302: Implement start_toggling for all port-types Guenter Roeck 2019-04-17 3:43 ` [PATCH v2 2/3] " Guenter Roeck 2019-04-17 3:42 [v2,1/3] usb: typec: tcpm: Notify the tcpc to start connection-detection for SRPs Guenter Roeck 2019-04-17 3:42 ` [PATCH v2 1/3] " Guenter Roeck 2019-04-16 20:07 [v2,3/3] usb: typec: fusb302: Revert "Resolve fixed power role contract setup" Hans de Goede 2019-04-16 20:07 ` [PATCH v2 3/3] " Hans de Goede 2019-04-16 20:07 [v2,1/3] usb: typec: tcpm: Notify the tcpc to start connection-detection for SRPs Hans de Goede 2019-04-16 20:07 ` [PATCH v2 1/3] " Hans de Goede
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190416200754.2826-2-hdegoede@redhat.com \ --to=hdegoede@redhat.com \ --cc=Adam.Thomson.Opensource@diasemi.com \ --cc=gregkh@linuxfoundation.org \ --cc=heikki.krogerus@linux.intel.com \ --cc=kyletso@google.com \ --cc=linux-usb@vger.kernel.org \ --cc=linux@roeck-us.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.