summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/nct6775.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-12-04 17:03:37 +0100
committerGuenter Roeck <linux@roeck-us.net>2013-04-08 06:16:39 +0200
commit8e9285b0bb2ab48924032147baa29699c0bbee7c (patch)
tree7f0f65823f5a3d99b166d86b16ea3430b9c5721b /drivers/hwmon/nct6775.c
parenthwmon: (nct6775) Add support for weighted fan control (diff)
downloadlinux-8e9285b0bb2ab48924032147baa29699c0bbee7c.tar.xz
linux-8e9285b0bb2ab48924032147baa29699c0bbee7c.zip
hwmon: (nct6775) Detect and report additional temperature sources
Scan all temperature sources used for fan control and report if additional monitoring registers are available. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/nct6775.c')
-rw-r--r--drivers/hwmon/nct6775.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index f80ff823c28e..6d5859718113 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -3364,6 +3364,32 @@ nct6775_check_fan_inputs(const struct nct6775_sio_data *sio_data,
return 0;
}
+static void add_temp_sensors(struct nct6775_data *data, const u16 *regp,
+ int *available, int *mask)
+{
+ int i;
+ u8 src;
+
+ for (i = 0; i < data->pwm_num && *available; i++) {
+ int index;
+
+ if (!regp[i])
+ continue;
+ src = nct6775_read_value(data, regp[i]);
+ src &= 0x1f;
+ if (!src || (*mask & (1 << src)))
+ continue;
+ if (src >= data->temp_label_num ||
+ !strlen(data->temp_label[src]))
+ continue;
+
+ index = __ffs(*available);
+ nct6775_write_value(data, data->REG_TEMP_SOURCE[index], src);
+ *available &= ~(1 << index);
+ *mask |= 1 << src;
+ }
+}
+
static int nct6775_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -3614,6 +3640,13 @@ static int nct6775_probe(struct platform_device *pdev)
mask |= 1 << src;
}
+ /*
+ * Now find unmonitored temperature registers and enable monitoring
+ * if additional monitoring registers are available.
+ */
+ add_temp_sensors(data, data->REG_TEMP_SEL, &available, &mask);
+ add_temp_sensors(data, data->REG_WEIGHT_TEMP_SEL, &available, &mask);
+
mask = 0;
s = NUM_TEMP_FIXED; /* First dynamic temperature attribute */
for (i = 0; i < num_reg_temp; i++) {