aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck <guenter.roeck@ericsson.com>2011-03-06 13:56:52 -0500
committerGuenter Roeck <guenter.roeck@ericsson.com>2011-03-15 01:39:09 -0400
commitb49547a5df96bc755d6f96abb8503678af49d91c (patch)
treec7b09bb99d93bbb3becf765ce2103c38c321ba1a /drivers/hwmon
parent954df6763cd84551a565a0c341d3401cf30b9d2d (diff)
hwmon: (pmbus) Improve support for paged temperature sensors
Assumption so far was that PMBus devices would support TEMP2 and TEMP3 registers only on page 0, and that only the TEMP1 register would be used/supported on other pages. Turns out that is not correct. UCD92xx devices support TEMP1 and TEMP2 on page 0, and TEMP2 on other pages. So it is necessary to change the core code such that it does not make a page based assumptions about temperature register support. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/pmbus_core.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/drivers/hwmon/pmbus_core.c b/drivers/hwmon/pmbus_core.c
index d025a118bf92..e9dda58a5b90 100644
--- a/drivers/hwmon/pmbus_core.c
+++ b/drivers/hwmon/pmbus_core.c
@@ -797,6 +797,12 @@ static const int pmbus_temp_registers[] = {
797 PMBUS_READ_TEMPERATURE_3 797 PMBUS_READ_TEMPERATURE_3
798}; 798};
799 799
800static const int pmbus_temp_flags[] = {
801 PMBUS_HAVE_TEMP,
802 PMBUS_HAVE_TEMP2,
803 PMBUS_HAVE_TEMP3
804};
805
800static const int pmbus_fan_registers[] = { 806static const int pmbus_fan_registers[] = {
801 PMBUS_READ_FAN_SPEED_1, 807 PMBUS_READ_FAN_SPEED_1,
802 PMBUS_READ_FAN_SPEED_2, 808 PMBUS_READ_FAN_SPEED_2,
@@ -871,17 +877,16 @@ static void pmbus_find_max_attr(struct i2c_client *client,
871 max_booleans += 2 * PMBUS_MAX_BOOLEANS_PER_FAN; 877 max_booleans += 2 * PMBUS_MAX_BOOLEANS_PER_FAN;
872 } 878 }
873 if (info->func[page] & PMBUS_HAVE_TEMP) { 879 if (info->func[page] & PMBUS_HAVE_TEMP) {
874 if (page == 0) { 880 max_sensors += PMBUS_MAX_SENSORS_PER_TEMP;
875 max_sensors += 881 max_booleans += PMBUS_MAX_BOOLEANS_PER_TEMP;
876 ARRAY_SIZE(pmbus_temp_registers) * 882 }
877 PMBUS_MAX_SENSORS_PER_TEMP; 883 if (info->func[page] & PMBUS_HAVE_TEMP2) {
878 max_booleans += 884 max_sensors += PMBUS_MAX_SENSORS_PER_TEMP;
879 ARRAY_SIZE(pmbus_temp_registers) * 885 max_booleans += PMBUS_MAX_BOOLEANS_PER_TEMP;
880 PMBUS_MAX_BOOLEANS_PER_TEMP; 886 }
881 } else { 887 if (info->func[page] & PMBUS_HAVE_TEMP3) {
882 max_sensors += PMBUS_MAX_SENSORS_PER_TEMP; 888 max_sensors += PMBUS_MAX_SENSORS_PER_TEMP;
883 max_booleans += PMBUS_MAX_BOOLEANS_PER_TEMP; 889 max_booleans += PMBUS_MAX_BOOLEANS_PER_TEMP;
884 }
885 } 890 }
886 } 891 }
887 data->max_sensors = max_sensors; 892 data->max_sensors = max_sensors;
@@ -1273,18 +1278,23 @@ static void pmbus_find_attributes(struct i2c_client *client,
1273 */ 1278 */
1274 in_index = 1; 1279 in_index = 1;
1275 for (page = 0; page < info->pages; page++) { 1280 for (page = 0; page < info->pages; page++) {
1276 int t, temps; 1281 int t;
1277
1278 if (!(info->func[page] & PMBUS_HAVE_TEMP))
1279 continue;
1280 1282
1281 temps = page ? 1 : ARRAY_SIZE(pmbus_temp_registers); 1283 for (t = 0; t < ARRAY_SIZE(pmbus_temp_registers); t++) {
1282 for (t = 0; t < temps; t++) {
1283 bool have_alarm = false; 1284 bool have_alarm = false;
1284 1285
1286 /*
1287 * A PMBus chip may support any combination of
1288 * temperature registers on any page. So we can not
1289 * abort after a failure to detect a register, but have
1290 * to continue checking for all registers on all pages.
1291 */
1292 if (!(info->func[page] & pmbus_temp_flags[t]))
1293 continue;
1294
1285 if (!pmbus_check_word_register 1295 if (!pmbus_check_word_register
1286 (client, page, pmbus_temp_registers[t])) 1296 (client, page, pmbus_temp_registers[t]))
1287 break; 1297 continue;
1288 1298
1289 i0 = data->num_sensors; 1299 i0 = data->num_sensors;
1290 pmbus_add_sensor(data, "temp", "input", in_index, page, 1300 pmbus_add_sensor(data, "temp", "input", in_index, page,