Skip to contentSkip to conversation

usb: typec: pd: Remove usb_suspend_supported sysfs from sink PDO

PATCH In review Saranya Gopal 2 participants 4 messages Feb 14, 2023

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

PATCH v3 1/2 usb: typec: pd: Remove usb_suspend_supported sysfs from sink PDO

As per USB PD specification, 28th bit of fixed supply sink PDO represents "higher capability" attribute and not "usb suspend supported" attribute. So, this patch removes the usb_suspend_supported attribute from sink PDO.

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

---
Changes from v2:
- Patch was split into 2
- This patch only removes usb_suspend_supported attribute for sink PDOs

 drivers/usb/typec/pd.c | 1 -
 1 file changed, 1 deletion(-)
drivers/usb/typec/pd.c +0 -1
index dc72005d68db..b5ab26422c34 100644
@@ -161,7 +161,6 @@ 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_unconstrained_power.attr,
 	&dev_attr_usb_communication_capable.attr,
 	&dev_attr_dual_role_data.attr,
Signature · 1 line
2.25.1
#1 lore raw

PATCH v3 2/2 usb: typec: pd: Add higher capability sysfs for sink PDO

28th bit of fixed supply sink PDO represents higher capability. When this bit is set, the sink device needs more than vsafe5V (eg: 12 V) to provide full functionality. This patch adds this higher capability sysfs interface for sink PDO.
28th bit of fixed supply source PDO represents usb_suspend_supported attribute. This usb_suspend_supported sysfs is already exposed for source PDOs. This patch adds 'source-capabilities' in usb_suspend_supported sysfs documentation for additional clarity.

---
Changes from v2:
- Patch was split into 2 and this one adds new sysfs for sink PDO
Changes from v1:
- Wrapped the description within 80 characters
- Added valid values for the new sysfs

 .../ABI/testing/sysfs-class-usb_power_delivery        | 11 ++++++++++-
 drivers/usb/typec/pd.c                                |  8 ++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
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 -0
index b5ab26422c34..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,6 +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_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 Reviewed-by on v3 2/2
#2 lore raw

Re: [PATCH v3 2/2] usb: typec: pd: Add higher capability sysfs for sink PDO

Quoted 10 lines · Saranya Gopal

28th bit of fixed supply sink PDO represents higher capability. When this bit is set, the sink device needs more than vsafe5V (eg: 12 V) to provide full functionality. This patch adds this higher capability sysfs interface for sink PDO.
28th bit of fixed supply source PDO represents usb_suspend_supported attribute. This usb_suspend_supported sysfs is already exposed for source PDOs. This patch adds 'source-capabilities' in usb_suspend_supported sysfs documentation for additional clarity.

Quoted 68 lines

---
Changes from v2:
- Patch was split into 2 and this one adds new sysfs for sink PDO
Changes from v1:
- Wrapped the description within 80 characters
- Added valid values for the new sysfs

 .../ABI/testing/sysfs-class-usb_power_delivery        | 11 ++++++++++-
 drivers/usb/typec/pd.c                                |  8 ++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
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 -0
index b5ab26422c34..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,6 +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_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
Signature · 1 line
heikki
maintainer Reviewed-by on v3 1/2
#3 lore raw
In reply to Saranya Gopal
Quoted 8 lines · Saranya Gopal

As per USB PD specification, 28th bit of fixed supply sink PDO represents "higher capability" attribute and not "usb suspend supported" attribute. So, this patch removes the usb_suspend_supported attribute from sink PDO.

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

---
Changes from v2:
- Patch was split into 2
- This patch only removes usb_suspend_supported attribute for sink PDOs

 drivers/usb/typec/pd.c | 1 -
 1 file changed, 1 deletion(-)
drivers/usb/typec/pd.c +0 -1
index dc72005d68db..b5ab26422c34 100644
@@ -161,7 +161,6 @@ 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_unconstrained_power.attr,
 	&dev_attr_usb_communication_capable.attr,
 	&dev_attr_dual_role_data.attr,
Signature · 1 line
2.25.1
Signature · 1 line
heikki