From: Jeff Lin <jefflin994697@gmail.com>
To: linux@roeck-us.net
Cc: jefflin994697@gmail.com, grantpeltier93@gmail.com,
karanja99erick@gmail.com, chiang.brian@inventec.com,
krzk@kernel.org, william@wkennington.com, tzungbi@kernel.org,
thorsten.blum@linux.dev, ninad@linux.ibm.com,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] hwmon: (pmbus) Add support for multiple-function pin
Date: Tue, 16 Dec 2025 17:16:16 +0800 [thread overview]
Message-ID: <20251216091617.2581192-2-jefflin994697@gmail.com> (raw)
In-Reply-To: <20251216091617.2581192-1-jefflin994697@gmail.com>
Some pmbus chip support the additional multiple-function pin, which can
detect and provide the connected device's current reading. The data
format of the multiple-function ping must be confirmed with the chip
vendor, as it may vary between different chips. However, it is
problematic if the data format differs from the original 'iin' and 'iout'
and we want to show both the current from multiple-function pin and the
original 'iin' and 'iout'.
To solve the problem, add support for additional virtual current input
and virtual current output, call it 'viin' and 'viout', respectively.
Signed-off-by: Jeff Lin <jefflin994697@gmail.com>
---
drivers/hwmon/pmbus/pmbus.h | 12 ++++++++++++
drivers/hwmon/pmbus/pmbus_core.c | 18 ++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
index d2e9bfb5320f..8a1c3a7a4f32 100644
--- a/drivers/hwmon/pmbus/pmbus.h
+++ b/drivers/hwmon/pmbus/pmbus.h
@@ -236,6 +236,14 @@ enum pmbus_regs {
PMBUS_VIRT_CURR_SAMPLES,
PMBUS_VIRT_POWER_SAMPLES,
PMBUS_VIRT_TEMP_SAMPLES,
+
+ /* Multiple function pin
+ *
+ * Drivers wanting to expose the value from multiple function pin
+ * should implement support in read_word_data callback.
+ */
+ PMBUS_VIRT_READ_IIN,
+ PMBUS_VIRT_READ_IOUT,
};
/*
@@ -381,6 +389,8 @@ enum pmbus_sensor_classes {
PSC_TEMPERATURE,
PSC_FAN,
PSC_PWM,
+ PSC_VIRT_CURRENT_IN,
+ PSC_VIRT_CURRENT_OUT,
PSC_NUM_CLASSES /* Number of power sensor classes */
};
@@ -411,6 +421,8 @@ enum pmbus_sensor_classes {
#define PMBUS_HAVE_PWM12 BIT(20)
#define PMBUS_HAVE_PWM34 BIT(21)
#define PMBUS_HAVE_SAMPLES BIT(22)
+#define PMBUS_HAVE_VIRT_IIN BIT(23)
+#define PMBUS_HAVE_VIRT_IOUT BIT(24)
#define PMBUS_PHASE_VIRTUAL BIT(30) /* Phases on this page are virtual */
#define PMBUS_PAGE_VIRTUAL BIT(31) /* Page is virtual */
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index be6d05def115..9a8eec5d3945 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -1929,6 +1929,16 @@ static const struct pmbus_sensor_attr current_attributes[] = {
.gbit = PB_STATUS_IOUT_OC,
.limit = iout_limit_attrs,
.nlimit = ARRAY_SIZE(iout_limit_attrs),
+ }, {
+ .reg = PMBUS_VIRT_READ_IIN,
+ .class = PSC_VIRT_CURRENT_IN,
+ .label = "viin",
+ .func = PMBUS_HAVE_VIRT_IIN
+ }, {
+ .reg = PMBUS_VIRT_READ_IOUT,
+ .class = PSC_VIRT_CURRENT_OUT,
+ .label = "viout",
+ .func = PMBUS_HAVE_VIRT_IOUT
}
};
@@ -2501,6 +2511,14 @@ static const struct pmbus_class_attr_map class_attr_map[] = {
.class = PSC_TEMPERATURE,
.attr = temp_attributes,
.nattr = ARRAY_SIZE(temp_attributes),
+ }, {
+ .class = PSC_VIRT_CURRENT_IN,
+ .attr = current_attributes,
+ .nattr = ARRAY_SIZE(current_attributes),
+ }, {
+ .class = PSC_VIRT_CURRENT_OUT,
+ .attr = current_attributes,
+ .nattr = ARRAY_SIZE(current_attributes),
}
};
--
2.34.1
next prev parent reply other threads:[~2025-12-16 9:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-16 9:16 [PATCH 0/2] hwmon/pmbus: (isl68137) Add multiple-function pin for Jeff Lin
2025-12-16 9:16 ` Jeff Lin [this message]
2025-12-16 9:45 ` [PATCH 1/2] hwmon: (pmbus) Add support for multiple-function pin Guenter Roeck
2025-12-16 9:16 ` [PATCH 2/2] hwmon/pmbus: (isl68137) Add multiple-function pin for raa229141a Jeff Lin
2025-12-16 9:56 ` Guenter Roeck
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=20251216091617.2581192-2-jefflin994697@gmail.com \
--to=jefflin994697@gmail.com \
--cc=chiang.brian@inventec.com \
--cc=grantpeltier93@gmail.com \
--cc=karanja99erick@gmail.com \
--cc=krzk@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=ninad@linux.ibm.com \
--cc=thorsten.blum@linux.dev \
--cc=tzungbi@kernel.org \
--cc=william@wkennington.com \
/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
all inboxes | Powered by JetHome®