Lines Matching +full:custom +full:- +full:temp
1 // SPDX-License-Identifier: GPL-2.0+
14 #include <linux/hwmon-sysfs.h>
36 #define CUSTOM_CURVE_POINTS 40 /* For temps from 20C to 59C (critical temp) */
75 "Coolant temp",
134 switch (priv->kind) { in kraken3_is_visible()
154 switch (priv->kind) { in kraken3_is_visible()
189 mutex_lock(&priv->buffer_lock); in kraken3_write_expanded()
191 memcpy_and_pad(priv->buffer, MAX_REPORT_LENGTH, cmd, cmd_length, 0x00); in kraken3_write_expanded()
192 ret = hid_hw_output_report(priv->hdev, priv->buffer, MAX_REPORT_LENGTH); in kraken3_write_expanded()
194 mutex_unlock(&priv->buffer_lock); in kraken3_write_expanded()
208 return -EINVAL; in kraken3_pwm_to_percent()
223 if (completion_done(&priv->status_report_processed)) in kraken3_read_x53()
226 * been received for some time in kraken3_raw_event(). On X-series sensor data in kraken3_read_x53()
229 return -ENODATA; in kraken3_read_x53()
238 ret = wait_for_completion_interruptible_timeout(&priv->status_report_processed, in kraken3_read_x53()
241 return -ETIMEDOUT; in kraken3_read_x53()
252 int ret = mutex_lock_interruptible(&priv->z53_status_request_lock); in kraken3_read_z53()
257 if (!time_after(jiffies, priv->updated + msecs_to_jiffies(STATUS_VALIDITY))) { in kraken3_read_z53()
266 spin_lock_bh(&priv->status_completion_lock); in kraken3_read_z53()
267 reinit_completion(&priv->status_report_processed); in kraken3_read_z53()
268 spin_unlock_bh(&priv->status_completion_lock); in kraken3_read_z53()
276 ret = wait_for_completion_interruptible_timeout(&priv->status_report_processed, in kraken3_read_z53()
279 ret = -ETIMEDOUT; in kraken3_read_z53()
282 mutex_unlock(&priv->z53_status_request_lock); in kraken3_read_z53()
295 if (time_after(jiffies, priv->updated + msecs_to_jiffies(STATUS_VALIDITY))) { in kraken3_read()
296 if (priv->kind == X53) in kraken3_read()
304 if (priv->is_device_faulty) in kraken3_read()
305 return -ENODATA; in kraken3_read()
310 *val = priv->temp_input[channel]; in kraken3_read()
313 *val = priv->fan_input[channel]; in kraken3_read()
318 *val = priv->channel_info[channel].mode; in kraken3_read()
321 *val = priv->channel_info[channel].reported_duty; in kraken3_read()
324 return -EOPNOTSUPP; in kraken3_read()
328 return -EOPNOTSUPP; in kraken3_read()
345 return -EOPNOTSUPP; in kraken3_read_string()
351 /* Writes custom curve to device */
363 if (priv->kind == KRAKEN2023) { in kraken3_write_curve()
394 /* Fill the custom curve with the fixed value we're setting */ in kraken3_write_fixed_duty()
395 for (i = 0; i < CUSTOM_CURVE_POINTS - 1; i++) in kraken3_write_fixed_duty()
398 /* Force duty to 100% at critical temp */ in kraken3_write_fixed_duty()
399 fixed_curve_points[CUSTOM_CURVE_POINTS - 1] = 100; in kraken3_write_fixed_duty()
417 priv->channel_info[channel].fixed_duty = val; in kraken3_write()
419 if (priv->channel_info[channel].mode == manual) { in kraken3_write()
428 priv->channel_info[channel].reported_duty = val; in kraken3_write()
433 return -EINVAL; in kraken3_write()
443 priv->channel_info[channel].mode = off; in kraken3_write()
449 priv->channel_info[channel].fixed_duty, in kraken3_write()
454 priv->channel_info[channel].mode = manual; in kraken3_write()
460 priv->channel_info[channel].pwm_points, in kraken3_write()
465 priv->channel_info[channel].mode = curve; in kraken3_write()
472 return -EOPNOTSUPP; in kraken3_write()
476 return -EOPNOTSUPP; in kraken3_write()
491 return -EINVAL; in kraken3_fan_curve_pwm_store()
493 val = kraken3_pwm_to_percent(val, dev_attr->nr); in kraken3_fan_curve_pwm_store()
497 priv->channel_info[dev_attr->nr].pwm_points[dev_attr->index] = val; in kraken3_fan_curve_pwm_store()
499 if (priv->channel_info[dev_attr->nr].mode == curve) { in kraken3_fan_curve_pwm_store()
503 priv->channel_info[dev_attr->nr].pwm_points, dev_attr->nr); in kraken3_fan_curve_pwm_store()
518 if (index >= CUSTOM_CURVE_POINTS && priv->kind == X53) in kraken3_curve_props_are_visible()
521 return attr->mode; in kraken3_curve_props_are_visible()
524 /* Custom pump curve from 20C to 59C (critical temp) */
566 /* Custom fan curve from 20C to 59C (critical temp) */
712 HWMON_CHANNEL_INFO(temp,
738 if (report->id == FIRMWARE_REPORT_ID) { in kraken3_raw_event()
741 priv->firmware_version[i] = data[FIRMWARE_VERSION_OFFSET + i]; in kraken3_raw_event()
743 if (!completion_done(&priv->fw_version_processed)) in kraken3_raw_event()
744 complete_all(&priv->fw_version_processed); in kraken3_raw_event()
749 if (report->id != STATUS_REPORT_ID) in kraken3_raw_event()
757 * Mark first X-series device report as received, in kraken3_raw_event()
758 * as well as all for Z-series, if faulty. in kraken3_raw_event()
760 spin_lock(&priv->status_completion_lock); in kraken3_raw_event()
761 if (priv->kind != X53 || !completion_done(&priv->status_report_processed)) { in kraken3_raw_event()
762 priv->is_device_faulty = true; in kraken3_raw_event()
763 complete_all(&priv->status_report_processed); in kraken3_raw_event()
765 spin_unlock(&priv->status_completion_lock); in kraken3_raw_event()
771 priv->is_device_faulty = false; in kraken3_raw_event()
774 priv->temp_input[0] = in kraken3_raw_event()
777 priv->fan_input[0] = get_unaligned_le16(data + PUMP_SPEED_OFFSET); in kraken3_raw_event()
778 priv->channel_info[0].reported_duty = kraken3_percent_to_pwm(data[PUMP_DUTY_OFFSET]); in kraken3_raw_event()
780 spin_lock(&priv->status_completion_lock); in kraken3_raw_event()
781 if (priv->kind == X53 && !completion_done(&priv->status_report_processed)) { in kraken3_raw_event()
782 /* Mark first X-series device report as received */ in kraken3_raw_event()
783 complete_all(&priv->status_report_processed); in kraken3_raw_event()
784 } else if (priv->kind == Z53 || priv->kind == KRAKEN2023) { in kraken3_raw_event()
786 priv->fan_input[1] = get_unaligned_le16(data + Z53_FAN_SPEED_OFFSET); in kraken3_raw_event()
787 priv->channel_info[1].reported_duty = in kraken3_raw_event()
790 if (!completion_done(&priv->status_report_processed)) in kraken3_raw_event()
791 complete_all(&priv->status_report_processed); in kraken3_raw_event()
793 spin_unlock(&priv->status_completion_lock); in kraken3_raw_event()
795 priv->updated = jiffies; in kraken3_raw_event()
827 ret = wait_for_completion_interruptible_timeout(&priv->fw_version_processed, in kraken3_get_fw_ver()
830 return -ETIMEDOUT; in kraken3_get_fw_ver()
850 struct kraken3_data *priv = seqf->private; in firmware_version_show()
852 seq_printf(seqf, "%u.%u.%u\n", priv->firmware_version[0], priv->firmware_version[1], in firmware_version_show()
853 priv->firmware_version[2]); in firmware_version_show()
863 if (!priv->firmware_version[0]) in kraken3_debugfs_init()
866 scnprintf(name, sizeof(name), "%s_%s-%s", DRIVER_NAME, device_name, in kraken3_debugfs_init()
867 dev_name(&priv->hdev->dev)); in kraken3_debugfs_init()
869 priv->debugfs = debugfs_create_dir(name, NULL); in kraken3_debugfs_init()
870 debugfs_create_file("firmware_version", 0444, priv->debugfs, priv, &firmware_version_fops); in kraken3_debugfs_init()
879 priv = devm_kzalloc(&hdev->dev, sizeof(*priv), GFP_KERNEL); in kraken3_probe()
881 return -ENOMEM; in kraken3_probe()
883 priv->hdev = hdev; in kraken3_probe()
887 * Initialize ->updated to STATUS_VALIDITY seconds in the past, making in kraken3_probe()
891 priv->updated = jiffies - msecs_to_jiffies(STATUS_VALIDITY); in kraken3_probe()
899 /* Enable hidraw so existing user-space tools can continue to work */ in kraken3_probe()
912 switch (hdev->product) { in kraken3_probe()
915 priv->kind = X53; in kraken3_probe()
919 priv->kind = Z53; in kraken3_probe()
923 priv->kind = KRAKEN2023; in kraken3_probe()
927 priv->kind = KRAKEN2023; in kraken3_probe()
931 ret = -ENODEV; in kraken3_probe()
935 priv->buffer = devm_kzalloc(&hdev->dev, MAX_REPORT_LENGTH, GFP_KERNEL); in kraken3_probe()
936 if (!priv->buffer) { in kraken3_probe()
937 ret = -ENOMEM; in kraken3_probe()
941 mutex_init(&priv->buffer_lock); in kraken3_probe()
942 mutex_init(&priv->z53_status_request_lock); in kraken3_probe()
943 init_completion(&priv->fw_version_processed); in kraken3_probe()
944 init_completion(&priv->status_report_processed); in kraken3_probe()
945 spin_lock_init(&priv->status_completion_lock); in kraken3_probe()
958 priv->hwmon_dev = hwmon_device_register_with_info(&hdev->dev, device_name, priv, in kraken3_probe()
960 if (IS_ERR(priv->hwmon_dev)) { in kraken3_probe()
961 ret = PTR_ERR(priv->hwmon_dev); in kraken3_probe()
981 debugfs_remove_recursive(priv->debugfs); in kraken3_remove()
982 hwmon_device_unregister(priv->hwmon_dev); in kraken3_remove()