public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/hwmon/pmbus: Add support for raa229141 in isl68137
@ 2025-09-26  1:45 Jeff Lin
  2025-09-26  8:27 ` Guenter Roeck
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Jeff Lin @ 2025-09-26  1:45 UTC (permalink / raw)
  To: jdelvare, linux
  Cc: cedricjustine.encarnacion, ninad, andriy.shevchenko,
	johnerasmusmari.geronimo, Mariel.Tinaco, jbrunet, kimseer.paller,
	leo.yang.sy0, nuno.sa, chiang.brian, gregkh, grantpeltier93,
	peterz, william, krzysztof.kozlowski, tzungbi, thorsten.blum,
	linux-hwmon, linux-kernel, Jeff Lin

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@gmail.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


^ permalink raw reply related	[flat|nested] 11+ messages in thread
* [PATCH v2] drivers/hwmon/pmbus: Add support for raa229141 in isl68137
@ 2025-11-06 10:45 Jeff Lin
  2025-11-12 20:13 ` Guenter Roeck
  0 siblings, 1 reply; 11+ messages in thread
From: Jeff Lin @ 2025-11-06 10:45 UTC (permalink / raw)
  To: jdelvare, linux
  Cc: Mariel.Tinaco, andriy.shevchenko, cedricjustine.encarnacion,
	chiang.brian, grantpeltier93, gregkh, jbrunet,
	johnerasmusmari.geronimo, kimseer.paller, krzysztof.kozlowski,
	leo.yang.sy0, linux-hwmon, linux-kernel, ninad, nuno.sa, peterz,
	thorsten.blum, tzungbi, william, Jeff Lin

The RAA229141A is a digital dual output multiphase (X+Y ≤ 12) PWM
controller designed to be compliant with Intel VR13, VR13.HC, VR14 and
VR14.Cloud specifications, targeting VCORE and auxiliary rails.

The RAA229141A supports the Intel SVID interface along with PMBus V1.3
specifications, making it ideal for controlling the microprocessor core and
system rails in Intel VR13, VR13.HC, VR14 and VR14.Cloud platforms.

Signed-off-by: Jeff Lin <jefflin994697@gmail.com>
---
v1 -> v2:
- Modify subject and description for the requirements
- Remove CONFIG_SENSORS_RAA229141 in Kconfig
- Remove the part for multifunction pin in v1 patchset
- Rename function raa_dmpvr2_2rail_isys to raa_dmpvr2_2rail_pmbus
- Link to v1: https://lore.kernel.org/all/20250926014552.1625950-1-jefflin994697@gmail.com/
---
 Documentation/hwmon/isl68137.rst | 10 ++++++++++
 drivers/hwmon/pmbus/isl68137.c   | 14 ++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/Documentation/hwmon/isl68137.rst b/Documentation/hwmon/isl68137.rst
index 5bc029c98383..e77f582c2850 100644
--- a/Documentation/hwmon/isl68137.rst
+++ b/Documentation/hwmon/isl68137.rst
@@ -414,6 +414,16 @@ Supported chips:
 
       Publicly available (after August 2020 launch) at the Renesas website
 
+  * Renesas RAA229141
+
+    Prefix: 'raa229141'
+
+    Addresses scanned: -
+
+    Datasheet:
+
+      Provided by Renesas upon request and NDA
+
 Authors:
       - Maxim Sloyko <maxims@google.com>
       - Robert Lippert <rlippert@google.com>
diff --git a/drivers/hwmon/pmbus/isl68137.c b/drivers/hwmon/pmbus/isl68137.c
index 6bba9b50c51b..97b61836f53a 100644
--- a/drivers/hwmon/pmbus/isl68137.c
+++ b/drivers/hwmon/pmbus/isl68137.c
@@ -65,6 +65,7 @@ enum chips {
 	raa228246,
 	raa229001,
 	raa229004,
+	raa229141,
 	raa229621,
 };
 
@@ -73,6 +74,7 @@ enum variants {
 	raa_dmpvr2_1rail,
 	raa_dmpvr2_2rail,
 	raa_dmpvr2_2rail_nontc,
+	raa_dmpvr2_2rail_pmbus,
 	raa_dmpvr2_3rail,
 	raa_dmpvr2_hv,
 };
@@ -399,6 +401,17 @@ 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;
+	case raa_dmpvr2_2rail_pmbus:
+		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->pages = 2;
+		info->read_word_data = raa_dmpvr2_read_word_data;
+		info->write_word_data = raa_dmpvr2_write_word_data;
+		break;
 	case raa_dmpvr2_3rail:
 		info->read_word_data = raa_dmpvr2_read_word_data;
 		info->write_word_data = raa_dmpvr2_write_word_data;
@@ -469,6 +482,7 @@ static const struct i2c_device_id raa_dmpvr_id[] = {
 	{"raa228246", raa_dmpvr2_2rail_nontc},
 	{"raa229001", raa_dmpvr2_2rail},
 	{"raa229004", raa_dmpvr2_2rail},
+	{"raa229141", raa_dmpvr2_2rail_pmbus},
 	{"raa229621", raa_dmpvr2_2rail},
 	{}
 };
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-11-12 20:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-26  1:45 [PATCH] drivers/hwmon/pmbus: Add support for raa229141 in isl68137 Jeff Lin
2025-09-26  8:27 ` Guenter Roeck
2025-11-06  9:33   ` Jeff Lin
2025-09-26 13:05 ` kernel test robot
2025-09-26 13:24 ` Guenter Roeck
2025-09-26 14:20 ` kernel test robot
2025-11-06  9:31 ` [PATCH v2] " Jeff Lin
2025-11-06  9:42   ` Andy Shevchenko
2025-11-10  1:09     ` Jeff Lin
  -- strict thread matches above, loose matches on Subject: below --
2025-11-06 10:45 Jeff Lin
2025-11-12 20:13 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox