mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] hwmon: (pmbus) Improve temperature sensor support
@ 2011-03-07 16:38 Guenter Roeck
  2011-03-07 16:38 ` [PATCH 1/2] hwmon: (pmbus) Improve support for paged temperature sensors Guenter Roeck
  2011-03-07 16:38 ` [PATCH 2/2] hwmon: (pmbus) Continuously update temperature limit registers Guenter Roeck
  0 siblings, 2 replies; 3+ messages in thread
From: Guenter Roeck @ 2011-03-07 16:38 UTC (permalink / raw)
  To: Jean Delvare
  Cc: Jonathan Cameron, Greg Schnorr, lm-sensors, linux-kernel, Guenter Roeck

The following two patches improve temperature sensor support for PMBus devices.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] hwmon: (pmbus) Improve support for paged temperature sensors
  2011-03-07 16:38 [PATCH 0/2] hwmon: (pmbus) Improve temperature sensor support Guenter Roeck
@ 2011-03-07 16:38 ` Guenter Roeck
  2011-03-07 16:38 ` [PATCH 2/2] hwmon: (pmbus) Continuously update temperature limit registers Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2011-03-07 16:38 UTC (permalink / raw)
  To: Jean Delvare
  Cc: Jonathan Cameron, Greg Schnorr, lm-sensors, linux-kernel, Guenter Roeck

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>
---
 drivers/hwmon/pmbus_core.c |   46 ++++++++++++++++++++++++++-----------------
 1 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/drivers/hwmon/pmbus_core.c b/drivers/hwmon/pmbus_core.c
index d025a11..e9dda58 100644
--- a/drivers/hwmon/pmbus_core.c
+++ b/drivers/hwmon/pmbus_core.c
@@ -797,6 +797,12 @@ static const int pmbus_temp_registers[] = {
 	PMBUS_READ_TEMPERATURE_3
 };
 
+static const int pmbus_temp_flags[] = {
+	PMBUS_HAVE_TEMP,
+	PMBUS_HAVE_TEMP2,
+	PMBUS_HAVE_TEMP3
+};
+
 static const int pmbus_fan_registers[] = {
 	PMBUS_READ_FAN_SPEED_1,
 	PMBUS_READ_FAN_SPEED_2,
@@ -871,17 +877,16 @@ static void pmbus_find_max_attr(struct i2c_client *client,
 			max_booleans += 2 * PMBUS_MAX_BOOLEANS_PER_FAN;
 		}
 		if (info->func[page] & PMBUS_HAVE_TEMP) {
-			if (page == 0) {
-				max_sensors +=
-				    ARRAY_SIZE(pmbus_temp_registers) *
-				    PMBUS_MAX_SENSORS_PER_TEMP;
-				max_booleans +=
-				    ARRAY_SIZE(pmbus_temp_registers) *
-				    PMBUS_MAX_BOOLEANS_PER_TEMP;
-			} else {
-				max_sensors += PMBUS_MAX_SENSORS_PER_TEMP;
-				max_booleans += PMBUS_MAX_BOOLEANS_PER_TEMP;
-			}
+			max_sensors += PMBUS_MAX_SENSORS_PER_TEMP;
+			max_booleans += PMBUS_MAX_BOOLEANS_PER_TEMP;
+		}
+		if (info->func[page] & PMBUS_HAVE_TEMP2) {
+			max_sensors += PMBUS_MAX_SENSORS_PER_TEMP;
+			max_booleans += PMBUS_MAX_BOOLEANS_PER_TEMP;
+		}
+		if (info->func[page] & PMBUS_HAVE_TEMP3) {
+			max_sensors += PMBUS_MAX_SENSORS_PER_TEMP;
+			max_booleans += PMBUS_MAX_BOOLEANS_PER_TEMP;
 		}
 	}
 	data->max_sensors = max_sensors;
@@ -1273,18 +1278,23 @@ static void pmbus_find_attributes(struct i2c_client *client,
 	 */
 	in_index = 1;
 	for (page = 0; page < info->pages; page++) {
-		int t, temps;
-
-		if (!(info->func[page] & PMBUS_HAVE_TEMP))
-			continue;
+		int t;
 
-		temps = page ? 1 : ARRAY_SIZE(pmbus_temp_registers);
-		for (t = 0; t < temps; t++) {
+		for (t = 0; t < ARRAY_SIZE(pmbus_temp_registers); t++) {
 			bool have_alarm = false;
 
+			/*
+			 * A PMBus chip may support any combination of
+			 * temperature registers on any page. So we can not
+			 * abort after a failure to detect a register, but have
+			 * to continue checking for all registers on all pages.
+			 */
+			if (!(info->func[page] & pmbus_temp_flags[t]))
+				continue;
+
 			if (!pmbus_check_word_register
 			    (client, page, pmbus_temp_registers[t]))
-				break;
+				continue;
 
 			i0 = data->num_sensors;
 			pmbus_add_sensor(data, "temp", "input", in_index, page,
-- 
1.7.3.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] hwmon: (pmbus) Continuously update temperature limit registers
  2011-03-07 16:38 [PATCH 0/2] hwmon: (pmbus) Improve temperature sensor support Guenter Roeck
  2011-03-07 16:38 ` [PATCH 1/2] hwmon: (pmbus) Improve support for paged temperature sensors Guenter Roeck
@ 2011-03-07 16:38 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2011-03-07 16:38 UTC (permalink / raw)
  To: Jean Delvare
  Cc: Jonathan Cameron, Greg Schnorr, lm-sensors, linux-kernel, Guenter Roeck

PMBus only has one set of limit registers for up to three temperature sensors.
Thus, changing a limit for one of the temperature sensors affects limits for
other temperature sensors in the same page (and potentially multiple pages
depending on the chip implementation). To handle this situation, re-read all
temperature limit registers when updating sensor data. This way, all affected
temperature limits are updated whenever the limit for a single sensor is
changed.

Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
---
 drivers/hwmon/pmbus_core.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/hwmon/pmbus_core.c b/drivers/hwmon/pmbus_core.c
index e9dda58..92540c9 100644
--- a/drivers/hwmon/pmbus_core.c
+++ b/drivers/hwmon/pmbus_core.c
@@ -1308,13 +1308,19 @@ static void pmbus_find_attributes(struct i2c_client *client,
 			 * Always compare current temperature against the limit
 			 * registers to determine alarm conditions for a
 			 * specific sensor.
+			 *
+			 * Since there is only one set of limit registers for
+			 * up to three temperature sensors, we need to update
+			 * all limit registers after the limit was changed for
+			 * one of the sensors. This ensures that correct limits
+			 * are reported for all temperature sensors.
 			 */
 			if (pmbus_check_word_register
 			    (client, page, PMBUS_UT_WARN_LIMIT)) {
 				i1 = data->num_sensors;
 				pmbus_add_sensor(data, "temp", "min", in_index,
 						 page, PMBUS_UT_WARN_LIMIT,
-						 PSC_TEMPERATURE, false);
+						 PSC_TEMPERATURE, true);
 				if (info->func[page] & PMBUS_HAVE_STATUS_TEMP) {
 					pmbus_add_boolean_cmp(data, "temp",
 						"min_alarm", in_index, i1, i0,
@@ -1329,7 +1335,7 @@ static void pmbus_find_attributes(struct i2c_client *client,
 				pmbus_add_sensor(data, "temp", "lcrit",
 						 in_index, page,
 						 PMBUS_UT_FAULT_LIMIT,
-						 PSC_TEMPERATURE, false);
+						 PSC_TEMPERATURE, true);
 				if (info->func[page] & PMBUS_HAVE_STATUS_TEMP) {
 					pmbus_add_boolean_cmp(data, "temp",
 						"lcrit_alarm", in_index, i1, i0,
@@ -1343,7 +1349,7 @@ static void pmbus_find_attributes(struct i2c_client *client,
 				i1 = data->num_sensors;
 				pmbus_add_sensor(data, "temp", "max", in_index,
 						 page, PMBUS_OT_WARN_LIMIT,
-						 PSC_TEMPERATURE, false);
+						 PSC_TEMPERATURE, true);
 				if (info->func[page] & PMBUS_HAVE_STATUS_TEMP) {
 					pmbus_add_boolean_cmp(data, "temp",
 						"max_alarm", in_index, i0, i1,
@@ -1357,7 +1363,7 @@ static void pmbus_find_attributes(struct i2c_client *client,
 				i1 = data->num_sensors;
 				pmbus_add_sensor(data, "temp", "crit", in_index,
 						 page, PMBUS_OT_FAULT_LIMIT,
-						 PSC_TEMPERATURE, false);
+						 PSC_TEMPERATURE, true);
 				if (info->func[page] & PMBUS_HAVE_STATUS_TEMP) {
 					pmbus_add_boolean_cmp(data, "temp",
 						"crit_alarm", in_index, i0, i1,
-- 
1.7.3.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-03-07 16:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-07 16:38 [PATCH 0/2] hwmon: (pmbus) Improve temperature sensor support Guenter Roeck
2011-03-07 16:38 ` [PATCH 1/2] hwmon: (pmbus) Improve support for paged temperature sensors Guenter Roeck
2011-03-07 16:38 ` [PATCH 2/2] hwmon: (pmbus) Continuously update temperature limit registers Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome