diff options
Diffstat (limited to 'drivers/hwmon/pmbus/pmbus_core.c')
-rw-r--r-- | drivers/hwmon/pmbus/pmbus_core.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index f2e47c7..ba59eae 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -515,16 +515,24 @@ static long pmbus_reg2data_direct(struct pmbus_data *data, /* * Convert VID sensor values to milli- or micro-units * depending on sensor type. - * We currently only support VR11. */ static long pmbus_reg2data_vid(struct pmbus_data *data, struct pmbus_sensor *sensor) { long val = sensor->data; + long rv = 0; - if (val < 0x02 || val > 0xb2) - return 0; - return DIV_ROUND_CLOSEST(160000 - (val - 2) * 625, 100); + switch (data->info->vrm_version) { + case vr11: + if (val >= 0x02 && val <= 0xb2) + rv = DIV_ROUND_CLOSEST(160000 - (val - 2) * 625, 100); + break; + case vr12: + if (val >= 0x01) + rv = 250 + (val - 1) * 5; + break; + } + return rv; } static long pmbus_reg2data(struct pmbus_data *data, struct pmbus_sensor *sensor) @@ -1329,6 +1337,10 @@ static const struct pmbus_limit_attr pin_limit_attrs[] = { .update = true, .attr = "average", }, { + .reg = PMBUS_VIRT_READ_PIN_MIN, + .update = true, + .attr = "input_lowest", + }, { .reg = PMBUS_VIRT_READ_PIN_MAX, .update = true, .attr = "input_highest", @@ -1359,6 +1371,10 @@ static const struct pmbus_limit_attr pout_limit_attrs[] = { .update = true, .attr = "average", }, { + .reg = PMBUS_VIRT_READ_POUT_MIN, + .update = true, + .attr = "input_lowest", + }, { .reg = PMBUS_VIRT_READ_POUT_MAX, .update = true, .attr = "input_highest", @@ -1735,6 +1751,11 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data, } } + /* Enable PEC if the controller supports it */ + ret = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY); + if (ret >= 0 && (ret & PB_CAPABILITY_ERROR_CHECK)) + client->flags |= I2C_CLIENT_PEC; + pmbus_clear_faults(client); if (info->identify) { @@ -1796,7 +1817,7 @@ static int pmbus_regulator_disable(struct regulator_dev *rdev) return _pmbus_regulator_on_off(rdev, 0); } -struct regulator_ops pmbus_regulator_ops = { +const struct regulator_ops pmbus_regulator_ops = { .enable = pmbus_regulator_enable, .disable = pmbus_regulator_disable, .is_enabled = pmbus_regulator_is_enabled, |