[PATCH 1/4] power: supply: Add sysfs entry for liquid detection control
From: Waqar Hameed
Date: Wed Oct 28 2026 - 17:59:29 EST
There are devices that have built-in liquid detection. For example to
mitigate corrosion caused by moisture in a port. In order to be able to
configure such devices, add sysfs entry for controlling a device's
liquid detection.
Signed-off-by: Waqar Hameed <waqar.hameed@xxxxxxxx>
---
Documentation/ABI/testing/sysfs-class-power | 19 +++++++++++++++++++
drivers/power/supply/power_supply_sysfs.c | 8 ++++++++
include/linux/power_supply.h | 8 ++++++++
3 files changed, 35 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power
index 671786d4600de..a98e6b2a75fbc 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -619,6 +619,25 @@ Description:
"Ship" (4) Ship mode.
============= ==================================
+What: /sys/class/power_supply/<supply_name>/liquid_detection_control
+Date: October 2026
+Contact: linux-pm@xxxxxxxxxxxxxxx
+Description:
+ Devices can have built-in liquid detection functionality. This
+ can for example be used to mitigate port corrosion caused by
+ moisture. This entry controls a device's liquid detection.
+
+ Access: Read, Write
+
+ Valid values:
+
+ ============= ===============================================
+ "Unknown" (0) Unknown state.
+ "Off" (1) Liquid detection is disabled.
+ "Auto" (2) Liquid detection is checked periodically.
+ "Once" (3) Check for liquid once then transition to "Off".
+ ============= ===============================================
+
**USB Properties**
What: /sys/class/power_supply/<supply_name>/input_current_limit
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index 9704557ffe1dc..661b42adf6efc 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -160,6 +160,13 @@ static const char *const POWER_SUPPLY_LOAD_SWITCH_TEXT[] = {
[POWER_SUPPLY_LOAD_SWITCH_SHIP] = "Ship",
};
+static const char *const POWER_SUPPLY_LIQUID_DETECTION_CONTROL_TEXT[] = {
+ [POWER_SUPPLY_LIQUID_DETECTION_CONTROL_UNKNOWN] = "Unknown",
+ [POWER_SUPPLY_LIQUID_DETECTION_CONTROL_OFF] = "Off",
+ [POWER_SUPPLY_LIQUID_DETECTION_CONTROL_AUTO] = "Auto",
+ [POWER_SUPPLY_LIQUID_DETECTION_CONTROL_ONCE] = "Once",
+};
+
static struct power_supply_attr power_supply_attrs[] __ro_after_init = {
/* Properties of type `int' */
POWER_SUPPLY_ENUM_ATTR(STATUS),
@@ -240,6 +247,7 @@ static struct power_supply_attr power_supply_attrs[] __ro_after_init = {
POWER_SUPPLY_ATTR(INTERNAL_RESISTANCE),
POWER_SUPPLY_ATTR(STATE_OF_HEALTH),
POWER_SUPPLY_ENUM_ATTR(LOAD_SWITCH),
+ POWER_SUPPLY_ENUM_ATTR(LIQUID_DETECTION_CONTROL),
/* Properties of type `const char *' */
POWER_SUPPLY_ATTR(MODEL_NAME),
POWER_SUPPLY_ATTR(MANUFACTURER),
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index cce61137aef4d..8e5bbdfebe794 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -112,6 +112,13 @@ enum {
POWER_SUPPLY_LOAD_SWITCH_SHIP,
};
+enum {
+ POWER_SUPPLY_LIQUID_DETECTION_CONTROL_UNKNOWN = 0,
+ POWER_SUPPLY_LIQUID_DETECTION_CONTROL_OFF,
+ POWER_SUPPLY_LIQUID_DETECTION_CONTROL_AUTO,
+ POWER_SUPPLY_LIQUID_DETECTION_CONTROL_ONCE,
+};
+
enum power_supply_property {
/* Properties of type `int' */
POWER_SUPPLY_PROP_STATUS = 0,
@@ -191,6 +198,7 @@ enum power_supply_property {
POWER_SUPPLY_PROP_INTERNAL_RESISTANCE,
POWER_SUPPLY_PROP_STATE_OF_HEALTH,
POWER_SUPPLY_PROP_LOAD_SWITCH,
+ POWER_SUPPLY_PROP_LIQUID_DETECTION_CONTROL,
/* Properties of type `const char *' */
POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_MANUFACTURER,
--
2.43.0