* [PATCH 0/2] hwmon/pmbus: (isl68137) Add multiple-function pin for
@ 2025-12-16 9:16 Jeff Lin
2025-12-16 9:16 ` [PATCH 1/2] hwmon: (pmbus) Add support for multiple-function pin Jeff Lin
2025-12-16 9:16 ` [PATCH 2/2] hwmon/pmbus: (isl68137) Add multiple-function pin for raa229141a Jeff Lin
0 siblings, 2 replies; 5+ messages in thread
From: Jeff Lin @ 2025-12-16 9:16 UTC (permalink / raw)
To: linux
Cc: jefflin994697, grantpeltier93, karanja99erick, chiang.brian,
krzk, william, tzungbi, thorsten.blum, ninad, linux-hwmon,
linux-kernel
This patch set add support for multiple-function pin for chip RAA229141A.
The RAA229141A extends the standard PMBus current monitoring with
multiple-function pins that allow sensing the current of adjacent
devices.
The changes include:
1. Add support for multiple-function pin in pmbus
2. Add multiple-function pin for raa229141a
Jeff Lin (2):
hwmon: (pmbus) Add support for multiple-function pin
hwmon/pmbus: (isl68137) Add multiple-function pin for raa229141
drivers/hwmon/pmbus/isl68137.c | 45 ++++++++++++++++++++++++++++++++
drivers/hwmon/pmbus/pmbus.h | 12 +++++++++
drivers/hwmon/pmbus/pmbus_core.c | 18 +++++++++++++
3 files changed, 75 insertions(+)
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] hwmon: (pmbus) Add support for multiple-function pin
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
2025-12-16 9:45 ` Guenter Roeck
2025-12-16 9:16 ` [PATCH 2/2] hwmon/pmbus: (isl68137) Add multiple-function pin for raa229141a Jeff Lin
1 sibling, 1 reply; 5+ messages in thread
From: Jeff Lin @ 2025-12-16 9:16 UTC (permalink / raw)
To: linux
Cc: jefflin994697, grantpeltier93, karanja99erick, chiang.brian,
krzk, william, tzungbi, thorsten.blum, ninad, linux-hwmon,
linux-kernel
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] hwmon/pmbus: (isl68137) Add multiple-function pin for raa229141a
2025-12-16 9:16 [PATCH 0/2] hwmon/pmbus: (isl68137) Add multiple-function pin for Jeff Lin
2025-12-16 9:16 ` [PATCH 1/2] hwmon: (pmbus) Add support for multiple-function pin Jeff Lin
@ 2025-12-16 9:16 ` Jeff Lin
2025-12-16 9:56 ` Guenter Roeck
1 sibling, 1 reply; 5+ messages in thread
From: Jeff Lin @ 2025-12-16 9:16 UTC (permalink / raw)
To: linux
Cc: jefflin994697, grantpeltier93, karanja99erick, chiang.brian,
krzk, william, tzungbi, thorsten.blum, ninad, linux-hwmon,
linux-kernel
In addition to supporting PMBus-based current monitoring, the RAA229141A
also provides two multifunction pins(PIN44,PIN45) that can be used to
sense the input and output current of nearby devices.
Readings from these multifunction pins are not reported using the
standard PMBus direct or linear data formats. Instead, they must be
retrieved via the Renesas-specific Dicrect Memory Access(DMA)
command codes and scaled by a factor of 10.
Signed-off-by: Jeff Lin <jefflin994697@gmail.com>
---
drivers/hwmon/pmbus/isl68137.c | 45 ++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/drivers/hwmon/pmbus/isl68137.c b/drivers/hwmon/pmbus/isl68137.c
index 97b61836f53a..e60771614941 100644
--- a/drivers/hwmon/pmbus/isl68137.c
+++ b/drivers/hwmon/pmbus/isl68137.c
@@ -178,6 +178,33 @@ static const struct attribute_group *isl68137_attribute_groups[] = {
NULL,
};
+#define RAA_READ_DMA_DATA 0xc5
+#define RAA_WRITE_DMA_ADDRESS 0xc7
+
+/* DMA address for input current in PIN44 and output current in PIN45 */
+static const unsigned char dma_address_in[] = { 0xD3, 0xE0 };
+static const unsigned char dma_address_out[] = { 0x42, 0xEE };
+static int read_val_route_by_dma(struct i2c_client *client, const char *addr)
+{
+ int ret;
+ /* Set up DMA address */
+ ret = i2c_smbus_write_i2c_block_data(client, RAA_WRITE_DMA_ADDRESS, 2, addr);
+
+ if (ret < 0) {
+ dev_err(&client->dev,
+ "Set DMA address failed for address 0x%02x 0x%02x\n", addr[0], addr[1]);
+ return ret;
+ }
+ /* Read DMA data */
+ u8 buf[2];
+
+ ret = i2c_smbus_read_i2c_block_data(client, RAA_READ_DMA_DATA, 2, buf);
+ if (ret < 0)
+ return ret;
+ u16 value = ((u16)buf[1]<<8) | buf[0];
+ return value;
+};
+
static int raa_dmpvr2_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{
@@ -207,6 +234,12 @@ static int raa_dmpvr2_read_word_data(struct i2c_client *client, int page,
ret = clamp_val(temp, 0, 0xffff);
}
break;
+ case PMBUS_VIRT_READ_IIN:
+ ret = read_val_route_by_dma(client, dma_address_in);
+ break;
+ case PMBUS_VIRT_READ_IOUT:
+ ret = read_val_route_by_dma(client, dma_address_out);
+ break;
default:
ret = -ENODATA;
break;
@@ -408,6 +441,18 @@ static int isl68137_probe(struct i2c_client *client)
info->format[PSC_CURRENT_OUT] = linear;
info->format[PSC_POWER] = linear;
info->format[PSC_TEMPERATURE] = linear;
+ info->format[PSC_VIRT_CURRENT_IN] = direct,
+ info->format[PSC_VIRT_CURRENT_OUT] = direct,
+ /* DIRECT read format 10mA/LSB */
+ info->m[PSC_VIRT_CURRENT_IN] = 1,
+ info->b[PSC_VIRT_CURRENT_IN] = 0,
+ info->R[PSC_VIRT_CURRENT_IN] = 2,
+ /* DIRECT read format 10mA/LSB */
+ info->m[PSC_VIRT_CURRENT_OUT] = 1,
+ info->b[PSC_VIRT_CURRENT_OUT] = 0,
+ info->R[PSC_VIRT_CURRENT_OUT] = 2,
+ info->func[0] |= PMBUS_HAVE_VIRT_IIN;
+ info->func[0] |= PMBUS_HAVE_VIRT_IOUT;
info->pages = 2;
info->read_word_data = raa_dmpvr2_read_word_data;
info->write_word_data = raa_dmpvr2_write_word_data;
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] hwmon: (pmbus) Add support for multiple-function pin
2025-12-16 9:16 ` [PATCH 1/2] hwmon: (pmbus) Add support for multiple-function pin Jeff Lin
@ 2025-12-16 9:45 ` Guenter Roeck
0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2025-12-16 9:45 UTC (permalink / raw)
To: Jeff Lin
Cc: grantpeltier93, karanja99erick, chiang.brian, krzk, william,
tzungbi, thorsten.blum, ninad, linux-hwmon, linux-kernel
On 12/16/25 01:16, Jeff Lin wrote:
> 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.
>
Those are just additional current input and output values. That does not
require additional sensor classes. Just use the chip driver to map the
readings from the chip format to the format used by the existing iin and
iout (there is no 'viin" or "viout").
Also, please point to the standard regarding "multiple function pin".
The term must only be used in the common code or definitions if it has
a reference in the standard. Otherwise it is just a manufacturer specific
extension which has no place in common code. The second patch of the series,
which accesses some very vendor specific functions, strongly suggests that
this is the case.
Guenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] hwmon/pmbus: (isl68137) Add multiple-function pin for raa229141a
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
0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2025-12-16 9:56 UTC (permalink / raw)
To: Jeff Lin
Cc: grantpeltier93, karanja99erick, chiang.brian, krzk, william,
tzungbi, thorsten.blum, ninad, linux-hwmon, linux-kernel
On 12/16/25 01:16, Jeff Lin wrote:
> In addition to supporting PMBus-based current monitoring, the RAA229141A
> also provides two multifunction pins(PIN44,PIN45) that can be used to
> sense the input and output current of nearby devices.
>
> Readings from these multifunction pins are not reported using the
> standard PMBus direct or linear data formats. Instead, they must be
> retrieved via the Renesas-specific Dicrect Memory Access(DMA)
> command codes and scaled by a factor of 10.
>
Is there a public datasheet to explain this ?
From what I can see in this code, it does not even remotely look like
it is part of the PMBus standard. It looks like very vendor specific
additional current values. Also, multi-function implies that those are,
as the name says, multi-function pins. There needs to be additional
information explaining how they are associated to specific functionality
such as input or output current. Just declaring that it be so is insufficient.
Guenter
> Signed-off-by: Jeff Lin <jefflin994697@gmail.com>
> ---
> drivers/hwmon/pmbus/isl68137.c | 45 ++++++++++++++++++++++++++++++++++
> 1 file changed, 45 insertions(+)
>
> diff --git a/drivers/hwmon/pmbus/isl68137.c b/drivers/hwmon/pmbus/isl68137.c
> index 97b61836f53a..e60771614941 100644
> --- a/drivers/hwmon/pmbus/isl68137.c
> +++ b/drivers/hwmon/pmbus/isl68137.c
> @@ -178,6 +178,33 @@ static const struct attribute_group *isl68137_attribute_groups[] = {
> NULL,
> };
>
> +#define RAA_READ_DMA_DATA 0xc5
> +#define RAA_WRITE_DMA_ADDRESS 0xc7
> +
> +/* DMA address for input current in PIN44 and output current in PIN45 */
> +static const unsigned char dma_address_in[] = { 0xD3, 0xE0 };
> +static const unsigned char dma_address_out[] = { 0x42, 0xEE };
> +static int read_val_route_by_dma(struct i2c_client *client, const char *addr)
> +{
> + int ret;
> + /* Set up DMA address */
> + ret = i2c_smbus_write_i2c_block_data(client, RAA_WRITE_DMA_ADDRESS, 2, addr);
> +
> + if (ret < 0) {
> + dev_err(&client->dev,
> + "Set DMA address failed for address 0x%02x 0x%02x\n", addr[0], addr[1]);
> + return ret;
> + }
> + /* Read DMA data */
> + u8 buf[2];
> +
> + ret = i2c_smbus_read_i2c_block_data(client, RAA_READ_DMA_DATA, 2, buf);
> + if (ret < 0)
> + return ret;
> + u16 value = ((u16)buf[1]<<8) | buf[0];
> + return value;
> +};
> +
> static int raa_dmpvr2_read_word_data(struct i2c_client *client, int page,
> int phase, int reg)
> {
> @@ -207,6 +234,12 @@ static int raa_dmpvr2_read_word_data(struct i2c_client *client, int page,
> ret = clamp_val(temp, 0, 0xffff);
> }
> break;
> + case PMBUS_VIRT_READ_IIN:
> + ret = read_val_route_by_dma(client, dma_address_in);
> + break;
> + case PMBUS_VIRT_READ_IOUT:
> + ret = read_val_route_by_dma(client, dma_address_out);
> + break;
> default:
> ret = -ENODATA;
> break;
> @@ -408,6 +441,18 @@ static int isl68137_probe(struct i2c_client *client)
> info->format[PSC_CURRENT_OUT] = linear;
> info->format[PSC_POWER] = linear;
> info->format[PSC_TEMPERATURE] = linear;
> + info->format[PSC_VIRT_CURRENT_IN] = direct,
> + info->format[PSC_VIRT_CURRENT_OUT] = direct,
> + /* DIRECT read format 10mA/LSB */
> + info->m[PSC_VIRT_CURRENT_IN] = 1,
> + info->b[PSC_VIRT_CURRENT_IN] = 0,
> + info->R[PSC_VIRT_CURRENT_IN] = 2,
> + /* DIRECT read format 10mA/LSB */
> + info->m[PSC_VIRT_CURRENT_OUT] = 1,
> + info->b[PSC_VIRT_CURRENT_OUT] = 0,
> + info->R[PSC_VIRT_CURRENT_OUT] = 2,
> + info->func[0] |= PMBUS_HAVE_VIRT_IIN;
> + info->func[0] |= PMBUS_HAVE_VIRT_IOUT;
> info->pages = 2;
> info->read_word_data = raa_dmpvr2_read_word_data;
> info->write_word_data = raa_dmpvr2_write_word_data;
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-12-16 9:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-16 9:16 [PATCH 0/2] hwmon/pmbus: (isl68137) Add multiple-function pin for Jeff Lin
2025-12-16 9:16 ` [PATCH 1/2] hwmon: (pmbus) Add support for multiple-function pin Jeff Lin
2025-12-16 9:45 ` 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
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®