diff options
| -rw-r--r-- | drivers/hwmon/lm90.c | 88 |
1 files changed, 61 insertions, 27 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 14e36c114d61..5e414ca80a78 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c | |||
| @@ -179,6 +179,23 @@ enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680, | |||
| 179 | #define LM90_HAVE_TEMP3 (1 << 6) /* 3rd temperature sensor */ | 179 | #define LM90_HAVE_TEMP3 (1 << 6) /* 3rd temperature sensor */ |
| 180 | #define LM90_HAVE_BROKEN_ALERT (1 << 7) /* Broken alert */ | 180 | #define LM90_HAVE_BROKEN_ALERT (1 << 7) /* Broken alert */ |
| 181 | 181 | ||
| 182 | /* LM90 status */ | ||
| 183 | #define LM90_STATUS_LTHRM (1 << 0) /* local THERM limit tripped */ | ||
| 184 | #define LM90_STATUS_RTHRM (1 << 1) /* remote THERM limit tripped */ | ||
| 185 | #define LM90_STATUS_ROPEN (1 << 2) /* remote is an open circuit */ | ||
| 186 | #define LM90_STATUS_RLOW (1 << 3) /* remote low temp limit tripped */ | ||
| 187 | #define LM90_STATUS_RHIGH (1 << 4) /* remote high temp limit tripped */ | ||
| 188 | #define LM90_STATUS_LLOW (1 << 5) /* local low temp limit tripped */ | ||
| 189 | #define LM90_STATUS_LHIGH (1 << 6) /* local high temp limit tripped */ | ||
| 190 | |||
| 191 | #define MAX6696_STATUS2_R2THRM (1 << 1) /* remote2 THERM limit tripped */ | ||
| 192 | #define MAX6696_STATUS2_R2OPEN (1 << 2) /* remote2 is an open circuit */ | ||
| 193 | #define MAX6696_STATUS2_R2LOW (1 << 3) /* remote2 low temp limit tripped */ | ||
| 194 | #define MAX6696_STATUS2_R2HIGH (1 << 4) /* remote2 high temp limit tripped */ | ||
| 195 | #define MAX6696_STATUS2_ROT2 (1 << 5) /* remote emergency limit tripped */ | ||
| 196 | #define MAX6696_STATUS2_R2OT2 (1 << 6) /* remote2 emergency limit tripped */ | ||
| 197 | #define MAX6696_STATUS2_LOT2 (1 << 7) /* local emergency limit tripped */ | ||
| 198 | |||
| 182 | /* | 199 | /* |
| 183 | * Driver data (common to all clients) | 200 | * Driver data (common to all clients) |
| 184 | */ | 201 | */ |
| @@ -1391,6 +1408,43 @@ static void lm90_init_client(struct i2c_client *client) | |||
| 1391 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config); | 1408 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config); |
| 1392 | } | 1409 | } |
| 1393 | 1410 | ||
| 1411 | static bool lm90_is_tripped(struct i2c_client *client, u16 *status) | ||
| 1412 | { | ||
| 1413 | struct lm90_data *data = i2c_get_clientdata(client); | ||
| 1414 | u8 st, st2 = 0; | ||
| 1415 | |||
| 1416 | lm90_read_reg(client, LM90_REG_R_STATUS, &st); | ||
| 1417 | |||
| 1418 | if (data->kind == max6696) | ||
| 1419 | lm90_read_reg(client, MAX6696_REG_R_STATUS2, &st2); | ||
| 1420 | |||
| 1421 | *status = st | (st2 << 8); | ||
| 1422 | |||
| 1423 | if ((st & 0x7f) == 0 && (st2 & 0xfe) == 0) | ||
| 1424 | return false; | ||
| 1425 | |||
| 1426 | if ((st & (LM90_STATUS_LLOW | LM90_STATUS_LHIGH | LM90_STATUS_LTHRM)) || | ||
| 1427 | (st2 & MAX6696_STATUS2_LOT2)) | ||
| 1428 | dev_warn(&client->dev, | ||
| 1429 | "temp%d out of range, please check!\n", 1); | ||
| 1430 | if ((st & (LM90_STATUS_RLOW | LM90_STATUS_RHIGH | LM90_STATUS_RTHRM)) || | ||
| 1431 | (st2 & MAX6696_STATUS2_ROT2)) | ||
| 1432 | dev_warn(&client->dev, | ||
| 1433 | "temp%d out of range, please check!\n", 2); | ||
| 1434 | if (st & LM90_STATUS_ROPEN) | ||
| 1435 | dev_warn(&client->dev, | ||
| 1436 | "temp%d diode open, please check!\n", 2); | ||
| 1437 | if (st2 & (MAX6696_STATUS2_R2LOW | MAX6696_STATUS2_R2HIGH | | ||
| 1438 | MAX6696_STATUS2_R2THRM | MAX6696_STATUS2_R2OT2)) | ||
| 1439 | dev_warn(&client->dev, | ||
| 1440 | "temp%d out of range, please check!\n", 3); | ||
| 1441 | if (st2 & MAX6696_STATUS2_R2OPEN) | ||
| 1442 | dev_warn(&client->dev, | ||
| 1443 | "temp%d diode open, please check!\n", 3); | ||
| 1444 | |||
| 1445 | return true; | ||
| 1446 | } | ||
| 1447 | |||
| 1394 | static int lm90_probe(struct i2c_client *client, | 1448 | static int lm90_probe(struct i2c_client *client, |
| 1395 | const struct i2c_device_id *id) | 1449 | const struct i2c_device_id *id) |
| 1396 | { | 1450 | { |
| @@ -1489,46 +1543,26 @@ static int lm90_remove(struct i2c_client *client) | |||
| 1489 | 1543 | ||
| 1490 | static void lm90_alert(struct i2c_client *client, unsigned int flag) | 1544 | static void lm90_alert(struct i2c_client *client, unsigned int flag) |
| 1491 | { | 1545 | { |
| 1492 | struct lm90_data *data = i2c_get_clientdata(client); | 1546 | u16 alarms; |
| 1493 | u8 config, alarms, alarms2 = 0; | ||
| 1494 | |||
| 1495 | lm90_read_reg(client, LM90_REG_R_STATUS, &alarms); | ||
| 1496 | |||
| 1497 | if (data->kind == max6696) | ||
| 1498 | lm90_read_reg(client, MAX6696_REG_R_STATUS2, &alarms2); | ||
| 1499 | |||
| 1500 | if ((alarms & 0x7f) == 0 && (alarms2 & 0xfe) == 0) { | ||
| 1501 | dev_info(&client->dev, "Everything OK\n"); | ||
| 1502 | } else { | ||
| 1503 | if ((alarms & 0x61) || (alarms2 & 0x80)) | ||
| 1504 | dev_warn(&client->dev, | ||
| 1505 | "temp%d out of range, please check!\n", 1); | ||
| 1506 | if ((alarms & 0x1a) || (alarms2 & 0x20)) | ||
| 1507 | dev_warn(&client->dev, | ||
| 1508 | "temp%d out of range, please check!\n", 2); | ||
| 1509 | if (alarms & 0x04) | ||
| 1510 | dev_warn(&client->dev, | ||
| 1511 | "temp%d diode open, please check!\n", 2); | ||
| 1512 | |||
| 1513 | if (alarms2 & 0x5a) | ||
| 1514 | dev_warn(&client->dev, | ||
| 1515 | "temp%d out of range, please check!\n", 3); | ||
| 1516 | if (alarms2 & 0x04) | ||
| 1517 | dev_warn(&client->dev, | ||
| 1518 | "temp%d diode open, please check!\n", 3); | ||
| 1519 | 1547 | ||
| 1548 | if (lm90_is_tripped(client, &alarms)) { | ||
| 1520 | /* | 1549 | /* |
| 1521 | * Disable ALERT# output, because these chips don't implement | 1550 | * Disable ALERT# output, because these chips don't implement |
| 1522 | * SMBus alert correctly; they should only hold the alert line | 1551 | * SMBus alert correctly; they should only hold the alert line |
| 1523 | * low briefly. | 1552 | * low briefly. |
| 1524 | */ | 1553 | */ |
| 1554 | struct lm90_data *data = i2c_get_clientdata(client); | ||
| 1555 | |||
| 1525 | if ((data->flags & LM90_HAVE_BROKEN_ALERT) | 1556 | if ((data->flags & LM90_HAVE_BROKEN_ALERT) |
| 1526 | && (alarms & data->alert_alarms)) { | 1557 | && (alarms & data->alert_alarms)) { |
| 1558 | u8 config; | ||
| 1527 | dev_dbg(&client->dev, "Disabling ALERT#\n"); | 1559 | dev_dbg(&client->dev, "Disabling ALERT#\n"); |
| 1528 | lm90_read_reg(client, LM90_REG_R_CONFIG1, &config); | 1560 | lm90_read_reg(client, LM90_REG_R_CONFIG1, &config); |
| 1529 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, | 1561 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, |
| 1530 | config | 0x80); | 1562 | config | 0x80); |
| 1531 | } | 1563 | } |
| 1564 | } else { | ||
| 1565 | dev_info(&client->dev, "Everything OK\n"); | ||
| 1532 | } | 1566 | } |
| 1533 | } | 1567 | } |
| 1534 | 1568 | ||
