Lines Matching +full:custom +full:- +full:temp

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (c) 2006-2008 Hans de Goede <hdegoede@redhat.com>
9 * This driver supports the sensor part of revision 3 of the custom Abit uGuru
25 #include <linux/hwmon-sysfs.h>
38 #define ABIT_UGURU3_TEMP_HIGH_ALARM_ENABLE 0x01 /* temp over warn */
41 #define ABIT_UGURU3_TEMP_HIGH_ALARM_FLAG 0x10 /* temp is over warn */
55 * cpu-speed independent, since the ISA-bus and not the CPU should be the
81 * sum of strlen +1 of: temp??_input\0, temp??_max\0, temp??_crit\0,
82 * temp??_alarm\0, temp??_alarm_enable\0, temp??_beep\0, temp??_shutdown\0,
83 * temp??_label\0
93 * temp sensors (second longest names_length).
96 (ABIT_UGURU3_MAX_NO_SENSORS - 16) * ABIT_UGURU3_TEMP_NAMES_LENGTH)
104 /* Two i/o-ports are used by uGuru */
111 * of the DATA register (0-255) on failure.
113 #define ABIT_UGURU3_SUCCESS -1
135 /* + 1 -> end of sensors indicated by a sensor with name == NULL */
177 * Settings of all 48 sensors, note in and temp sensors (the first 32
195 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
196 { "ATX +12V (4-pin)", 8, 0, 60, 1, 0 },
217 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
218 { "ATX +12V (4-pin)", 8, 0, 60, 1, 0 },
238 { 0x000E, { NULL } /* AL-8, need DMI string */, {
246 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
247 { "ATX +12V (4-pin)", 8, 0, 60, 1, 0 },
268 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
269 { "ATX +12V (4-pin)", 8, 0, 60, 1, 0 },
288 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
289 { "ATX +12V (4-pin)", 8, 0, 60, 1, 0 },
313 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
314 { "ATX +12V (4-pin)", 8, 0, 60, 1, 0 },
338 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
339 { "ATX +12V (4-pin)", 8, 0, 60, 1, 0 },
360 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
361 { "ATX +12V (4-pin)", 8, 0, 60, 1, 0 },
389 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
390 { "ATX +12V (4-pin)", 8, 0, 60, 1, 0 },
410 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
411 { "ATX +12V (4-pin)", 8, 0, 60, 1, 0 },
426 { 0x0016, { "AW9D-MAX", NULL }, {
434 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
435 { "ATX +12V (4-pin)", 8, 0, 60, 1, 0 },
464 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
465 { "ATX +12V (4-pin)", 8, 0, 60, 1, 0 },
487 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
488 { "ATX +12V (4-pin)", 8, 0, 60, 1, 0 },
514 { "ATX +12V (24-Pin)", 12, 0, 60, 1, 0 },
515 { "ATX +12V (4-pin)", 8, 0, 60, 1, 0 },
541 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
542 { "ATX +12V (8-pin)", 8, 0, 60, 1, 0 },
569 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
570 { "ATX +12V (8-pin)", 8, 0, 60, 1, 0 },
596 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
597 { "ATX +12V (8-pin)", 8, 0, 60, 1, 0 },
638 while ((x = inb_p(data->addr + ABIT_UGURU3_DATA)) & in abituguru3_wait_while_busy()
640 timeout--; in abituguru3_wait_while_busy()
659 while (!((x = inb_p(data->addr + ABIT_UGURU3_DATA)) & in abituguru3_wait_for_read()
661 timeout--; in abituguru3_wait_for_read()
686 return -EIO; in abituguru3_synchronize()
689 outb(0x20, data->addr + ABIT_UGURU3_DATA); in abituguru3_synchronize()
694 return -EIO; in abituguru3_synchronize()
697 outb(0x10, data->addr + ABIT_UGURU3_CMD); in abituguru3_synchronize()
702 return -EIO; in abituguru3_synchronize()
705 outb(0x00, data->addr + ABIT_UGURU3_CMD); in abituguru3_synchronize()
710 return -EIO; in abituguru3_synchronize()
717 return -EIO; in abituguru3_synchronize()
720 while ((x = inb(data->addr + ABIT_UGURU3_CMD)) != 0xAC) { in abituguru3_synchronize()
721 timeout--; in abituguru3_synchronize()
726 return -EIO; in abituguru3_synchronize()
746 outb(0x1A, data->addr + ABIT_UGURU3_DATA); in abituguru3_read()
752 return -EIO; in abituguru3_read()
755 outb(bank, data->addr + ABIT_UGURU3_CMD); in abituguru3_read()
761 return -EIO; in abituguru3_read()
764 outb(offset, data->addr + ABIT_UGURU3_CMD); in abituguru3_read()
770 return -EIO; in abituguru3_read()
773 outb(count, data->addr + ABIT_UGURU3_CMD); in abituguru3_read()
779 return -EIO; in abituguru3_read()
790 buf[i] = inb(data->addr + ABIT_UGURU3_CMD); in abituguru3_read()
820 * sensor_device_attribute_2->index: index into the data->sensors array
821 * sensor_device_attribute_2->nr: register offset, bitmask or NA.
834 return -EIO; in show_value()
836 sensor = &data->sensors[attr->index]; in show_value()
839 if (attr->nr) in show_value()
840 value = data->settings[sensor->port][attr->nr]; in show_value()
842 value = data->value[sensor->port]; in show_value()
845 value = (value * sensor->multiplier) / sensor->divisor + in show_value()
846 sensor->offset; in show_value()
852 if (sensor->type == ABIT_UGURU3_TEMP_SENSOR) in show_value()
866 return -EIO; in show_alarm()
868 port = data->sensors[attr->index].port; in show_alarm()
872 * given in attr->nr also check if the alarm matches the type of alarm in show_alarm()
876 if ((data->alarms[port / 8] & (0x01 << (port % 8))) && in show_alarm()
877 (!attr->nr || (data->settings[port][0] & attr->nr))) in show_alarm()
889 if (data->settings[data->sensors[attr->index].port][0] & attr->nr) in show_mask()
901 return sprintf(buf, "%s\n", data->sensors[attr->index].name); in show_label()
930 SENSOR_ATTR_2(temp%d_input, 0444, show_value, NULL, 0, 0),
931 SENSOR_ATTR_2(temp%d_max, 0444, show_value, NULL, 1, 0),
932 SENSOR_ATTR_2(temp%d_crit, 0444, show_value, NULL, 2, 0),
933 SENSOR_ATTR_2(temp%d_alarm, 0444, show_alarm, NULL, 0, 0),
934 SENSOR_ATTR_2(temp%d_beep, 0444, show_mask, NULL,
936 SENSOR_ATTR_2(temp%d_shutdown, 0444, show_mask, NULL,
938 SENSOR_ATTR_2(temp%d_alarm_enable, 0444, show_mask, NULL,
940 SENSOR_ATTR_2(temp%d_label, 0444, show_label, NULL, 0, 0)
963 int i, j, type, used, sysfs_names_free, sysfs_attr_i, res = -ENODEV; in abituguru3_probe()
968 data = devm_kzalloc(&pdev->dev, sizeof(struct abituguru3_data), in abituguru3_probe()
971 return -ENOMEM; in abituguru3_probe()
973 data->addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start; in abituguru3_probe()
974 mutex_init(&data->update_lock); in abituguru3_probe()
984 if (!abituguru3_update_device(&pdev->dev)) in abituguru3_probe()
997 data->sensors = abituguru3_motherboards[i].sensors; in abituguru3_probe()
1003 sysfs_filename = data->sysfs_names; in abituguru3_probe()
1005 for (i = 0; data->sensors[i].name; i++) { in abituguru3_probe()
1010 res = -ENAMETOOLONG; in abituguru3_probe()
1013 type = data->sensors[i].type; in abituguru3_probe()
1018 data->sysfs_attr[sysfs_attr_i] = in abituguru3_probe()
1020 data->sysfs_attr[sysfs_attr_i].dev_attr.attr.name = in abituguru3_probe()
1022 data->sysfs_attr[sysfs_attr_i].index = i; in abituguru3_probe()
1024 sysfs_names_free -= used; in abituguru3_probe()
1033 res = -ENAMETOOLONG; in abituguru3_probe()
1039 if (device_create_file(&pdev->dev, in abituguru3_probe()
1040 &data->sysfs_attr[i].dev_attr)) in abituguru3_probe()
1043 if (device_create_file(&pdev->dev, in abituguru3_probe()
1047 data->hwmon_dev = hwmon_device_register(&pdev->dev); in abituguru3_probe()
1048 if (IS_ERR(data->hwmon_dev)) { in abituguru3_probe()
1049 res = PTR_ERR(data->hwmon_dev); in abituguru3_probe()
1056 for (i = 0; data->sysfs_attr[i].dev_attr.attr.name; i++) in abituguru3_probe()
1057 device_remove_file(&pdev->dev, &data->sysfs_attr[i].dev_attr); in abituguru3_probe()
1059 device_remove_file(&pdev->dev, in abituguru3_probe()
1069 hwmon_device_unregister(data->hwmon_dev); in abituguru3_remove()
1070 for (i = 0; data->sysfs_attr[i].dev_attr.attr.name; i++) in abituguru3_remove()
1071 device_remove_file(&pdev->dev, &data->sysfs_attr[i].dev_attr); in abituguru3_remove()
1073 device_remove_file(&pdev->dev, in abituguru3_remove()
1082 mutex_lock(&data->update_lock); in abituguru3_update_device()
1083 if (!data->valid || time_after(jiffies, data->last_updated + HZ)) { in abituguru3_update_device()
1084 /* Clear data->valid while updating */ in abituguru3_update_device()
1085 data->valid = false; in abituguru3_update_device()
1090 1, data->alarms, 48/8) != (48/8)) in abituguru3_update_device()
1092 /* Read in and temp sensors (3 byte settings / sensor) */ in abituguru3_update_device()
1096 1, &data->value[i]) != 1) in abituguru3_update_device()
1102 data->settings[i], 3) != 3) in abituguru3_update_device()
1105 /* Read temp sensors (2 byte settings / sensor) */ in abituguru3_update_device()
1109 1, &data->value[32 + i]) != 1) in abituguru3_update_device()
1115 data->settings[32 + i], 2) != 2) in abituguru3_update_device()
1118 data->last_updated = jiffies; in abituguru3_update_device()
1119 data->valid = true; in abituguru3_update_device()
1122 mutex_unlock(&data->update_lock); in abituguru3_update_device()
1123 if (data->valid) in abituguru3_update_device()
1136 mutex_lock(&data->update_lock); in abituguru3_suspend()
1143 mutex_unlock(&data->update_lock); in abituguru3_resume()
1161 int i, err = (force) ? 1 : -ENODEV; in abituguru3_dmi_detect()
1180 while (sublen > 0 && board_name[sublen - 1] == ' ') in abituguru3_dmi_detect()
1181 sublen--; in abituguru3_dmi_detect()
1225 return -ENODEV; in abituguru3_detect()
1261 err = -ENOMEM; in abituguru3_init()
1266 res.end = ABIT_UGURU3_BASE + ABIT_UGURU3_REGION_LENGTH - 1; in abituguru3_init()