From: Guenter Roeck <linux@roeck-us.net>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Adam Thomson <Adam.Thomson.Opensource@diasemi.com>,
Kyle Tso <kyletso@google.com>,
linux-usb@vger.kernel.org
Subject: [1/3] usb: typec: tcpm: Add start_srp_connection_detect callback
Date: Mon, 15 Apr 2019 11:38:51 -0700 [thread overview]
Message-ID: <20190415183851.GC22463@roeck-us.net> (raw)
On Mon, Apr 15, 2019 at 07:53:58PM +0200, Hans de Goede wrote:
> Hi Guenter,
>
> On 15-04-19 17:51, Guenter Roeck wrote:
> >On Sat, Apr 13, 2019 at 10:39:53PM +0200, Hans de Goede wrote:
> >>Some tcpc device-drivers need to explicitly be told to watch for connection
> >>events, otherwise the tcpc will not generate any TCPM_CC_EVENTs and devices
> >>being plugged into the Type-C port will not be noticed.
> >>
> >>For dual-role ports tcpm_start_drp_toggling() is used to tell the tcpc to
> >>watch for connection events. But for single-role ports we've so far been
> >>falling back to just calling tcpm_set_cc(). For some tcpc-s such as the
> >>fusb302 this is not enough and no TCPM_CC_EVENT will be generated.
> >>
> >>This commit adds a new start_srp_connection_detect callback to tcpc_dev
> >>and when this is implemented calls this in place of start_drp_toggling
> >>for SRP devices.
> >>
> >
> >Do we indeed need an additional callback for this purpose, or would a single
> >"start_connection_detect" call to replace start_drp_toggling be sufficient ?
> >If necessary, we could add the port type as argument (if the low level driver
> >doesn't already know that).
>
> A single "start_connection_detect" call to replace start_drp_toggling will be
> sufficient AFAICT.
>
> If you prefer that option, I can rework the patch-set accordingly.
>
Yes, I do. I find it quite pointless to have two callbacks if exactly one
is ever called.
Thanks,
Guenter
> Regards,
>
> Hans
>
>
>
> >>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>
> >>---
> >> drivers/usb/typec/tcpm/tcpm.c | 8 ++++++++
> >> include/linux/usb/tcpm.h | 6 ++++++
> >> 2 files changed, 14 insertions(+)
> >>
> >>diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> >>index a2233d72ae7c..1af54af90b50 100644
> >>--- a/drivers/usb/typec/tcpm/tcpm.c
> >>+++ b/drivers/usb/typec/tcpm/tcpm.c
> >>@@ -2553,6 +2553,14 @@ static bool tcpm_start_drp_toggling(struct tcpm_port *port,
> >> return true;
> >> }
> >>+ if (port->tcpc->start_srp_connection_detect &&
> >>+ port->port_type != TYPEC_PORT_DRP) {
> >>+ tcpm_log_force(port, "Start SRP connection detection");
> >>+ ret = port->tcpc->start_srp_connection_detect(port->tcpc, cc);
> >>+ if (!ret)
> >>+ return true;
> >>+ }
> >>+
> >> return false;
> >> }
> >>diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
> >>index 0c532ca3f079..bf2bbbf2e2b2 100644
> >>--- a/include/linux/usb/tcpm.h
> >>+++ b/include/linux/usb/tcpm.h
> >>@@ -125,6 +125,10 @@ struct tcpc_config {
> >> * Optional; if supported by hardware, called to start DRP
> >> * toggling. DRP toggling is stopped automatically if
> >> * a connection is established.
> >>+ * @start_srp_connection_detect:
> >>+ * Optional; if supported by hardware, called to start connection
> >>+ * detection for single role ports. Connection detection is stopped
> >>+ * automatically if a connection is established.
> >> * @try_role: Optional; called to set a preferred role
> >> * @pd_transmit:Called to transmit PD message
> >> * @mux: Pointer to multiplexer data
> >>@@ -149,6 +153,8 @@ struct tcpc_dev {
> >> enum typec_role role, enum typec_data_role data);
> >> int (*start_drp_toggling)(struct tcpc_dev *dev,
> >> enum typec_cc_status cc);
> >>+ int (*start_srp_connection_detect)(struct tcpc_dev *dev,
> >>+ enum typec_cc_status cc);
> >> int (*try_role)(struct tcpc_dev *dev, int role);
> >> int (*pd_transmit)(struct tcpc_dev *dev, enum tcpm_transmit_type type,
> >> const struct pd_message *msg);
> >>--
> >>2.21.0
> >>
WARNING: multiple messages have this Message-ID (diff)
From: Guenter Roeck <linux@roeck-us.net>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Adam Thomson <Adam.Thomson.Opensource@diasemi.com>,
Kyle Tso <kyletso@google.com>,
linux-usb@vger.kernel.org
Subject: Re: [PATCH 1/3] usb: typec: tcpm: Add start_srp_connection_detect callback
Date: Mon, 15 Apr 2019 11:38:51 -0700 [thread overview]
Message-ID: <20190415183851.GC22463@roeck-us.net> (raw)
Message-ID: <20190415183851.4zk68DGoedZXU3oxKIcm-V4J1oMO55DVsO6Z-Jw4kBY@z> (raw)
In-Reply-To: <c66d328e-0cea-9962-1fb6-009f78bf946e@redhat.com>
On Mon, Apr 15, 2019 at 07:53:58PM +0200, Hans de Goede wrote:
> Hi Guenter,
>
> On 15-04-19 17:51, Guenter Roeck wrote:
> >On Sat, Apr 13, 2019 at 10:39:53PM +0200, Hans de Goede wrote:
> >>Some tcpc device-drivers need to explicitly be told to watch for connection
> >>events, otherwise the tcpc will not generate any TCPM_CC_EVENTs and devices
> >>being plugged into the Type-C port will not be noticed.
> >>
> >>For dual-role ports tcpm_start_drp_toggling() is used to tell the tcpc to
> >>watch for connection events. But for single-role ports we've so far been
> >>falling back to just calling tcpm_set_cc(). For some tcpc-s such as the
> >>fusb302 this is not enough and no TCPM_CC_EVENT will be generated.
> >>
> >>This commit adds a new start_srp_connection_detect callback to tcpc_dev
> >>and when this is implemented calls this in place of start_drp_toggling
> >>for SRP devices.
> >>
> >
> >Do we indeed need an additional callback for this purpose, or would a single
> >"start_connection_detect" call to replace start_drp_toggling be sufficient ?
> >If necessary, we could add the port type as argument (if the low level driver
> >doesn't already know that).
>
> A single "start_connection_detect" call to replace start_drp_toggling will be
> sufficient AFAICT.
>
> If you prefer that option, I can rework the patch-set accordingly.
>
Yes, I do. I find it quite pointless to have two callbacks if exactly one
is ever called.
Thanks,
Guenter
> Regards,
>
> Hans
>
>
>
> >>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>
> >>---
> >> drivers/usb/typec/tcpm/tcpm.c | 8 ++++++++
> >> include/linux/usb/tcpm.h | 6 ++++++
> >> 2 files changed, 14 insertions(+)
> >>
> >>diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> >>index a2233d72ae7c..1af54af90b50 100644
> >>--- a/drivers/usb/typec/tcpm/tcpm.c
> >>+++ b/drivers/usb/typec/tcpm/tcpm.c
> >>@@ -2553,6 +2553,14 @@ static bool tcpm_start_drp_toggling(struct tcpm_port *port,
> >> return true;
> >> }
> >>+ if (port->tcpc->start_srp_connection_detect &&
> >>+ port->port_type != TYPEC_PORT_DRP) {
> >>+ tcpm_log_force(port, "Start SRP connection detection");
> >>+ ret = port->tcpc->start_srp_connection_detect(port->tcpc, cc);
> >>+ if (!ret)
> >>+ return true;
> >>+ }
> >>+
> >> return false;
> >> }
> >>diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
> >>index 0c532ca3f079..bf2bbbf2e2b2 100644
> >>--- a/include/linux/usb/tcpm.h
> >>+++ b/include/linux/usb/tcpm.h
> >>@@ -125,6 +125,10 @@ struct tcpc_config {
> >> * Optional; if supported by hardware, called to start DRP
> >> * toggling. DRP toggling is stopped automatically if
> >> * a connection is established.
> >>+ * @start_srp_connection_detect:
> >>+ * Optional; if supported by hardware, called to start connection
> >>+ * detection for single role ports. Connection detection is stopped
> >>+ * automatically if a connection is established.
> >> * @try_role: Optional; called to set a preferred role
> >> * @pd_transmit:Called to transmit PD message
> >> * @mux: Pointer to multiplexer data
> >>@@ -149,6 +153,8 @@ struct tcpc_dev {
> >> enum typec_role role, enum typec_data_role data);
> >> int (*start_drp_toggling)(struct tcpc_dev *dev,
> >> enum typec_cc_status cc);
> >>+ int (*start_srp_connection_detect)(struct tcpc_dev *dev,
> >>+ enum typec_cc_status cc);
> >> int (*try_role)(struct tcpc_dev *dev, int role);
> >> int (*pd_transmit)(struct tcpc_dev *dev, enum tcpm_transmit_type type,
> >> const struct pd_message *msg);
> >>--
> >>2.21.0
> >>
next prev reply other threads:[~2019-04-15 18:38 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-13 20:39 [1/3] usb: typec: tcpm: Add start_srp_connection_detect callback Hans de Goede
2019-04-13 20:39 ` [PATCH 1/3] " Hans de Goede
2019-04-13 20:39 ` [2/3] usb: typec: fusb302: Implement start_srp_connection_detect Hans de Goede
2019-04-13 20:39 ` [PATCH 2/3] " Hans de Goede
2019-04-14 7:40 ` [2/3] " Sergei Shtylyov
2019-04-14 7:40 ` [PATCH 2/3] " Sergei Shtylyov
2019-04-16 20:06 ` [2/3] " Hans de Goede
2019-04-16 20:06 ` [PATCH 2/3] " Hans de Goede
2019-04-13 20:39 ` [3/3] usb: typec: fusb302: Revert "Resolve fixed power role contract setup" Hans de Goede
2019-04-13 20:39 ` [PATCH 3/3] " Hans de Goede
2019-04-15 10:31 ` [1/3] usb: typec: tcpm: Add start_srp_connection_detect callback Opensource [Adam Thomson]
2019-04-15 10:31 ` [PATCH 1/3] " Adam Thomson
2019-04-15 10:37 ` [1/3] " Hans de Goede
2019-04-15 10:37 ` [PATCH 1/3] " Hans de Goede
2019-04-15 13:22 ` [1/3] " Guenter Roeck
2019-04-15 13:22 ` [PATCH 1/3] " Guenter Roeck
2019-04-15 13:28 ` [1/3] " Opensource [Adam Thomson]
2019-04-15 13:28 ` [PATCH 1/3] " Adam Thomson
2019-04-15 15:51 ` [1/3] " Guenter Roeck
2019-04-15 15:51 ` [PATCH 1/3] " Guenter Roeck
2019-04-15 17:53 ` [1/3] " Hans de Goede
2019-04-15 17:53 ` [PATCH 1/3] " Hans de Goede
2019-04-15 18:38 ` Guenter Roeck [this message]
2019-04-15 18:38 ` Guenter Roeck
2019-04-16 20:07 ` [1/3] " Hans de Goede
2019-04-16 20:07 ` [PATCH 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=20190415183851.GC22463@roeck-us.net \
--to=linux@roeck-us.net \
--cc=Adam.Thomson.Opensource@diasemi.com \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=kyletso@google.com \
--cc=linux-usb@vger.kernel.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).