From: Amit Sunil Dhamne via B4 Relay <devnull+amitsd.google.com@kernel.org>
To: Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Badhri Jagan Sridharan <badhri@google.com>,
Sebastian Reichel <sre@kernel.org>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Len Brown <len.brown@intel.com>, Pavel Machek <pavel@kernel.org>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, linux-pm@vger.kernel.org,
RD Babiera <rdbabiera@google.com>, Kyle Tso <kyletso@google.com>,
Amit Sunil Dhamne <amitsd@google.com>
Subject: [PATCH 4/5] power: supply: core: add vendor and product id properties
Date: Wed, 12 Mar 2025 16:42:04 -0700 [thread overview]
Message-ID: <20250312-batt_ops-v1-4-88e0bb3129fd@google.com> (raw)
In-Reply-To: <20250312-batt_ops-v1-0-88e0bb3129fd@google.com>
From: Amit Sunil Dhamne <amitsd@google.com>
Add the following properties:
* Vendor Identifier (VID): Assigned to the battery manufacturer by USB
Implementers Forum (USB-IF).
* Product Identifier (PID) assigned by the manufacturer to the
battery.
This info is required by USB Type-C PD devices containing batteries.
This enables the USB Type C devices to respond to a Battery capacity
request from the port partner by querying for the PID & VID assigned to
the batteries. Refer to "USB Power Delivery Specification Rev3.1 v1.8"
Chapter 5.5 Battery_Capabilities Message.
Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
---
Documentation/ABI/testing/sysfs-class-power | 20 ++++++++++++++++++++
Documentation/power/power_supply_class.rst | 11 +++++++++++
drivers/power/supply/power_supply_sysfs.c | 2 ++
include/linux/power_supply.h | 2 ++
4 files changed, 35 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power
index 2a5c1a09a28f91beec6b18ca7b4492093026bc81..b2f377efbf065f7674b8ce44df1bc447c2f1223d 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -822,3 +822,23 @@ Description:
Each entry is a link to the device which registered the extension.
Access: Read
+
+What: /sys/class/power_supply/<supply_name>/usbif_vendor_id
+Date: March 2025
+Contact: linux-pm@vger.kernel.org
+Description:
+ Reports the vendor id assigned to the battery manufacturer by USB
+ Implementers Forum (USB-IF).
+
+ Access: Read
+ Valid values: 0x0-0xffff
+
+What: /sys/class/power_supply/<supply_name>/usbif_product_id
+Date: March 2025
+Contact: linux-pm@vger.kernel.org
+Description:
+ Reports the product id assigned to the battery by the manufacturer
+ (associated with usbif_vendor_id).
+
+ Access: Read
+ Valid values: 0x0-0xffff
diff --git a/Documentation/power/power_supply_class.rst b/Documentation/power/power_supply_class.rst
index da8e275a14ffb9f84bae9ae1efc4720a55ea3010..6d0a6bcf501e719fa4454845b583a8b38d371bb4 100644
--- a/Documentation/power/power_supply_class.rst
+++ b/Documentation/power/power_supply_class.rst
@@ -213,6 +213,17 @@ TIME_TO_FULL
seconds left for battery to be considered full
(i.e. while battery is charging)
+USBIF_VENDOR_ID
+ Vendor ID (VID) assigned to manufacturer or device vendor associated with the
+ battery by USB Implementers Forum (USB-IF). This property is described in
+ "USB Power Delivery Specification Rev3.1 V1.8" Chapter 6.5.5 Battery
+ Capabilities, Section 6.5.5.1 Vendor ID (VID).
+USBIF_PRODUCT_ID
+ Product ID (PID) assigned to the battery, such that if the VID belongs to the
+ manufacturer then the PID will be designated by it. Similarly if the VID
+ belongs to the device vendor then the PID will be designated by it. This
+ property is described in "USB Power Delivery Specification Rev3.1 V1.8"
+ Chapter 6.5.5 Battery Capabilities, Section 6.5.5.2 Product ID (PID).
Battery <-> external power supply interaction
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index edb058c19c9c44ad9ad97a626fc8f59e3d3735a6..534ed3cd049866fa747455bb6dae1ec2dc5e2da6 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -211,6 +211,8 @@ static struct power_supply_attr power_supply_attrs[] __ro_after_init = {
POWER_SUPPLY_ATTR(TIME_TO_EMPTY_AVG),
POWER_SUPPLY_ATTR(TIME_TO_FULL_NOW),
POWER_SUPPLY_ATTR(TIME_TO_FULL_AVG),
+ POWER_SUPPLY_ATTR(USBIF_VENDOR_ID),
+ POWER_SUPPLY_ATTR(USBIF_PRODUCT_ID),
POWER_SUPPLY_ENUM_ATTR(TYPE),
POWER_SUPPLY_ENUM_ATTR(USB_TYPE),
POWER_SUPPLY_ENUM_ATTR(SCOPE),
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 3f062607e5cd7c7f04384e34128ae0953e25d981..86be5c79db6055611153aa206981cf3de87f1381 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -165,6 +165,8 @@ enum power_supply_property {
POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
POWER_SUPPLY_PROP_TIME_TO_FULL_NOW,
POWER_SUPPLY_PROP_TIME_TO_FULL_AVG,
+ POWER_SUPPLY_PROP_USBIF_VENDOR_ID,
+ POWER_SUPPLY_PROP_USBIF_PRODUCT_ID,
POWER_SUPPLY_PROP_TYPE, /* use power_supply.type instead */
POWER_SUPPLY_PROP_USB_TYPE,
POWER_SUPPLY_PROP_SCOPE,
--
2.49.0.rc0.332.g42c0ae87b1-goog
next prev parent reply other threads:[~2025-03-12 23:43 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-12 23:42 [PATCH 0/5] Add support for Battery Status & Battery Caps AMS in TCPM Amit Sunil Dhamne via B4 Relay
2025-03-12 23:42 ` [PATCH 1/5] dt-bindings: connector: add fixed-batteries property Amit Sunil Dhamne via B4 Relay
2025-03-13 8:48 ` Krzysztof Kozlowski
2025-03-15 0:56 ` Amit Sunil Dhamne
2025-03-16 16:49 ` Krzysztof Kozlowski
2025-03-20 19:49 ` Amit Sunil Dhamne
2025-03-16 16:55 ` Krzysztof Kozlowski
2025-03-20 19:45 ` Amit Sunil Dhamne
2025-03-12 23:42 ` [PATCH 2/5] power: supply: core: add function to get supplies from fwnode Amit Sunil Dhamne via B4 Relay
2025-03-19 13:54 ` Heikki Krogerus
2025-04-08 19:54 ` Amit Sunil Dhamne
2025-03-12 23:42 ` [PATCH 3/5] usb: typec: tcpm: Add support for Battery Status response message Amit Sunil Dhamne via B4 Relay
2025-03-12 23:42 ` Amit Sunil Dhamne via B4 Relay [this message]
2025-03-12 23:42 ` [PATCH 5/5] usb: typec: tcpm: Add support for Battery Cap " Amit Sunil Dhamne via B4 Relay
2025-03-13 8:50 ` [PATCH 0/5] Add support for Battery Status & Battery Caps AMS in TCPM Krzysztof Kozlowski
2025-03-15 0:49 ` Amit Sunil Dhamne
2025-03-16 16:52 ` Krzysztof Kozlowski
2025-03-20 21:11 ` Amit Sunil Dhamne
2025-03-21 7:51 ` Krzysztof Kozlowski
2025-04-03 3:41 ` Amit Sunil Dhamne
2025-04-03 8:00 ` Krzysztof Kozlowski
2025-04-03 8:02 ` Krzysztof Kozlowski
2025-04-08 19:50 ` Amit Sunil Dhamne
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=20250312-batt_ops-v1-4-88e0bb3129fd@google.com \
--to=devnull+amitsd.google.com@kernel.org \
--cc=amitsd@google.com \
--cc=badhri@google.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=krzk+dt@kernel.org \
--cc=kyletso@google.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
--cc=rdbabiera@google.com \
--cc=robh@kernel.org \
--cc=sre@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