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_req(st->sdev, scsi_cmd, data_dir, in drivetemp_scsi_command()
196 st->smartdata, ATA_SECT_SIZE, NULL, HZ, 5, in drivetemp_scsi_command()
210 u8 *buf = st->smartdata; in drivetemp_get_smarttemp()
226 dev_dbg(&st->sdev->sdev_gendev, in drivetemp_get_smarttemp()
228 return -EIO; in drivetemp_get_smarttemp()
254 return -ENXIO; in drivetemp_get_smarttemp()
259 u8 *buf = st->smartdata; in drivetemp_get_scttemp()
268 return -ENODATA; in drivetemp_get_scttemp()
273 return -ENODATA; in drivetemp_get_scttemp()
278 return -ENODATA; in drivetemp_get_scttemp()
282 err = -EINVAL; in drivetemp_get_scttemp()
291 * freeze until power-cycled under heavy write loads when their temperature is
298 * The models from this array are prefix-matched.
305 struct scsi_device *sdev = st->sdev; in drivetemp_sct_avoid()
308 if (!sdev->model) in drivetemp_sct_avoid()
314 * This field is space-filled, but is NOT NULL-terminated. in drivetemp_sct_avoid()
317 if (!strncmp(sdev->model, sct_avoid_models[ctr], in drivetemp_sct_avoid()
326 struct scsi_device *sdev = st->sdev; in drivetemp_identify_sata()
327 u8 *buf = st->smartdata; in drivetemp_identify_sata()
339 /* SCSI-ATA Translation present? */ in drivetemp_identify_sata()
341 vpd = rcu_dereference(sdev->vpd_pg89); in drivetemp_identify_sata()
347 if (!vpd || vpd->len < 572 || vpd->data[56] != ATA_CMD_ID_ATA || in drivetemp_identify_sata()
348 vpd->data[36] != 0x34) { in drivetemp_identify_sata()
350 return -ENODEV; in drivetemp_identify_sata()
352 ata_id = (u16 *)&vpd->data[60]; in drivetemp_identify_sata()
364 return -ENODEV; in drivetemp_identify_sata()
367 dev_notice(&sdev->sdev_gendev, in drivetemp_identify_sata()
368 "will avoid using SCT for temperature monitoring\n"); in drivetemp_identify_sata()
388 st->have_temp_lowest = temp_is_valid(buf[SCT_STATUS_TEMP_LOWEST]); in drivetemp_identify_sata()
389 st->have_temp_highest = temp_is_valid(buf[SCT_STATUS_TEMP_HIGHEST]); in drivetemp_identify_sata()
394 /* Request and read temperature history table */ in drivetemp_identify_sata()
395 memset(buf, '\0', sizeof(st->smartdata)); in drivetemp_identify_sata()
398 buf[4] = 2; /* temperature history table */ in drivetemp_identify_sata()
409 * Temperature limits per AT Attachment 8 - in drivetemp_identify_sata()
410 * ATA/ATAPI Command Set (ATA8-ACS) in drivetemp_identify_sata()
412 st->have_temp_max = temp_is_valid(buf[6]); in drivetemp_identify_sata()
413 st->have_temp_crit = temp_is_valid(buf[7]); in drivetemp_identify_sata()
414 st->have_temp_min = temp_is_valid(buf[8]); in drivetemp_identify_sata()
415 st->have_temp_lcrit = temp_is_valid(buf[9]); in drivetemp_identify_sata()
417 st->temp_max = temp_from_sct(buf[6]); in drivetemp_identify_sata()
418 st->temp_crit = temp_from_sct(buf[7]); in drivetemp_identify_sata()
419 st->temp_min = temp_from_sct(buf[8]); in drivetemp_identify_sata()
420 st->temp_lcrit = temp_from_sct(buf[9]); in drivetemp_identify_sata()
424 st->get_temp = drivetemp_get_scttemp; in drivetemp_identify_sata()
429 return -ENODEV; in drivetemp_identify_sata()
430 st->get_temp = drivetemp_get_smarttemp; in drivetemp_identify_sata()
436 struct scsi_device *sdev = st->sdev; in drivetemp_identify()
439 if (!sdev->inquiry || sdev->inquiry_len < 16) in drivetemp_identify()
440 return -ENODEV; in drivetemp_identify()
443 if (sdev->type != TYPE_DISK && sdev->type != TYPE_ZBC) in drivetemp_identify()
444 return -ENODEV; in drivetemp_identify()
456 return -EINVAL; in drivetemp_read()
462 mutex_lock(&st->lock); in drivetemp_read()
463 err = st->get_temp(st, attr, val); in drivetemp_read()
464 mutex_unlock(&st->lock); in drivetemp_read()
467 *val = st->temp_lcrit; in drivetemp_read()
470 *val = st->temp_min; in drivetemp_read()
473 *val = st->temp_max; in drivetemp_read()
476 *val = st->temp_crit; in drivetemp_read()
479 err = -EINVAL; in drivetemp_read()
497 if (st->have_temp_lowest) in drivetemp_is_visible()
501 if (st->have_temp_highest) in drivetemp_is_visible()
505 if (st->have_temp_min) in drivetemp_is_visible()
509 if (st->have_temp_max) in drivetemp_is_visible()
513 if (st->have_temp_lcrit) in drivetemp_is_visible()
517 if (st->have_temp_crit) in drivetemp_is_visible()
531 HWMON_CHANNEL_INFO(chip,
551 * The device argument points to sdev->sdev_dev. Its parent is
552 * sdev->sdev_gendev, which we can use to get the scsi_device pointer.
556 struct scsi_device *sdev = to_scsi_device(dev->parent); in drivetemp_add()
562 return -ENOMEM; in drivetemp_add()
564 st->sdev = sdev; in drivetemp_add()
565 st->dev = dev; in drivetemp_add()
566 mutex_init(&st->lock); in drivetemp_add()
569 err = -ENODEV; in drivetemp_add()
573 st->hwdev = hwmon_device_register_with_info(dev->parent, "drivetemp", in drivetemp_add()
576 if (IS_ERR(st->hwdev)) { in drivetemp_add()
577 err = PTR_ERR(st->hwdev); in drivetemp_add()
581 list_add(&st->list, &drivetemp_devlist); in drivetemp_add()
594 if (st->dev == dev) { in drivetemp_remove()
595 list_del(&st->list); in drivetemp_remove()
596 hwmon_device_unregister(st->hwdev); in drivetemp_remove()
621 MODULE_AUTHOR("Guenter Roeck <linus@roeck-us.net>");
622 MODULE_DESCRIPTION("Hard drive temperature monitor");