Skip to content

Commit dd5219c

Browse files
committed
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 98ac8af commit dd5219c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

drivers/hwmon/pmbus/adm1275.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ enum chips { adm1075, adm1272, adm1275, adm1276, adm1278, adm1293, adm1294 };
2727
#define ADM1275_PEAK_IOUT 0xd0
2828
#define ADM1275_PEAK_VIN 0xd1
2929
#define ADM1275_PEAK_VOUT 0xd2
30+
#define ADM1275_PMON_CONTROL 0xd3
3031
#define ADM1275_PMON_CONFIG 0xd4
3132

33+
#define ADM1275_CONVERT_EN BIT(0)
34+
3235
#define ADM1275_VIN_VOUT_SELECT BIT(6)
3336
#define ADM1275_VRANGE BIT(5)
3437
#define ADM1075_IRANGE_50 BIT(4)
@@ -202,7 +205,11 @@ static int adm1275_read_samples(const struct adm1275_data *data,
202205
static int adm1275_write_pmon_config(const struct adm1275_data *data,
203206
struct i2c_client *client, u16 word)
204207
{
205-
int ret;
208+
int ret, ret2;
209+
210+
ret = i2c_smbus_write_byte_data(client, ADM1275_PMON_CONTROL, 0);
211+
if (ret)
212+
return ret;
206213

207214
if (data->have_power_sampling)
208215
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,
211218
ret = i2c_smbus_write_byte_data(client, ADM1275_PMON_CONFIG,
212219
word);
213220

221+
/*
222+
* We still want to re-enable conversions if writing into
223+
* ADM1275_PMON_CONFIG failed.
224+
*/
225+
ret2 = i2c_smbus_write_byte_data(client, ADM1275_PMON_CONTROL,
226+
ADM1275_CONVERT_EN);
227+
if (!ret)
228+
ret = ret2;
229+
214230
return ret;
215231
}
216232

0 commit comments

Comments
 (0)