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 2/2] hwmon/pmbus: (isl68137) Add multiple-function pin for raa229141a
Date: Tue, 16 Dec 2025 17:16:17 +0800 [thread overview]
Message-ID: <20251216091617.2581192-3-jefflin994697@gmail.com> (raw)
In-Reply-To: <20251216091617.2581192-1-jefflin994697@gmail.com>
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
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 ` [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 ` Jeff Lin [this message]
2025-12-16 9:56 ` [PATCH 2/2] hwmon/pmbus: (isl68137) Add multiple-function pin for raa229141a 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-3-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®