diff options
author | Jim Cromie <jim.cromie@gmail.com> | 2008-10-18 23:27:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-20 11:52:35 -0400 |
commit | 28f74e71775b1ae0ebf7fe87f7a7f39ecb77a2b8 (patch) | |
tree | 906ab2c98ed3d9034a170a2fcf9948097a084eaa /drivers/hwmon | |
parent | 4d235ba6c2e9c717da8facafd1b990dcb687d1e0 (diff) |
hwmon/pc87360 separate alarm files: define some constants
Bring hwmon/pc87360 into agreement with
Documentation/hwmon/sysfs-interface.
Patchset adds separate limit alarms for voltages and temps, it also adds
temp[123]_fault files. On my Soekris, temps 1,2 are unused/unconnected,
so temp[123]_fault = 1,1,0 respectively. This agrees with
/usr/bin/sensors, which has always shown them as OPEN. Temps 4,5,6 are
thermistor based, and dont have a fault bit in their status register.
This patch:
2 different kinds of constants added:
- CHAN_ALM_* constants for (later) vin, temp alarm callbacks.
- CHAN_* conversion constants, used in _init_device, partly for RW1C bits
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/pc87360.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index 9b462bb13fa3..1043b116bded 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c | |||
@@ -489,6 +489,11 @@ static struct sensor_device_attribute in_max[] = { | |||
489 | SENSOR_ATTR(in10_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 10), | 489 | SENSOR_ATTR(in10_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 10), |
490 | }; | 490 | }; |
491 | 491 | ||
492 | /* (temp & vin) channel status register alarm bits (pdf sec.11.5.12) */ | ||
493 | #define CHAN_ALM_MIN 0x02 /* min limit crossed */ | ||
494 | #define CHAN_ALM_MAX 0x04 /* max limit exceeded */ | ||
495 | #define TEMP_ALM_CRIT 0x08 /* temp crit exceeded (temp only) */ | ||
496 | |||
492 | #define VIN_UNIT_ATTRS(X) \ | 497 | #define VIN_UNIT_ATTRS(X) \ |
493 | &in_input[X].dev_attr.attr, \ | 498 | &in_input[X].dev_attr.attr, \ |
494 | &in_status[X].dev_attr.attr, \ | 499 | &in_status[X].dev_attr.attr, \ |
@@ -1131,6 +1136,12 @@ static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank, | |||
1131 | mutex_unlock(&(data->lock)); | 1136 | mutex_unlock(&(data->lock)); |
1132 | } | 1137 | } |
1133 | 1138 | ||
1139 | /* (temp & vin) channel conversion status register flags (pdf sec.11.5.12) */ | ||
1140 | #define CHAN_CNVRTD 0x80 /* new data ready */ | ||
1141 | #define CHAN_ENA 0x01 /* enabled channel (temp or vin) */ | ||
1142 | #define CHAN_ALM_ENA 0x10 /* propagate to alarms-reg ?? (chk val!) */ | ||
1143 | #define CHAN_READY (CHAN_ENA|CHAN_CNVRTD) /* sample ready mask */ | ||
1144 | |||
1134 | static void pc87360_init_device(struct platform_device *pdev, | 1145 | static void pc87360_init_device(struct platform_device *pdev, |
1135 | int use_thermistors) | 1146 | int use_thermistors) |
1136 | { | 1147 | { |
@@ -1156,7 +1167,7 @@ static void pc87360_init_device(struct platform_device *pdev, | |||
1156 | /* Forcibly enable voltage channel */ | 1167 | /* Forcibly enable voltage channel */ |
1157 | reg = pc87360_read_value(data, LD_IN, i, | 1168 | reg = pc87360_read_value(data, LD_IN, i, |
1158 | PC87365_REG_IN_STATUS); | 1169 | PC87365_REG_IN_STATUS); |
1159 | if (!(reg & 0x01)) { | 1170 | if (!(reg & CHAN_ENA)) { |
1160 | dev_dbg(&pdev->dev, "Forcibly " | 1171 | dev_dbg(&pdev->dev, "Forcibly " |
1161 | "enabling in%d\n", i); | 1172 | "enabling in%d\n", i); |
1162 | pc87360_write_value(data, LD_IN, i, | 1173 | pc87360_write_value(data, LD_IN, i, |
@@ -1171,7 +1182,7 @@ static void pc87360_init_device(struct platform_device *pdev, | |||
1171 | for (i = 11; i < data->innr; i++) { | 1182 | for (i = 11; i < data->innr; i++) { |
1172 | reg = pc87360_read_value(data, LD_IN, i, | 1183 | reg = pc87360_read_value(data, LD_IN, i, |
1173 | PC87365_REG_TEMP_STATUS); | 1184 | PC87365_REG_TEMP_STATUS); |
1174 | use_thermistors = use_thermistors || (reg & 0x01); | 1185 | use_thermistors = use_thermistors || (reg & CHAN_ENA); |
1175 | } | 1186 | } |
1176 | 1187 | ||
1177 | i = use_thermistors ? 2 : 0; | 1188 | i = use_thermistors ? 2 : 0; |
@@ -1180,7 +1191,7 @@ static void pc87360_init_device(struct platform_device *pdev, | |||
1180 | /* Forcibly enable temperature channel */ | 1191 | /* Forcibly enable temperature channel */ |
1181 | reg = pc87360_read_value(data, LD_TEMP, i, | 1192 | reg = pc87360_read_value(data, LD_TEMP, i, |
1182 | PC87365_REG_TEMP_STATUS); | 1193 | PC87365_REG_TEMP_STATUS); |
1183 | if (!(reg & 0x01)) { | 1194 | if (!(reg & CHAN_ENA)) { |
1184 | dev_dbg(&pdev->dev, "Forcibly " | 1195 | dev_dbg(&pdev->dev, "Forcibly " |
1185 | "enabling temp%d\n", i+1); | 1196 | "enabling temp%d\n", i+1); |
1186 | pc87360_write_value(data, LD_TEMP, i, | 1197 | pc87360_write_value(data, LD_TEMP, i, |
@@ -1197,7 +1208,7 @@ static void pc87360_init_device(struct platform_device *pdev, | |||
1197 | diodes */ | 1208 | diodes */ |
1198 | reg = pc87360_read_value(data, LD_TEMP, | 1209 | reg = pc87360_read_value(data, LD_TEMP, |
1199 | (i-11)/2, PC87365_REG_TEMP_STATUS); | 1210 | (i-11)/2, PC87365_REG_TEMP_STATUS); |
1200 | if (reg & 0x01) { | 1211 | if (reg & CHAN_ENA) { |
1201 | dev_dbg(&pdev->dev, "Skipping " | 1212 | dev_dbg(&pdev->dev, "Skipping " |
1202 | "temp%d, pin already in use " | 1213 | "temp%d, pin already in use " |
1203 | "by temp%d\n", i-7, (i-11)/2); | 1214 | "by temp%d\n", i-7, (i-11)/2); |
@@ -1207,7 +1218,7 @@ static void pc87360_init_device(struct platform_device *pdev, | |||
1207 | /* Forcibly enable thermistor channel */ | 1218 | /* Forcibly enable thermistor channel */ |
1208 | reg = pc87360_read_value(data, LD_IN, i, | 1219 | reg = pc87360_read_value(data, LD_IN, i, |
1209 | PC87365_REG_IN_STATUS); | 1220 | PC87365_REG_IN_STATUS); |
1210 | if (!(reg & 0x01)) { | 1221 | if (!(reg & CHAN_ENA)) { |
1211 | dev_dbg(&pdev->dev, "Forcibly " | 1222 | dev_dbg(&pdev->dev, "Forcibly " |
1212 | "enabling temp%d\n", i-7); | 1223 | "enabling temp%d\n", i-7); |
1213 | pc87360_write_value(data, LD_IN, i, | 1224 | pc87360_write_value(data, LD_IN, i, |
@@ -1221,7 +1232,7 @@ static void pc87360_init_device(struct platform_device *pdev, | |||
1221 | if (data->innr) { | 1232 | if (data->innr) { |
1222 | reg = pc87360_read_value(data, LD_IN, NO_BANK, | 1233 | reg = pc87360_read_value(data, LD_IN, NO_BANK, |
1223 | PC87365_REG_IN_CONFIG); | 1234 | PC87365_REG_IN_CONFIG); |
1224 | if (reg & 0x01) { | 1235 | if (reg & CHAN_ENA) { |
1225 | dev_dbg(&pdev->dev, "Forcibly " | 1236 | dev_dbg(&pdev->dev, "Forcibly " |
1226 | "enabling monitoring (VLM)\n"); | 1237 | "enabling monitoring (VLM)\n"); |
1227 | pc87360_write_value(data, LD_IN, NO_BANK, | 1238 | pc87360_write_value(data, LD_IN, NO_BANK, |
@@ -1233,7 +1244,7 @@ static void pc87360_init_device(struct platform_device *pdev, | |||
1233 | if (data->tempnr) { | 1244 | if (data->tempnr) { |
1234 | reg = pc87360_read_value(data, LD_TEMP, NO_BANK, | 1245 | reg = pc87360_read_value(data, LD_TEMP, NO_BANK, |
1235 | PC87365_REG_TEMP_CONFIG); | 1246 | PC87365_REG_TEMP_CONFIG); |
1236 | if (reg & 0x01) { | 1247 | if (reg & CHAN_ENA) { |
1237 | dev_dbg(&pdev->dev, "Forcibly enabling " | 1248 | dev_dbg(&pdev->dev, "Forcibly enabling " |
1238 | "monitoring (TMS)\n"); | 1249 | "monitoring (TMS)\n"); |
1239 | pc87360_write_value(data, LD_TEMP, NO_BANK, | 1250 | pc87360_write_value(data, LD_TEMP, NO_BANK, |
@@ -1336,11 +1347,11 @@ static struct pc87360_data *pc87360_update_device(struct device *dev) | |||
1336 | pc87360_write_value(data, LD_IN, i, | 1347 | pc87360_write_value(data, LD_IN, i, |
1337 | PC87365_REG_IN_STATUS, | 1348 | PC87365_REG_IN_STATUS, |
1338 | data->in_status[i]); | 1349 | data->in_status[i]); |
1339 | if ((data->in_status[i] & 0x81) == 0x81) { | 1350 | if ((data->in_status[i] & CHAN_READY) == CHAN_READY) { |
1340 | data->in[i] = pc87360_read_value(data, LD_IN, | 1351 | data->in[i] = pc87360_read_value(data, LD_IN, |
1341 | i, PC87365_REG_IN); | 1352 | i, PC87365_REG_IN); |
1342 | } | 1353 | } |
1343 | if (data->in_status[i] & 0x01) { | 1354 | if (data->in_status[i] & CHAN_ENA) { |
1344 | data->in_min[i] = pc87360_read_value(data, | 1355 | data->in_min[i] = pc87360_read_value(data, |
1345 | LD_IN, i, | 1356 | LD_IN, i, |
1346 | PC87365_REG_IN_MIN); | 1357 | PC87365_REG_IN_MIN); |
@@ -1373,12 +1384,12 @@ static struct pc87360_data *pc87360_update_device(struct device *dev) | |||
1373 | pc87360_write_value(data, LD_TEMP, i, | 1384 | pc87360_write_value(data, LD_TEMP, i, |
1374 | PC87365_REG_TEMP_STATUS, | 1385 | PC87365_REG_TEMP_STATUS, |
1375 | data->temp_status[i]); | 1386 | data->temp_status[i]); |
1376 | if ((data->temp_status[i] & 0x81) == 0x81) { | 1387 | if ((data->temp_status[i] & CHAN_READY) == CHAN_READY) { |
1377 | data->temp[i] = pc87360_read_value(data, | 1388 | data->temp[i] = pc87360_read_value(data, |
1378 | LD_TEMP, i, | 1389 | LD_TEMP, i, |
1379 | PC87365_REG_TEMP); | 1390 | PC87365_REG_TEMP); |
1380 | } | 1391 | } |
1381 | if (data->temp_status[i] & 0x01) { | 1392 | if (data->temp_status[i] & CHAN_ENA) { |
1382 | data->temp_min[i] = pc87360_read_value(data, | 1393 | data->temp_min[i] = pc87360_read_value(data, |
1383 | LD_TEMP, i, | 1394 | LD_TEMP, i, |
1384 | PC87365_REG_TEMP_MIN); | 1395 | PC87365_REG_TEMP_MIN); |