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
| ||
|
Message-ID: <20250510091937.2298256-4-paweldembicki@gmail.com> Date: Sat, 10 May 2025 11:18:46 +0200 From: Pawel Dembicki <paweldembicki@...il.com> To: linux-hwmon@...r.kernel.org Cc: Pawel Dembicki <paweldembicki@...il.com>, Jean Delvare <jdelvare@...e.com>, Guenter Roeck <linux@...ck-us.net>, Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, Jonathan Corbet <corbet@....net>, Noah Wang <noahwang.wang@...look.com>, Fabio Estevam <festevam@...il.com>, Naresh Solanki <naresh.solanki@...ements.com>, Michal Simek <michal.simek@....com>, Grant Peltier <grantpeltier93@...il.com>, Laurent Pinchart <laurent.pinchart@...asonboard.com>, Peter Zijlstra <peterz@...radead.org>, Shen Lichuan <shenlichuan@...o.com>, Greg KH <gregkh@...uxfoundation.org>, Charles Hsu <ythsu0511@...il.com>, devicetree@...r.kernel.org, linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org Subject: [PATCH v3 3/5] 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@...il.com> --- v3: - droped comments and indexed the table with enums instead - use device_property_read_u32() instead of_property_read_u32() v2: - renamed property to mps,vout-fb-divider-ratio-permille - added register value range checking --- drivers/hwmon/pmbus/mpq8785.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/hwmon/pmbus/mpq8785.c b/drivers/hwmon/pmbus/mpq8785.c index d0ac294b4bbc..2e7c0d0c3f81 100644 --- a/drivers/hwmon/pmbus/mpq8785.c +++ b/drivers/hwmon/pmbus/mpq8785.c @@ -5,11 +5,16 @@ #include <linux/i2c.h> #include <linux/module.h> +#include <linux/property.h> #include <linux/of_device.h> #include "pmbus.h" enum chips { mpq8785 }; +static u16 voltage_scale_loop_max_val[] = { + [mpq8785] = GENMASK(10, 0), +}; + static int mpq8785_identify(struct i2c_client *client, struct pmbus_driver_info *info) { @@ -74,6 +79,8 @@ static int mpq8785_probe(struct i2c_client *client) struct device *dev = &client->dev; struct pmbus_driver_info *info; enum chips chip_id; + u32 voltage_scale; + int ret; info = devm_kmemdup(dev, &mpq8785_info, sizeof(*info), GFP_KERNEL); if (!info) @@ -92,6 +99,17 @@ static int mpq8785_probe(struct i2c_client *client) return -ENODEV; } + if (!device_property_read_u32(dev, "mps,vout-fb-divider-ratio-permille", + &voltage_scale)) { + if (voltage_scale > voltage_scale_loop_max_val[chip_id]) + return -EINVAL; + + ret = i2c_smbus_write_word_data(client, PMBUS_VOUT_SCALE_LOOP, + voltage_scale); + if (ret) + return ret; + } + return pmbus_do_probe(client, info); }; -- 2.43.0
Powered by blists - more mailing lists