All of lore.kernel.org
 help / color / mirror / Atom feed
From: Badhri Jagan Sridharan <badhri@google.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Guenter Roeck <linux@roeck-us.net>
Cc: Badhri Jagan Sridharan <Badhri@google.com>
Subject: [PATCH] usb: typec: Defer checking of valid power role swap to low level drivers
Date: Wed, 17 May 2017 00:32:19 -0700	[thread overview]
Message-ID: <20170517073219.8315-1-Badhri@google.com> (raw)

With this CL the lower level drivers are reponsible to check and make sure
that the role swap can be performed.

This facilitates the lower level driver to attempt to perform role swap
through initial connection process.

Quoting from the Type-C specification release(page 24),
role swaps are not limited to devices that only support PD.

"Two independent set of mechanisms are defined to allow a USB Type-C
DRP to functionally swap power and data roles. When USB PD is
supported, power and data role swapping is performed as a subsequent
step following the initial connection process. For non-PD implementations,
power/data role swapping can optionally be dealt with as part of the initial
connection process."

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
---
 Documentation/ABI/testing/sysfs-class-typec |  7 +++++--
 drivers/usb/typec/typec.c                   | 10 ----------
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-class-typec b/Documentation/ABI/testing/sysfs-class-typec
index d4a3d23eb09c..ba4ca684adb2 100644
--- a/Documentation/ABI/testing/sysfs-class-typec
+++ b/Documentation/ABI/testing/sysfs-class-typec
@@ -20,13 +20,16 @@ Date:		April 2017
 Contact:	Heikki Krogerus <heikki.krogerus@linux.intel.com>
 Description:
 		The supported power roles. This attribute can be used to request
-		power role swap on the port when the port supports USB Power
-		Delivery. Swapping is supported as synchronous operation, so
+		power role swap. Swapping is supported as synchronous operation, so
 		write(2) to the attribute will not return until the operation
 		has finished. The attribute is notified about role changes so
 		that poll(2) on the attribute wakes up. Change on the role will
 		also generate uevent KOBJ_CHANGE. The current role is show in
 		brackets, for example "[source] sink" when in source mode.
+		When both the port and the port-partner supports USB Power
+		Delivery, the PR_SWAP command is used to perform the role swap.
+		Otherwise, the port roles would be re-resolved by forcing
+		a disconnect and reconnect.
 
 		Valid values: source, sink
 
diff --git a/drivers/usb/typec/typec.c b/drivers/usb/typec/typec.c
index 89e540bb7ff3..fd2d661665fa 100644
--- a/drivers/usb/typec/typec.c
+++ b/drivers/usb/typec/typec.c
@@ -887,21 +887,11 @@ static ssize_t power_role_store(struct device *dev,
 	struct typec_port *port = to_typec_port(dev);
 	int ret = size;
 
-	if (!port->cap->pd_revision) {
-		dev_dbg(dev, "USB Power Delivery not supported\n");
-		return -EOPNOTSUPP;
-	}
-
 	if (!port->cap->pr_set) {
 		dev_dbg(dev, "power role swapping not supported\n");
 		return -EOPNOTSUPP;
 	}
 
-	if (port->pwr_opmode != TYPEC_PWR_MODE_PD) {
-		dev_dbg(dev, "partner unable to swap power role\n");
-		return -EIO;
-	}
-
 	ret = sysfs_match_string(typec_roles, buf);
 	if (ret < 0)
 		return ret;
-- 
2.13.0.303.g4ebf302169-goog

             reply	other threads:[~2017-05-17  7:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-17  7:32 Badhri Jagan Sridharan [this message]
2017-05-17  7:34 ` [PATCH] usb: typec: Defer checking of valid power role swap to low level drivers Oliver Neukum
2017-05-17  9:36   ` Guenter Roeck
2017-05-17 12:38     ` Heikki Krogerus
2017-05-17 13:02       ` Guenter Roeck
2017-05-17 13:51         ` Heikki Krogerus
2017-05-17 18:05           ` Badhri Jagan Sridharan
2017-05-18  9:13     ` Oliver Neukum
2017-05-18 16:51       ` Guenter Roeck
2017-05-18 21:08         ` Badhri Jagan Sridharan
2017-05-18 21:13           ` Badhri Jagan Sridharan
2017-05-19 10:35           ` Heikki Krogerus
2017-05-19 13:27             ` Guenter Roeck
2017-05-19 10:40           ` Oliver Neukum
2017-05-17  8:08 ` Greg Kroah-Hartman
2017-05-17  9:43   ` Guenter Roeck

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=20170517073219.8315-1-Badhri@google.com \
    --to=badhri@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --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: link
Be 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.