Lines Matching +full:chip +full:- +full:temperature +full:- +full:threshold +full:- +full:celsius

1 // SPDX-License-Identifier: GPL-2.0
3 * Hwmon client for disk and solid state drives with temperature sensors
7 * Hwmon client for S.M.A.R.T. hard disk drives with temperature sensors.
10 * hwmon: Driver for SCSI/ATA temperature sensors
13 * This drive supports reporting the temperature of SATA drives. It can be
14 * easily extended to report the temperature of SCSI drives.
16 * The primary means to read drive temperatures and temperature limits
18 * ATA8-ACS.
19 * It can be used to read the current drive temperature, temperature limits,
21 * feature set is documented in "AT Attachment 8 - ATA/ATAPI Command Set
22 * (ATA8-ACS)".
30 * http://www.cropel.com/library/smart-attribute-list.aspx).
32 * 190 Temperature Temperature, monitored by a sensor somewhere inside
34 * temperature (hexadecimal) in its rightmost two digits.
36 * 194 Temperature Temperature, monitored by a sensor somewhere inside
38 * temperature (hexadecimal) in its rightmost two digits.
40 * 231 Temperature Temperature, monitored by a sensor somewhere inside
42 * temperature (hexadecimal) in its rightmost two digits.
46 * 190 Temperature Value is equal to (100-temp. °C), allowing manufacturer
47 * Difference or to set a minimum threshold which corresponds to a
48 * Airflow maximum temperature. This also follows the convention of
49 * Temperature 100 being a best-case value and lower values being
51 * report raw Temperature (identical to 0xC2) or
52 * Temperature minus 50 here.
53 * 194 Temperature or Indicates the device temperature, if the appropriate
54 * Temperature sensor is fitted. Lowest byte of the raw value contains
55 * Celsius the exact temperature value (Celsius degrees).
58 * Temperature A normalized value of 100 represents a new drive, with
59 * a threshold value at 10 indicating a need for
61 * operating in read-only mode to allow data recovery.
62 * Previously (pre-2010) occasionally used for Drive
63 * Temperature (more typically reported at 0xC2).
65 * Common denominator is that the first raw byte reports the temperature
67 * temperature in the second raw byte.
70 * - SAMSUNG SV0412H and SAMSUNG SV1204H) report the temperature in 10th
72 * - A few Maxtor drives report an unknown or bad value in attribute 194.
73 * - Certain Apple SSD drives report an unknown value in attribute 190.
77 * Also, the second raw byte (possibly reporting the fractional temperature)
80 * Many drives also report temperature limits in additional SMART data raw
86 * in attribute 231, but do not support temperature sensors. For this reason,
91 * temperature and, if available, temperature limits.
92 * - Otherwise, if SMART attribute 194 is supported, it is used to read
93 * the temperature.
94 * - Otherwise, if SMART attribute 190 is supported, it is used to read
95 * the temperature.
172 scsi_cmd[1] = (5 << 1); /* PIO Data-out */ in drivetemp_scsi_command()
180 scsi_cmd[1] = (4 << 1); /* PIO Data-in */ in drivetemp_scsi_command()
195 return scsi_execute_cmd(st->sdev, scsi_cmd, op, st->smartdata, in drivetemp_scsi_command()
209 u8 *buf = st->smartdata; in drivetemp_get_smarttemp()
225 dev_dbg(&st->sdev->sdev_gendev, in drivetemp_get_smarttemp()
227 return -EIO; in drivetemp_get_smarttemp()
253 return -ENXIO; in drivetemp_get_smarttemp()
258 u8 *buf = st->smartdata; in drivetemp_get_scttemp()
267 return -ENODATA; in drivetemp_get_scttemp()
272 return -ENODATA; in drivetemp_get_scttemp()
277 return -ENODATA; in drivetemp_get_scttemp()
281 err = -EINVAL; in drivetemp_get_scttemp()
290 * freeze until power-cycled under heavy write loads when their temperature is
297 * The models from this array are prefix-matched.
304 struct scsi_device *sdev = st->sdev; in drivetemp_sct_avoid()
307 if (!sdev->model) in drivetemp_sct_avoid()
313 * This field is space-filled, but is NOT NULL-terminated. in drivetemp_sct_avoid()
316 if (!strncmp(sdev->model, sct_avoid_models[ctr], in drivetemp_sct_avoid()
325 struct scsi_device *sdev = st->sdev; in drivetemp_identify_sata()
326 u8 *buf = st->smartdata; in drivetemp_identify_sata()
338 /* SCSI-ATA Translation present? */ in drivetemp_identify_sata()
340 vpd = rcu_dereference(sdev->vpd_pg89); in drivetemp_identify_sata()
346 if (!vpd || vpd->len < 572 || vpd->data[56] != ATA_CMD_ID_ATA || in drivetemp_identify_sata()
347 vpd->data[36] != 0x34) { in drivetemp_identify_sata()
349 return -ENODEV; in drivetemp_identify_sata()
351 ata_id = (u16 *)&vpd->data[60]; in drivetemp_identify_sata()
363 return -ENODEV; in drivetemp_identify_sata()
366 dev_notice(&sdev->sdev_gendev, in drivetemp_identify_sata()
367 "will avoid using SCT for temperature monitoring\n"); in drivetemp_identify_sata()
387 st->have_temp_lowest = temp_is_valid(buf[SCT_STATUS_TEMP_LOWEST]); in drivetemp_identify_sata()
388 st->have_temp_highest = temp_is_valid(buf[SCT_STATUS_TEMP_HIGHEST]); in drivetemp_identify_sata()
393 /* Request and read temperature history table */ in drivetemp_identify_sata()
394 memset(buf, '\0', sizeof(st->smartdata)); in drivetemp_identify_sata()
397 buf[4] = 2; /* temperature history table */ in drivetemp_identify_sata()
408 * Temperature limits per AT Attachment 8 - in drivetemp_identify_sata()
409 * ATA/ATAPI Command Set (ATA8-ACS) in drivetemp_identify_sata()
411 st->have_temp_max = temp_is_valid(buf[6]); in drivetemp_identify_sata()
412 st->have_temp_crit = temp_is_valid(buf[7]); in drivetemp_identify_sata()
413 st->have_temp_min = temp_is_valid(buf[8]); in drivetemp_identify_sata()
414 st->have_temp_lcrit = temp_is_valid(buf[9]); in drivetemp_identify_sata()
416 st->temp_max = temp_from_sct(buf[6]); in drivetemp_identify_sata()
417 st->temp_crit = temp_from_sct(buf[7]); in drivetemp_identify_sata()
418 st->temp_min = temp_from_sct(buf[8]); in drivetemp_identify_sata()
419 st->temp_lcrit = temp_from_sct(buf[9]); in drivetemp_identify_sata()
423 st->get_temp = drivetemp_get_scttemp; in drivetemp_identify_sata()
428 return -ENODEV; in drivetemp_identify_sata()
429 st->get_temp = drivetemp_get_smarttemp; in drivetemp_identify_sata()
435 struct scsi_device *sdev = st->sdev; in drivetemp_identify()
438 if (!sdev->inquiry || sdev->inquiry_len < 16) in drivetemp_identify()
439 return -ENODEV; in drivetemp_identify()
442 if (sdev->type != TYPE_DISK && sdev->type != TYPE_ZBC) in drivetemp_identify()
443 return -ENODEV; in drivetemp_identify()
455 return -EINVAL; in drivetemp_read()
461 mutex_lock(&st->lock); in drivetemp_read()
462 err = st->get_temp(st, attr, val); in drivetemp_read()
463 mutex_unlock(&st->lock); in drivetemp_read()
466 *val = st->temp_lcrit; in drivetemp_read()
469 *val = st->temp_min; in drivetemp_read()
472 *val = st->temp_max; in drivetemp_read()
475 *val = st->temp_crit; in drivetemp_read()
478 err = -EINVAL; in drivetemp_read()
496 if (st->have_temp_lowest) in drivetemp_is_visible()
500 if (st->have_temp_highest) in drivetemp_is_visible()
504 if (st->have_temp_min) in drivetemp_is_visible()
508 if (st->have_temp_max) in drivetemp_is_visible()
512 if (st->have_temp_lcrit) in drivetemp_is_visible()
516 if (st->have_temp_crit) in drivetemp_is_visible()
530 HWMON_CHANNEL_INFO(chip,
550 * The device argument points to sdev->sdev_dev. Its parent is
551 * sdev->sdev_gendev, which we can use to get the scsi_device pointer.
555 struct scsi_device *sdev = to_scsi_device(dev->parent); in drivetemp_add()
561 return -ENOMEM; in drivetemp_add()
563 st->sdev = sdev; in drivetemp_add()
564 st->dev = dev; in drivetemp_add()
565 mutex_init(&st->lock); in drivetemp_add()
568 err = -ENODEV; in drivetemp_add()
572 st->hwdev = hwmon_device_register_with_info(dev->parent, "drivetemp", in drivetemp_add()
575 if (IS_ERR(st->hwdev)) { in drivetemp_add()
576 err = PTR_ERR(st->hwdev); in drivetemp_add()
580 list_add(&st->list, &drivetemp_devlist); in drivetemp_add()
593 if (st->dev == dev) { in drivetemp_remove()
594 list_del(&st->list); in drivetemp_remove()
595 hwmon_device_unregister(st->hwdev); in drivetemp_remove()
620 MODULE_AUTHOR("Guenter Roeck <linus@roeck-us.net>");
621 MODULE_DESCRIPTION("Hard drive temperature monitor");