Skip to content

Commit

Permalink
usb: typec: Allow power role swapping even without USB PD
Browse files Browse the repository at this point in the history
Even though originally the USB Type-C Specification did not
describe the steps for power role swapping without USB PD
contract in place, it did not actually mean power role swap
without USB PD was not allowed. The USB Type-C Specification
did not clearly separate the data and power roles until in
the release 1.2 which is why there also were no clear steps
for the scenario where only the power role was swapped
without USB PD contract before that.

Since in the latest version of the specification the power
role swap without USB PD is now clearly mentioned as allowed
operation, removing the check that prevented power role swap
without USB PD support.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20200211112531.86510-4-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Heikki Krogerus authored and Greg Kroah-Hartman committed Feb 12, 2020
1 parent 7932306 commit ae4ba35
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
14 changes: 7 additions & 7 deletions Documentation/ABI/testing/sysfs-class-typec
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ 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
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.
power role swap on the port. 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.

Valid values: source, sink

Expand Down
6 changes: 0 additions & 6 deletions drivers/usb/typec/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,11 +1112,6 @@ static ssize_t power_role_store(struct device *dev,
struct typec_port *port = to_typec_port(dev);
int ret;

if (!port->cap->pd_revision) {
dev_dbg(dev, "USB Power Delivery not supported\n");
return -EOPNOTSUPP;
}

if (!port->ops || !port->ops->pr_set) {
dev_dbg(dev, "power role swapping not supported\n");
return -EOPNOTSUPP;
Expand Down Expand Up @@ -1338,7 +1333,6 @@ static umode_t typec_attr_is_visible(struct kobject *kobj,
return 0444;
} else if (attr == &dev_attr_power_role.attr) {
if (port->cap->type != TYPEC_PORT_DRP ||
!port->cap->pd_revision ||
!port->ops || !port->ops->pr_set)
return 0444;
} else if (attr == &dev_attr_vconn_source.attr) {
Expand Down

0 comments on commit ae4ba35

Please sign in to comment.