lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250926014552.1625950-1-jefflin994697@gmail.com>
Date: Fri, 26 Sep 2025 09:45:52 +0800
From: Jeff Lin <jefflin994697@...il.com>
To: jdelvare@...e.com,
	linux@...ck-us.net
Cc: cedricjustine.encarnacion@...log.com,
	ninad@...ux.ibm.com,
	andriy.shevchenko@...ux.intel.com,
	johnerasmusmari.geronimo@...log.com,
	Mariel.Tinaco@...log.com,
	jbrunet@...libre.com,
	kimseer.paller@...log.com,
	leo.yang.sy0@...il.com,
	nuno.sa@...log.com,
	chiang.brian@...entec.com,
	gregkh@...uxfoundation.org,
	grantpeltier93@...il.com,
	peterz@...radead.org,
	william@...nnington.com,
	krzysztof.kozlowski@...aro.org,
	tzungbi@...nel.org,
	thorsten.blum@...ux.dev,
	linux-hwmon@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Jeff Lin <jefflin994697@...il.com>
Subject: [PATCH] drivers/hwmon/pmbus: Add support for raa229141 in isl68137

In chip RAA229141 there exist ISYS pin which can report the current data
for the device connected to this chip through this pin by routed by Direct
Memory Access(DMA) command. To read the data in ISYS pin, we have to set
the DMA address to 0xC5 and then read the DMA data from 0xC7. And then use
the Direct read format with 10mA per LSB to transfer the data in 0xC7.
And for ISYS input pin, the DMA address is 0xE0D3 and for ISYS output pin,
the DMA address is 0xEE42.

Signed-off-by: Jeff Lin <jefflin994697@...il.com>
---
 drivers/hwmon/pmbus/Kconfig      | 10 +++++
 drivers/hwmon/pmbus/isl68137.c   | 65 ++++++++++++++++++++++++++++++++
 drivers/hwmon/pmbus/pmbus.h      | 11 ++++++
 drivers/hwmon/pmbus/pmbus_core.c | 20 ++++++++++
 4 files changed, 106 insertions(+)

diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index 55e492452ce8..a14393d41412 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -211,6 +211,16 @@ config SENSORS_ISL68137
 	  This driver can also be built as a module. If so, the module will
 	  be called isl68137.
 
+config SENSORS_RAA229141
+	bool "Renesas RAA229141 Supply"
+	default n
+	help
+	  If you say yes here you get the support for Renesas RAA229140 and
+	  RAA229141.
+
+	  This driver can also be built as a module. If so, the module will
+	  be called raa229141.
+
 config SENSORS_LM25066
 	tristate "National Semiconductor LM25066 and compatibles"
 	help
diff --git a/drivers/hwmon/pmbus/isl68137.c b/drivers/hwmon/pmbus/isl68137.c
index c52c55d2e7f4..04a582ba9416 100644
--- a/drivers/hwmon/pmbus/isl68137.c
+++ b/drivers/hwmon/pmbus/isl68137.c
@@ -63,6 +63,9 @@ enum chips {
 	raa228228,
 	raa229001,
 	raa229004,
++#if IS_ENABLED(CONFIG_SENSORS_RAA229141)
++	raa229141,
++#endif /* CONFIG_SENSORS_RAA229141 */
 	raa229621,
 };
 
@@ -71,6 +74,9 @@ enum variants {
 	raa_dmpvr2_1rail,
 	raa_dmpvr2_2rail,
 	raa_dmpvr2_2rail_nontc,
+#if IS_ENABLED(CONFIG_SENSORS_RAA229141)
+	raa_dmpvr2_2rail_isys,
+#endif /* CONFIG_SENSORS_RAA229141 */
 	raa_dmpvr2_3rail,
 	raa_dmpvr2_hv,
 };
@@ -174,6 +180,34 @@ static const struct attribute_group *isl68137_attribute_groups[] = {
 	NULL,
 };
 
+#if IS_ENABLED(CONFIG_SENSORS_RAA229141)
+#define RAA_READ_DMA_DATA	0xc5
+#define RAA_WRITE_DMA_ADDRESS 0xc7
+
+/* DMA address for input and output */
+static const unsigned char dma_address_in[] = { 0xD3, 0xE0 };
+static const unsigned char dma_address_out[] = { 0x42, 0xEE };
+int read_isys_route_dma(struct i2c_client *client, const char *addr)
+{
+	int ret;
+
+	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;
+	}
+	// DIRECT ISYS format 10mA/LSB
+	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;
+};
+#endif /* CONFIG_SENSORS_RAA229141 */
+
 static int raa_dmpvr2_read_word_data(struct i2c_client *client, int page,
 				     int phase, int reg)
 {
@@ -183,6 +217,14 @@ static int raa_dmpvr2_read_word_data(struct i2c_client *client, int page,
 	u64 temp;
 
 	switch (reg) {
+#if IS_ENABLED(CONFIG_SENSORS_RAA229141)
+	case PMBUS_VIRT_READ_ISYSIN:
+		ret = read_isys_route_dma(client, dma_address_in);
+		break;
+	case PMBUS_VIRT_READ_ISYSOUT:
+		ret = read_isys_route_dma(client, dma_address_out);
+		break;
+#endif /* CONFIG_SENSORS_RAA229141 */
 	case PMBUS_VIRT_READ_VMON:
 		ret = pmbus_read_word_data(client, page, phase,
 					   RAA_DMPVR2_READ_VMON);
@@ -253,6 +295,12 @@ static struct pmbus_driver_info raa_dmpvr_info = {
 	.format[PSC_CURRENT_OUT] = direct,
 	.format[PSC_POWER] = direct,
 	.format[PSC_TEMPERATURE] = direct,
+#if IS_ENABLED(CONFIG_SENSORS_RAA229141)
+	.format[PSC_ISYS] = direct,
+	.m[PSC_ISYS] = 1,
+	.b[PSC_ISYS] = 0,
+	.R[PSC_ISYS] = 2,
+#endif /* CONFIG_SENSORS_RAA229141 */
 	.m[PSC_VOLTAGE_IN] = 1,
 	.b[PSC_VOLTAGE_IN] = 0,
 	.R[PSC_VOLTAGE_IN] = 2,
@@ -398,6 +446,20 @@ static int isl68137_probe(struct i2c_client *client)
 		info->read_word_data = raa_dmpvr2_read_word_data;
 		info->write_word_data = raa_dmpvr2_write_word_data;
 		break;
+#if IS_ENABLED(CONFIG_SENSORS_RAA229141)
+	case raa_dmpvr2_2rail_isys:
+		info->format[PSC_VOLTAGE_IN] = linear,
+		info->format[PSC_VOLTAGE_OUT] = linear,
+		info->format[PSC_CURRENT_IN] = linear;
+		info->format[PSC_CURRENT_OUT] = linear;
+		info->format[PSC_POWER] = linear;
+		info->format[PSC_TEMPERATURE] = linear;
+		info->func[0] |= PMBUS_HAVE_ISYSIN;
+		info->func[0] |= PMBUS_HAVE_ISYSOUT;
+		info->pages = 2;
+		info->read_word_data = raa_dmpvr2_read_word_data;
+		break;
+#endif /* CONFIG_SENSORS_RAA229141 */
 	case raa_dmpvr2_3rail:
 		info->read_word_data = raa_dmpvr2_read_word_data;
 		info->write_word_data = raa_dmpvr2_write_word_data;
@@ -466,6 +528,9 @@ static const struct i2c_device_id raa_dmpvr_id[] = {
 	{"raa228228", raa_dmpvr2_2rail_nontc},
 	{"raa229001", raa_dmpvr2_2rail},
 	{"raa229004", raa_dmpvr2_2rail},
+#if IS_ENABLED(CONFIG_SENSORS_RAA229141)
+	{"raa229141", raa_dmpvr2_2rail_isys},
+#endif /* CONFIG_SENSORS_RAA229141 */
 	{"raa229621", raa_dmpvr2_2rail},
 	{}
 };
diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
index d2e9bfb5320f..ec5a4b9286cc 100644
--- a/drivers/hwmon/pmbus/pmbus.h
+++ b/drivers/hwmon/pmbus/pmbus.h
@@ -236,6 +236,10 @@ enum pmbus_regs {
 	PMBUS_VIRT_CURR_SAMPLES,
 	PMBUS_VIRT_POWER_SAMPLES,
 	PMBUS_VIRT_TEMP_SAMPLES,
+#if IS_ENABLED(CONFIG_SENSORS_RAA229141)
+	PMBUS_VIRT_READ_ISYSIN,
+	PMBUS_VIRT_READ_ISYSOUT,
+#endif /* CONFIG_SENSORS_RAA229141 */
 };
 
 /*
@@ -381,6 +385,9 @@ enum pmbus_sensor_classes {
 	PSC_TEMPERATURE,
 	PSC_FAN,
 	PSC_PWM,
+#if IS_ENABLED(CONFIG_SENSORS_RAA229141)
+	PSC_ISYS,
+#endif /* CONFIG_SENSORS_RAA229141 */
 	PSC_NUM_CLASSES		/* Number of power sensor classes */
 };
 
@@ -411,6 +418,10 @@ enum pmbus_sensor_classes {
 #define PMBUS_HAVE_PWM12	BIT(20)
 #define PMBUS_HAVE_PWM34	BIT(21)
 #define PMBUS_HAVE_SAMPLES	BIT(22)
+#if IS_ENABLED(CONFIG_SENSORS_RAA229141)
+#define PMBUS_HAVE_ISYSIN	BIT(23)
+#define PMBUS_HAVE_ISYSOUT	BIT(24)
+#endif /* CONFIG_SENSORS_RAA229141 */
 
 #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..88344c088f6d 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -1929,6 +1929,20 @@ static const struct pmbus_sensor_attr current_attributes[] = {
 		.gbit = PB_STATUS_IOUT_OC,
 		.limit = iout_limit_attrs,
 		.nlimit = ARRAY_SIZE(iout_limit_attrs),
+#if IS_ENABLED(CONFIG_SENSORS_RAA229141)
+	}, {
+		.reg = PMBUS_VIRT_READ_ISYSIN,
+		.class = PSC_ISYS,
+		.label = "isysin",
+		.paged = true,
+		.func = PMBUS_HAVE_ISYSIN,
+	}, {
+		.reg = PMBUS_VIRT_READ_ISYSOUT,
+		.class = PSC_ISYS,
+		.label = "isysout",
+		.paged = true,
+		.func = PMBUS_HAVE_ISYSOUT,
+#endif /* CONFIG_SENSORS_RAA229141 */
 	}
 };
 
@@ -2501,6 +2515,12 @@ static const struct pmbus_class_attr_map class_attr_map[] = {
 		.class = PSC_TEMPERATURE,
 		.attr = temp_attributes,
 		.nattr = ARRAY_SIZE(temp_attributes),
+#if IS_ENABLED(CONFIG_SENSORS_RAA229141)
+	}, {
+		.class = PSC_ISYS,
+		.attr = current_attributes,
+		.nattr = ARRAY_SIZE(current_attributes),
+#endif /* CONFIG_SENSORS_RAA229141 */
 	}
 };
 
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ