mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] hwmon: (pmbus/core) Add a vout_command debugfs entry
@ 2026-11-08 17:32 Vincent Jardin via B4 Relay
  2026-11-08 18:08 ` Guenter Roeck
  0 siblings, 1 reply; 3+ messages in thread
From: Vincent Jardin via B4 Relay @ 2026-11-08 17:32 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: linux-hwmon, linux-kernel, Vincent Jardin

From: Vincent Jardin <vjardin@free.fr>

The vout hwmon attributes and the regulator get_voltage() callback
both report READ_VOUT.

On a regulator whose configuration applies a load line (droop),
READ_VOUT sits below the setpoint under load by design, so user space
cannot see what the regulator was actually set to.

max20730 already exposes a driver-specific vout_command entry. Add
vout<page>_command to the PMBus core debugfs, for every page with VOUT
and a readable VOUT_COMMAND, in millivolts like the in*_input attributes.

Signed-off-by: Vincent Jardin <vjardin@free.fr>
---
 drivers/hwmon/pmbus/pmbus_core.c | 42 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 40 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 37b650b85d1c..1ad5523a9624 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -3833,6 +3833,33 @@ static int pmbus_debugfs_get_status(void *data, u64 *val)
 DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops_status, pmbus_debugfs_get_status,
 			 NULL, "0x%04llx\n");
 
+static int pmbus_debugfs_get_vout_command(void *data, u64 *val)
+{
+	struct pmbus_debugfs_entry *entry = data;
+	struct i2c_client *client = entry->client;
+	struct pmbus_data *pdata = i2c_get_clientdata(client);
+	struct pmbus_sensor s = {
+		.page = entry->page,
+		.reg = entry->reg,
+		.class = PSC_VOLTAGE_OUT,
+		.convert = true,
+	};
+	int rc;
+
+	guard(pmbus_lock)(client);
+
+	rc = _pmbus_read_word_data(client, entry->page, 0xff, entry->reg);
+	if (rc < 0)
+		return rc;
+
+	s.data = rc;
+	*val = pmbus_reg2data(pdata, &s);
+
+	return 0;
+}
+DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops_vout_command,
+			 pmbus_debugfs_get_vout_command, NULL, "%lld\n");
+
 static ssize_t pmbus_debugfs_block_read(struct file *file, char __user *buf,
 					size_t count, loff_t *ppos)
 {
@@ -3940,11 +3967,11 @@ static void pmbus_init_debugfs(struct i2c_client *client,
 	 * device specific:
 	 *	ARRAY_SIZE(pmbus_debugfs_block_data) + 2
 	 * page specific:
-	 *	ARRAY_SIZE(pmbus_debugfs_status_data) + 1
+	 *	ARRAY_SIZE(pmbus_debugfs_status_data) + 2
 	 */
 	entries = devm_kcalloc(data->dev,
 			       ARRAY_SIZE(pmbus_debugfs_block_data) + 2 +
-			       data->info->pages * (ARRAY_SIZE(pmbus_debugfs_status_data) + 1),
+			       data->info->pages * (ARRAY_SIZE(pmbus_debugfs_status_data) + 2),
 			       sizeof(*entries), GFP_KERNEL);
 	if (!entries)
 		return;
@@ -4013,6 +4040,17 @@ static void pmbus_init_debugfs(struct i2c_client *client,
 						    &pmbus_debugfs_ops);
 			}
 		}
+
+		if ((data->info->func[page] & PMBUS_HAVE_VOUT) &&
+		    pmbus_check_word_register(client, page, PMBUS_VOUT_COMMAND)) {
+			entries[idx].client = client;
+			entries[idx].page = page;
+			entries[idx].reg = PMBUS_VOUT_COMMAND;
+			scnprintf(name, PMBUS_NAME_SIZE, "vout%d_command", page);
+			debugfs_create_file(name, 0444, debugfs,
+					    &entries[idx++],
+					    &pmbus_debugfs_ops_vout_command);
+		}
 	}
 }
 

---
base-commit: d4193d2a0ffa407478bce4a094e1ae085ceb38ec
change-id: 20261108-for-upstream-pmbus-vout-command-debugfs-v1-6fe3ec237b1a

Best regards,
-- 
Vincent Jardin <vjardin@free.fr>



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

* Re: [PATCH] hwmon: (pmbus/core) Add a vout_command debugfs entry
  2026-11-08 17:32 [PATCH] hwmon: (pmbus/core) Add a vout_command debugfs entry Vincent Jardin via B4 Relay
@ 2026-11-08 18:08 ` Guenter Roeck
  2026-11-09  9:28   ` Vincent Jardin
  0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2026-11-08 18:08 UTC (permalink / raw)
  To: vjardin; +Cc: linux-hwmon, linux-kernel

On 11/8/26 09:32, Vincent Jardin via B4 Relay wrote:
> From: Vincent Jardin <vjardin@free.fr>
> 
> The vout hwmon attributes and the regulator get_voltage() callback
> both report READ_VOUT.
> 
> On a regulator whose configuration applies a load line (droop),
> READ_VOUT sits below the setpoint under load by design, so user space
> cannot see what the regulator was actually set to.
> 
> max20730 already exposes a driver-specific vout_command entry. Add
> vout<page>_command to the PMBus core debugfs, for every page with VOUT
> and a readable VOUT_COMMAND, in millivolts like the in*_input attributes.
> 
> Signed-off-by: Vincent Jardin <vjardin@free.fr>
> ---
>   drivers/hwmon/pmbus/pmbus_core.c | 42 ++++++++++++++++++++++++++++++++++++++--
>   1 file changed, 40 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> index 37b650b85d1c..1ad5523a9624 100644
> --- a/drivers/hwmon/pmbus/pmbus_core.c
> +++ b/drivers/hwmon/pmbus/pmbus_core.c
> @@ -3833,6 +3833,33 @@ static int pmbus_debugfs_get_status(void *data, u64 *val)
>   DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops_status, pmbus_debugfs_get_status,
>   			 NULL, "0x%04llx\n");
>   
> +static int pmbus_debugfs_get_vout_command(void *data, u64 *val)
> +{
> +	struct pmbus_debugfs_entry *entry = data;
> +	struct i2c_client *client = entry->client;
> +	struct pmbus_data *pdata = i2c_get_clientdata(client);
> +	struct pmbus_sensor s = {
> +		.page = entry->page,
> +		.reg = entry->reg,
> +		.class = PSC_VOLTAGE_OUT,
> +		.convert = true,
> +	};
> +	int rc;
> +
> +	guard(pmbus_lock)(client);
> +
> +	rc = _pmbus_read_word_data(client, entry->page, 0xff, entry->reg);
> +	if (rc < 0)
> +		return rc;
> +
> +	s.data = rc;
> +	*val = pmbus_reg2data(pdata, &s);
> +

Why not use the already existing pmbus_vout_command_mv() ?

Thanks,
Guenter


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

* Re: [PATCH] hwmon: (pmbus/core) Add a vout_command debugfs entry
  2026-11-08 18:08 ` Guenter Roeck
@ 2026-11-09  9:28   ` Vincent Jardin
  0 siblings, 0 replies; 3+ messages in thread
From: Vincent Jardin @ 2026-11-09  9:28 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: linux-hwmon, linux-kernel

Hi Guenter,

> Why not use the already existing pmbus_vout_command_mv() ?

Thanks, I did include your feedback into the v2, Sashiko is ok:
  https://lore.kernel.org/all/sashiko-outbox-204002@kernel.org/ 

Best regards,
  Vincent

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

end of thread, other threads:[~2026-11-09  9:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-08 17:32 [PATCH] hwmon: (pmbus/core) Add a vout_command debugfs entry Vincent Jardin via B4 Relay
2026-11-08 18:08 ` Guenter Roeck
2026-11-09  9:28   ` Vincent Jardin

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®