Skip to content

Commit dc1a4ba

Browse files
CHKDSK88groeck
authored andcommitted
hwmon: pmbus: mpq8785: Implement VOUT feedback resistor divider ratio configuration
Implement support for setting the VOUT_SCALE_LOOP PMBus register based on an optional device tree property "mps,vout-fb-divider-ratio-permille". This allows the driver to provide the correct VOUT value depending on the feedback voltage divider configuration for chips where the bootloader does not configure the VOUT_SCALE_LOOP register. Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com> Link: https://lore.kernel.org/r/20250511035701.2607947-4-paweldembicki@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 1bc6020 commit dc1a4ba

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/hwmon/pmbus/mpq8785.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@
55

66
#include <linux/i2c.h>
77
#include <linux/module.h>
8+
#include <linux/property.h>
89
#include <linux/of_device.h>
910
#include "pmbus.h"
1011

1112
enum chips { mpq8785 };
1213

14+
static u16 voltage_scale_loop_max_val[] = {
15+
[mpq8785] = GENMASK(10, 0),
16+
};
17+
1318
static int mpq8785_identify(struct i2c_client *client,
1419
struct pmbus_driver_info *info)
1520
{
@@ -74,6 +79,8 @@ static int mpq8785_probe(struct i2c_client *client)
7479
struct device *dev = &client->dev;
7580
struct pmbus_driver_info *info;
7681
enum chips chip_id;
82+
u32 voltage_scale;
83+
int ret;
7784

7885
info = devm_kmemdup(dev, &mpq8785_info, sizeof(*info), GFP_KERNEL);
7986
if (!info)
@@ -92,6 +99,17 @@ static int mpq8785_probe(struct i2c_client *client)
9299
return -ENODEV;
93100
}
94101

102+
if (!device_property_read_u32(dev, "mps,vout-fb-divider-ratio-permille",
103+
&voltage_scale)) {
104+
if (voltage_scale > voltage_scale_loop_max_val[chip_id])
105+
return -EINVAL;
106+
107+
ret = i2c_smbus_write_word_data(client, PMBUS_VOUT_SCALE_LOOP,
108+
voltage_scale);
109+
if (ret)
110+
return ret;
111+
}
112+
95113
return pmbus_do_probe(client, info);
96114
};
97115

0 commit comments

Comments
 (0)