Lines Matching +full:battery +full:- +full:profile

1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Copyright(C) 2010-2011 Corentin Chary <corentin.chary@gmail.com>
22 #include <linux/hwmon-sysfs.h>
25 #include <linux/input/sparse-keymap.h>
31 #include <linux/platform_data/x86/asus-wmi.h>
41 #include <acpi/battery.h>
44 #include "asus-wmi.h"
57 #define ASUS_WMI_MGMT_GUID "97845ED0-4E6D-11DE-8A39-0800200C9A66"
158 u16 mfun; /* probably "Multi-function" to be called */
159 u16 sfun; /* probably "Sub-function" to be called */
169 u32 speed; /* read: RPM/100 - write: 0-255 */
173 * <platform>/ - debugfs root directory
174 * dev_id - current dev_id
175 * ctrl_param - current ctrl_param
176 * method_id - current method_id
177 * devs - call DEVS(dev_id, ctrl_param) and print result
178 * dsts - call DSTS(dev_id) and print result
179 * call - call method_id(dev_id, ctrl_param) and print result
322 return -EIO; in asus_wmi_evaluate_method3()
325 if (obj && obj->type == ACPI_TYPE_INTEGER) in asus_wmi_evaluate_method3()
326 tmp = (u32) obj->integer.value; in asus_wmi_evaluate_method3()
334 return -ENODEV; in asus_wmi_evaluate_method3()
365 return -EIO; in asus_wmi_evaluate_method5()
368 if (obj && obj->type == ACPI_TYPE_INTEGER) in asus_wmi_evaluate_method5()
369 tmp = (u32) obj->integer.value; in asus_wmi_evaluate_method5()
377 return -ENODEV; in asus_wmi_evaluate_method5()
404 return -EIO; in asus_wmi_evaluate_method_buf()
408 switch (obj->type) { in asus_wmi_evaluate_method_buf()
410 if (obj->buffer.length > size) { in asus_wmi_evaluate_method_buf()
411 err = -ENOSPC; in asus_wmi_evaluate_method_buf()
414 if (obj->buffer.length == 0) { in asus_wmi_evaluate_method_buf()
415 err = -ENODATA; in asus_wmi_evaluate_method_buf()
419 memcpy(ret_buffer, obj->buffer.pointer, obj->buffer.length); in asus_wmi_evaluate_method_buf()
422 err = (u32)obj->integer.value; in asus_wmi_evaluate_method_buf()
425 err = -ENODEV; in asus_wmi_evaluate_method_buf()
431 err = -ENODATA; in asus_wmi_evaluate_method_buf()
434 err = -ENODATA; in asus_wmi_evaluate_method_buf()
460 return -ENOMEM; in asus_wmi_evaluate_method_agfn()
470 return -ENXIO; in asus_wmi_evaluate_method_agfn()
477 return asus_wmi_evaluate_method(asus->dsts_id, dev_id, 0, retval); in asus_wmi_get_devstate()
499 return -ENODEV; in asus_wmi_get_devstate_bits()
503 return -ENODEV; in asus_wmi_get_devstate_bits()
526 input_report_switch(asus->inputdev, SW_TABLET_MODE, in asus_wmi_tablet_sw_report()
527 asus->tablet_switch_inverted ? !value : value); in asus_wmi_tablet_sw_report()
528 input_sync(asus->inputdev); in asus_wmi_tablet_sw_report()
533 struct device *dev = &asus->platform_device->dev; in asus_wmi_tablet_sw_init()
538 input_set_capability(asus->inputdev, EV_SW, SW_TABLET_MODE); in asus_wmi_tablet_sw_init()
540 asus->tablet_switch_dev_id = dev_id; in asus_wmi_tablet_sw_init()
541 asus->tablet_switch_event_code = event_code; in asus_wmi_tablet_sw_init()
542 } else if (result == -ENODEV) { in asus_wmi_tablet_sw_init()
543 …dev_err(dev, "This device has tablet-mode-switch quirk but got ENODEV checking it. This is a bug."… in asus_wmi_tablet_sw_init()
545 dev_err(dev, "Error checking for tablet-mode-switch: %d\n", result); in asus_wmi_tablet_sw_init()
551 struct device *dev = &asus->platform_device->dev; in asus_wmi_input_init()
554 asus->inputdev = input_allocate_device(); in asus_wmi_input_init()
555 if (!asus->inputdev) in asus_wmi_input_init()
556 return -ENOMEM; in asus_wmi_input_init()
558 asus->inputdev->name = asus->driver->input_name; in asus_wmi_input_init()
559 asus->inputdev->phys = asus->driver->input_phys; in asus_wmi_input_init()
560 asus->inputdev->id.bustype = BUS_HOST; in asus_wmi_input_init()
561 asus->inputdev->dev.parent = dev; in asus_wmi_input_init()
562 set_bit(EV_REP, asus->inputdev->evbit); in asus_wmi_input_init()
564 err = sparse_keymap_setup(asus->inputdev, asus->driver->keymap, NULL); in asus_wmi_input_init()
568 switch (asus->driver->quirks->tablet_switch_mode) { in asus_wmi_input_init()
572 asus->tablet_switch_inverted = true; in asus_wmi_input_init()
583 err = input_register_device(asus->inputdev); in asus_wmi_input_init()
590 input_free_device(asus->inputdev); in asus_wmi_input_init()
596 if (asus->inputdev) in asus_wmi_input_exit()
597 input_unregister_device(asus->inputdev); in asus_wmi_input_exit()
599 asus->inputdev = NULL; in asus_wmi_input_exit()
608 if (!asus->tablet_switch_dev_id) in asus_wmi_tablet_mode_get_state()
611 result = asus_wmi_get_devstate_simple(asus, asus->tablet_switch_dev_id); in asus_wmi_tablet_mode_get_state()
666 return -EINVAL; in dgpu_disable_store()
668 if (asus->gpu_mux_mode_available) { in dgpu_disable_store()
674 err = -ENODEV; in dgpu_disable_store()
688 return -EIO; in dgpu_disable_store()
691 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "dgpu_disable"); in dgpu_disable_store()
726 return -EINVAL; in egpu_enable_store()
734 if (asus->gpu_mux_mode_available) { in egpu_enable_store()
742 err = -ENODEV; in egpu_enable_store()
756 return -EIO; in egpu_enable_store()
759 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "egpu_enable"); in egpu_enable_store()
808 return -EINVAL; in gpu_mux_mode_store()
810 if (asus->dgpu_disable_available) { in gpu_mux_mode_store()
816 err = -ENODEV; in gpu_mux_mode_store()
822 if (asus->egpu_enable_available) { in gpu_mux_mode_store()
828 err = -ENODEV; in gpu_mux_mode_store()
842 return -EIO; in gpu_mux_mode_store()
845 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "gpu_mux_mode"); in gpu_mux_mode_store()
860 return -EINVAL; in kbd_rgb_mode_store()
871 return -EINVAL; in kbd_rgb_mode_store()
928 return -EINVAL; in kbd_rgb_state_store()
992 return -EINVAL; in ppt_pl2_sppt_store()
1002 return -EIO; in ppt_pl2_sppt_store()
1005 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_pl2_sppt"); in ppt_pl2_sppt_store()
1026 return -EINVAL; in ppt_pl1_spl_store()
1036 return -EIO; in ppt_pl1_spl_store()
1039 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_pl1_spl"); in ppt_pl1_spl_store()
1060 return -EINVAL; in ppt_fppt_store()
1070 return -EIO; in ppt_fppt_store()
1073 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_fpu_sppt"); in ppt_fppt_store()
1094 return -EINVAL; in ppt_apu_sppt_store()
1104 return -EIO; in ppt_apu_sppt_store()
1107 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_apu_sppt"); in ppt_apu_sppt_store()
1128 return -EINVAL; in ppt_platform_sppt_store()
1138 return -EIO; in ppt_platform_sppt_store()
1141 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_platform_sppt"); in ppt_platform_sppt_store()
1162 return -EINVAL; in nv_dynamic_boost_store()
1172 return -EIO; in nv_dynamic_boost_store()
1175 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "nv_dynamic_boost"); in nv_dynamic_boost_store()
1196 return -EINVAL; in nv_temp_target_store()
1206 return -EIO; in nv_temp_target_store()
1209 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "nv_temp_target"); in nv_temp_target_store()
1215 /* Battery ********************************************************************/
1217 /* The battery maximum charging percentage */
1231 return -EINVAL; in charge_control_end_threshold_store()
1238 return -EIO; in charge_control_end_threshold_store()
1256 static int asus_wmi_battery_add(struct power_supply *battery, struct acpi_battery_hook *hook) in asus_wmi_battery_add() argument
1258 /* The WMI method does not provide a way to specific a battery, so we in asus_wmi_battery_add()
1259 * just assume it is the first battery. in asus_wmi_battery_add()
1261 * battery is named BATT. in asus_wmi_battery_add()
1263 if (strcmp(battery->desc->name, "BAT0") != 0 && in asus_wmi_battery_add()
1264 strcmp(battery->desc->name, "BAT1") != 0 && in asus_wmi_battery_add()
1265 strcmp(battery->desc->name, "BATC") != 0 && in asus_wmi_battery_add()
1266 strcmp(battery->desc->name, "BATT") != 0) in asus_wmi_battery_add()
1267 return -ENODEV; in asus_wmi_battery_add()
1269 if (device_create_file(&battery->dev, in asus_wmi_battery_add()
1271 return -ENODEV; in asus_wmi_battery_add()
1275 * a battery is added. in asus_wmi_battery_add()
1283 static int asus_wmi_battery_remove(struct power_supply *battery, struct acpi_battery_hook *hook) in asus_wmi_battery_remove() argument
1285 device_remove_file(&battery->dev, in asus_wmi_battery_remove()
1293 .name = "ASUS Battery Extension",
1298 asus->battery_rsoc_available = false; in asus_wmi_battery_init()
1300 asus->battery_rsoc_available = true; in asus_wmi_battery_init()
1307 if (asus->battery_rsoc_available) in asus_wmi_battery_exit()
1326 ctrl_param = asus->tpd_led_wk; in tpd_led_update()
1337 asus->tpd_led_wk = !!value; in tpd_led_set()
1338 queue_work(asus->led_workqueue, &asus->tpd_led_work); in tpd_led_set()
1359 ctrl_param = 0x80 | (asus->kbd_led_wk & 0x7F); in kbd_led_update()
1368 * bits 0-2: level in kbd_led_read()
1370 * bit 8-10: environment (0: dark, 1: normal, 2: light) in kbd_led_read()
1396 max_level = asus->kbd_led.max_brightness; in do_kbd_led_set()
1398 asus->kbd_led_wk = clamp_val(value, 0, max_level); in do_kbd_led_set()
1406 if (led_cdev->flags & LED_UNREGISTERING) in kbd_led_set()
1414 struct led_classdev *led_cdev = &asus->kbd_led; in kbd_led_set_by_kbd()
1417 led_classdev_notify_brightness_hw_changed(led_cdev, asus->kbd_led_wk); in kbd_led_set_by_kbd()
1450 ctrl_param = asus->wlan_led_wk; in wlan_led_update()
1461 asus->wlan_led_wk = !!value; in wlan_led_set()
1462 queue_work(asus->led_workqueue, &asus->wlan_led_work); in wlan_led_set()
1483 ctrl_param = asus->lightbar_led_wk; in lightbar_led_update()
1494 asus->lightbar_led_wk = !!value; in lightbar_led_set()
1495 queue_work(asus->led_workqueue, &asus->lightbar_led_work); in lightbar_led_set()
1521 led_classdev_unregister(&asus->kbd_led); in asus_wmi_led_exit()
1522 led_classdev_unregister(&asus->tpd_led); in asus_wmi_led_exit()
1523 led_classdev_unregister(&asus->wlan_led); in asus_wmi_led_exit()
1524 led_classdev_unregister(&asus->lightbar_led); in asus_wmi_led_exit()
1525 led_classdev_unregister(&asus->micmute_led); in asus_wmi_led_exit()
1527 if (asus->led_workqueue) in asus_wmi_led_exit()
1528 destroy_workqueue(asus->led_workqueue); in asus_wmi_led_exit()
1535 if (asus->kbd_rgb_mode_available) in asus_wmi_led_init()
1537 if (asus->kbd_rgb_state_available) in asus_wmi_led_init()
1540 asus->led_workqueue = create_singlethread_workqueue("led_workqueue"); in asus_wmi_led_init()
1541 if (!asus->led_workqueue) in asus_wmi_led_init()
1542 return -ENOMEM; in asus_wmi_led_init()
1545 INIT_WORK(&asus->tpd_led_work, tpd_led_update); in asus_wmi_led_init()
1547 asus->tpd_led.name = "asus::touchpad"; in asus_wmi_led_init()
1548 asus->tpd_led.brightness_set = tpd_led_set; in asus_wmi_led_init()
1549 asus->tpd_led.brightness_get = tpd_led_get; in asus_wmi_led_init()
1550 asus->tpd_led.max_brightness = 1; in asus_wmi_led_init()
1552 rv = led_classdev_register(&asus->platform_device->dev, in asus_wmi_led_init()
1553 &asus->tpd_led); in asus_wmi_led_init()
1559 asus->kbd_led_wk = led_val; in asus_wmi_led_init()
1560 asus->kbd_led.name = "asus::kbd_backlight"; in asus_wmi_led_init()
1561 asus->kbd_led.flags = LED_BRIGHT_HW_CHANGED; in asus_wmi_led_init()
1562 asus->kbd_led.brightness_set = kbd_led_set; in asus_wmi_led_init()
1563 asus->kbd_led.brightness_get = kbd_led_get; in asus_wmi_led_init()
1564 asus->kbd_led.max_brightness = 3; in asus_wmi_led_init()
1567 asus->kbd_led.groups = kbd_rgb_mode_groups; in asus_wmi_led_init()
1569 rv = led_classdev_register(&asus->platform_device->dev, in asus_wmi_led_init()
1570 &asus->kbd_led); in asus_wmi_led_init()
1576 && (asus->driver->quirks->wapf > 0)) { in asus_wmi_led_init()
1577 INIT_WORK(&asus->wlan_led_work, wlan_led_update); in asus_wmi_led_init()
1579 asus->wlan_led.name = "asus::wlan"; in asus_wmi_led_init()
1580 asus->wlan_led.brightness_set = wlan_led_set; in asus_wmi_led_init()
1582 asus->wlan_led.brightness_get = wlan_led_get; in asus_wmi_led_init()
1583 asus->wlan_led.flags = LED_CORE_SUSPENDRESUME; in asus_wmi_led_init()
1584 asus->wlan_led.max_brightness = 1; in asus_wmi_led_init()
1585 asus->wlan_led.default_trigger = "asus-wlan"; in asus_wmi_led_init()
1587 rv = led_classdev_register(&asus->platform_device->dev, in asus_wmi_led_init()
1588 &asus->wlan_led); in asus_wmi_led_init()
1594 INIT_WORK(&asus->lightbar_led_work, lightbar_led_update); in asus_wmi_led_init()
1596 asus->lightbar_led.name = "asus::lightbar"; in asus_wmi_led_init()
1597 asus->lightbar_led.brightness_set = lightbar_led_set; in asus_wmi_led_init()
1598 asus->lightbar_led.brightness_get = lightbar_led_get; in asus_wmi_led_init()
1599 asus->lightbar_led.max_brightness = 1; in asus_wmi_led_init()
1601 rv = led_classdev_register(&asus->platform_device->dev, in asus_wmi_led_init()
1602 &asus->lightbar_led); in asus_wmi_led_init()
1606 asus->micmute_led.name = "platform::micmute"; in asus_wmi_led_init()
1607 asus->micmute_led.max_brightness = 1; in asus_wmi_led_init()
1608 asus->micmute_led.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE); in asus_wmi_led_init()
1609 asus->micmute_led.brightness_set_blocking = micmute_led_set; in asus_wmi_led_init()
1610 asus->micmute_led.default_trigger = "audio-micmute"; in asus_wmi_led_init()
1612 rv = led_classdev_register(&asus->platform_device->dev, in asus_wmi_led_init()
1613 &asus->micmute_led); in asus_wmi_led_init()
1647 mutex_lock(&asus->wmi_lock); in asus_rfkill_hotplug()
1649 mutex_unlock(&asus->wmi_lock); in asus_rfkill_hotplug()
1651 mutex_lock(&asus->hotplug_lock); in asus_rfkill_hotplug()
1654 if (asus->wlan.rfkill) in asus_rfkill_hotplug()
1655 rfkill_set_sw_state(asus->wlan.rfkill, blocked); in asus_rfkill_hotplug()
1657 if (asus->hotplug_slot.ops) { in asus_rfkill_hotplug()
1701 mutex_unlock(&asus->hotplug_lock); in asus_rfkill_hotplug()
1718 queue_work(asus->hotplug_workqueue, &asus->hotplug_work); in asus_rfkill_notify()
1728 return -ENODEV; in asus_register_rfkill_notifier()
1782 int ret = -ENOMEM; in asus_setup_pci_hotplug()
1787 return -ENODEV; in asus_setup_pci_hotplug()
1790 asus->hotplug_workqueue = in asus_setup_pci_hotplug()
1792 if (!asus->hotplug_workqueue) in asus_setup_pci_hotplug()
1795 INIT_WORK(&asus->hotplug_work, asus_hotplug_work); in asus_setup_pci_hotplug()
1797 asus->hotplug_slot.ops = &asus_hotplug_slot_ops; in asus_setup_pci_hotplug()
1799 ret = pci_hp_register(&asus->hotplug_slot, bus, 0, "asus-wifi"); in asus_setup_pci_hotplug()
1801 pr_err("Unable to register hotplug slot - %d\n", ret); in asus_setup_pci_hotplug()
1808 asus->hotplug_slot.ops = NULL; in asus_setup_pci_hotplug()
1809 destroy_workqueue(asus->hotplug_workqueue); in asus_setup_pci_hotplug()
1821 u32 dev_id = priv->dev_id; in asus_rfkill_set()
1832 priv->asus->driver->wlan_ctrl_by_user) in asus_rfkill_set()
1843 result = asus_wmi_get_devstate_simple(priv->asus, priv->dev_id); in asus_rfkill_query()
1848 rfkill_set_sw_state(priv->rfkill, !result); in asus_rfkill_query()
1854 struct asus_wmi *asus = priv->asus; in asus_rfkill_wlan_set()
1864 mutex_lock(&asus->wmi_lock); in asus_rfkill_wlan_set()
1866 mutex_unlock(&asus->wmi_lock); in asus_rfkill_wlan_set()
1885 struct rfkill **rfkill = &arfkill->rfkill; in asus_new_rfkill()
1890 arfkill->dev_id = dev_id; in asus_new_rfkill()
1891 arfkill->asus = asus; in asus_new_rfkill()
1894 asus->driver->quirks->hotplug_wireless) in asus_new_rfkill()
1895 *rfkill = rfkill_alloc(name, &asus->platform_device->dev, type, in asus_new_rfkill()
1898 *rfkill = rfkill_alloc(name, &asus->platform_device->dev, type, in asus_new_rfkill()
1902 return -EINVAL; in asus_new_rfkill()
1905 (asus->driver->quirks->wapf > 0)) in asus_new_rfkill()
1906 rfkill_set_led_trigger_name(*rfkill, "asus-wlan"); in asus_new_rfkill()
1920 if (asus->driver->wlan_ctrl_by_user && ashs_present()) in asus_wmi_rfkill_exit()
1926 if (asus->wlan.rfkill) { in asus_wmi_rfkill_exit()
1927 rfkill_unregister(asus->wlan.rfkill); in asus_wmi_rfkill_exit()
1928 rfkill_destroy(asus->wlan.rfkill); in asus_wmi_rfkill_exit()
1929 asus->wlan.rfkill = NULL; in asus_wmi_rfkill_exit()
1936 if (asus->hotplug_slot.ops) in asus_wmi_rfkill_exit()
1937 pci_hp_deregister(&asus->hotplug_slot); in asus_wmi_rfkill_exit()
1938 if (asus->hotplug_workqueue) in asus_wmi_rfkill_exit()
1939 destroy_workqueue(asus->hotplug_workqueue); in asus_wmi_rfkill_exit()
1941 if (asus->bluetooth.rfkill) { in asus_wmi_rfkill_exit()
1942 rfkill_unregister(asus->bluetooth.rfkill); in asus_wmi_rfkill_exit()
1943 rfkill_destroy(asus->bluetooth.rfkill); in asus_wmi_rfkill_exit()
1944 asus->bluetooth.rfkill = NULL; in asus_wmi_rfkill_exit()
1946 if (asus->wimax.rfkill) { in asus_wmi_rfkill_exit()
1947 rfkill_unregister(asus->wimax.rfkill); in asus_wmi_rfkill_exit()
1948 rfkill_destroy(asus->wimax.rfkill); in asus_wmi_rfkill_exit()
1949 asus->wimax.rfkill = NULL; in asus_wmi_rfkill_exit()
1951 if (asus->wwan3g.rfkill) { in asus_wmi_rfkill_exit()
1952 rfkill_unregister(asus->wwan3g.rfkill); in asus_wmi_rfkill_exit()
1953 rfkill_destroy(asus->wwan3g.rfkill); in asus_wmi_rfkill_exit()
1954 asus->wwan3g.rfkill = NULL; in asus_wmi_rfkill_exit()
1956 if (asus->gps.rfkill) { in asus_wmi_rfkill_exit()
1957 rfkill_unregister(asus->gps.rfkill); in asus_wmi_rfkill_exit()
1958 rfkill_destroy(asus->gps.rfkill); in asus_wmi_rfkill_exit()
1959 asus->gps.rfkill = NULL; in asus_wmi_rfkill_exit()
1961 if (asus->uwb.rfkill) { in asus_wmi_rfkill_exit()
1962 rfkill_unregister(asus->uwb.rfkill); in asus_wmi_rfkill_exit()
1963 rfkill_destroy(asus->uwb.rfkill); in asus_wmi_rfkill_exit()
1964 asus->uwb.rfkill = NULL; in asus_wmi_rfkill_exit()
1972 mutex_init(&asus->hotplug_lock); in asus_wmi_rfkill_init()
1973 mutex_init(&asus->wmi_lock); in asus_wmi_rfkill_init()
1975 result = asus_new_rfkill(asus, &asus->wlan, "asus-wlan", in asus_wmi_rfkill_init()
1978 if (result && result != -ENODEV) in asus_wmi_rfkill_init()
1981 result = asus_new_rfkill(asus, &asus->bluetooth, in asus_wmi_rfkill_init()
1982 "asus-bluetooth", RFKILL_TYPE_BLUETOOTH, in asus_wmi_rfkill_init()
1985 if (result && result != -ENODEV) in asus_wmi_rfkill_init()
1988 result = asus_new_rfkill(asus, &asus->wimax, "asus-wimax", in asus_wmi_rfkill_init()
1991 if (result && result != -ENODEV) in asus_wmi_rfkill_init()
1994 result = asus_new_rfkill(asus, &asus->wwan3g, "asus-wwan3g", in asus_wmi_rfkill_init()
1997 if (result && result != -ENODEV) in asus_wmi_rfkill_init()
2000 result = asus_new_rfkill(asus, &asus->gps, "asus-gps", in asus_wmi_rfkill_init()
2003 if (result && result != -ENODEV) in asus_wmi_rfkill_init()
2006 result = asus_new_rfkill(asus, &asus->uwb, "asus-uwb", in asus_wmi_rfkill_init()
2009 if (result && result != -ENODEV) in asus_wmi_rfkill_init()
2012 if (!asus->driver->quirks->hotplug_wireless) in asus_wmi_rfkill_init()
2017 * If we get -EBUSY then something else is handling the PCI hotplug - in asus_wmi_rfkill_init()
2020 if (result == -EBUSY) in asus_wmi_rfkill_init()
2033 if (result && result != -ENODEV) in asus_wmi_rfkill_init()
2036 if (result == -ENODEV) in asus_wmi_rfkill_init()
2070 return -EINVAL; in panel_od_store()
2081 return -EIO; in panel_od_store()
2084 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "panel_od"); in panel_od_store()
2090 /* Mini-LED mode **************************************************************/
2118 return -EINVAL; in mini_led_mode_store()
2123 pr_warn("Failed to set mini-LED: %d\n", err); in mini_led_mode_store()
2128 pr_warn("Failed to set mini-LED mode (result): 0x%x\n", result); in mini_led_mode_store()
2129 return -EIO; in mini_led_mode_store()
2132 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "mini_led_mode"); in mini_led_mode_store()
2144 u32 ports_available = asus->driver->quirks->xusb2pr; in asus_wmi_set_xusb2pr()
2190 return -EINVAL; in asus_agfn_fan_speed_read()
2195 return -ENXIO; in asus_agfn_fan_speed_read()
2218 return -EINVAL; in asus_agfn_fan_speed_write()
2223 return -ENXIO; in asus_agfn_fan_speed_write()
2226 asus->agfn_pwm = *speed; in asus_agfn_fan_speed_write()
2253 * - ASUS_WMI_UNSUPPORTED_METHOD is returned in asus_wmi_has_agfn_fan()
2254 * - reverved bits are non-zero in asus_wmi_has_agfn_fan()
2255 * - sfun and presence bit are not set in asus_wmi_has_agfn_fan()
2258 || (!asus->sfun && !(value & ASUS_WMI_DSTS_PRESENCE_BIT))); in asus_wmi_has_agfn_fan()
2266 switch (asus->fan_type) { in asus_fan_set_auto()
2274 return -EIO; in asus_fan_set_auto()
2280 return -ENXIO; in asus_fan_set_auto()
2284 return -ENXIO; in asus_fan_set_auto()
2290 if (asus->gpu_fan_type == FAN_TYPE_SPEC83) { in asus_fan_set_auto()
2297 return -EIO; in asus_fan_set_auto()
2312 if (asus->agfn_pwm >= 0) in pwm1_show()
2313 return sprintf(buf, "%d\n", asus->agfn_pwm); in pwm1_show()
2317 * we read a current value through the (now-deprecated) FAN_CTRL device. in pwm1_show()
2333 value = -1; in pwm1_show()
2357 asus->fan_pwm_mode = ASUS_FAN_CTRL_MANUAL; in pwm1_store()
2370 switch (asus->fan_type) { in fan1_input_show()
2382 if (asus->fan_pwm_mode == ASUS_FAN_CTRL_MANUAL) in fan1_input_show()
2383 return -ENXIO; in fan1_input_show()
2388 return -ENXIO; in fan1_input_show()
2393 return -ENXIO; in fan1_input_show()
2396 return sysfs_emit(buf, "%d\n", value < 0 ? -1 : value * 100); in fan1_input_show()
2414 return sysfs_emit(buf, "%d\n", asus->fan_pwm_mode); in pwm1_enable_show()
2432 if (asus->fan_type == FAN_TYPE_SPEC83) { in pwm1_enable_store()
2441 return -EINVAL; in pwm1_enable_store()
2450 return -EIO; in pwm1_enable_store()
2451 } else if (asus->fan_type == FAN_TYPE_AGFN) { in pwm1_enable_store()
2463 return -EINVAL; in pwm1_enable_store()
2467 asus->fan_pwm_mode = state; in pwm1_enable_store()
2470 if (asus->cpu_fan_curve_available) in pwm1_enable_store()
2471 asus->custom_fan_curves[FAN_CURVE_DEV_CPU].enabled = false; in pwm1_enable_store()
2472 if (asus->gpu_fan_curve_available) in pwm1_enable_store()
2473 asus->custom_fan_curves[FAN_CURVE_DEV_GPU].enabled = false; in pwm1_enable_store()
2474 if (asus->mid_fan_curve_available) in pwm1_enable_store()
2475 asus->custom_fan_curves[FAN_CURVE_DEV_MID].enabled = false; in pwm1_enable_store()
2559 return sysfs_emit(buf, "%d\n", asus->gpu_fan_pwm_mode); in pwm2_enable_show()
2584 return -EINVAL; in pwm2_enable_store()
2593 return -EIO; in pwm2_enable_store()
2595 asus->gpu_fan_pwm_mode = state; in pwm2_enable_store()
2605 return sysfs_emit(buf, "%d\n", asus->mid_fan_pwm_mode); in pwm3_enable_show()
2630 return -EINVAL; in pwm3_enable_store()
2639 return -EIO; in pwm3_enable_store()
2641 asus->mid_fan_pwm_mode = state; in pwm3_enable_store()
2650 /* Fan2 - GPU fan */
2654 /* Fan3 - Middle/center fan */
2682 struct asus_wmi *asus = dev_get_drvdata(dev->parent); in asus_hwmon_sysfs_is_visible()
2686 if (asus->fan_type != FAN_TYPE_AGFN) in asus_hwmon_sysfs_is_visible()
2691 if (asus->fan_type == FAN_TYPE_NONE) in asus_hwmon_sysfs_is_visible()
2696 if (asus->gpu_fan_type == FAN_TYPE_NONE) in asus_hwmon_sysfs_is_visible()
2701 if (asus->mid_fan_type == FAN_TYPE_NONE) in asus_hwmon_sysfs_is_visible()
2712 * If the temperature value in deci-Kelvin is near the absolute in asus_hwmon_sysfs_is_visible()
2719 return attr->mode; in asus_hwmon_sysfs_is_visible()
2730 struct device *dev = &asus->platform_device->dev; in asus_wmi_hwmon_init()
2745 asus->gpu_fan_type = FAN_TYPE_NONE; in asus_wmi_fan_init()
2746 asus->mid_fan_type = FAN_TYPE_NONE; in asus_wmi_fan_init()
2747 asus->fan_type = FAN_TYPE_NONE; in asus_wmi_fan_init()
2748 asus->agfn_pwm = -1; in asus_wmi_fan_init()
2750 if (asus->driver->quirks->wmi_ignore_fan) in asus_wmi_fan_init()
2751 asus->fan_type = FAN_TYPE_NONE; in asus_wmi_fan_init()
2753 asus->fan_type = FAN_TYPE_SPEC83; in asus_wmi_fan_init()
2755 asus->fan_type = FAN_TYPE_AGFN; in asus_wmi_fan_init()
2759 asus->gpu_fan_type = FAN_TYPE_SPEC83; in asus_wmi_fan_init()
2763 asus->mid_fan_type = FAN_TYPE_SPEC83; in asus_wmi_fan_init()
2765 if (asus->fan_type == FAN_TYPE_NONE) in asus_wmi_fan_init()
2766 return -ENODEV; in asus_wmi_fan_init()
2769 asus->fan_pwm_mode = ASUS_FAN_CTRL_AUTO; in asus_wmi_fan_init()
2780 asus->fan_boost_mode_available = false; in fan_boost_mode_check_present()
2785 if (err == -ENODEV) in fan_boost_mode_check_present()
2793 asus->fan_boost_mode_available = true; in fan_boost_mode_check_present()
2794 asus->fan_boost_mode_mask = result & ASUS_FAN_BOOST_MODES_MASK; in fan_boost_mode_check_present()
2806 value = asus->fan_boost_mode; in fan_boost_mode_write()
2812 sysfs_notify(&asus->platform_device->dev.kobj, NULL, in fan_boost_mode_write()
2823 return -EIO; in fan_boost_mode_write()
2831 u8 mask = asus->fan_boost_mode_mask; in fan_boost_mode_switch_next()
2833 if (asus->fan_boost_mode == ASUS_FAN_BOOST_MODE_NORMAL) { in fan_boost_mode_switch_next()
2835 asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_OVERBOOST; in fan_boost_mode_switch_next()
2837 asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_SILENT; in fan_boost_mode_switch_next()
2838 } else if (asus->fan_boost_mode == ASUS_FAN_BOOST_MODE_OVERBOOST) { in fan_boost_mode_switch_next()
2840 asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_SILENT; in fan_boost_mode_switch_next()
2842 asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_NORMAL; in fan_boost_mode_switch_next()
2844 asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_NORMAL; in fan_boost_mode_switch_next()
2855 return sysfs_emit(buf, "%d\n", asus->fan_boost_mode); in fan_boost_mode_show()
2863 u8 mask = asus->fan_boost_mode_mask; in fan_boost_mode_store()
2875 return -EINVAL; in fan_boost_mode_store()
2878 return -EINVAL; in fan_boost_mode_store()
2880 return -EINVAL; in fan_boost_mode_store()
2883 asus->fan_boost_mode = new_mode; in fan_boost_mode_store()
2889 // Fan boost mode: 0 - normal, 1 - overboost, 2 - silent
2899 data->temps[i] = buf[i]; in fan_curve_copy_from_buf()
2903 data->percents[i] = in fan_curve_copy_from_buf()
2915 if (asus->throttle_thermal_policy_available) in fan_curve_get_factory_default()
2916 mode = asus->throttle_thermal_policy_mode; in fan_curve_get_factory_default()
2923 err = asus_wmi_evaluate_method_buf(asus->dsts_id, fan_dev, mode, buf, in fan_curve_get_factory_default()
2937 curves = &asus->custom_fan_curves[fan_idx]; in fan_curve_get_factory_default()
2938 curves->device_id = fan_dev; in fan_curve_get_factory_default()
2952 if (asus->fan_type == FAN_TYPE_NONE) in fan_curve_check_present()
2968 int index = to_sensor_dev_attr(attr)->index; in fan_curve_attr_select()
2970 return &asus->custom_fan_curves[index]; in fan_curve_attr_select()
2977 int nr = to_sensor_dev_attr_2(attr)->nr; in fan_curve_attr_2_select()
2979 return &asus->custom_fan_curves[nr & ~FAN_CURVE_PWM_MASK]; in fan_curve_attr_2_select()
2991 pwm = dev_attr->nr & FAN_CURVE_PWM_MASK; in fan_curve_show()
2992 index = dev_attr->index; in fan_curve_show()
2995 value = data->percents[index]; in fan_curve_show()
2997 value = data->temps[index]; in fan_curve_show()
3009 u8 *percents = data->percents; in fan_curve_write()
3010 u8 *temps = data->temps; in fan_curve_write()
3013 if (!data->enabled) in fan_curve_write()
3026 data->device_id, in fan_curve_write()
3041 pwm = dev_attr->nr & FAN_CURVE_PWM_MASK; in fan_curve_store()
3042 index = dev_attr->index; in fan_curve_store()
3049 data->percents[index] = value; in fan_curve_store()
3051 data->temps[index] = value; in fan_curve_store()
3056 * many changes as one-write-per-change. in fan_curve_store()
3058 data->enabled = false; in fan_curve_store()
3072 if (data->enabled) in fan_curve_enable_show()
3094 data->enabled = true; in fan_curve_enable_store()
3097 data->enabled = false; in fan_curve_enable_store()
3104 err = fan_curve_get_factory_default(asus, data->device_id); in fan_curve_enable_store()
3107 data->enabled = false; in fan_curve_enable_store()
3110 return -EINVAL; in fan_curve_enable_store()
3113 if (data->enabled) { in fan_curve_enable_store()
3122 if (asus->throttle_thermal_policy_available) { in fan_curve_enable_store()
3127 } else if (asus->fan_type == FAN_TYPE_SPEC83) { in fan_curve_enable_store()
3133 err = fan_curve_get_factory_default(asus, data->device_id); in fan_curve_enable_store()
3314 struct asus_wmi *asus = dev_get_drvdata(dev->parent); in asus_fan_curve_is_visible()
3320 if (asus->cpu_fan_curve_available && attr->name[3] == '1') in asus_fan_curve_is_visible()
3323 if (asus->gpu_fan_curve_available && attr->name[3] == '2') in asus_fan_curve_is_visible()
3326 if (asus->mid_fan_curve_available && attr->name[3] == '3') in asus_fan_curve_is_visible()
3344 struct device *dev = &asus->platform_device->dev; in asus_wmi_custom_fan_curve_init()
3348 err = fan_curve_check_present(asus, &asus->cpu_fan_curve_available, in asus_wmi_custom_fan_curve_init()
3353 err = fan_curve_check_present(asus, &asus->gpu_fan_curve_available, in asus_wmi_custom_fan_curve_init()
3358 err = fan_curve_check_present(asus, &asus->mid_fan_curve_available, in asus_wmi_custom_fan_curve_init()
3363 if (!asus->cpu_fan_curve_available in asus_wmi_custom_fan_curve_init()
3364 && !asus->gpu_fan_curve_available in asus_wmi_custom_fan_curve_init()
3365 && !asus->mid_fan_curve_available) in asus_wmi_custom_fan_curve_init()
3387 asus->throttle_thermal_policy_available = false; in throttle_thermal_policy_check_present()
3393 if (err == -ENODEV) in throttle_thermal_policy_check_present()
3399 asus->throttle_thermal_policy_available = true; in throttle_thermal_policy_check_present()
3410 value = asus->throttle_thermal_policy_mode; in throttle_thermal_policy_write()
3415 sysfs_notify(&asus->platform_device->dev.kobj, NULL, in throttle_thermal_policy_write()
3426 return -EIO; in throttle_thermal_policy_write()
3430 if (asus->cpu_fan_curve_available) in throttle_thermal_policy_write()
3431 asus->custom_fan_curves[FAN_CURVE_DEV_CPU].enabled = false; in throttle_thermal_policy_write()
3432 if (asus->gpu_fan_curve_available) in throttle_thermal_policy_write()
3433 asus->custom_fan_curves[FAN_CURVE_DEV_GPU].enabled = false; in throttle_thermal_policy_write()
3434 if (asus->mid_fan_curve_available) in throttle_thermal_policy_write()
3435 asus->custom_fan_curves[FAN_CURVE_DEV_MID].enabled = false; in throttle_thermal_policy_write()
3442 if (!asus->throttle_thermal_policy_available) in throttle_thermal_policy_set_default()
3445 asus->throttle_thermal_policy_mode = ASUS_THROTTLE_THERMAL_POLICY_DEFAULT; in throttle_thermal_policy_set_default()
3451 u8 new_mode = asus->throttle_thermal_policy_mode + 1; in throttle_thermal_policy_switch_next()
3457 asus->throttle_thermal_policy_mode = new_mode; in throttle_thermal_policy_switch_next()
3475 u8 mode = asus->throttle_thermal_policy_mode; in throttle_thermal_policy_show()
3494 return -EINVAL; in throttle_thermal_policy_store()
3496 asus->throttle_thermal_policy_mode = new_mode; in throttle_thermal_policy_store()
3510 // Throttle thermal policy: 0 - default, 1 - overboost, 2 - silent
3513 /* Platform profile ***********************************************************/
3515 enum platform_profile_option *profile) in asus_wmi_platform_profile_get() argument
3522 tp = asus->throttle_thermal_policy_mode; in asus_wmi_platform_profile_get()
3526 *profile = PLATFORM_PROFILE_BALANCED; in asus_wmi_platform_profile_get()
3529 *profile = PLATFORM_PROFILE_PERFORMANCE; in asus_wmi_platform_profile_get()
3532 *profile = PLATFORM_PROFILE_QUIET; in asus_wmi_platform_profile_get()
3535 return -EINVAL; in asus_wmi_platform_profile_get()
3542 enum platform_profile_option profile) in asus_wmi_platform_profile_set() argument
3549 switch (profile) { in asus_wmi_platform_profile_set()
3560 return -EOPNOTSUPP; in asus_wmi_platform_profile_set()
3563 asus->throttle_thermal_policy_mode = tp; in asus_wmi_platform_profile_set()
3569 struct device *dev = &asus->platform_device->dev; in platform_profile_setup()
3576 if (!asus->throttle_thermal_policy_available) in platform_profile_setup()
3581 asus->platform_profile_handler.profile_get = asus_wmi_platform_profile_get; in platform_profile_setup()
3582 asus->platform_profile_handler.profile_set = asus_wmi_platform_profile_set; in platform_profile_setup()
3584 set_bit(PLATFORM_PROFILE_QUIET, asus->platform_profile_handler.choices); in platform_profile_setup()
3586 asus->platform_profile_handler.choices); in platform_profile_setup()
3588 asus->platform_profile_handler.choices); in platform_profile_setup()
3590 err = platform_profile_register(&asus->platform_profile_handler); in platform_profile_setup()
3594 asus->platform_profile_support = true; in platform_profile_setup()
3604 if (asus->driver->quirks->store_backlight_power) in read_backlight_power()
3605 ret = !asus->driver->panel_power; in read_backlight_power()
3629 return -ENODEV; in read_brightness_max()
3652 if ((asus->driver->brightness < bd->props.brightness) || in get_scalar_command()
3653 bd->props.brightness == bd->props.max_brightness) in get_scalar_command()
3655 else if ((asus->driver->brightness > bd->props.brightness) || in get_scalar_command()
3656 bd->props.brightness == 0) in get_scalar_command()
3659 asus->driver->brightness = bd->props.brightness; in get_scalar_command()
3671 if (power != -ENODEV && bd->props.power != power) { in update_bl_status()
3672 ctrl_param = !!(bd->props.power == FB_BLANK_UNBLANK); in update_bl_status()
3675 if (asus->driver->quirks->store_backlight_power) in update_bl_status()
3676 asus->driver->panel_power = bd->props.power; in update_bl_status()
3680 if (asus->driver->quirks->scalar_panel_brightness) in update_bl_status()
3684 if (asus->driver->quirks->scalar_panel_brightness) in update_bl_status()
3687 ctrl_param = bd->props.brightness; in update_bl_status()
3702 struct backlight_device *bd = asus->backlight_device; in asus_wmi_backlight_notify()
3703 int old = bd->props.brightness; in asus_wmi_backlight_notify()
3707 new = code - NOTIFY_BRNUP_MIN + 1; in asus_wmi_backlight_notify()
3709 new = code - NOTIFY_BRNDOWN_MIN; in asus_wmi_backlight_notify()
3711 bd->props.brightness = new; in asus_wmi_backlight_notify()
3730 if (power == -ENODEV) in asus_wmi_backlight_init()
3738 bd = backlight_device_register(asus->driver->name, in asus_wmi_backlight_init()
3739 &asus->platform_device->dev, asus, in asus_wmi_backlight_init()
3746 asus->backlight_device = bd; in asus_wmi_backlight_init()
3748 if (asus->driver->quirks->store_backlight_power) in asus_wmi_backlight_init()
3749 asus->driver->panel_power = power; in asus_wmi_backlight_init()
3751 bd->props.brightness = read_brightness(bd); in asus_wmi_backlight_init()
3752 bd->props.power = power; in asus_wmi_backlight_init()
3755 asus->driver->brightness = bd->props.brightness; in asus_wmi_backlight_init()
3762 backlight_device_unregister(asus->backlight_device); in asus_wmi_backlight_exit()
3764 asus->backlight_device = NULL; in asus_wmi_backlight_exit()
3779 /* Fn-lock ********************************************************************/
3793 int mode = asus->fnlock_locked; in asus_wmi_fnlock_update()
3811 return -EIO; in asus_wmi_get_event_code()
3816 if (obj && obj->type == ACPI_TYPE_INTEGER) in asus_wmi_get_event_code()
3817 code = (int)(obj->integer.value & WMI_EVENT_MASK); in asus_wmi_get_event_code()
3819 code = -EIO; in asus_wmi_get_event_code()
3830 if (asus->driver->key_filter) { in asus_wmi_handle_event_code()
3831 asus->driver->key_filter(asus->driver, &code, &key_value, in asus_wmi_handle_event_code()
3844 kbd_led_set_by_kbd(asus, asus->kbd_led_wk + 1); in asus_wmi_handle_event_code()
3848 kbd_led_set_by_kbd(asus, asus->kbd_led_wk - 1); in asus_wmi_handle_event_code()
3852 if (asus->kbd_led_wk == asus->kbd_led.max_brightness) in asus_wmi_handle_event_code()
3855 kbd_led_set_by_kbd(asus, asus->kbd_led_wk + 1); in asus_wmi_handle_event_code()
3860 asus->fnlock_locked = !asus->fnlock_locked; in asus_wmi_handle_event_code()
3865 if (code == asus->tablet_switch_event_code) { in asus_wmi_handle_event_code()
3871 if (asus->fan_boost_mode_available) in asus_wmi_handle_event_code()
3873 if (asus->throttle_thermal_policy_available) in asus_wmi_handle_event_code()
3879 if (is_display_toggle(code) && asus->driver->quirks->no_display_toggle) in asus_wmi_handle_event_code()
3882 if (!sparse_keymap_report_event(asus->inputdev, code, in asus_wmi_handle_event_code()
3909 if (!asus->wmi_event_queue || value != WMI_EVENT_VALUE_ATK) in asus_wmi_notify()
3933 return -EIO; in asus_wmi_notify_queue_flush()
4010 return -EINVAL; in cpufv_store()
4053 int devid = -1; in asus_sysfs_is_visible()
4066 ok = asus->charge_mode_available; in asus_sysfs_is_visible()
4068 ok = asus->egpu_enable_available; in asus_sysfs_is_visible()
4070 ok = asus->egpu_connect_available; in asus_sysfs_is_visible()
4072 ok = asus->dgpu_disable_available; in asus_sysfs_is_visible()
4074 ok = asus->gpu_mux_mode_available; in asus_sysfs_is_visible()
4076 ok = asus->fan_boost_mode_available; in asus_sysfs_is_visible()
4078 ok = asus->throttle_thermal_policy_available; in asus_sysfs_is_visible()
4080 ok = asus->ppt_pl2_sppt_available; in asus_sysfs_is_visible()
4082 ok = asus->ppt_pl1_spl_available; in asus_sysfs_is_visible()
4084 ok = asus->ppt_fppt_available; in asus_sysfs_is_visible()
4086 ok = asus->ppt_apu_sppt_available; in asus_sysfs_is_visible()
4088 ok = asus->ppt_plat_sppt_available; in asus_sysfs_is_visible()
4090 ok = asus->nv_dyn_boost_available; in asus_sysfs_is_visible()
4092 ok = asus->nv_temp_tgt_available; in asus_sysfs_is_visible()
4094 ok = asus->panel_overdrive_available; in asus_sysfs_is_visible()
4096 ok = asus->mini_led_mode_available; in asus_sysfs_is_visible()
4098 if (devid != -1) in asus_sysfs_is_visible()
4101 return ok ? attr->mode : 0; in asus_sysfs_is_visible()
4111 sysfs_remove_group(&device->dev.kobj, &platform_attribute_group); in asus_wmi_sysfs_exit()
4116 return sysfs_create_group(&device->dev.kobj, &platform_attribute_group); in asus_wmi_sysfs_init()
4123 struct device *dev = &asus->platform_device->dev; in asus_wmi_platform_init()
4134 asus->spec = rv; in asus_wmi_platform_init()
4140 * bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card. in asus_wmi_platform_init()
4145 asus->sfun = rv; in asus_wmi_platform_init()
4163 return -ENODEV; in asus_wmi_platform_init()
4167 asus->dsts_id = ASUS_WMI_METHODID_DCTS; in asus_wmi_platform_init()
4170 asus->dsts_id = ASUS_WMI_METHODID_DSTS; in asus_wmi_platform_init()
4182 wmi_uid = wmi_get_acpi_device_uid(asus->driver->event_guid); in asus_wmi_platform_init()
4187 asus->wmi_event_queue = true; in asus_wmi_platform_init()
4192 if (asus->driver->quirks->wapf >= 0) in asus_wmi_platform_init()
4194 asus->driver->quirks->wapf, NULL); in asus_wmi_platform_init()
4209 struct asus_wmi *asus = m->private; in show_dsts()
4211 u32 retval = -1; in show_dsts()
4213 err = asus_wmi_get_devstate(asus, asus->debug.dev_id, &retval); in show_dsts()
4217 seq_printf(m, "DSTS(%#x) = %#x\n", asus->debug.dev_id, retval); in show_dsts()
4224 struct asus_wmi *asus = m->private; in show_devs()
4226 u32 retval = -1; in show_devs()
4228 err = asus_wmi_set_devstate(asus->debug.dev_id, asus->debug.ctrl_param, in show_devs()
4233 seq_printf(m, "DEVS(%#x, %#x) = %#x\n", asus->debug.dev_id, in show_devs()
4234 asus->debug.ctrl_param, retval); in show_devs()
4241 struct asus_wmi *asus = m->private; in show_call()
4243 .arg0 = asus->debug.dev_id, in show_call()
4244 .arg1 = asus->debug.ctrl_param, in show_call()
4252 0, asus->debug.method_id, in show_call()
4256 return -EIO; in show_call()
4259 if (obj && obj->type == ACPI_TYPE_INTEGER) in show_call()
4260 seq_printf(m, "%#x(%#x, %#x) = %#x\n", asus->debug.method_id, in show_call()
4261 asus->debug.dev_id, asus->debug.ctrl_param, in show_call()
4262 (u32) obj->integer.value); in show_call()
4264 seq_printf(m, "%#x(%#x, %#x) = t:%d\n", asus->debug.method_id, in show_call()
4265 asus->debug.dev_id, asus->debug.ctrl_param, in show_call()
4266 obj ? obj->type : -1); in show_call()
4281 struct asus_wmi_debugfs_node *node = inode->i_private; in asus_wmi_debugfs_open()
4283 return single_open(file, node->show, node->asus); in asus_wmi_debugfs_open()
4296 debugfs_remove_recursive(asus->debug.root); in asus_wmi_debugfs_exit()
4303 asus->debug.root = debugfs_create_dir(asus->driver->name, NULL); in asus_wmi_debugfs_init()
4305 debugfs_create_x32("method_id", S_IRUGO | S_IWUSR, asus->debug.root, in asus_wmi_debugfs_init()
4306 &asus->debug.method_id); in asus_wmi_debugfs_init()
4308 debugfs_create_x32("dev_id", S_IRUGO | S_IWUSR, asus->debug.root, in asus_wmi_debugfs_init()
4309 &asus->debug.dev_id); in asus_wmi_debugfs_init()
4311 debugfs_create_x32("ctrl_param", S_IRUGO | S_IWUSR, asus->debug.root, in asus_wmi_debugfs_init()
4312 &asus->debug.ctrl_param); in asus_wmi_debugfs_init()
4317 node->asus = asus; in asus_wmi_debugfs_init()
4318 debugfs_create_file(node->name, S_IFREG | S_IRUGO, in asus_wmi_debugfs_init()
4319 asus->debug.root, node, in asus_wmi_debugfs_init()
4328 struct platform_driver *pdrv = to_platform_driver(pdev->dev.driver); in asus_wmi_add()
4337 return -ENOMEM; in asus_wmi_add()
4339 asus->driver = wdrv; in asus_wmi_add()
4340 asus->platform_device = pdev; in asus_wmi_add()
4341 wdrv->platform_device = pdev; in asus_wmi_add()
4342 platform_set_drvdata(asus->platform_device, asus); in asus_wmi_add()
4344 if (wdrv->detect_quirks) in asus_wmi_add()
4345 wdrv->detect_quirks(asus->driver); in asus_wmi_add()
4351 asus->charge_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CHARGE_MODE); in asus_wmi_add()
4352 asus->egpu_enable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU); in asus_wmi_add()
4353 asus->egpu_connect_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU_CONNECTED); in asus_wmi_add()
4354 asus->dgpu_disable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_DGPU); in asus_wmi_add()
4355 asus->gpu_mux_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_MUX); in asus_wmi_add()
4356 asus->kbd_rgb_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE); in asus_wmi_add()
4357 asus->kbd_rgb_state_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_STATE); in asus_wmi_add()
4358 asus->ppt_pl2_sppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_PL2_SPPT); in asus_wmi_add()
4359 asus->ppt_pl1_spl_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_PL1_SPL); in asus_wmi_add()
4360 asus->ppt_fppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_FPPT); in asus_wmi_add()
4361 asus->ppt_apu_sppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_APU_SPPT); in asus_wmi_add()
4362 asus->ppt_plat_sppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_PLAT_SPPT); in asus_wmi_add()
4363 asus->nv_dyn_boost_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_DYN_BOOST); in asus_wmi_add()
4364 asus->nv_temp_tgt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_THERM_TARGET); in asus_wmi_add()
4365 asus->panel_overdrive_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PANEL_OD); in asus_wmi_add()
4366 asus->mini_led_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE); in asus_wmi_add()
4382 err = asus_wmi_sysfs_init(asus->platform_device); in asus_wmi_add()
4406 asus->driver->wlan_ctrl_by_user = 1; in asus_wmi_add()
4408 if (!(asus->driver->wlan_ctrl_by_user && ashs_present())) { in asus_wmi_add()
4414 if (asus->driver->quirks->wmi_force_als_set) in asus_wmi_add()
4417 if (asus->driver->quirks->xusb2pr) in asus_wmi_add()
4422 if (err && err != -ENODEV) in asus_wmi_add()
4424 } else if (asus->driver->quirks->wmi_backlight_set_devstate) in asus_wmi_add()
4428 asus->fnlock_locked = fnlock_default; in asus_wmi_add()
4432 status = wmi_install_notify_handler(asus->driver->event_guid, in asus_wmi_add()
4435 pr_err("Unable to register notify handler - %d\n", status); in asus_wmi_add()
4436 err = -ENODEV; in asus_wmi_add()
4456 asus_wmi_sysfs_exit(asus->platform_device); in asus_wmi_add()
4461 if (asus->platform_profile_support) in asus_wmi_add()
4474 wmi_remove_notify_handler(asus->driver->event_guid); in asus_wmi_remove()
4480 asus_wmi_sysfs_exit(asus->platform_device); in asus_wmi_remove()
4485 if (asus->platform_profile_support) in asus_wmi_remove()
4492 /* Platform driver - hibernate/resume callbacks *******************************/
4498 if (asus->wlan.rfkill) { in asus_hotk_thaw()
4502 * Work around bios bug - acpi _PTS turns off the wireless led in asus_hotk_thaw()
4517 if (!IS_ERR_OR_NULL(asus->kbd_led.dev)) in asus_hotk_resume()
4533 if (asus->wlan.rfkill) in asus_hotk_restore()
4536 if (asus->bluetooth.rfkill) { in asus_hotk_restore()
4539 rfkill_set_sw_state(asus->bluetooth.rfkill, bl); in asus_hotk_restore()
4541 if (asus->wimax.rfkill) { in asus_hotk_restore()
4543 rfkill_set_sw_state(asus->wimax.rfkill, bl); in asus_hotk_restore()
4545 if (asus->wwan3g.rfkill) { in asus_hotk_restore()
4547 rfkill_set_sw_state(asus->wwan3g.rfkill, bl); in asus_hotk_restore()
4549 if (asus->gps.rfkill) { in asus_hotk_restore()
4551 rfkill_set_sw_state(asus->gps.rfkill, bl); in asus_hotk_restore()
4553 if (asus->uwb.rfkill) { in asus_hotk_restore()
4555 rfkill_set_sw_state(asus->uwb.rfkill, bl); in asus_hotk_restore()
4557 if (!IS_ERR_OR_NULL(asus->kbd_led.dev)) in asus_hotk_restore()
4577 struct platform_driver *pdrv = to_platform_driver(pdev->dev.driver); in asus_wmi_probe()
4583 return -ENODEV; in asus_wmi_probe()
4586 if (wdrv->event_guid && !wmi_has_guid(wdrv->event_guid)) { in asus_wmi_probe()
4588 return -ENODEV; in asus_wmi_probe()
4591 if (wdrv->probe) { in asus_wmi_probe()
4592 ret = wdrv->probe(pdev); in asus_wmi_probe()
4608 return -EBUSY; in asus_wmi_register_driver()
4610 platform_driver = &driver->platform_driver; in asus_wmi_register_driver()
4611 platform_driver->remove = asus_wmi_remove; in asus_wmi_register_driver()
4612 platform_driver->driver.owner = driver->owner; in asus_wmi_register_driver()
4613 platform_driver->driver.name = driver->name; in asus_wmi_register_driver()
4614 platform_driver->driver.pm = &asus_pm_ops; in asus_wmi_register_driver()
4629 platform_device_unregister(driver->platform_device); in asus_wmi_unregister_driver()
4630 platform_driver_unregister(&driver->platform_driver); in asus_wmi_unregister_driver()