Lines Matching +full:gpu +full:- +full:top +full:- +full:thermal
1 // SPDX-License-Identifier: GPL-2.0-or-later
18 #include <linux/hwmon-sysfs.h>
27 #include "alienware-wmi.h"
65 …_PARM_DESC(force_platform_profile, "Forces auto-detecting thermal profiles without checking if WMI…
69 MODULE_PARM_DESC(force_gmode, "Forces G-Mode when performance profile is selected");
93 .ident = "Alienware Area-51m",
96 DMI_MATCH(DMI_PRODUCT_NAME, "Alienware Area-51m"),
101 .ident = "Alienware Area-51m R2",
104 DMI_MATCH(DMI_PRODUCT_NAME, "Alienware Area-51m R2"),
408 * It can toggle between standard system GPU output and HDMI input.
420 ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_HDMI_CABLE, in cable_show()
429 pr_err("alienware-wmi: unknown HDMI cable status: %d\n", ret); in cable_show()
443 ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_HDMI_STATUS, in source_show()
447 return sysfs_emit(buf, "[input] gpu unknown\n"); in source_show()
449 return sysfs_emit(buf, "input [gpu] unknown\n"); in source_show()
452 pr_err("alienware-wmi: unknown HDMI source status: %u\n", ret); in source_show()
453 return sysfs_emit(buf, "input gpu [unknown]\n"); in source_show()
463 if (strcmp(buf, "gpu\n") == 0) in source_store()
469 pr_debug("alienware-wmi: setting hdmi to %d : %s", args.arg, buf); in source_store()
471 ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_HDMI_SOURCE, &args, in source_store()
474 pr_err("alienware-wmi: HDMI toggle failed: results: %u\n", ret); in source_store()
484 return alienware_interface == WMAX && alienfx->hdmi_mux; in hdmi_group_visible()
502 * - Currently supports reading cable status
503 * - Leaving expansion room to possibly support dock/undock events later
515 ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_AMPLIFIER_CABLE, in status_show()
524 pr_err("alienware-wmi: unknown amplifier cable status: %d\n", ret); in status_show()
532 return alienware_interface == WMAX && alienfx->amplifier; in amplifier_group_visible()
549 * - Modifies BIOS setting for deep sleep control allowing extra wakeup events
561 ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_DEEP_SLEEP_STATUS, in deepsleep_show()
572 pr_err("alienware-wmi: unknown deep sleep status: %d\n", ret); in deepsleep_show()
589 pr_debug("alienware-wmi: setting deep sleep to %d : %s", args.arg, buf); in deepsleep_store()
591 ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_DEEP_SLEEP_CONTROL, in deepsleep_store()
594 pr_err("alienware-wmi: deep sleep control failed: results: %u\n", ret); in deepsleep_store()
603 return alienware_interface == WMAX && alienfx->deepslp; in deepsleep_group_visible()
648 return -EBADRQC; in awcc_wmi_command()
725 * awcc_op_get_resource_id - Get the resource ID at a given index
733 * - Fan IDs
734 * - Sensor IDs
735 * - Unknown IDs
736 * - Thermal Profile IDs
741 * Return: 0 on success, -errno on failure
839 * - Provides temperature and fan speed monitoring as well as manual fan
850 temp_count = bitmap_weight(priv->temp_sensors, AWCC_ID_BITMAP_SIZE); in awcc_hwmon_is_visible()
854 return channel < priv->fan_count ? 0444 : 0; in awcc_hwmon_is_visible()
856 return channel < priv->fan_count ? 0444 : 0; in awcc_hwmon_is_visible()
873 temp = find_nth_bit(priv->temp_sensors, AWCC_ID_BITMAP_SIZE, channel); in awcc_hwmon_read()
877 ret = awcc_op_get_temperature(priv->wdev, temp, &state); in awcc_hwmon_read()
884 return -EOPNOTSUPP; in awcc_hwmon_read()
889 fan = priv->fan_data[channel]; in awcc_hwmon_read()
893 ret = awcc_op_get_fan_rpm(priv->wdev, fan->id, &state); in awcc_hwmon_read()
900 *val = fan->min_rpm; in awcc_hwmon_read()
903 *val = fan->max_rpm; in awcc_hwmon_read()
906 return -EOPNOTSUPP; in awcc_hwmon_read()
911 fan = priv->fan_data[channel]; in awcc_hwmon_read()
915 *val = fan->auto_channels_temp; in awcc_hwmon_read()
918 return -EOPNOTSUPP; in awcc_hwmon_read()
923 return -EOPNOTSUPP; in awcc_hwmon_read()
937 temp = find_nth_bit(priv->temp_sensors, AWCC_ID_BITMAP_SIZE, channel); in awcc_hwmon_read_string()
947 *str = "GPU"; in awcc_hwmon_read_string()
956 switch (priv->fan_data[channel]->id) { in awcc_hwmon_read_string()
963 *str = "GPU Fan"; in awcc_hwmon_read_string()
974 *str = "Top Fan"; in awcc_hwmon_read_string()
998 return -EOPNOTSUPP; in awcc_hwmon_read_string()
1047 int index = to_sensor_dev_attr(attr)->index; in fan_boost_show()
1048 struct awcc_fan_data *fan = priv->fan_data[index]; in fan_boost_show()
1052 ret = awcc_op_get_fan_boost(priv->wdev, fan->id, &boost); in fan_boost_show()
1063 int index = to_sensor_dev_attr(attr)->index; in fan_boost_store()
1064 struct awcc_fan_data *fan = priv->fan_data[index]; in fan_boost_store()
1072 ret = awcc_op_set_fan_boost(priv->wdev, fan->id, clamp_val(val, 0, 255)); in fan_boost_store()
1088 return n < priv->fan_count ? attr->mode : 0; in fan_boost_attr_visible()
1120 struct awcc_priv *priv = dev_get_drvdata(&wdev->dev); in awcc_hwmon_temps_init()
1125 for (i = 0; i < priv->temp_count; i++) { in awcc_hwmon_temps_init()
1130 ret = awcc_op_get_resource_id(wdev, i + priv->fan_count, &id); in awcc_hwmon_temps_init()
1134 __set_bit(id, priv->temp_sensors); in awcc_hwmon_temps_init()
1142 struct awcc_priv *priv = dev_get_drvdata(&wdev->dev); in awcc_hwmon_fans_init()
1151 for (i = 0; i < priv->fan_count; i++) { in awcc_hwmon_fans_init()
1152 fan_data = devm_kzalloc(&wdev->dev, sizeof(*fan_data), GFP_KERNEL); in awcc_hwmon_fans_init()
1154 return -ENOMEM; in awcc_hwmon_fans_init()
1190 fan_data->id = id; in awcc_hwmon_fans_init()
1191 fan_data->min_rpm = min_rpm; in awcc_hwmon_fans_init()
1192 fan_data->max_rpm = max_rpm; in awcc_hwmon_fans_init()
1193 bitmap_gather(gather, fan_temps, priv->temp_sensors, AWCC_ID_BITMAP_SIZE); in awcc_hwmon_fans_init()
1194 bitmap_copy(&fan_data->auto_channels_temp, gather, BITS_PER_LONG); in awcc_hwmon_fans_init()
1195 priv->fan_data[i] = fan_data; in awcc_hwmon_fans_init()
1203 struct awcc_priv *priv = dev_get_drvdata(&wdev->dev); in awcc_hwmon_init()
1206 priv->fan_data = devm_kcalloc(&wdev->dev, priv->fan_count, in awcc_hwmon_init()
1207 sizeof(*priv->fan_data), GFP_KERNEL); in awcc_hwmon_init()
1208 if (!priv->fan_data) in awcc_hwmon_init()
1209 return -ENOMEM; in awcc_hwmon_init()
1219 priv->hwdev = devm_hwmon_device_register_with_info(&wdev->dev, "alienware_wmi", in awcc_hwmon_init()
1223 return PTR_ERR_OR_ZERO(priv->hwdev); in awcc_hwmon_init()
1234 for (i = 0; i < priv->fan_count; i++) { in awcc_hwmon_suspend()
1235 fan = priv->fan_data[i]; in awcc_hwmon_suspend()
1237 ret = awcc_thermal_information(priv->wdev, AWCC_OP_GET_FAN_BOOST, in awcc_hwmon_suspend()
1238 fan->id, &boost); in awcc_hwmon_suspend()
1242 fan->suspend_cache = ret ? 0 : clamp_val(boost, 0, 255); in awcc_hwmon_suspend()
1244 awcc_op_set_fan_boost(priv->wdev, fan->id, 0); in awcc_hwmon_suspend()
1257 for (i = 0; i < priv->fan_count; i++) { in awcc_hwmon_resume()
1258 fan = priv->fan_data[i]; in awcc_hwmon_resume()
1260 if (!fan->suspend_cache) in awcc_hwmon_resume()
1263 ret = awcc_op_set_fan_boost(priv->wdev, fan->id, fan->suspend_cache); in awcc_hwmon_resume()
1270 * Thermal Profile control
1271 * - Provides thermal profile control through the Platform Profile API
1280 ret = awcc_op_get_current_profile(priv->wdev, &out_data); in awcc_platform_profile_get()
1296 return -ENODATA; in awcc_platform_profile_get()
1309 if (awcc->gmode) { in awcc_platform_profile_set()
1313 ret = awcc_game_shift_status(priv->wdev, in awcc_platform_profile_set()
1322 ret = awcc_game_shift_status(priv->wdev, in awcc_platform_profile_set()
1331 return awcc_op_activate_profile(priv->wdev, priv->supported_profiles[profile]); in awcc_platform_profile_set()
1343 * Thermal profile IDs are listed last at offset in awcc_platform_profile_probe()
1346 for (unsigned int i = 0; i < ARRAY_SIZE(priv->res_count) - 1; i++) in awcc_platform_profile_probe()
1347 offset += priv->res_count[i]; in awcc_platform_profile_probe()
1349 for (unsigned int i = 0; i < priv->profile_count; i++) { in awcc_platform_profile_probe()
1350 ret = awcc_op_get_resource_id(priv->wdev, i + offset, &id); in awcc_platform_profile_probe()
1352 * Some devices report an incorrect number of thermal profiles in awcc_platform_profile_probe()
1355 if (ret == -EBADRQC) in awcc_platform_profile_probe()
1361 dev_dbg(&priv->wdev->dev, "Unmapped thermal profile ID 0x%02x\n", id); in awcc_platform_profile_probe()
1367 priv->supported_profiles[profile] = id; in awcc_platform_profile_probe()
1373 return -ENODEV; in awcc_platform_profile_probe()
1375 if (awcc->gmode) { in awcc_platform_profile_probe()
1376 priv->supported_profiles[PLATFORM_PROFILE_PERFORMANCE] = in awcc_platform_profile_probe()
1383 priv->supported_profiles[PLATFORM_PROFILE_CUSTOM] = in awcc_platform_profile_probe()
1399 struct awcc_priv *priv = dev_get_drvdata(&wdev->dev); in awcc_platform_profile_init()
1401 priv->ppdev = devm_platform_profile_register(&wdev->dev, "alienware-wmi", in awcc_platform_profile_init()
1404 return PTR_ERR_OR_ZERO(priv->ppdev); in awcc_platform_profile_init()
1412 struct device *dev = seq->private; in awcc_debugfs_system_description_read()
1415 seq_printf(seq, "0x%08x\n", priv->system_description); in awcc_debugfs_system_description_read()
1422 struct device *dev = seq->private; in awcc_debugfs_hwmon_data_read()
1427 seq_printf(seq, "Number of fans: %u\n", priv->fan_count); in awcc_debugfs_hwmon_data_read()
1428 seq_printf(seq, "Number of temperature sensors: %u\n\n", priv->temp_count); in awcc_debugfs_hwmon_data_read()
1430 for (u32 i = 0; i < priv->fan_count; i++) { in awcc_debugfs_hwmon_data_read()
1431 fan = priv->fan_data[i]; in awcc_debugfs_hwmon_data_read()
1434 seq_printf(seq, " ID: 0x%02x\n", fan->id); in awcc_debugfs_hwmon_data_read()
1436 fan->auto_channels_temp); in awcc_debugfs_hwmon_data_read()
1440 for_each_set_bit(bit, priv->temp_sensors, AWCC_ID_BITMAP_SIZE) in awcc_debugfs_hwmon_data_read()
1448 struct device *dev = seq->private; in awcc_debugfs_pprof_data_read()
1451 seq_printf(seq, "Number of thermal profiles: %u\n\n", priv->profile_count); in awcc_debugfs_pprof_data_read()
1454 if (!priv->supported_profiles[i]) in awcc_debugfs_pprof_data_read()
1458 seq_printf(seq, " ID: 0x%02x\n", priv->supported_profiles[i]); in awcc_debugfs_pprof_data_read()
1466 unsigned long pin = debugfs_get_aux_num(seq->file); in awcc_gpio_pin_show()
1467 struct wmi_device *wdev = seq->private; in awcc_gpio_pin_show()
1484 struct seq_file *seq = file->private_data; in awcc_gpio_pin_write()
1485 struct wmi_device *wdev = seq->private; in awcc_gpio_pin_write()
1490 return -EINVAL; in awcc_gpio_pin_write()
1514 struct awcc_priv *priv = dev_get_drvdata(&wdev->dev); in awcc_debugfs_init()
1520 scnprintf(name, sizeof(name), "%s-%s", "alienware-wmi", dev_name(&wdev->dev)); in awcc_debugfs_init()
1523 debugfs_create_devm_seqfile(&wdev->dev, "system_description", root, in awcc_debugfs_init()
1526 if (awcc->hwmon) in awcc_debugfs_init()
1527 debugfs_create_devm_seqfile(&wdev->dev, "hwmon_data", root, in awcc_debugfs_init()
1530 if (awcc->pprof) in awcc_debugfs_init()
1531 debugfs_create_devm_seqfile(&wdev->dev, "pprof_data", root, in awcc_debugfs_init()
1536 dev_dbg(&wdev->dev, "Failed to get total GPIO Pin count\n"); in awcc_debugfs_init()
1539 dev_dbg(&wdev->dev, "Reported GPIO Pin count may be incorrect: %u\n", gpio_count); in awcc_debugfs_init()
1545 priv->gpio_count = gpio_count; in awcc_debugfs_init()
1546 debugfs_create_u32("total_gpios", 0444, gpio_ctl, &priv->gpio_count); in awcc_debugfs_init()
1555 devm_add_action_or_reset(&wdev->dev, awcc_debugfs_remove, root); in awcc_debugfs_init()
1563 priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL); in alienware_awcc_setup()
1565 return -ENOMEM; in alienware_awcc_setup()
1568 0, &priv->system_description); in alienware_awcc_setup()
1573 for (unsigned int i = 0; i < ARRAY_SIZE(priv->res_count); i++) { in alienware_awcc_setup()
1574 if (priv->res_count[i] > AWCC_MAX_RES_COUNT) { in alienware_awcc_setup()
1575 dev_err(&wdev->dev, "Malformed system description: 0x%08x\n", in alienware_awcc_setup()
1576 priv->system_description); in alienware_awcc_setup()
1577 return -ENXIO; in alienware_awcc_setup()
1581 priv->wdev = wdev; in alienware_awcc_setup()
1582 dev_set_drvdata(&wdev->dev, priv); in alienware_awcc_setup()
1584 if (awcc->hwmon) { in alienware_awcc_setup()
1590 if (awcc->pprof) { in alienware_awcc_setup()
1609 .colors = priv->colors[location], in wmax_wmi_update_led()
1610 .state = priv->lighting_control_state, in wmax_wmi_update_led()
1650 if (awcc && awcc->hwmon) in wmax_wmi_suspend()
1658 if (awcc && awcc->hwmon) in wmax_wmi_resume()
1674 .name = "alienware-wmi-wmax",
1689 awcc = id->driver_data; in alienware_wmax_wmi_init()
1695 awcc->hwmon = true; in alienware_wmax_wmi_init()
1702 awcc->pprof = true; in alienware_wmax_wmi_init()
1707 awcc->gmode = true; in alienware_wmax_wmi_init()