summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2023-06-14 09:36:05 -0700
committerGuenter Roeck <linux@roeck-us.net>2023-06-22 10:39:58 -0700
commitdd5219ce4f295a129ee38baff308f9c1e4f0761b (patch)
tree55fd34774b0b98dd9d7aeb5bbad4aa61560904e1 /drivers/hwmon
parent98ac8af4e7b2f260236cf468762450630e73eb67 (diff)
downloadlinux-stable-dd5219ce4f295a129ee38baff308f9c1e4f0761b.tar.gz
linux-stable-dd5219ce4f295a129ee38baff308f9c1e4f0761b.tar.bz2
linux-stable-dd5219ce4f295a129ee38baff308f9c1e4f0761b.zip
hwmon: (pmbus/adm1275) Disable ADC while updating PMON_CONFIG
According to ADI, changing PMON_CONFIG while the ADC is running can have unexpected results. ADI recommends halting the ADC with PMON_CONTROL before setting PMON_CONFIG and then resume after. Follow ADI recommendation and disable ADC while PMON_CONFIG is updated. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20230614163605.3688964-3-linux@roeck-us.net Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/pmbus/adm1275.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c
index 84a1b3aa99ba..e2c61d6fa521 100644
--- a/drivers/hwmon/pmbus/adm1275.c
+++ b/drivers/hwmon/pmbus/adm1275.c
@@ -27,8 +27,11 @@ enum chips { adm1075, adm1272, adm1275, adm1276, adm1278, adm1293, adm1294 };
#define ADM1275_PEAK_IOUT 0xd0
#define ADM1275_PEAK_VIN 0xd1
#define ADM1275_PEAK_VOUT 0xd2
+#define ADM1275_PMON_CONTROL 0xd3
#define ADM1275_PMON_CONFIG 0xd4
+#define ADM1275_CONVERT_EN BIT(0)
+
#define ADM1275_VIN_VOUT_SELECT BIT(6)
#define ADM1275_VRANGE BIT(5)
#define ADM1075_IRANGE_50 BIT(4)
@@ -202,7 +205,11 @@ static int adm1275_read_samples(const struct adm1275_data *data,
static int adm1275_write_pmon_config(const struct adm1275_data *data,
struct i2c_client *client, u16 word)
{
- int ret;
+ int ret, ret2;
+
+ ret = i2c_smbus_write_byte_data(client, ADM1275_PMON_CONTROL, 0);
+ if (ret)
+ return ret;
if (data->have_power_sampling)
ret = i2c_smbus_write_word_data(client, ADM1275_PMON_CONFIG,
@@ -211,6 +218,15 @@ static int adm1275_write_pmon_config(const struct adm1275_data *data,
ret = i2c_smbus_write_byte_data(client, ADM1275_PMON_CONFIG,
word);
+ /*
+ * We still want to re-enable conversions if writing into
+ * ADM1275_PMON_CONFIG failed.
+ */
+ ret2 = i2c_smbus_write_byte_data(client, ADM1275_PMON_CONTROL,
+ ADM1275_CONVERT_EN);
+ if (!ret)
+ ret = ret2;
+
return ret;
}