Skip to contentSkip to conversation

usb: typec: pd: Add higher_capability sysfs for sink PDO

PATCH In review Saranya Gopal 3 participants 4 messages Feb 13, 2023 – Feb 14, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 usb: typec: pd: Add higher_capability sysfs for sink PDO

As per USB PD specification, 28th bit of sink fixed power supply PDO represents higher capability. If this bit is set, it indicates that the sink needs more than vsafe5V to provide full functionality. This patch replaces usb_suspend_supported sysfs with higher_capability sysfs for sink PDO.

Fixes 662a60102c12 ("usb: typec: Separate USB Power Delivery from USB Type-C")

---
Changed from v1:
- Added the valid values for the sysfs
- Wrapped the description alone to 80 characters

 .../ABI/testing/sysfs-class-usb_power_delivery        | 11 ++++++++++-
 drivers/usb/typec/pd.c                                |  9 ++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)
Documentation/ABI/testing/sysfs-class-usb_power_delivery +10 -1
index ce2b1b563cb3..1bf9d1d7902c 100644
@@ -69,7 +69,7 @@ Description:
 		This file contains boolean value that tells does the device
 		support both source and sink power roles.
 
-What:		/sys/class/usb_power_delivery/.../<capability>/1:fixed_supply/usb_suspend_supported
+What:		/sys/class/usb_power_delivery/.../source-capabilities/1:fixed_supply/usb_suspend_supported
 Date:		May 2022
 Contact:	Heikki Krogerus <[email protected]>
 Description:
@@ -78,6 +78,15 @@ Description:
 		will follow the USB 2.0 and USB 3.2 rules for suspend and
 		resume.
 
+What:		/sys/class/usb_power_delivery/.../sink-capabilities/1:fixed_supply/higher_capability
+Date:		February 2023
+Contact:	Saranya Gopal <[email protected]>
+Description:
+		This file shows the value of the Higher capability bit in
+		vsafe5V Fixed Supply Object. If the bit is set, then the sink
+		needs more than vsafe5V(eg. 12 V) to provide full functionality.
+		Valid values: 0, 1
+
 What:		/sys/class/usb_power_delivery/.../<capability>/1:fixed_supply/unconstrained_power
 Date:		May 2022
 Contact:	Heikki Krogerus <[email protected]>
drivers/usb/typec/pd.c +8 -1
index dc72005d68db..59c537a5e600 100644
@@ -48,6 +48,13 @@ usb_suspend_supported_show(struct device *dev, struct device_attribute *attr, ch
 }
 static DEVICE_ATTR_RO(usb_suspend_supported);
 
+static ssize_t
+higher_capability_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	return sysfs_emit(buf, "%u\n", !!(to_pdo(dev)->pdo & PDO_FIXED_HIGHER_CAP));
+}
+static DEVICE_ATTR_RO(higher_capability);
+
 static ssize_t
 unconstrained_power_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
@@ -161,7 +168,7 @@ static struct device_type source_fixed_supply_type = {
 
 static struct attribute *sink_fixed_supply_attrs[] = {
 	&dev_attr_dual_role_power.attr,
-	&dev_attr_usb_suspend_supported.attr,
+	&dev_attr_higher_capability.attr,
 	&dev_attr_unconstrained_power.attr,
 	&dev_attr_usb_communication_capable.attr,
 	&dev_attr_dual_role_data.attr,
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 23 lines · Saranya Gopal

As per USB PD specification, 28th bit of sink fixed power supply PDO represents higher capability. If this bit is set, it indicates that the sink needs more than vsafe5V to provide full functionality. This patch replaces usb_suspend_supported sysfs with higher_capability sysfs for sink PDO.

Fixes 662a60102c12 ("usb: typec: Separate USB Power Delivery from USB Type-C")

---
Changed from v1:
- Added the valid values for the sysfs
- Wrapped the description alone to 80 characters

 .../ABI/testing/sysfs-class-usb_power_delivery        | 11 ++++++++++-
 drivers/usb/typec/pd.c                                |  9 ++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)
Documentation/ABI/testing/sysfs-class-usb_power_delivery +0 -0
index ce2b1b563cb3..1bf9d1d7902c 100644

Documentation/ABI/testing/sysfs-class-usb_power_delivery Description: · line 72

Quoted 5 lines
Documentation/ABI/testing/sysfs-class-usb_power_delivery +1 -1
@@ -69,7 +69,7 @@ Description:
 		This file contains boolean value that tells does the device
 		support both source and sink power roles.
 
-What:		/sys/class/usb_power_delivery/.../<capability>/1:fixed_supply/usb_suspend_supported
+What:		/sys/class/usb_power_delivery/.../source-capabilities/1:fixed_supply/usb_suspend_supported

How does this relate to this specific change? You didn't mention it in the changelog at all :(

Quoted 38 lines
Documentation/ABI/testing/sysfs-class-usb_power_delivery +9 -0
 Date:		May 2022
 Contact:	Heikki Krogerus <[email protected]>
 Description:
@@ -78,6 +78,15 @@ Description:
 		will follow the USB 2.0 and USB 3.2 rules for suspend and
 		resume.
 
+What:		/sys/class/usb_power_delivery/.../sink-capabilities/1:fixed_supply/higher_capability
+Date:		February 2023
+Contact:	Saranya Gopal <[email protected]>
+Description:
+		This file shows the value of the Higher capability bit in
+		vsafe5V Fixed Supply Object. If the bit is set, then the sink
+		needs more than vsafe5V(eg. 12 V) to provide full functionality.
+		Valid values: 0, 1
+
 What:		/sys/class/usb_power_delivery/.../<capability>/1:fixed_supply/unconstrained_power
 Date:		May 2022
 Contact:	Heikki Krogerus <[email protected]>
drivers/usb/typec/pd.c +7 -0
index dc72005d68db..59c537a5e600 100644
@@ -48,6 +48,13 @@ usb_suspend_supported_show(struct device *dev, struct device_attribute *attr, ch
 }
 static DEVICE_ATTR_RO(usb_suspend_supported);
 
+static ssize_t
+higher_capability_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	return sysfs_emit(buf, "%u\n", !!(to_pdo(dev)->pdo & PDO_FIXED_HIGHER_CAP));
+}
+static DEVICE_ATTR_RO(higher_capability);
+
 static ssize_t
 unconstrained_power_show(struct device *dev, struct device_attribute *attr, char *buf)
 {

drivers/usb/typec/pd.c static struct device_type source_fixed_supply_type = { · line 171

Quoted 5 lines
drivers/usb/typec/pd.c +1 -1
@@ -161,7 +168,7 @@ static struct device_type source_fixed_supply_type = {
 
 static struct attribute *sink_fixed_supply_attrs[] = {
 	&dev_attr_dual_role_power.attr,
-	&dev_attr_usb_suspend_supported.attr,
+	&dev_attr_higher_capability.attr,

So you deleted an attribute from this device, ok, but again, I don't understand how this is considered a "fix" other than perhaps the old attribute does not relate to this device?

And if so, then make that a single patch, with a Fixes: tag, and we can properly backport that one, and then have a second patch that adds the new attribute.

Again, adding a new attribute is a "new feature" not a fix, right?

thanks,

greg k-h

#2 lore raw

Hi Greg,

Quoted 43 lines

-----Original Message-----
From: Greg KH <[email protected]>
Sent: Monday, February 13, 2023 8:50 PM
To: Gopal, Saranya <[email protected]>
Cc: [email protected]; [email protected]; Regupathy, Rajaram <[email protected]>
Subject: Re: [PATCH v2] usb: typec: pd: Add higher_capability sysfs for sink PDO

Quoted 4 lines · Saranya Gopal

As per USB PD specification, 28th bit of sink fixed power supply PDO represents higher capability. If this bit is set, it indicates that the sink needs more than vsafe5V to provide full functionality. This patch replaces usb_suspend_supported sysfs with

higher_capability

Quoted 3 lines

sysfs for sink PDO.

Fixes 662a60102c12 ("usb: typec: Separate USB Power Delivery

from USB Type-C")

Quoted 8 lines

---
Changed from v1:
- Added the valid values for the sysfs
- Wrapped the description alone to 80 characters

 .../ABI/testing/sysfs-class-usb_power_delivery        | 11

++++++++++-

Review

Quoted 4 lines
 drivers/usb/typec/pd.c                                |  9 ++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

usb_power_delivery b/Documentation/ABI/testing/sysfs-class- usb_power_delivery

Documentation/ABI/testing/sysfs-class-usb_power_delivery Description: · line 69

Quoted 5 lines

index ce2b1b563cb3..1bf9d1d7902c 100644

Documentation/ABI/testing/sysfs-class-usb_power_delivery +0 -0
@@ -69,7 +69,7 @@ Description:
 		This file contains boolean value that tells does the

device

Documentation/ABI/testing/sysfs-class-usb_power_delivery Description:

Quoted 3 lines
Documentation/ABI/testing/sysfs-class-usb_power_delivery +0 -1
 		support both source and sink power roles.
 
-What:
Quoted 8 lines
	/sys/class/usb_power_delivery/.../<capability>/1:fixed_sup

ply/usb_suspend_supported

Documentation/ABI/testing/sysfs-class-usb_power_delivery Description: · line 72

Quoted 1 line
Documentation/ABI/testing/sysfs-class-usb_power_delivery +1 -0
+What:		/sys/class/usb_power_delivery/.../source-

capabilities/1:fixed_supply/usb_suspend_supported

How does this relate to this specific change? You didn't mention it in
the changelog at all :(

It is related because source PDO still needs this sysfs. The sink PDO needs the new sysfs.
I wanted to make it clear by specifying source_capabilities here. Sorry that my commit message was not clear. I will fix it in v3.

Quoted 52 lines

Documentation/ABI/testing/sysfs-class-usb_power_delivery Description: · line 78

Quoted 6 lines
Documentation/ABI/testing/sysfs-class-usb_power_delivery +0 -0
 Date:		May 2022
 Contact:	Heikki Krogerus <[email protected]>
 Description:
@@ -78,6 +78,15 @@ Description:
 		will follow the USB 2.0 and USB 3.2 rules for

suspend and

Documentation/ABI/testing/sysfs-class-usb_power_delivery Description: · line 81

Quoted 3 lines
Documentation/ABI/testing/sysfs-class-usb_power_delivery +1 -0
 		resume.
 
+What:		/sys/class/usb_power_delivery/.../sink-

capabilities/1:fixed_supply/higher_capability

Documentation/ABI/testing/sysfs-class-usb_power_delivery Description:

Quoted 4 lines
Documentation/ABI/testing/sysfs-class-usb_power_delivery +4 -0
+Date:		February 2023
+Contact:	Saranya Gopal <[email protected]>
+Description:
+		This file shows the value of the Higher capability bit

in

Documentation/ABI/testing/sysfs-class-usb_power_delivery Description: · line 86

Quoted 1 line
Documentation/ABI/testing/sysfs-class-usb_power_delivery +1 -0
+		vsafe5V Fixed Supply Object. If the bit is set, then

the sink

Documentation/ABI/testing/sysfs-class-usb_power_delivery Description: · line 87

Quoted 1 line
Documentation/ABI/testing/sysfs-class-usb_power_delivery +1 -0
+		needs more than vsafe5V(eg. 12 V) to provide full

functionality.

Documentation/ABI/testing/sysfs-class-usb_power_delivery Description:

Quoted 3 lines
Documentation/ABI/testing/sysfs-class-usb_power_delivery +2 -0
+		Valid values: 0, 1
+
 What:
	/sys/class/usb_power_delivery/.../<capability>/1:fixed_sup

ply/unconstrained_power

drivers/usb/typec/pd.c usb_suspend_supported_show(struct

Quoted 7 lines
Documentation/ABI/testing/sysfs-class-usb_power_delivery +0 -0
 Date:		May 2022
 Contact:	Heikki Krogerus <[email protected]>
drivers/usb/typec/pd.c +0 -0
index dc72005d68db..59c537a5e600 100644
@@ -48,6 +48,13 @@ usb_suspend_supported_show(struct

device *dev, struct device_attribute *attr, ch

drivers/usb/typec/pd.c usb_suspend_supported_show(struct device *dev, struct device_attribute *attr, ch

Quoted 5 lines
drivers/usb/typec/pd.c +2 -0
 }
 static DEVICE_ATTR_RO(usb_suspend_supported);
 
+static ssize_t
+higher_capability_show(struct device *dev, struct

device_attribute *attr, char *buf)

drivers/usb/typec/pd.c usb_suspend_supported_show(struct · line 54

Quoted 2 lines
drivers/usb/typec/pd.c +2 -0
+{
+	return sysfs_emit(buf, "%u\n", !!(to_pdo(dev)->pdo &

PDO_FIXED_HIGHER_CAP));

drivers/usb/typec/pd.c usb_suspend_supported_show(struct device *dev, struct device_attribute *attr, ch

Quoted 5 lines
drivers/usb/typec/pd.c +3 -0
+}
+static DEVICE_ATTR_RO(higher_capability);
+
 static ssize_t
 unconstrained_power_show(struct device *dev, struct

device_attribute *attr, char *buf)

drivers/usb/typec/pd.c static struct device_type

Quoted 2 lines
drivers/usb/typec/pd.c +0 -0
 {
@@ -161,7 +168,7 @@ static struct device_type

source_fixed_supply_type = {

Quoted 1 line
Quoted 8 lines

drivers/usb/typec/pd.c static struct device_type source_fixed_supply_type = { · line 171

Quoted 4 lines

static struct attribute *sink_fixed_supply_attrs[] = {

drivers/usb/typec/pd.c +1 -1
 	&dev_attr_dual_role_power.attr,
-	&dev_attr_usb_suspend_supported.attr,
+	&dev_attr_higher_capability.attr,

So you deleted an attribute from this device, ok, but again, I don't understand how this is considered a "fix" other than perhaps the old attribute does not relate to this device?

As per USB PD specification:
28th bit of the fixed supply "sink" PDO represents higher capability (whether sink device needs more than vSafe5V (eg:12 V) for full functionality).
28th bit of the fixed supply "source" PDO represents usb_suspend_supported attribute. Before this patch, 28th bit of sink PDO was wrongly representing usb_suspend_supported attribute. We had to add the new attribute to correctly represent the 28th bit of sink PDO. Does it make sense to add fixes tag now if I add these additional details in commit message? Or do you still prefer not to add fixes tag for this patch?

Thanks,
Saranya

Quoted 12 lines

And if so, then make that a single patch, with a Fixes: tag, and we can
properly backport that one, and then have a second patch that adds the
new attribute.

Again, adding a new attribute is a "new feature" not a fix, right?

thanks,

greg k-h

maintainer
#3 lore raw
Quoted 12 lines · Saranya
Quoted 3 lines

So you deleted an attribute from this device, ok, but again, I don't understand how this is considered a "fix" other than perhaps the old attribute does not relate to this device?

As per USB PD specification:
28th bit of the fixed supply "sink" PDO represents higher capability (whether sink device needs more than vSafe5V (eg:12 V) for full functionality).
28th bit of the fixed supply "source" PDO represents usb_suspend_supported attribute. Before this patch, 28th bit of sink PDO was wrongly representing usb_suspend_supported attribute. We had to add the new attribute to correctly represent the 28th bit of sink PDO. Does it make sense to add fixes tag now if I add these additional details in commit message? Or do you still prefer not to add fixes tag for this patch?

Quoted 11 lines

Thanks,
Saranya

Quoted 8 lines

And if so, then make that a single patch, with a Fixes: tag, and we can
properly backport that one, and then have a second patch that adds the
new attribute.

Again, adding a new attribute is a "new feature" not a fix, right?

This is true. Saranya, please split the patch in two like Greg pointed out.

thanks,

Signature · 1 line
heikki