Lines Matching +full:scaled +full:- +full:output +full:- +full:hz
1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Copyright (C) 2018-2019 Ed Brindley <kernel@maidavale.org>
9 * - CPU Core Voltage,
10 * - CPU SOC Voltage,
11 * - DRAM Voltage,
12 * - VDDP Voltage,
13 * - 1.8V PLL Voltage,
14 * - +12V Voltage,
15 * - +5V Voltage,
16 * - 3VSB Voltage,
17 * - VBAT Voltage,
18 * - AVCC3 Voltage,
19 * - SB 1.05V Voltage,
20 * - CPU Core Voltage,
21 * - CPU SOC Voltage,
22 * - DRAM Voltage,
23 * - CPU Fan RPM,
24 * - Chassis Fan 1 RPM,
25 * - Chassis Fan 2 RPM,
26 * - Chassis Fan 3 RPM,
27 * - HAMP Fan RPM,
28 * - Water Pump RPM,
29 * - CPU OPT RPM,
30 * - Water Flow RPM,
31 * - AIO Pump RPM,
32 * - CPU Temperature,
33 * - CPU Socket Temperature,
34 * - Motherboard Temperature,
35 * - Chipset Temperature,
36 * - Tsensor 1 Temperature,
37 * - CPU VRM Temperature,
38 * - Water In,
39 * - Water Out,
40 * - CPU VRM Output Current.
54 #define ASUSWMI_MONITORING_GUID "466747A0-70EC-11DE-8A39-0800200C9A66"
71 DMI_EXACT_MATCH_ASUS_BOARD_NAME("PRIME X399-A"),
72 DMI_EXACT_MATCH_ASUS_BOARD_NAME("PRIME X470-PRO"),
75 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG CROSSHAIR VI HERO (WI-FI AC)"),
77 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG CROSSHAIR VII HERO (WI-FI)"),
78 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX B450-E GAMING"),
79 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX B450-F GAMING"),
80 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX B450-F GAMING II"),
81 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX B450-I GAMING"),
82 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX X399-E GAMING"),
83 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX X470-F GAMING"),
84 DMI_EXACT_MATCH_ASUS_BOARD_NAME("ROG STRIX X470-I GAMING"),
113 SCALED = 0x3, enumerator
138 * struct asus_wmi_sensor_info - sensor info.
174 static int asus_wmi_call_method(u32 method_id, u32 *args, struct acpi_buffer *output) in asus_wmi_call_method() argument
180 method_id, &input, output); in asus_wmi_call_method()
182 return -EIO; in asus_wmi_call_method()
192 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; in asus_wmi_get_version() local
197 err = asus_wmi_call_method(ASUSWMI_METHODID_GET_VERSION, args, &output); in asus_wmi_get_version()
201 obj = output.pointer; in asus_wmi_get_version()
203 return -EIO; in asus_wmi_get_version()
205 if (obj->type != ACPI_TYPE_INTEGER) { in asus_wmi_get_version()
206 err = -EIO; in asus_wmi_get_version()
211 *version = obj->integer.value; in asus_wmi_get_version()
223 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; in asus_wmi_get_item_count() local
228 err = asus_wmi_call_method(ASUSWMI_METHODID_GET_NUMBER, args, &output); in asus_wmi_get_item_count()
232 obj = output.pointer; in asus_wmi_get_item_count()
234 return -EIO; in asus_wmi_get_item_count()
236 if (obj->type != ACPI_TYPE_INTEGER) { in asus_wmi_get_item_count()
237 err = -EIO; in asus_wmi_get_item_count()
242 *count = obj->integer.value; in asus_wmi_get_item_count()
257 return -ENOMEM; in asus_wmi_hwmon_add_chan_info()
259 asus_wmi_hwmon_chan->type = type; in asus_wmi_hwmon_add_chan_info()
260 asus_wmi_hwmon_chan->config = cfg; in asus_wmi_hwmon_add_chan_info()
272 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; in asus_wmi_sensor_info() local
277 err = asus_wmi_call_method(ASUSWMI_METHODID_GET_INFO, args, &output); in asus_wmi_sensor_info()
281 s->id = index; in asus_wmi_sensor_info()
283 obj = output.pointer; in asus_wmi_sensor_info()
285 return -EIO; in asus_wmi_sensor_info()
287 if (obj->type != ACPI_TYPE_PACKAGE) { in asus_wmi_sensor_info()
288 err = -EIO; in asus_wmi_sensor_info()
292 if (obj->package.count != 5) { in asus_wmi_sensor_info()
293 err = -EIO; in asus_wmi_sensor_info()
297 name_obj = obj->package.elements[0]; in asus_wmi_sensor_info()
299 err = -EIO; in asus_wmi_sensor_info()
303 strscpy(s->name, name_obj.string.pointer, sizeof(s->name)); in asus_wmi_sensor_info()
305 data_type_obj = obj->package.elements[1]; in asus_wmi_sensor_info()
307 err = -EIO; in asus_wmi_sensor_info()
311 s->data_type = data_type_obj.integer.value; in asus_wmi_sensor_info()
313 location_obj = obj->package.elements[2]; in asus_wmi_sensor_info()
315 err = -EIO; in asus_wmi_sensor_info()
319 s->location = location_obj.integer.value; in asus_wmi_sensor_info()
321 source_obj = obj->package.elements[3]; in asus_wmi_sensor_info()
323 err = -EIO; in asus_wmi_sensor_info()
327 s->source = source_obj.integer.value; in asus_wmi_sensor_info()
329 type_obj = obj->package.elements[4]; in asus_wmi_sensor_info()
331 err = -EIO; in asus_wmi_sensor_info()
336 s->type = type_obj.integer.value; in asus_wmi_sensor_info()
345 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; in asus_wmi_update_buffer() local
348 return asus_wmi_call_method(ASUSWMI_METHODID_UPDATE_BUFFER, args, &output); in asus_wmi_update_buffer()
353 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; in asus_wmi_get_sensor_value() local
358 err = asus_wmi_call_method(ASUSWMI_METHODID_GET_VALUE, args, &output); in asus_wmi_get_sensor_value()
362 obj = output.pointer; in asus_wmi_get_sensor_value()
364 return -EIO; in asus_wmi_get_sensor_value()
366 if (obj->type != ACPI_TYPE_INTEGER) { in asus_wmi_get_sensor_value()
367 err = -EIO; in asus_wmi_get_sensor_value()
372 *value = obj->integer.value; in asus_wmi_get_sensor_value()
386 for (i = 0; i < sensor_data->wmi.sensor_count; i++) { in asus_wmi_update_values_for_source()
387 sensor = sensor_data->wmi.info_by_id[i]; in asus_wmi_update_values_for_source()
388 if (sensor && sensor->source == source) { in asus_wmi_update_values_for_source()
389 ret = asus_wmi_get_sensor_value(sensor->id, &value); in asus_wmi_update_values_for_source()
393 sensor->cached_value = value; in asus_wmi_update_values_for_source()
423 mutex_lock(&sensor_data->lock); in asus_wmi_get_cached_value_or_update()
425 if (time_after(jiffies, sensor_data->wmi.source_last_updated[sensor->source] + HZ)) { in asus_wmi_get_cached_value_or_update()
426 ret = asus_wmi_update_buffer(sensor->source); in asus_wmi_get_cached_value_or_update()
430 ret = asus_wmi_update_values_for_source(sensor->source, sensor_data); in asus_wmi_get_cached_value_or_update()
434 sensor_data->wmi.source_last_updated[sensor->source] = jiffies; in asus_wmi_get_cached_value_or_update()
437 *value = sensor->cached_value; in asus_wmi_get_cached_value_or_update()
440 mutex_unlock(&sensor_data->lock); in asus_wmi_get_cached_value_or_update()
455 sensor = *(sensor_data->wmi.info[type] + channel); in asus_wmi_hwmon_read()
461 *val = asus_wmi_scale_sensor_value(value, sensor->data_type); in asus_wmi_hwmon_read()
473 sensor = *(sensor_data->wmi.info[type] + channel); in asus_wmi_hwmon_read_string()
474 *str = sensor->name; in asus_wmi_hwmon_read_string()
486 sensor = *(sensor_data->wmi.info[type] + channel); in asus_wmi_hwmon_is_visible()
517 for (i = 0; i < sensor_data->wmi.sensor_count; i++) { in asus_wmi_configure_sensor_setup()
545 return -ENOMEM; in asus_wmi_configure_sensor_setup()
550 return -ENOMEM; in asus_wmi_configure_sensor_setup()
555 sensor_data->wmi.info_by_id = devm_kcalloc(dev, sensor_data->wmi.sensor_count, in asus_wmi_configure_sensor_setup()
556 sizeof(*sensor_data->wmi.info_by_id), in asus_wmi_configure_sensor_setup()
559 if (!sensor_data->wmi.info_by_id) in asus_wmi_configure_sensor_setup()
560 return -ENOMEM; in asus_wmi_configure_sensor_setup()
574 sensor_data->wmi.info[type] = devm_kcalloc(dev, in asus_wmi_configure_sensor_setup()
576 sizeof(*sensor_data->wmi.info), in asus_wmi_configure_sensor_setup()
578 if (!sensor_data->wmi.info[type]) in asus_wmi_configure_sensor_setup()
579 return -ENOMEM; in asus_wmi_configure_sensor_setup()
582 for (i = sensor_data->wmi.sensor_count - 1; i >= 0; i--) { in asus_wmi_configure_sensor_setup()
585 return -ENOMEM; in asus_wmi_configure_sensor_setup()
591 switch (temp_sensor->data_type) { in asus_wmi_configure_sensor_setup()
597 type = asus_data_types[temp_sensor->data_type]; in asus_wmi_configure_sensor_setup()
598 idx = --nr_count[type]; in asus_wmi_configure_sensor_setup()
599 *(sensor_data->wmi.info[type] + idx) = temp_sensor; in asus_wmi_configure_sensor_setup()
600 sensor_data->wmi.info_by_id[i] = temp_sensor; in asus_wmi_configure_sensor_setup()
606 sensor_data->wmi.sensor_count); in asus_wmi_configure_sensor_setup()
617 struct device *dev = &wdev->dev; in asus_wmi_probe()
621 return -ENODEV; in asus_wmi_probe()
625 return -ENOMEM; in asus_wmi_probe()
628 return -ENODEV; in asus_wmi_probe()
630 if (asus_wmi_get_item_count(&sensor_data->wmi.sensor_count)) in asus_wmi_probe()
631 return -ENODEV; in asus_wmi_probe()
633 if (sensor_data->wmi.sensor_count <= 0 || version < 2) { in asus_wmi_probe()
635 version, sensor_data->wmi.sensor_count); in asus_wmi_probe()
637 return -ENODEV; in asus_wmi_probe()
640 mutex_init(&sensor_data->lock); in asus_wmi_probe()