diff mbox series

[2/3] hwmon: (pmbus) Add paged VIN, IIN, PIN, temp detection support

Message ID 1559751434-19879-3-git-send-email-hancock@sedsystems.ca (mailing list archive)
State Superseded
Headers show
Series Add pmbus support for Infineon IRPS5401 | expand

Commit Message

Robert Hancock June 5, 2019, 4:17 p.m. UTC
Add support for detecting multi-paged VIN, IIN, PIN and temperature
parameters to the generic detection code in pmbus_find_sensor_groups.
Paged VIN, IIN and PIN parameters were just added to the pmbus core,
and temperature parameters could already be paged but were not
auto-detected as such.

Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
---
 drivers/hwmon/pmbus/pmbus.c | 46 ++++++++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c
index c0bc43d..970322f 100644
--- a/drivers/hwmon/pmbus/pmbus.c
+++ b/drivers/hwmon/pmbus/pmbus.c
@@ -29,17 +29,8 @@  static void pmbus_find_sensor_groups(struct i2c_client *client,
 	int page;
 
 	/* Sensors detected on page 0 only */
-	if (pmbus_check_word_register(client, 0, PMBUS_READ_VIN))
-		info->func[0] |= PMBUS_HAVE_VIN;
 	if (pmbus_check_word_register(client, 0, PMBUS_READ_VCAP))
 		info->func[0] |= PMBUS_HAVE_VCAP;
-	if (pmbus_check_word_register(client, 0, PMBUS_READ_IIN))
-		info->func[0] |= PMBUS_HAVE_IIN;
-	if (pmbus_check_word_register(client, 0, PMBUS_READ_PIN))
-		info->func[0] |= PMBUS_HAVE_PIN;
-	if (info->func[0]
-	    && pmbus_check_byte_register(client, 0, PMBUS_STATUS_INPUT))
-		info->func[0] |= PMBUS_HAVE_STATUS_INPUT;
 	if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_12) &&
 	    pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) {
 		info->func[0] |= PMBUS_HAVE_FAN12;
@@ -52,20 +43,19 @@  static void pmbus_find_sensor_groups(struct i2c_client *client,
 		if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_34))
 			info->func[0] |= PMBUS_HAVE_STATUS_FAN34;
 	}
-	if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_1))
-		info->func[0] |= PMBUS_HAVE_TEMP;
-	if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_2))
-		info->func[0] |= PMBUS_HAVE_TEMP2;
-	if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_3))
-		info->func[0] |= PMBUS_HAVE_TEMP3;
-	if (info->func[0] & (PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2
-			     | PMBUS_HAVE_TEMP3)
-	    && pmbus_check_byte_register(client, 0,
-					 PMBUS_STATUS_TEMPERATURE))
-			info->func[0] |= PMBUS_HAVE_STATUS_TEMP;
 
 	/* Sensors detected on all pages */
 	for (page = 0; page < info->pages; page++) {
+		if (pmbus_check_word_register(client, page, PMBUS_READ_VIN))
+			info->func[page] |= PMBUS_HAVE_VIN;
+		if (pmbus_check_word_register(client, page, PMBUS_READ_IIN))
+			info->func[page] |= PMBUS_HAVE_IIN;
+		if (pmbus_check_word_register(client, page, PMBUS_READ_PIN))
+			info->func[page] |= PMBUS_HAVE_PIN;
+		if (info->func[page] & (PMBUS_HAVE_VIN | PMBUS_HAVE_IIN
+				      | PMBUS_HAVE_PIN) &&
+		    pmbus_check_byte_register(client, page, PMBUS_STATUS_INPUT))
+			info->func[page] |= PMBUS_HAVE_STATUS_INPUT;
 		if (pmbus_check_word_register(client, page, PMBUS_READ_VOUT)) {
 			info->func[page] |= PMBUS_HAVE_VOUT;
 			if (pmbus_check_byte_register(client, page,
@@ -74,12 +64,26 @@  static void pmbus_find_sensor_groups(struct i2c_client *client,
 		}
 		if (pmbus_check_word_register(client, page, PMBUS_READ_IOUT)) {
 			info->func[page] |= PMBUS_HAVE_IOUT;
-			if (pmbus_check_byte_register(client, 0,
+			if (pmbus_check_byte_register(client, page,
 						      PMBUS_STATUS_IOUT))
 				info->func[page] |= PMBUS_HAVE_STATUS_IOUT;
 		}
 		if (pmbus_check_word_register(client, page, PMBUS_READ_POUT))
 			info->func[page] |= PMBUS_HAVE_POUT;
+		if (pmbus_check_word_register(client, page,
+					      PMBUS_READ_TEMPERATURE_1))
+			info->func[page] |= PMBUS_HAVE_TEMP;
+		if (pmbus_check_word_register(client, page,
+					      PMBUS_READ_TEMPERATURE_2))
+			info->func[page] |= PMBUS_HAVE_TEMP2;
+		if (pmbus_check_word_register(client, page,
+					      PMBUS_READ_TEMPERATURE_3))
+			info->func[page] |= PMBUS_HAVE_TEMP3;
+		if (info->func[page] & (PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2
+				     | PMBUS_HAVE_TEMP3) &&
+		    pmbus_check_byte_register(client, page,
+					      PMBUS_STATUS_TEMPERATURE))
+			info->func[page] |= PMBUS_HAVE_STATUS_TEMP;
 	}
 }