Lines Matching full:asus

3  * Asus PC WMI hotkey driver
32 #include <linux/platform_data/x86/asus-wmi.h>
45 #include "asus-wmi.h"
49 MODULE_DESCRIPTION("Asus Generic WMI Driver");
120 /* Limits for tunables available on ASUS ROG laptops */
223 struct asus_wmi *asus; member
296 /* Tunables provided by ASUS for gaming laptops */
537 static int asus_wmi_get_devstate(struct asus_wmi *asus, u32 dev_id, u32 *retval) in asus_wmi_get_devstate() argument
541 err = asus_wmi_evaluate_method(asus->dsts_id, dev_id, 0, retval); in asus_wmi_get_devstate()
560 static int asus_wmi_get_devstate_bits(struct asus_wmi *asus, in asus_wmi_get_devstate_bits() argument
566 err = asus_wmi_get_devstate(asus, dev_id, &retval); in asus_wmi_get_devstate_bits()
581 static int asus_wmi_get_devstate_simple(struct asus_wmi *asus, u32 dev_id) in asus_wmi_get_devstate_simple() argument
583 return asus_wmi_get_devstate_bits(asus, dev_id, in asus_wmi_get_devstate_simple()
587 static bool asus_wmi_dev_is_present(struct asus_wmi *asus, u32 dev_id) in asus_wmi_dev_is_present() argument
590 int status = asus_wmi_get_devstate(asus, dev_id, &retval); in asus_wmi_dev_is_present()
597 static void asus_wmi_tablet_sw_report(struct asus_wmi *asus, bool value) in asus_wmi_tablet_sw_report() argument
599 input_report_switch(asus->inputdev, SW_TABLET_MODE, in asus_wmi_tablet_sw_report()
600 asus->tablet_switch_inverted ? !value : value); in asus_wmi_tablet_sw_report()
601 input_sync(asus->inputdev); in asus_wmi_tablet_sw_report()
604 static void asus_wmi_tablet_sw_init(struct asus_wmi *asus, u32 dev_id, int event_code) in asus_wmi_tablet_sw_init() argument
606 struct device *dev = &asus->platform_device->dev; in asus_wmi_tablet_sw_init()
609 result = asus_wmi_get_devstate_simple(asus, dev_id); in asus_wmi_tablet_sw_init()
611 input_set_capability(asus->inputdev, EV_SW, SW_TABLET_MODE); in asus_wmi_tablet_sw_init()
612 asus_wmi_tablet_sw_report(asus, result); in asus_wmi_tablet_sw_init()
613 asus->tablet_switch_dev_id = dev_id; in asus_wmi_tablet_sw_init()
614 asus->tablet_switch_event_code = event_code; in asus_wmi_tablet_sw_init()
622 static int asus_wmi_input_init(struct asus_wmi *asus) in asus_wmi_input_init() argument
624 struct device *dev = &asus->platform_device->dev; in asus_wmi_input_init()
627 asus->inputdev = input_allocate_device(); in asus_wmi_input_init()
628 if (!asus->inputdev) in asus_wmi_input_init()
631 asus->inputdev->name = asus->driver->input_name; in asus_wmi_input_init()
632 asus->inputdev->phys = asus->driver->input_phys; in asus_wmi_input_init()
633 asus->inputdev->id.bustype = BUS_HOST; in asus_wmi_input_init()
634 asus->inputdev->dev.parent = dev; in asus_wmi_input_init()
635 set_bit(EV_REP, asus->inputdev->evbit); in asus_wmi_input_init()
637 err = sparse_keymap_setup(asus->inputdev, asus->driver->keymap, NULL); in asus_wmi_input_init()
641 switch (asus->driver->quirks->tablet_switch_mode) { in asus_wmi_input_init()
645 asus->tablet_switch_inverted = true; in asus_wmi_input_init()
646 asus_wmi_tablet_sw_init(asus, ASUS_WMI_DEVID_KBD_DOCK, NOTIFY_KBD_DOCK_CHANGE); in asus_wmi_input_init()
649 asus_wmi_tablet_sw_init(asus, ASUS_WMI_DEVID_LID_FLIP, NOTIFY_LID_FLIP); in asus_wmi_input_init()
652 asus_wmi_tablet_sw_init(asus, ASUS_WMI_DEVID_LID_FLIP_ROG, NOTIFY_LID_FLIP_ROG); in asus_wmi_input_init()
656 err = input_register_device(asus->inputdev); in asus_wmi_input_init()
663 input_free_device(asus->inputdev); in asus_wmi_input_init()
667 static void asus_wmi_input_exit(struct asus_wmi *asus) in asus_wmi_input_exit() argument
669 if (asus->inputdev) in asus_wmi_input_exit()
670 input_unregister_device(asus->inputdev); in asus_wmi_input_exit()
672 asus->inputdev = NULL; in asus_wmi_input_exit()
677 static void asus_wmi_tablet_mode_get_state(struct asus_wmi *asus) in asus_wmi_tablet_mode_get_state() argument
681 if (!asus->tablet_switch_dev_id) in asus_wmi_tablet_mode_get_state()
684 result = asus_wmi_get_devstate_simple(asus, asus->tablet_switch_dev_id); in asus_wmi_tablet_mode_get_state()
686 asus_wmi_tablet_sw_report(asus, result); in asus_wmi_tablet_mode_get_state()
693 struct asus_wmi *asus = dev_get_drvdata(dev); in charge_mode_show() local
696 result = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_CHARGE_MODE, &value); in charge_mode_show()
709 struct asus_wmi *asus = dev_get_drvdata(dev); in dgpu_disable_show() local
712 result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_DGPU); in dgpu_disable_show()
732 struct asus_wmi *asus = dev_get_drvdata(dev); in dgpu_disable_store() local
741 if (asus->gpu_mux_dev) { in dgpu_disable_store()
742 result = asus_wmi_get_devstate_simple(asus, asus->gpu_mux_dev); in dgpu_disable_store()
764 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "dgpu_disable"); in dgpu_disable_store()
774 struct asus_wmi *asus = dev_get_drvdata(dev); in egpu_enable_show() local
777 result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_EGPU); in egpu_enable_show()
792 struct asus_wmi *asus = dev_get_drvdata(dev); in egpu_enable_store() local
801 err = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_EGPU_CONNECTED); in egpu_enable_store()
807 if (asus->gpu_mux_dev) { in egpu_enable_store()
808 result = asus_wmi_get_devstate_simple(asus, asus->gpu_mux_dev); in egpu_enable_store()
832 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "egpu_enable"); in egpu_enable_store()
842 struct asus_wmi *asus = dev_get_drvdata(dev); in egpu_connected_show() local
845 result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_EGPU_CONNECTED); in egpu_connected_show()
858 struct asus_wmi *asus = dev_get_drvdata(dev); in gpu_mux_mode_show() local
861 result = asus_wmi_get_devstate_simple(asus, asus->gpu_mux_dev); in gpu_mux_mode_show()
872 struct asus_wmi *asus = dev_get_drvdata(dev); in gpu_mux_mode_store() local
883 if (asus->dgpu_disable_available) { in gpu_mux_mode_store()
884 result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_DGPU); in gpu_mux_mode_store()
895 if (asus->egpu_enable_available) { in gpu_mux_mode_store()
896 result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_EGPU); in gpu_mux_mode_store()
907 err = asus_wmi_set_devstate(asus->gpu_mux_dev, optimus, &result); in gpu_mux_mode_store()
912 /* !1 is considered a fail by ASUS */ in gpu_mux_mode_store()
918 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "gpu_mux_mode"); in gpu_mux_mode_store()
931 struct asus_wmi *asus; in kbd_rgb_mode_store() local
935 asus = container_of(led, struct asus_wmi, kbd_led); in kbd_rgb_mode_store()
970 err = asus_wmi_evaluate_method3(ASUS_WMI_METHODID_DEVS, asus->kbd_rgb_dev, in kbd_rgb_mode_store()
1050 struct asus_wmi *asus = dev_get_drvdata(dev); in ppt_pl2_sppt_store() local
1072 asus->ppt_pl2_sppt = value; in ppt_pl2_sppt_store()
1073 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_pl2_sppt"); in ppt_pl2_sppt_store()
1082 struct asus_wmi *asus = dev_get_drvdata(dev); in ppt_pl2_sppt_show() local
1084 return sysfs_emit(buf, "%u\n", asus->ppt_pl2_sppt); in ppt_pl2_sppt_show()
1093 struct asus_wmi *asus = dev_get_drvdata(dev); in ppt_pl1_spl_store() local
1115 asus->ppt_pl1_spl = value; in ppt_pl1_spl_store()
1116 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_pl1_spl"); in ppt_pl1_spl_store()
1124 struct asus_wmi *asus = dev_get_drvdata(dev); in ppt_pl1_spl_show() local
1126 return sysfs_emit(buf, "%u\n", asus->ppt_pl1_spl); in ppt_pl1_spl_show()
1135 struct asus_wmi *asus = dev_get_drvdata(dev); in ppt_fppt_store() local
1157 asus->ppt_fppt = value; in ppt_fppt_store()
1158 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_fpu_sppt"); in ppt_fppt_store()
1167 struct asus_wmi *asus = dev_get_drvdata(dev); in ppt_fppt_show() local
1169 return sysfs_emit(buf, "%u\n", asus->ppt_fppt); in ppt_fppt_show()
1178 struct asus_wmi *asus = dev_get_drvdata(dev); in ppt_apu_sppt_store() local
1200 asus->ppt_apu_sppt = value; in ppt_apu_sppt_store()
1201 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_apu_sppt"); in ppt_apu_sppt_store()
1210 struct asus_wmi *asus = dev_get_drvdata(dev); in ppt_apu_sppt_show() local
1212 return sysfs_emit(buf, "%u\n", asus->ppt_apu_sppt); in ppt_apu_sppt_show()
1221 struct asus_wmi *asus = dev_get_drvdata(dev); in ppt_platform_sppt_store() local
1243 asus->ppt_platform_sppt = value; in ppt_platform_sppt_store()
1244 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_platform_sppt"); in ppt_platform_sppt_store()
1253 struct asus_wmi *asus = dev_get_drvdata(dev); in ppt_platform_sppt_show() local
1255 return sysfs_emit(buf, "%u\n", asus->ppt_platform_sppt); in ppt_platform_sppt_show()
1264 struct asus_wmi *asus = dev_get_drvdata(dev); in nv_dynamic_boost_store() local
1286 asus->nv_dynamic_boost = value; in nv_dynamic_boost_store()
1287 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "nv_dynamic_boost"); in nv_dynamic_boost_store()
1296 struct asus_wmi *asus = dev_get_drvdata(dev); in nv_dynamic_boost_show() local
1298 return sysfs_emit(buf, "%u\n", asus->nv_dynamic_boost); in nv_dynamic_boost_show()
1307 struct asus_wmi *asus = dev_get_drvdata(dev); in nv_temp_target_store() local
1329 asus->nv_temp_target = value; in nv_temp_target_store()
1330 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "nv_temp_target"); in nv_temp_target_store()
1339 struct asus_wmi *asus = dev_get_drvdata(dev); in nv_temp_target_show() local
1341 return sysfs_emit(buf, "%u\n", asus->nv_temp_target); in nv_temp_target_show()
1349 struct asus_wmi *asus = dev_get_drvdata(dev); in mcu_powersave_show() local
1352 result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_MCU_POWERSAVE); in mcu_powersave_show()
1366 struct asus_wmi *asus = dev_get_drvdata(dev); in mcu_powersave_store() local
1386 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "mcu_powersave"); in mcu_powersave_store()
1437 * Note: On some newer ASUS laptops (Zenbook UM431DA), the primary/first in asus_wmi_battery_add()
1470 .name = "ASUS Battery Extension",
1473 static void asus_wmi_battery_init(struct asus_wmi *asus) in asus_wmi_battery_init() argument
1475 asus->battery_rsoc_available = false; in asus_wmi_battery_init()
1476 if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_RSOC)) { in asus_wmi_battery_init()
1477 asus->battery_rsoc_available = true; in asus_wmi_battery_init()
1482 static void asus_wmi_battery_exit(struct asus_wmi *asus) in asus_wmi_battery_exit() argument
1484 if (asus->battery_rsoc_available) in asus_wmi_battery_exit()
1493 * subsystem asks, we avoid messing with the Asus ACPI stuff during a
1499 struct asus_wmi *asus; in tpd_led_update() local
1501 asus = container_of(work, struct asus_wmi, tpd_led_work); in tpd_led_update()
1503 ctrl_param = asus->tpd_led_wk; in tpd_led_update()
1510 struct asus_wmi *asus; in tpd_led_set() local
1512 asus = container_of(led_cdev, struct asus_wmi, tpd_led); in tpd_led_set()
1514 asus->tpd_led_wk = !!value; in tpd_led_set()
1515 queue_work(asus->led_workqueue, &asus->tpd_led_work); in tpd_led_set()
1518 static int read_tpd_led_state(struct asus_wmi *asus) in read_tpd_led_state() argument
1520 return asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_TOUCHPAD_LED); in read_tpd_led_state()
1525 struct asus_wmi *asus; in tpd_led_get() local
1527 asus = container_of(led_cdev, struct asus_wmi, tpd_led); in tpd_led_get()
1529 return read_tpd_led_state(asus); in tpd_led_get()
1532 static void kbd_led_update(struct asus_wmi *asus) in kbd_led_update() argument
1536 ctrl_param = 0x80 | (asus->kbd_led_wk & 0x7F); in kbd_led_update()
1540 static int kbd_led_read(struct asus_wmi *asus, int *level, int *env) in kbd_led_read() argument
1550 retval = asus_wmi_get_devstate_bits(asus, ASUS_WMI_DEVID_KBD_BACKLIGHT, in kbd_led_read()
1569 struct asus_wmi *asus; in do_kbd_led_set() local
1572 asus = container_of(led_cdev, struct asus_wmi, kbd_led); in do_kbd_led_set()
1573 max_level = asus->kbd_led.max_brightness; in do_kbd_led_set()
1575 asus->kbd_led_wk = clamp_val(value, 0, max_level); in do_kbd_led_set()
1576 kbd_led_update(asus); in do_kbd_led_set()
1589 static void kbd_led_set_by_kbd(struct asus_wmi *asus, enum led_brightness value) in kbd_led_set_by_kbd() argument
1591 struct led_classdev *led_cdev = &asus->kbd_led; in kbd_led_set_by_kbd()
1594 led_classdev_notify_brightness_hw_changed(led_cdev, asus->kbd_led_wk); in kbd_led_set_by_kbd()
1599 struct asus_wmi *asus; in kbd_led_get() local
1602 asus = container_of(led_cdev, struct asus_wmi, kbd_led); in kbd_led_get()
1604 retval = kbd_led_read(asus, &value, NULL); in kbd_led_get()
1611 static int wlan_led_unknown_state(struct asus_wmi *asus) in wlan_led_unknown_state() argument
1615 asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_WIRELESS_LED, &result); in wlan_led_unknown_state()
1623 struct asus_wmi *asus; in wlan_led_update() local
1625 asus = container_of(work, struct asus_wmi, wlan_led_work); in wlan_led_update()
1627 ctrl_param = asus->wlan_led_wk; in wlan_led_update()
1634 struct asus_wmi *asus; in wlan_led_set() local
1636 asus = container_of(led_cdev, struct asus_wmi, wlan_led); in wlan_led_set()
1638 asus->wlan_led_wk = !!value; in wlan_led_set()
1639 queue_work(asus->led_workqueue, &asus->wlan_led_work); in wlan_led_set()
1644 struct asus_wmi *asus; in wlan_led_get() local
1647 asus = container_of(led_cdev, struct asus_wmi, wlan_led); in wlan_led_get()
1648 asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_WIRELESS_LED, &result); in wlan_led_get()
1655 struct asus_wmi *asus; in lightbar_led_update() local
1658 asus = container_of(work, struct asus_wmi, lightbar_led_work); in lightbar_led_update()
1660 ctrl_param = asus->lightbar_led_wk; in lightbar_led_update()
1667 struct asus_wmi *asus; in lightbar_led_set() local
1669 asus = container_of(led_cdev, struct asus_wmi, lightbar_led); in lightbar_led_set()
1671 asus->lightbar_led_wk = !!value; in lightbar_led_set()
1672 queue_work(asus->led_workqueue, &asus->lightbar_led_work); in lightbar_led_set()
1677 struct asus_wmi *asus; in lightbar_led_get() local
1680 asus = container_of(led_cdev, struct asus_wmi, lightbar_led); in lightbar_led_get()
1681 asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_LIGHTBAR, &result); in lightbar_led_get()
1698 struct asus_wmi *asus; in camera_led_get() local
1701 asus = container_of(led_cdev, struct asus_wmi, camera_led); in camera_led_get()
1702 asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_CAMERA_LED, &result); in camera_led_get()
1717 static void asus_wmi_led_exit(struct asus_wmi *asus) in asus_wmi_led_exit() argument
1719 led_classdev_unregister(&asus->kbd_led); in asus_wmi_led_exit()
1720 led_classdev_unregister(&asus->tpd_led); in asus_wmi_led_exit()
1721 led_classdev_unregister(&asus->wlan_led); in asus_wmi_led_exit()
1722 led_classdev_unregister(&asus->lightbar_led); in asus_wmi_led_exit()
1723 led_classdev_unregister(&asus->micmute_led); in asus_wmi_led_exit()
1724 led_classdev_unregister(&asus->camera_led); in asus_wmi_led_exit()
1726 if (asus->led_workqueue) in asus_wmi_led_exit()
1727 destroy_workqueue(asus->led_workqueue); in asus_wmi_led_exit()
1730 static int asus_wmi_led_init(struct asus_wmi *asus) in asus_wmi_led_init() argument
1734 if (asus->kbd_rgb_dev) in asus_wmi_led_init()
1736 if (asus->kbd_rgb_state_available) in asus_wmi_led_init()
1739 asus->led_workqueue = create_singlethread_workqueue("led_workqueue"); in asus_wmi_led_init()
1740 if (!asus->led_workqueue) in asus_wmi_led_init()
1743 if (read_tpd_led_state(asus) >= 0) { in asus_wmi_led_init()
1744 INIT_WORK(&asus->tpd_led_work, tpd_led_update); in asus_wmi_led_init()
1746 asus->tpd_led.name = "asus::touchpad"; in asus_wmi_led_init()
1747 asus->tpd_led.brightness_set = tpd_led_set; in asus_wmi_led_init()
1748 asus->tpd_led.brightness_get = tpd_led_get; in asus_wmi_led_init()
1749 asus->tpd_led.max_brightness = 1; in asus_wmi_led_init()
1751 rv = led_classdev_register(&asus->platform_device->dev, in asus_wmi_led_init()
1752 &asus->tpd_led); in asus_wmi_led_init()
1757 if (!kbd_led_read(asus, &led_val, NULL) && !dmi_check_system(asus_use_hid_led_dmi_ids)) { in asus_wmi_led_init()
1758 pr_info("using asus-wmi for asus::kbd_backlight\n"); in asus_wmi_led_init()
1759 asus->kbd_led_wk = led_val; in asus_wmi_led_init()
1760 asus->kbd_led.name = "asus::kbd_backlight"; in asus_wmi_led_init()
1761 asus->kbd_led.flags = LED_BRIGHT_HW_CHANGED; in asus_wmi_led_init()
1762 asus->kbd_led.brightness_set = kbd_led_set; in asus_wmi_led_init()
1763 asus->kbd_led.brightness_get = kbd_led_get; in asus_wmi_led_init()
1764 asus->kbd_led.max_brightness = 3; in asus_wmi_led_init()
1767 asus->kbd_led.groups = kbd_rgb_mode_groups; in asus_wmi_led_init()
1769 rv = led_classdev_register(&asus->platform_device->dev, in asus_wmi_led_init()
1770 &asus->kbd_led); in asus_wmi_led_init()
1775 if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_WIRELESS_LED) in asus_wmi_led_init()
1776 && (asus->driver->quirks->wapf > 0)) { in asus_wmi_led_init()
1777 INIT_WORK(&asus->wlan_led_work, wlan_led_update); in asus_wmi_led_init()
1779 asus->wlan_led.name = "asus::wlan"; in asus_wmi_led_init()
1780 asus->wlan_led.brightness_set = wlan_led_set; in asus_wmi_led_init()
1781 if (!wlan_led_unknown_state(asus)) in asus_wmi_led_init()
1782 asus->wlan_led.brightness_get = wlan_led_get; in asus_wmi_led_init()
1783 asus->wlan_led.flags = LED_CORE_SUSPENDRESUME; in asus_wmi_led_init()
1784 asus->wlan_led.max_brightness = 1; in asus_wmi_led_init()
1785 asus->wlan_led.default_trigger = "asus-wlan"; in asus_wmi_led_init()
1787 rv = led_classdev_register(&asus->platform_device->dev, in asus_wmi_led_init()
1788 &asus->wlan_led); in asus_wmi_led_init()
1793 if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_LIGHTBAR)) { in asus_wmi_led_init()
1794 INIT_WORK(&asus->lightbar_led_work, lightbar_led_update); in asus_wmi_led_init()
1796 asus->lightbar_led.name = "asus::lightbar"; in asus_wmi_led_init()
1797 asus->lightbar_led.brightness_set = lightbar_led_set; in asus_wmi_led_init()
1798 asus->lightbar_led.brightness_get = lightbar_led_get; in asus_wmi_led_init()
1799 asus->lightbar_led.max_brightness = 1; in asus_wmi_led_init()
1801 rv = led_classdev_register(&asus->platform_device->dev, in asus_wmi_led_init()
1802 &asus->lightbar_led); in asus_wmi_led_init()
1805 if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MICMUTE_LED)) { in asus_wmi_led_init()
1806 asus->micmute_led.name = "platform::micmute"; in asus_wmi_led_init()
1807 asus->micmute_led.max_brightness = 1; in asus_wmi_led_init()
1808 asus->micmute_led.brightness_set_blocking = micmute_led_set; in asus_wmi_led_init()
1809 asus->micmute_led.default_trigger = "audio-micmute"; in asus_wmi_led_init()
1811 rv = led_classdev_register(&asus->platform_device->dev, in asus_wmi_led_init()
1812 &asus->micmute_led); in asus_wmi_led_init()
1817 if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CAMERA_LED)) { in asus_wmi_led_init()
1818 asus->camera_led.name = "asus::camera"; in asus_wmi_led_init()
1819 asus->camera_led.max_brightness = 1; in asus_wmi_led_init()
1820 asus->camera_led.brightness_get = camera_led_get; in asus_wmi_led_init()
1821 asus->camera_led.brightness_set_blocking = camera_led_set; in asus_wmi_led_init()
1823 rv = led_classdev_register(&asus->platform_device->dev, in asus_wmi_led_init()
1824 &asus->camera_led); in asus_wmi_led_init()
1829 if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_OOBE)) { in asus_wmi_led_init()
1841 asus_wmi_led_exit(asus); in asus_wmi_led_init()
1851 static bool asus_wlan_rfkill_blocked(struct asus_wmi *asus) in asus_wlan_rfkill_blocked() argument
1853 int result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_WLAN); in asus_wlan_rfkill_blocked()
1860 static void asus_rfkill_hotplug(struct asus_wmi *asus) in asus_rfkill_hotplug() argument
1868 mutex_lock(&asus->wmi_lock); in asus_rfkill_hotplug()
1869 blocked = asus_wlan_rfkill_blocked(asus); in asus_rfkill_hotplug()
1870 mutex_unlock(&asus->wmi_lock); in asus_rfkill_hotplug()
1872 mutex_lock(&asus->hotplug_lock); in asus_rfkill_hotplug()
1875 if (asus->wlan.rfkill) in asus_rfkill_hotplug()
1876 rfkill_set_sw_state(asus->wlan.rfkill, blocked); in asus_rfkill_hotplug()
1878 if (asus->hotplug_slot.ops) { in asus_rfkill_hotplug()
1922 mutex_unlock(&asus->hotplug_lock); in asus_rfkill_hotplug()
1927 struct asus_wmi *asus = data; in asus_rfkill_notify() local
1939 queue_work(asus->hotplug_workqueue, &asus->hotplug_work); in asus_rfkill_notify()
1942 static int asus_register_rfkill_notifier(struct asus_wmi *asus, char *node) in asus_register_rfkill_notifier() argument
1952 asus_rfkill_notify, asus); in asus_register_rfkill_notifier()
1959 static void asus_unregister_rfkill_notifier(struct asus_wmi *asus, char *node) in asus_unregister_rfkill_notifier() argument
1977 struct asus_wmi *asus = container_of(hotplug_slot, in asus_get_adapter_status() local
1979 int result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_WLAN); in asus_get_adapter_status()
1995 struct asus_wmi *asus; in asus_hotplug_work() local
1997 asus = container_of(work, struct asus_wmi, hotplug_work); in asus_hotplug_work()
1998 asus_rfkill_hotplug(asus); in asus_hotplug_work()
2001 static int asus_setup_pci_hotplug(struct asus_wmi *asus) in asus_setup_pci_hotplug() argument
2011 asus->hotplug_workqueue = in asus_setup_pci_hotplug()
2013 if (!asus->hotplug_workqueue) in asus_setup_pci_hotplug()
2016 INIT_WORK(&asus->hotplug_work, asus_hotplug_work); in asus_setup_pci_hotplug()
2018 asus->hotplug_slot.ops = &asus_hotplug_slot_ops; in asus_setup_pci_hotplug()
2020 ret = pci_hp_register(&asus->hotplug_slot, bus, 0, "asus-wifi"); in asus_setup_pci_hotplug()
2029 asus->hotplug_slot.ops = NULL; in asus_setup_pci_hotplug()
2030 destroy_workqueue(asus->hotplug_workqueue); in asus_setup_pci_hotplug()
2053 priv->asus->driver->wlan_ctrl_by_user) in asus_rfkill_set()
2064 result = asus_wmi_get_devstate_simple(priv->asus, priv->dev_id); in asus_rfkill_query()
2075 struct asus_wmi *asus = priv->asus; in asus_rfkill_wlan_set() local
2085 mutex_lock(&asus->wmi_lock); in asus_rfkill_wlan_set()
2087 mutex_unlock(&asus->wmi_lock); in asus_rfkill_wlan_set()
2101 static int asus_new_rfkill(struct asus_wmi *asus, in asus_new_rfkill() argument
2105 int result = asus_wmi_get_devstate_simple(asus, dev_id); in asus_new_rfkill()
2112 arfkill->asus = asus; in asus_new_rfkill()
2115 asus->driver->quirks->hotplug_wireless) in asus_new_rfkill()
2116 *rfkill = rfkill_alloc(name, &asus->platform_device->dev, type, in asus_new_rfkill()
2119 *rfkill = rfkill_alloc(name, &asus->platform_device->dev, type, in asus_new_rfkill()
2126 (asus->driver->quirks->wapf > 0)) in asus_new_rfkill()
2127 rfkill_set_led_trigger_name(*rfkill, "asus-wlan"); in asus_new_rfkill()
2139 static void asus_wmi_rfkill_exit(struct asus_wmi *asus) in asus_wmi_rfkill_exit() argument
2141 if (asus->driver->wlan_ctrl_by_user && ashs_present()) in asus_wmi_rfkill_exit()
2144 asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P5"); in asus_wmi_rfkill_exit()
2145 asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P6"); in asus_wmi_rfkill_exit()
2146 asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P7"); in asus_wmi_rfkill_exit()
2147 if (asus->wlan.rfkill) { in asus_wmi_rfkill_exit()
2148 rfkill_unregister(asus->wlan.rfkill); in asus_wmi_rfkill_exit()
2149 rfkill_destroy(asus->wlan.rfkill); in asus_wmi_rfkill_exit()
2150 asus->wlan.rfkill = NULL; in asus_wmi_rfkill_exit()
2156 asus_rfkill_hotplug(asus); in asus_wmi_rfkill_exit()
2157 if (asus->hotplug_slot.ops) in asus_wmi_rfkill_exit()
2158 pci_hp_deregister(&asus->hotplug_slot); in asus_wmi_rfkill_exit()
2159 if (asus->hotplug_workqueue) in asus_wmi_rfkill_exit()
2160 destroy_workqueue(asus->hotplug_workqueue); in asus_wmi_rfkill_exit()
2162 if (asus->bluetooth.rfkill) { in asus_wmi_rfkill_exit()
2163 rfkill_unregister(asus->bluetooth.rfkill); in asus_wmi_rfkill_exit()
2164 rfkill_destroy(asus->bluetooth.rfkill); in asus_wmi_rfkill_exit()
2165 asus->bluetooth.rfkill = NULL; in asus_wmi_rfkill_exit()
2167 if (asus->wimax.rfkill) { in asus_wmi_rfkill_exit()
2168 rfkill_unregister(asus->wimax.rfkill); in asus_wmi_rfkill_exit()
2169 rfkill_destroy(asus->wimax.rfkill); in asus_wmi_rfkill_exit()
2170 asus->wimax.rfkill = NULL; in asus_wmi_rfkill_exit()
2172 if (asus->wwan3g.rfkill) { in asus_wmi_rfkill_exit()
2173 rfkill_unregister(asus->wwan3g.rfkill); in asus_wmi_rfkill_exit()
2174 rfkill_destroy(asus->wwan3g.rfkill); in asus_wmi_rfkill_exit()
2175 asus->wwan3g.rfkill = NULL; in asus_wmi_rfkill_exit()
2177 if (asus->gps.rfkill) { in asus_wmi_rfkill_exit()
2178 rfkill_unregister(asus->gps.rfkill); in asus_wmi_rfkill_exit()
2179 rfkill_destroy(asus->gps.rfkill); in asus_wmi_rfkill_exit()
2180 asus->gps.rfkill = NULL; in asus_wmi_rfkill_exit()
2182 if (asus->uwb.rfkill) { in asus_wmi_rfkill_exit()
2183 rfkill_unregister(asus->uwb.rfkill); in asus_wmi_rfkill_exit()
2184 rfkill_destroy(asus->uwb.rfkill); in asus_wmi_rfkill_exit()
2185 asus->uwb.rfkill = NULL; in asus_wmi_rfkill_exit()
2189 static int asus_wmi_rfkill_init(struct asus_wmi *asus) in asus_wmi_rfkill_init() argument
2193 mutex_init(&asus->hotplug_lock); in asus_wmi_rfkill_init()
2194 mutex_init(&asus->wmi_lock); in asus_wmi_rfkill_init()
2196 result = asus_new_rfkill(asus, &asus->wlan, "asus-wlan", in asus_wmi_rfkill_init()
2202 result = asus_new_rfkill(asus, &asus->bluetooth, in asus_wmi_rfkill_init()
2203 "asus-bluetooth", RFKILL_TYPE_BLUETOOTH, in asus_wmi_rfkill_init()
2209 result = asus_new_rfkill(asus, &asus->wimax, "asus-wimax", in asus_wmi_rfkill_init()
2215 result = asus_new_rfkill(asus, &asus->wwan3g, "asus-wwan3g", in asus_wmi_rfkill_init()
2221 result = asus_new_rfkill(asus, &asus->gps, "asus-gps", in asus_wmi_rfkill_init()
2227 result = asus_new_rfkill(asus, &asus->uwb, "asus-uwb", in asus_wmi_rfkill_init()
2233 if (!asus->driver->quirks->hotplug_wireless) in asus_wmi_rfkill_init()
2236 result = asus_setup_pci_hotplug(asus); in asus_wmi_rfkill_init()
2244 asus_register_rfkill_notifier(asus, "\\_SB.PCI0.P0P5"); in asus_wmi_rfkill_init()
2245 asus_register_rfkill_notifier(asus, "\\_SB.PCI0.P0P6"); in asus_wmi_rfkill_init()
2246 asus_register_rfkill_notifier(asus, "\\_SB.PCI0.P0P7"); in asus_wmi_rfkill_init()
2251 asus_rfkill_hotplug(asus); in asus_wmi_rfkill_init()
2255 asus_wmi_rfkill_exit(asus); in asus_wmi_rfkill_init()
2267 struct asus_wmi *asus = dev_get_drvdata(dev); in panel_od_show() local
2270 result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_PANEL_OD); in panel_od_show()
2284 struct asus_wmi *asus = dev_get_drvdata(dev); in panel_od_store() local
2305 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "panel_od"); in panel_od_store()
2316 struct asus_wmi *asus = dev_get_drvdata(dev); in boot_sound_show() local
2319 result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_BOOT_SOUND); in boot_sound_show()
2333 struct asus_wmi *asus = dev_get_drvdata(dev); in boot_sound_store() local
2353 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "boot_sound"); in boot_sound_store()
2363 struct asus_wmi *asus = dev_get_drvdata(dev); in mini_led_mode_show() local
2367 err = asus_wmi_get_devstate(asus, asus->mini_led_dev_id, &value); in mini_led_mode_show()
2376 if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2) { in mini_led_mode_show()
2400 struct asus_wmi *asus = dev_get_drvdata(dev); in mini_led_mode_store() local
2406 if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE && in mini_led_mode_store()
2409 if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2 && in mini_led_mode_store()
2417 if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2) { in mini_led_mode_store()
2431 err = asus_wmi_set_devstate(asus->mini_led_dev_id, mode, &result); in mini_led_mode_store()
2442 sysfs_notify(&asus->platform_device->dev.kobj, NULL, "mini_led_mode"); in mini_led_mode_store()
2451 struct asus_wmi *asus = dev_get_drvdata(dev); in available_mini_led_mode_show() local
2453 switch (asus->mini_led_dev_id) { in available_mini_led_mode_show()
2467 static void asus_wmi_set_xusb2pr(struct asus_wmi *asus) in asus_wmi_set_xusb2pr() argument
2471 u32 ports_available = asus->driver->quirks->xusb2pr; in asus_wmi_set_xusb2pr()
2503 static int asus_agfn_fan_speed_read(struct asus_wmi *asus, int fan, in asus_agfn_fan_speed_read() argument
2530 static int asus_agfn_fan_speed_write(struct asus_wmi *asus, int fan, in asus_agfn_fan_speed_write() argument
2553 asus->agfn_pwm = *speed; in asus_agfn_fan_speed_write()
2562 static bool asus_wmi_has_agfn_fan(struct asus_wmi *asus) in asus_wmi_has_agfn_fan() argument
2568 status = asus_agfn_fan_speed_read(asus, 1, &speed); in asus_wmi_has_agfn_fan()
2572 status = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FAN_CTRL, &value); in asus_wmi_has_agfn_fan()
2585 || (!asus->sfun && !(value & ASUS_WMI_DSTS_PRESENCE_BIT))); in asus_wmi_has_agfn_fan()
2588 static int asus_fan_set_auto(struct asus_wmi *asus) in asus_fan_set_auto() argument
2593 switch (asus->fan_type) { in asus_fan_set_auto()
2605 status = asus_agfn_fan_speed_write(asus, 0, NULL); in asus_fan_set_auto()
2617 if (asus->gpu_fan_type == FAN_TYPE_SPEC83) { in asus_fan_set_auto()
2634 struct asus_wmi *asus = dev_get_drvdata(dev); in pwm1_show() local
2639 if (asus->agfn_pwm >= 0) in pwm1_show()
2640 return sysfs_emit(buf, "%d\n", asus->agfn_pwm); in pwm1_show()
2646 err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FAN_CTRL, &value); in pwm1_show()
2669 struct asus_wmi *asus = dev_get_drvdata(dev); in pwm1_store() local
2680 state = asus_agfn_fan_speed_write(asus, 1, &value); in pwm1_store()
2684 asus->fan_pwm_mode = ASUS_FAN_CTRL_MANUAL; in pwm1_store()
2693 struct asus_wmi *asus = dev_get_drvdata(dev); in fan1_input_show() local
2697 switch (asus->fan_type) { in fan1_input_show()
2699 ret = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_CPU_FAN_CTRL, in fan1_input_show()
2709 if (asus->fan_pwm_mode == ASUS_FAN_CTRL_MANUAL) in fan1_input_show()
2712 ret = asus_agfn_fan_speed_read(asus, 1, &value); in fan1_input_show()
2730 struct asus_wmi *asus = dev_get_drvdata(dev); in pwm1_enable_show() local
2741 return sysfs_emit(buf, "%d\n", asus->fan_pwm_mode); in pwm1_enable_show()
2748 struct asus_wmi *asus = dev_get_drvdata(dev); in pwm1_enable_store() local
2759 if (asus->fan_type == FAN_TYPE_SPEC83) { in pwm1_enable_store()
2778 } else if (asus->fan_type == FAN_TYPE_AGFN) { in pwm1_enable_store()
2784 status = asus_fan_set_auto(asus); in pwm1_enable_store()
2794 asus->fan_pwm_mode = state; in pwm1_enable_store()
2797 if (asus->cpu_fan_curve_available) in pwm1_enable_store()
2798 asus->custom_fan_curves[FAN_CURVE_DEV_CPU].enabled = false; in pwm1_enable_store()
2799 if (asus->gpu_fan_curve_available) in pwm1_enable_store()
2800 asus->custom_fan_curves[FAN_CURVE_DEV_GPU].enabled = false; in pwm1_enable_store()
2801 if (asus->mid_fan_curve_available) in pwm1_enable_store()
2802 asus->custom_fan_curves[FAN_CURVE_DEV_MID].enabled = false; in pwm1_enable_store()
2811 struct asus_wmi *asus = dev_get_drvdata(dev); in asus_hwmon_temp1() local
2815 err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_THERMAL_CTRL, &value); in asus_hwmon_temp1()
2828 struct asus_wmi *asus = dev_get_drvdata(dev); in fan2_input_show() local
2832 ret = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_GPU_FAN_CTRL, &value); in fan2_input_show()
2846 struct asus_wmi *asus = dev_get_drvdata(dev); in fan3_input_show() local
2850 ret = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_MID_FAN_CTRL, &value); in fan3_input_show()
2863 struct asus_wmi *asus = dev_get_drvdata(dev); in pwm2_enable_show() local
2865 return sysfs_emit(buf, "%d\n", asus->gpu_fan_pwm_mode); in pwm2_enable_show()
2872 struct asus_wmi *asus = dev_get_drvdata(dev); in pwm2_enable_store() local
2901 asus->gpu_fan_pwm_mode = state; in pwm2_enable_store()
2909 struct asus_wmi *asus = dev_get_drvdata(dev); in pwm3_enable_show() local
2911 return sysfs_emit(buf, "%d\n", asus->mid_fan_pwm_mode); in pwm3_enable_show()
2918 struct asus_wmi *asus = dev_get_drvdata(dev); in pwm3_enable_store() local
2947 asus->mid_fan_pwm_mode = state; in pwm3_enable_store()
2989 struct asus_wmi *asus = dev_get_drvdata(dev->parent); in asus_hwmon_sysfs_is_visible() local
2993 if (asus->fan_type != FAN_TYPE_AGFN) in asus_hwmon_sysfs_is_visible()
2998 if (asus->fan_type == FAN_TYPE_NONE) in asus_hwmon_sysfs_is_visible()
3003 if (asus->gpu_fan_type == FAN_TYPE_NONE) in asus_hwmon_sysfs_is_visible()
3008 if (asus->mid_fan_type == FAN_TYPE_NONE) in asus_hwmon_sysfs_is_visible()
3011 int err = asus_wmi_get_devstate(asus, in asus_hwmon_sysfs_is_visible()
3035 static int asus_wmi_hwmon_init(struct asus_wmi *asus) in asus_wmi_hwmon_init() argument
3037 struct device *dev = &asus->platform_device->dev; in asus_wmi_hwmon_init()
3040 hwmon = devm_hwmon_device_register_with_groups(dev, "asus", asus, in asus_wmi_hwmon_init()
3044 pr_err("Could not register asus hwmon device\n"); in asus_wmi_hwmon_init()
3050 static int asus_wmi_fan_init(struct asus_wmi *asus) in asus_wmi_fan_init() argument
3052 asus->gpu_fan_type = FAN_TYPE_NONE; in asus_wmi_fan_init()
3053 asus->mid_fan_type = FAN_TYPE_NONE; in asus_wmi_fan_init()
3054 asus->fan_type = FAN_TYPE_NONE; in asus_wmi_fan_init()
3055 asus->agfn_pwm = -1; in asus_wmi_fan_init()
3057 if (asus->driver->quirks->wmi_ignore_fan) in asus_wmi_fan_init()
3058 asus->fan_type = FAN_TYPE_NONE; in asus_wmi_fan_init()
3059 else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CPU_FAN_CTRL)) in asus_wmi_fan_init()
3060 asus->fan_type = FAN_TYPE_SPEC83; in asus_wmi_fan_init()
3061 else if (asus_wmi_has_agfn_fan(asus)) in asus_wmi_fan_init()
3062 asus->fan_type = FAN_TYPE_AGFN; in asus_wmi_fan_init()
3065 if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_FAN_CTRL)) in asus_wmi_fan_init()
3066 asus->gpu_fan_type = FAN_TYPE_SPEC83; in asus_wmi_fan_init()
3069 if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MID_FAN_CTRL)) in asus_wmi_fan_init()
3070 asus->mid_fan_type = FAN_TYPE_SPEC83; in asus_wmi_fan_init()
3072 if (asus->fan_type == FAN_TYPE_NONE) in asus_wmi_fan_init()
3075 asus_fan_set_auto(asus); in asus_wmi_fan_init()
3076 asus->fan_pwm_mode = ASUS_FAN_CTRL_AUTO; in asus_wmi_fan_init()
3082 static int fan_boost_mode_check_present(struct asus_wmi *asus) in fan_boost_mode_check_present() argument
3087 asus->fan_boost_mode_available = false; in fan_boost_mode_check_present()
3089 err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FAN_BOOST_MODE, in fan_boost_mode_check_present()
3100 asus->fan_boost_mode_available = true; in fan_boost_mode_check_present()
3101 asus->fan_boost_mode_mask = result & ASUS_FAN_BOOST_MODES_MASK; in fan_boost_mode_check_present()
3107 static int fan_boost_mode_write(struct asus_wmi *asus) in fan_boost_mode_write() argument
3113 value = asus->fan_boost_mode; in fan_boost_mode_write()
3119 sysfs_notify(&asus->platform_device->dev.kobj, NULL, in fan_boost_mode_write()
3136 static int fan_boost_mode_switch_next(struct asus_wmi *asus) in fan_boost_mode_switch_next() argument
3138 u8 mask = asus->fan_boost_mode_mask; in fan_boost_mode_switch_next()
3140 if (asus->fan_boost_mode == ASUS_FAN_BOOST_MODE_NORMAL) { in fan_boost_mode_switch_next()
3142 asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_OVERBOOST; in fan_boost_mode_switch_next()
3144 asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_SILENT; in fan_boost_mode_switch_next()
3145 } else if (asus->fan_boost_mode == ASUS_FAN_BOOST_MODE_OVERBOOST) { in fan_boost_mode_switch_next()
3147 asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_SILENT; in fan_boost_mode_switch_next()
3149 asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_NORMAL; in fan_boost_mode_switch_next()
3151 asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_NORMAL; in fan_boost_mode_switch_next()
3154 return fan_boost_mode_write(asus); in fan_boost_mode_switch_next()
3160 struct asus_wmi *asus = dev_get_drvdata(dev); in fan_boost_mode_show() local
3162 return sysfs_emit(buf, "%d\n", asus->fan_boost_mode); in fan_boost_mode_show()
3169 struct asus_wmi *asus = dev_get_drvdata(dev); in fan_boost_mode_store() local
3170 u8 mask = asus->fan_boost_mode_mask; in fan_boost_mode_store()
3190 asus->fan_boost_mode = new_mode; in fan_boost_mode_store()
3191 fan_boost_mode_write(asus); in fan_boost_mode_store()
3215 static int fan_curve_get_factory_default(struct asus_wmi *asus, u32 fan_dev) in fan_curve_get_factory_default() argument
3222 if (asus->throttle_thermal_policy_dev) in fan_curve_get_factory_default()
3223 mode = asus->throttle_thermal_policy_mode; in fan_curve_get_factory_default()
3230 err = asus_wmi_evaluate_method_buf(asus->dsts_id, fan_dev, mode, buf, in fan_curve_get_factory_default()
3244 curves = &asus->custom_fan_curves[fan_idx]; in fan_curve_get_factory_default()
3252 static int fan_curve_check_present(struct asus_wmi *asus, bool *available, in fan_curve_check_present() argument
3259 if (asus->fan_type == FAN_TYPE_NONE) in fan_curve_check_present()
3262 err = fan_curve_get_factory_default(asus, fan_dev); in fan_curve_check_present()
3272 static struct fan_curve_data *fan_curve_attr_select(struct asus_wmi *asus, in fan_curve_attr_select() argument
3277 return &asus->custom_fan_curves[index]; in fan_curve_attr_select()
3281 static struct fan_curve_data *fan_curve_attr_2_select(struct asus_wmi *asus, in fan_curve_attr_2_select() argument
3286 return &asus->custom_fan_curves[nr & ~FAN_CURVE_PWM_MASK]; in fan_curve_attr_2_select()
3293 struct asus_wmi *asus = dev_get_drvdata(dev); in fan_curve_show() local
3297 data = fan_curve_attr_2_select(asus, attr); in fan_curve_show()
3312 static int fan_curve_write(struct asus_wmi *asus, in fan_curve_write() argument
3342 struct asus_wmi *asus = dev_get_drvdata(dev); in fan_curve_store() local
3347 data = fan_curve_attr_2_select(asus, attr); in fan_curve_store()
3373 struct asus_wmi *asus = dev_get_drvdata(dev); in fan_curve_enable_show() local
3377 data = fan_curve_attr_select(asus, attr); in fan_curve_enable_show()
3389 struct asus_wmi *asus = dev_get_drvdata(dev); in fan_curve_enable_store() local
3393 data = fan_curve_attr_select(asus, attr); in fan_curve_enable_store()
3411 err = fan_curve_get_factory_default(asus, data->device_id); in fan_curve_enable_store()
3421 err = fan_curve_write(asus, data); in fan_curve_enable_store()
3429 if (asus->throttle_thermal_policy_dev) { in fan_curve_enable_store()
3430 err = throttle_thermal_policy_write(asus); in fan_curve_enable_store()
3434 } else if (asus->fan_type == FAN_TYPE_SPEC83) { in fan_curve_enable_store()
3435 err = asus_fan_set_auto(asus); in fan_curve_enable_store()
3440 err = fan_curve_get_factory_default(asus, data->device_id); in fan_curve_enable_store()
3443 err = fan_curve_write(asus, data); in fan_curve_enable_store()
3621 struct asus_wmi *asus = dev_get_drvdata(dev->parent); in asus_fan_curve_is_visible() local
3627 if (asus->cpu_fan_curve_available && attr->name[3] == '1') in asus_fan_curve_is_visible()
3630 if (asus->gpu_fan_curve_available && attr->name[3] == '2') in asus_fan_curve_is_visible()
3633 if (asus->mid_fan_curve_available && attr->name[3] == '3') in asus_fan_curve_is_visible()
3649 static int asus_wmi_custom_fan_curve_init(struct asus_wmi *asus) in asus_wmi_custom_fan_curve_init() argument
3651 struct device *dev = &asus->platform_device->dev; in asus_wmi_custom_fan_curve_init()
3655 err = fan_curve_check_present(asus, &asus->cpu_fan_curve_available, in asus_wmi_custom_fan_curve_init()
3663 err = fan_curve_check_present(asus, &asus->gpu_fan_curve_available, in asus_wmi_custom_fan_curve_init()
3671 err = fan_curve_check_present(asus, &asus->mid_fan_curve_available, in asus_wmi_custom_fan_curve_init()
3679 if (!asus->cpu_fan_curve_available in asus_wmi_custom_fan_curve_init()
3680 && !asus->gpu_fan_curve_available in asus_wmi_custom_fan_curve_init()
3681 && !asus->mid_fan_curve_available) in asus_wmi_custom_fan_curve_init()
3685 dev, "asus_custom_fan_curve", asus, asus_fan_curve_attr_groups); in asus_wmi_custom_fan_curve_init()
3697 static int throttle_thermal_policy_write(struct asus_wmi *asus) in throttle_thermal_policy_write() argument
3699 u8 value = asus->throttle_thermal_policy_mode; in throttle_thermal_policy_write()
3703 err = asus_wmi_set_devstate(asus->throttle_thermal_policy_dev, in throttle_thermal_policy_write()
3706 sysfs_notify(&asus->platform_device->dev.kobj, NULL, in throttle_thermal_policy_write()
3721 if (asus->cpu_fan_curve_available) in throttle_thermal_policy_write()
3722 asus->custom_fan_curves[FAN_CURVE_DEV_CPU].enabled = false; in throttle_thermal_policy_write()
3723 if (asus->gpu_fan_curve_available) in throttle_thermal_policy_write()
3724 asus->custom_fan_curves[FAN_CURVE_DEV_GPU].enabled = false; in throttle_thermal_policy_write()
3725 if (asus->mid_fan_curve_available) in throttle_thermal_policy_write()
3726 asus->custom_fan_curves[FAN_CURVE_DEV_MID].enabled = false; in throttle_thermal_policy_write()
3731 static int throttle_thermal_policy_set_default(struct asus_wmi *asus) in throttle_thermal_policy_set_default() argument
3733 if (!asus->throttle_thermal_policy_dev) in throttle_thermal_policy_set_default()
3736 asus->throttle_thermal_policy_mode = ASUS_THROTTLE_THERMAL_POLICY_DEFAULT; in throttle_thermal_policy_set_default()
3737 return throttle_thermal_policy_write(asus); in throttle_thermal_policy_set_default()
3740 static int throttle_thermal_policy_switch_next(struct asus_wmi *asus) in throttle_thermal_policy_switch_next() argument
3742 u8 new_mode = asus->throttle_thermal_policy_mode + 1; in throttle_thermal_policy_switch_next()
3748 asus->throttle_thermal_policy_mode = new_mode; in throttle_thermal_policy_switch_next()
3749 err = throttle_thermal_policy_write(asus); in throttle_thermal_policy_switch_next()
3765 struct asus_wmi *asus = dev_get_drvdata(dev); in throttle_thermal_policy_show() local
3766 u8 mode = asus->throttle_thermal_policy_mode; in throttle_thermal_policy_show()
3775 struct asus_wmi *asus = dev_get_drvdata(dev); in throttle_thermal_policy_store() local
3787 asus->throttle_thermal_policy_mode = new_mode; in throttle_thermal_policy_store()
3788 err = throttle_thermal_policy_write(asus); in throttle_thermal_policy_store()
3807 static int asus_wmi_platform_profile_to_vivo(struct asus_wmi *asus, int mode) in asus_wmi_platform_profile_to_vivo() argument
3811 vivo = asus->throttle_thermal_policy_dev == ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY_VIVO; in asus_wmi_platform_profile_to_vivo()
3827 static int asus_wmi_platform_profile_mode_from_vivo(struct asus_wmi *asus, int mode) in asus_wmi_platform_profile_mode_from_vivo() argument
3831 vivo = asus->throttle_thermal_policy_dev == ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY_VIVO; in asus_wmi_platform_profile_mode_from_vivo()
3850 struct asus_wmi *asus; in asus_wmi_platform_profile_get() local
3853 asus = container_of(pprof, struct asus_wmi, platform_profile_handler); in asus_wmi_platform_profile_get()
3854 tp = asus->throttle_thermal_policy_mode; in asus_wmi_platform_profile_get()
3856 switch (asus_wmi_platform_profile_mode_from_vivo(asus, tp)) { in asus_wmi_platform_profile_get()
3876 struct asus_wmi *asus; in asus_wmi_platform_profile_set() local
3879 asus = container_of(pprof, struct asus_wmi, platform_profile_handler); in asus_wmi_platform_profile_set()
3895 asus->throttle_thermal_policy_mode = asus_wmi_platform_profile_to_vivo(asus, tp); in asus_wmi_platform_profile_set()
3896 return throttle_thermal_policy_write(asus); in asus_wmi_platform_profile_set()
3899 static int platform_profile_setup(struct asus_wmi *asus) in platform_profile_setup() argument
3901 struct device *dev = &asus->platform_device->dev; in platform_profile_setup()
3908 if (!asus->throttle_thermal_policy_dev) in platform_profile_setup()
3915 err = throttle_thermal_policy_set_default(asus); in platform_profile_setup()
3923 asus->platform_profile_handler.profile_get = asus_wmi_platform_profile_get; in platform_profile_setup()
3924 asus->platform_profile_handler.profile_set = asus_wmi_platform_profile_set; in platform_profile_setup()
3926 set_bit(PLATFORM_PROFILE_QUIET, asus->platform_profile_handler.choices); in platform_profile_setup()
3928 asus->platform_profile_handler.choices); in platform_profile_setup()
3930 asus->platform_profile_handler.choices); in platform_profile_setup()
3932 err = platform_profile_register(&asus->platform_profile_handler); in platform_profile_setup()
3941 asus->platform_profile_support = true; in platform_profile_setup()
3947 static int read_backlight_power(struct asus_wmi *asus) in read_backlight_power() argument
3951 if (asus->driver->quirks->store_backlight_power) in read_backlight_power()
3952 ret = !asus->driver->panel_power; in read_backlight_power()
3954 ret = asus_wmi_get_devstate_simple(asus, in read_backlight_power()
3963 static int read_brightness_max(struct asus_wmi *asus) in read_brightness_max() argument
3968 err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_BRIGHTNESS, &retval); in read_brightness_max()
3983 struct asus_wmi *asus = bl_get_data(bd); in read_brightness() local
3987 err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_BRIGHTNESS, &retval); in read_brightness()
3996 struct asus_wmi *asus = bl_get_data(bd); in get_scalar_command() local
3999 if ((asus->driver->brightness < bd->props.brightness) || in get_scalar_command()
4002 else if ((asus->driver->brightness > bd->props.brightness) || in get_scalar_command()
4006 asus->driver->brightness = bd->props.brightness; in get_scalar_command()
4013 struct asus_wmi *asus = bl_get_data(bd); in update_bl_status() local
4017 power = read_backlight_power(asus); in update_bl_status()
4022 if (asus->driver->quirks->store_backlight_power) in update_bl_status()
4023 asus->driver->panel_power = bd->props.power; in update_bl_status()
4027 if (asus->driver->quirks->scalar_panel_brightness) in update_bl_status()
4031 if (asus->driver->quirks->scalar_panel_brightness) in update_bl_status()
4047 static int asus_wmi_backlight_notify(struct asus_wmi *asus, int code) in asus_wmi_backlight_notify() argument
4049 struct backlight_device *bd = asus->backlight_device; in asus_wmi_backlight_notify()
4065 static int asus_wmi_backlight_init(struct asus_wmi *asus) in asus_wmi_backlight_init() argument
4072 max = read_brightness_max(asus); in asus_wmi_backlight_init()
4076 power = read_backlight_power(asus); in asus_wmi_backlight_init()
4085 bd = backlight_device_register(asus->driver->name, in asus_wmi_backlight_init()
4086 &asus->platform_device->dev, asus, in asus_wmi_backlight_init()
4093 asus->backlight_device = bd; in asus_wmi_backlight_init()
4095 if (asus->driver->quirks->store_backlight_power) in asus_wmi_backlight_init()
4096 asus->driver->panel_power = power; in asus_wmi_backlight_init()
4102 asus->driver->brightness = bd->props.brightness; in asus_wmi_backlight_init()
4107 static void asus_wmi_backlight_exit(struct asus_wmi *asus) in asus_wmi_backlight_exit() argument
4109 backlight_device_unregister(asus->backlight_device); in asus_wmi_backlight_exit()
4111 asus->backlight_device = NULL; in asus_wmi_backlight_exit()
4128 static int read_screenpad_backlight_power(struct asus_wmi *asus) in read_screenpad_backlight_power() argument
4132 ret = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_SCREENPAD_POWER); in read_screenpad_backlight_power()
4141 struct asus_wmi *asus = bl_get_data(bd); in read_screenpad_brightness() local
4145 err = read_screenpad_backlight_power(asus); in read_screenpad_brightness()
4150 return asus->driver->screenpad_brightness - ASUS_SCREENPAD_BRIGHT_MIN; in read_screenpad_brightness()
4152 err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_SCREENPAD_LIGHT, &retval); in read_screenpad_brightness()
4161 struct asus_wmi *asus = bl_get_data(bd); in update_screenpad_bl_status() local
4165 power = read_screenpad_backlight_power(asus); in update_screenpad_bl_status()
4172 ctrl_param = asus->driver->screenpad_brightness - ASUS_SCREENPAD_BRIGHT_MIN; in update_screenpad_bl_status()
4186 asus->driver->screenpad_brightness = bd->props.brightness + ASUS_SCREENPAD_BRIGHT_MIN; in update_screenpad_bl_status()
4197 static int asus_screenpad_init(struct asus_wmi *asus) in asus_screenpad_init() argument
4204 power = read_screenpad_backlight_power(asus); in asus_screenpad_init()
4209 err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_SCREENPAD_LIGHT, &brightness); in asus_screenpad_init()
4221 &asus->platform_device->dev, asus, in asus_screenpad_init()
4228 asus->screenpad_backlight_device = bd; in asus_screenpad_init()
4229 asus->driver->screenpad_brightness = brightness; in asus_screenpad_init()
4237 static void asus_screenpad_exit(struct asus_wmi *asus) in asus_screenpad_exit() argument
4239 backlight_device_unregister(asus->screenpad_backlight_device); in asus_screenpad_exit()
4241 asus->screenpad_backlight_device = NULL; in asus_screenpad_exit()
4246 static bool asus_wmi_has_fnlock_key(struct asus_wmi *asus) in asus_wmi_has_fnlock_key() argument
4250 asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FNLOCK, &result); in asus_wmi_has_fnlock_key()
4256 static void asus_wmi_fnlock_update(struct asus_wmi *asus) in asus_wmi_fnlock_update() argument
4258 int mode = asus->fnlock_locked; in asus_wmi_fnlock_update()
4277 static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus) in asus_wmi_handle_event_code() argument
4282 if (asus->driver->key_filter) { in asus_wmi_handle_event_code()
4283 asus->driver->key_filter(asus->driver, &code, &key_value, in asus_wmi_handle_event_code()
4291 asus_wmi_backlight_notify(asus, code); in asus_wmi_handle_event_code()
4296 kbd_led_set_by_kbd(asus, asus->kbd_led_wk + 1); in asus_wmi_handle_event_code()
4300 kbd_led_set_by_kbd(asus, asus->kbd_led_wk - 1); in asus_wmi_handle_event_code()
4304 if (asus->kbd_led_wk == asus->kbd_led.max_brightness) in asus_wmi_handle_event_code()
4305 kbd_led_set_by_kbd(asus, 0); in asus_wmi_handle_event_code()
4307 kbd_led_set_by_kbd(asus, asus->kbd_led_wk + 1); in asus_wmi_handle_event_code()
4312 asus->fnlock_locked = !asus->fnlock_locked; in asus_wmi_handle_event_code()
4313 asus_wmi_fnlock_update(asus); in asus_wmi_handle_event_code()
4317 if (code == asus->tablet_switch_event_code) { in asus_wmi_handle_event_code()
4318 asus_wmi_tablet_mode_get_state(asus); in asus_wmi_handle_event_code()
4323 if (asus->fan_boost_mode_available) in asus_wmi_handle_event_code()
4324 fan_boost_mode_switch_next(asus); in asus_wmi_handle_event_code()
4325 if (asus->throttle_thermal_policy_dev) in asus_wmi_handle_event_code()
4326 throttle_thermal_policy_switch_next(asus); in asus_wmi_handle_event_code()
4331 if (is_display_toggle(code) && asus->driver->quirks->no_display_toggle) in asus_wmi_handle_event_code()
4334 if (!sparse_keymap_report_event(asus->inputdev, code, in asus_wmi_handle_event_code()
4341 struct asus_wmi *asus = context; in asus_wmi_notify() local
4349 asus_wmi_handle_event_code(code, asus); in asus_wmi_notify()
4354 static ssize_t store_sys_wmi(struct asus_wmi *asus, int devid, in store_sys_wmi() argument
4360 value = asus_wmi_get_devstate_simple(asus, devid); in store_sys_wmi()
4375 static ssize_t show_sys_wmi(struct asus_wmi *asus, int devid, char *buf) in show_sys_wmi() argument
4377 int value = asus_wmi_get_devstate_simple(asus, devid); in show_sys_wmi()
4390 struct asus_wmi *asus = dev_get_drvdata(dev); \
4392 return show_sys_wmi(asus, _cm, buf); \
4398 struct asus_wmi *asus = dev_get_drvdata(dev); \
4400 return store_sys_wmi(asus, _cm, buf, count); \
4470 struct asus_wmi *asus = dev_get_drvdata(dev); in asus_sysfs_is_visible() local
4487 ok = asus->egpu_enable_available; in asus_sysfs_is_visible()
4491 ok = asus->dgpu_disable_available; in asus_sysfs_is_visible()
4493 ok = asus->gpu_mux_dev != 0; in asus_sysfs_is_visible()
4495 ok = asus->fan_boost_mode_available; in asus_sysfs_is_visible()
4497 ok = asus->throttle_thermal_policy_dev != 0; in asus_sysfs_is_visible()
4519 ok = asus->mini_led_dev_id != 0; in asus_sysfs_is_visible()
4521 ok = asus->mini_led_dev_id != 0; in asus_sysfs_is_visible()
4524 ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0); in asus_sysfs_is_visible()
4548 static int asus_wmi_platform_init(struct asus_wmi *asus) in asus_wmi_platform_init() argument
4550 struct device *dev = &asus->platform_device->dev; in asus_wmi_platform_init()
4561 asus->spec = rv; in asus_wmi_platform_init()
4572 asus->sfun = rv; in asus_wmi_platform_init()
4594 asus->dsts_id = ASUS_WMI_METHODID_DCTS; in asus_wmi_platform_init()
4597 asus->dsts_id = ASUS_WMI_METHODID_DSTS; in asus_wmi_platform_init()
4602 if (asus->driver->quirks->wapf >= 0) in asus_wmi_platform_init()
4604 asus->driver->quirks->wapf, NULL); in asus_wmi_platform_init()
4612 struct asus_wmi *asus; member
4619 struct asus_wmi *asus = m->private; in show_dsts() local
4623 err = asus_wmi_get_devstate(asus, asus->debug.dev_id, &retval); in show_dsts()
4627 seq_printf(m, "DSTS(%#x) = %#x\n", asus->debug.dev_id, retval); in show_dsts()
4634 struct asus_wmi *asus = m->private; in show_devs() local
4638 err = asus_wmi_set_devstate(asus->debug.dev_id, asus->debug.ctrl_param, in show_devs()
4643 seq_printf(m, "DEVS(%#x, %#x) = %#x\n", asus->debug.dev_id, in show_devs()
4644 asus->debug.ctrl_param, retval); in show_devs()
4651 struct asus_wmi *asus = m->private; in show_call() local
4653 .arg0 = asus->debug.dev_id, in show_call()
4654 .arg1 = asus->debug.ctrl_param, in show_call()
4662 0, asus->debug.method_id, in show_call()
4670 seq_printf(m, "%#x(%#x, %#x) = %#x\n", asus->debug.method_id, in show_call()
4671 asus->debug.dev_id, asus->debug.ctrl_param, in show_call()
4674 seq_printf(m, "%#x(%#x, %#x) = t:%d\n", asus->debug.method_id, in show_call()
4675 asus->debug.dev_id, asus->debug.ctrl_param, in show_call()
4693 return single_open(file, node->show, node->asus); in asus_wmi_debugfs_open()
4704 static void asus_wmi_debugfs_exit(struct asus_wmi *asus) in asus_wmi_debugfs_exit() argument
4706 debugfs_remove_recursive(asus->debug.root); in asus_wmi_debugfs_exit()
4709 static void asus_wmi_debugfs_init(struct asus_wmi *asus) in asus_wmi_debugfs_init() argument
4713 asus->debug.root = debugfs_create_dir(asus->driver->name, NULL); in asus_wmi_debugfs_init()
4715 debugfs_create_x32("method_id", S_IRUGO | S_IWUSR, asus->debug.root, in asus_wmi_debugfs_init()
4716 &asus->debug.method_id); in asus_wmi_debugfs_init()
4718 debugfs_create_x32("dev_id", S_IRUGO | S_IWUSR, asus->debug.root, in asus_wmi_debugfs_init()
4719 &asus->debug.dev_id); in asus_wmi_debugfs_init()
4721 debugfs_create_x32("ctrl_param", S_IRUGO | S_IWUSR, asus->debug.root, in asus_wmi_debugfs_init()
4722 &asus->debug.ctrl_param); in asus_wmi_debugfs_init()
4727 node->asus = asus; in asus_wmi_debugfs_init()
4729 asus->debug.root, node, in asus_wmi_debugfs_init()
4740 struct asus_wmi *asus; in asus_wmi_add() local
4745 asus = kzalloc(sizeof(struct asus_wmi), GFP_KERNEL); in asus_wmi_add()
4746 if (!asus) in asus_wmi_add()
4749 asus->driver = wdrv; in asus_wmi_add()
4750 asus->platform_device = pdev; in asus_wmi_add()
4752 platform_set_drvdata(asus->platform_device, asus); in asus_wmi_add()
4755 wdrv->detect_quirks(asus->driver); in asus_wmi_add()
4757 err = asus_wmi_platform_init(asus); in asus_wmi_add()
4762 asus->ppt_pl2_sppt = 5; in asus_wmi_add()
4763 asus->ppt_pl1_spl = 5; in asus_wmi_add()
4764 asus->ppt_apu_sppt = 5; in asus_wmi_add()
4765 asus->ppt_platform_sppt = 5; in asus_wmi_add()
4766 asus->ppt_fppt = 5; in asus_wmi_add()
4767 asus->nv_dynamic_boost = 5; in asus_wmi_add()
4768 asus->nv_temp_target = 75; in asus_wmi_add()
4770 asus->egpu_enable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU); in asus_wmi_add()
4771 asus->dgpu_disable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_DGPU); in asus_wmi_add()
4772 asus->kbd_rgb_state_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_STATE); in asus_wmi_add()
4773 asus->ally_mcu_usb_switch = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE) in asus_wmi_add()
4776 if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE)) in asus_wmi_add()
4777 asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE; in asus_wmi_add()
4778 else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE2)) in asus_wmi_add()
4779 asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE2; in asus_wmi_add()
4781 if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_MUX)) in asus_wmi_add()
4782 asus->gpu_mux_dev = ASUS_WMI_DEVID_GPU_MUX; in asus_wmi_add()
4783 else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_MUX_VIVO)) in asus_wmi_add()
4784 asus->gpu_mux_dev = ASUS_WMI_DEVID_GPU_MUX_VIVO; in asus_wmi_add()
4786 if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE)) in asus_wmi_add()
4787 asus->kbd_rgb_dev = ASUS_WMI_DEVID_TUF_RGB_MODE; in asus_wmi_add()
4788 else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE2)) in asus_wmi_add()
4789 asus->kbd_rgb_dev = ASUS_WMI_DEVID_TUF_RGB_MODE2; in asus_wmi_add()
4791 if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY)) in asus_wmi_add()
4792 asus->throttle_thermal_policy_dev = ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY; in asus_wmi_add()
4793 else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY_VIVO)) in asus_wmi_add()
4794 asus->throttle_thermal_policy_dev = ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY_VIVO; in asus_wmi_add()
4796 err = fan_boost_mode_check_present(asus); in asus_wmi_add()
4800 err = platform_profile_setup(asus); in asus_wmi_add()
4804 err = asus_wmi_sysfs_init(asus->platform_device); in asus_wmi_add()
4808 err = asus_wmi_input_init(asus); in asus_wmi_add()
4812 err = asus_wmi_fan_init(asus); /* probably no problems on error */ in asus_wmi_add()
4814 err = asus_wmi_hwmon_init(asus); in asus_wmi_add()
4818 err = asus_wmi_custom_fan_curve_init(asus); in asus_wmi_add()
4822 err = asus_wmi_led_init(asus); in asus_wmi_add()
4826 asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_WLAN, &result); in asus_wmi_add()
4828 asus->driver->wlan_ctrl_by_user = 1; in asus_wmi_add()
4830 if (!(asus->driver->wlan_ctrl_by_user && ashs_present())) { in asus_wmi_add()
4831 err = asus_wmi_rfkill_init(asus); in asus_wmi_add()
4836 if (asus->driver->quirks->wmi_force_als_set) in asus_wmi_add()
4839 if (asus->driver->quirks->xusb2pr) in asus_wmi_add()
4840 asus_wmi_set_xusb2pr(asus); in asus_wmi_add()
4843 err = asus_wmi_backlight_init(asus); in asus_wmi_add()
4846 } else if (asus->driver->quirks->wmi_backlight_set_devstate) in asus_wmi_add()
4849 if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_SCREENPAD_LIGHT)) { in asus_wmi_add()
4850 err = asus_screenpad_init(asus); in asus_wmi_add()
4855 if (asus_wmi_has_fnlock_key(asus)) { in asus_wmi_add()
4856 asus->fnlock_locked = fnlock_default; in asus_wmi_add()
4857 asus_wmi_fnlock_update(asus); in asus_wmi_add()
4860 status = wmi_install_notify_handler(asus->driver->event_guid, in asus_wmi_add()
4861 asus_wmi_notify, asus); in asus_wmi_add()
4868 if (asus->driver->i8042_filter) { in asus_wmi_add()
4869 err = i8042_install_filter(asus->driver->i8042_filter); in asus_wmi_add()
4874 asus_wmi_battery_init(asus); in asus_wmi_add()
4876 asus_wmi_debugfs_init(asus); in asus_wmi_add()
4881 asus_wmi_backlight_exit(asus); in asus_wmi_add()
4883 asus_wmi_rfkill_exit(asus); in asus_wmi_add()
4885 asus_screenpad_exit(asus); in asus_wmi_add()
4887 asus_wmi_led_exit(asus); in asus_wmi_add()
4890 asus_wmi_input_exit(asus); in asus_wmi_add()
4892 asus_wmi_sysfs_exit(asus->platform_device); in asus_wmi_add()
4896 if (asus->platform_profile_support) in asus_wmi_add()
4900 kfree(asus); in asus_wmi_add()
4906 struct asus_wmi *asus; in asus_wmi_remove() local
4908 asus = platform_get_drvdata(device); in asus_wmi_remove()
4909 if (asus->driver->i8042_filter) in asus_wmi_remove()
4910 i8042_remove_filter(asus->driver->i8042_filter); in asus_wmi_remove()
4911 wmi_remove_notify_handler(asus->driver->event_guid); in asus_wmi_remove()
4912 asus_wmi_backlight_exit(asus); in asus_wmi_remove()
4913 asus_screenpad_exit(asus); in asus_wmi_remove()
4914 asus_wmi_input_exit(asus); in asus_wmi_remove()
4915 asus_wmi_led_exit(asus); in asus_wmi_remove()
4916 asus_wmi_rfkill_exit(asus); in asus_wmi_remove()
4917 asus_wmi_debugfs_exit(asus); in asus_wmi_remove()
4918 asus_wmi_sysfs_exit(asus->platform_device); in asus_wmi_remove()
4919 asus_fan_set_auto(asus); in asus_wmi_remove()
4920 throttle_thermal_policy_set_default(asus); in asus_wmi_remove()
4921 asus_wmi_battery_exit(asus); in asus_wmi_remove()
4923 if (asus->platform_profile_support) in asus_wmi_remove()
4926 kfree(asus); in asus_wmi_remove()
4933 struct asus_wmi *asus = dev_get_drvdata(device); in asus_hotk_thaw() local
4935 if (asus->wlan.rfkill) { in asus_hotk_thaw()
4943 wlan = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_WLAN); in asus_hotk_thaw()
4952 struct asus_wmi *asus = dev_get_drvdata(device); in asus_hotk_resume() local
4954 if (!IS_ERR_OR_NULL(asus->kbd_led.dev)) in asus_hotk_resume()
4955 kbd_led_update(asus); in asus_hotk_resume()
4957 if (asus_wmi_has_fnlock_key(asus)) in asus_hotk_resume()
4958 asus_wmi_fnlock_update(asus); in asus_hotk_resume()
4960 asus_wmi_tablet_mode_get_state(asus); in asus_hotk_resume()
4967 struct asus_wmi *asus = dev_get_drvdata(device); in asus_hotk_resume_early() local
4969 if (asus->ally_mcu_usb_switch) { in asus_hotk_resume_early()
4981 struct asus_wmi *asus = dev_get_drvdata(device); in asus_hotk_prepare() local
4983 if (asus->ally_mcu_usb_switch) { in asus_hotk_prepare()
4995 struct asus_wmi *asus = dev_get_drvdata(device); in asus_hotk_restore() local
4999 if (asus->wlan.rfkill) in asus_hotk_restore()
5000 asus_rfkill_hotplug(asus); in asus_hotk_restore()
5002 if (asus->bluetooth.rfkill) { in asus_hotk_restore()
5003 bl = !asus_wmi_get_devstate_simple(asus, in asus_hotk_restore()
5005 rfkill_set_sw_state(asus->bluetooth.rfkill, bl); in asus_hotk_restore()
5007 if (asus->wimax.rfkill) { in asus_hotk_restore()
5008 bl = !asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_WIMAX); in asus_hotk_restore()
5009 rfkill_set_sw_state(asus->wimax.rfkill, bl); in asus_hotk_restore()
5011 if (asus->wwan3g.rfkill) { in asus_hotk_restore()
5012 bl = !asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_WWAN3G); in asus_hotk_restore()
5013 rfkill_set_sw_state(asus->wwan3g.rfkill, bl); in asus_hotk_restore()
5015 if (asus->gps.rfkill) { in asus_hotk_restore()
5016 bl = !asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPS); in asus_hotk_restore()
5017 rfkill_set_sw_state(asus->gps.rfkill, bl); in asus_hotk_restore()
5019 if (asus->uwb.rfkill) { in asus_hotk_restore()
5020 bl = !asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_UWB); in asus_hotk_restore()
5021 rfkill_set_sw_state(asus->uwb.rfkill, bl); in asus_hotk_restore()
5023 if (!IS_ERR_OR_NULL(asus->kbd_led.dev)) in asus_hotk_restore()
5024 kbd_led_update(asus); in asus_hotk_restore()
5026 if (asus_wmi_has_fnlock_key(asus)) in asus_hotk_restore()
5027 asus_wmi_fnlock_update(asus); in asus_hotk_restore()
5029 asus_wmi_tablet_mode_get_state(asus); in asus_hotk_restore()
5050 pr_warn("ASUS Management GUID not found\n"); in asus_wmi_probe()
5055 pr_warn("ASUS Event GUID not found\n"); in asus_wmi_probe()
5105 pr_info("ASUS WMI generic driver loaded\n"); in asus_wmi_init()
5111 pr_info("ASUS WMI generic driver unloaded\n"); in asus_wmi_exit()