diff options
Diffstat (limited to 'drivers/platform/x86/asus-wmi.c')
-rw-r--r-- | drivers/platform/x86/asus-wmi.c | 239 |
1 files changed, 212 insertions, 27 deletions
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 65b66aa44c78..95cba9ebf6c0 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/debugfs.h> | 44 | #include <linux/debugfs.h> |
45 | #include <linux/seq_file.h> | 45 | #include <linux/seq_file.h> |
46 | #include <linux/platform_device.h> | 46 | #include <linux/platform_device.h> |
47 | #include <linux/thermal.h> | ||
47 | #include <acpi/acpi_bus.h> | 48 | #include <acpi/acpi_bus.h> |
48 | #include <acpi/acpi_drivers.h> | 49 | #include <acpi/acpi_drivers.h> |
49 | 50 | ||
@@ -66,6 +67,8 @@ MODULE_LICENSE("GPL"); | |||
66 | #define NOTIFY_BRNUP_MAX 0x1f | 67 | #define NOTIFY_BRNUP_MAX 0x1f |
67 | #define NOTIFY_BRNDOWN_MIN 0x20 | 68 | #define NOTIFY_BRNDOWN_MIN 0x20 |
68 | #define NOTIFY_BRNDOWN_MAX 0x2e | 69 | #define NOTIFY_BRNDOWN_MAX 0x2e |
70 | #define NOTIFY_KBD_BRTUP 0xc4 | ||
71 | #define NOTIFY_KBD_BRTDWN 0xc5 | ||
69 | 72 | ||
70 | /* WMI Methods */ | 73 | /* WMI Methods */ |
71 | #define ASUS_WMI_METHODID_SPEC 0x43455053 /* BIOS SPECification */ | 74 | #define ASUS_WMI_METHODID_SPEC 0x43455053 /* BIOS SPECification */ |
@@ -93,6 +96,7 @@ MODULE_LICENSE("GPL"); | |||
93 | /* Wireless */ | 96 | /* Wireless */ |
94 | #define ASUS_WMI_DEVID_HW_SWITCH 0x00010001 | 97 | #define ASUS_WMI_DEVID_HW_SWITCH 0x00010001 |
95 | #define ASUS_WMI_DEVID_WIRELESS_LED 0x00010002 | 98 | #define ASUS_WMI_DEVID_WIRELESS_LED 0x00010002 |
99 | #define ASUS_WMI_DEVID_CWAP 0x00010003 | ||
96 | #define ASUS_WMI_DEVID_WLAN 0x00010011 | 100 | #define ASUS_WMI_DEVID_WLAN 0x00010011 |
97 | #define ASUS_WMI_DEVID_BLUETOOTH 0x00010013 | 101 | #define ASUS_WMI_DEVID_BLUETOOTH 0x00010013 |
98 | #define ASUS_WMI_DEVID_GPS 0x00010015 | 102 | #define ASUS_WMI_DEVID_GPS 0x00010015 |
@@ -102,6 +106,12 @@ MODULE_LICENSE("GPL"); | |||
102 | 106 | ||
103 | /* Leds */ | 107 | /* Leds */ |
104 | /* 0x000200XX and 0x000400XX */ | 108 | /* 0x000200XX and 0x000400XX */ |
109 | #define ASUS_WMI_DEVID_LED1 0x00020011 | ||
110 | #define ASUS_WMI_DEVID_LED2 0x00020012 | ||
111 | #define ASUS_WMI_DEVID_LED3 0x00020013 | ||
112 | #define ASUS_WMI_DEVID_LED4 0x00020014 | ||
113 | #define ASUS_WMI_DEVID_LED5 0x00020015 | ||
114 | #define ASUS_WMI_DEVID_LED6 0x00020016 | ||
105 | 115 | ||
106 | /* Backlight and Brightness */ | 116 | /* Backlight and Brightness */ |
107 | #define ASUS_WMI_DEVID_BACKLIGHT 0x00050011 | 117 | #define ASUS_WMI_DEVID_BACKLIGHT 0x00050011 |
@@ -174,13 +184,18 @@ struct asus_wmi { | |||
174 | 184 | ||
175 | struct led_classdev tpd_led; | 185 | struct led_classdev tpd_led; |
176 | int tpd_led_wk; | 186 | int tpd_led_wk; |
187 | struct led_classdev kbd_led; | ||
188 | int kbd_led_wk; | ||
177 | struct workqueue_struct *led_workqueue; | 189 | struct workqueue_struct *led_workqueue; |
178 | struct work_struct tpd_led_work; | 190 | struct work_struct tpd_led_work; |
191 | struct work_struct kbd_led_work; | ||
179 | 192 | ||
180 | struct asus_rfkill wlan; | 193 | struct asus_rfkill wlan; |
181 | struct asus_rfkill bluetooth; | 194 | struct asus_rfkill bluetooth; |
182 | struct asus_rfkill wimax; | 195 | struct asus_rfkill wimax; |
183 | struct asus_rfkill wwan3g; | 196 | struct asus_rfkill wwan3g; |
197 | struct asus_rfkill gps; | ||
198 | struct asus_rfkill uwb; | ||
184 | 199 | ||
185 | struct hotplug_slot *hotplug_slot; | 200 | struct hotplug_slot *hotplug_slot; |
186 | struct mutex hotplug_lock; | 201 | struct mutex hotplug_lock; |
@@ -205,6 +220,7 @@ static int asus_wmi_input_init(struct asus_wmi *asus) | |||
205 | asus->inputdev->phys = asus->driver->input_phys; | 220 | asus->inputdev->phys = asus->driver->input_phys; |
206 | asus->inputdev->id.bustype = BUS_HOST; | 221 | asus->inputdev->id.bustype = BUS_HOST; |
207 | asus->inputdev->dev.parent = &asus->platform_device->dev; | 222 | asus->inputdev->dev.parent = &asus->platform_device->dev; |
223 | set_bit(EV_REP, asus->inputdev->evbit); | ||
208 | 224 | ||
209 | err = sparse_keymap_setup(asus->inputdev, asus->driver->keymap, NULL); | 225 | err = sparse_keymap_setup(asus->inputdev, asus->driver->keymap, NULL); |
210 | if (err) | 226 | if (err) |
@@ -359,30 +375,80 @@ static enum led_brightness tpd_led_get(struct led_classdev *led_cdev) | |||
359 | return read_tpd_led_state(asus); | 375 | return read_tpd_led_state(asus); |
360 | } | 376 | } |
361 | 377 | ||
362 | static int asus_wmi_led_init(struct asus_wmi *asus) | 378 | static void kbd_led_update(struct work_struct *work) |
363 | { | 379 | { |
364 | int rv; | 380 | int ctrl_param = 0; |
381 | struct asus_wmi *asus; | ||
365 | 382 | ||
366 | if (read_tpd_led_state(asus) < 0) | 383 | asus = container_of(work, struct asus_wmi, kbd_led_work); |
367 | return 0; | ||
368 | 384 | ||
369 | asus->led_workqueue = create_singlethread_workqueue("led_workqueue"); | 385 | /* |
370 | if (!asus->led_workqueue) | 386 | * bits 0-2: level |
371 | return -ENOMEM; | 387 | * bit 7: light on/off |
372 | INIT_WORK(&asus->tpd_led_work, tpd_led_update); | 388 | */ |
389 | if (asus->kbd_led_wk > 0) | ||
390 | ctrl_param = 0x80 | (asus->kbd_led_wk & 0x7F); | ||
373 | 391 | ||
374 | asus->tpd_led.name = "asus::touchpad"; | 392 | asus_wmi_set_devstate(ASUS_WMI_DEVID_KBD_BACKLIGHT, ctrl_param, NULL); |
375 | asus->tpd_led.brightness_set = tpd_led_set; | 393 | } |
376 | asus->tpd_led.brightness_get = tpd_led_get; | ||
377 | asus->tpd_led.max_brightness = 1; | ||
378 | 394 | ||
379 | rv = led_classdev_register(&asus->platform_device->dev, &asus->tpd_led); | 395 | static int kbd_led_read(struct asus_wmi *asus, int *level, int *env) |
380 | if (rv) { | 396 | { |
381 | destroy_workqueue(asus->led_workqueue); | 397 | int retval; |
382 | return rv; | 398 | |
399 | /* | ||
400 | * bits 0-2: level | ||
401 | * bit 7: light on/off | ||
402 | * bit 8-10: environment (0: dark, 1: normal, 2: light) | ||
403 | * bit 17: status unknown | ||
404 | */ | ||
405 | retval = asus_wmi_get_devstate_bits(asus, ASUS_WMI_DEVID_KBD_BACKLIGHT, | ||
406 | 0xFFFF); | ||
407 | |||
408 | /* Unknown status is considered as off */ | ||
409 | if (retval == 0x8000) | ||
410 | retval = 0; | ||
411 | |||
412 | if (retval >= 0) { | ||
413 | if (level) | ||
414 | *level = retval & 0x80 ? retval & 0x7F : 0; | ||
415 | if (env) | ||
416 | *env = (retval >> 8) & 0x7F; | ||
417 | retval = 0; | ||
383 | } | 418 | } |
384 | 419 | ||
385 | return 0; | 420 | return retval; |
421 | } | ||
422 | |||
423 | static void kbd_led_set(struct led_classdev *led_cdev, | ||
424 | enum led_brightness value) | ||
425 | { | ||
426 | struct asus_wmi *asus; | ||
427 | |||
428 | asus = container_of(led_cdev, struct asus_wmi, kbd_led); | ||
429 | |||
430 | if (value > asus->kbd_led.max_brightness) | ||
431 | value = asus->kbd_led.max_brightness; | ||
432 | else if (value < 0) | ||
433 | value = 0; | ||
434 | |||
435 | asus->kbd_led_wk = value; | ||
436 | queue_work(asus->led_workqueue, &asus->kbd_led_work); | ||
437 | } | ||
438 | |||
439 | static enum led_brightness kbd_led_get(struct led_classdev *led_cdev) | ||
440 | { | ||
441 | struct asus_wmi *asus; | ||
442 | int retval, value; | ||
443 | |||
444 | asus = container_of(led_cdev, struct asus_wmi, kbd_led); | ||
445 | |||
446 | retval = kbd_led_read(asus, &value, NULL); | ||
447 | |||
448 | if (retval < 0) | ||
449 | return retval; | ||
450 | |||
451 | return value; | ||
386 | } | 452 | } |
387 | 453 | ||
388 | static void asus_wmi_led_exit(struct asus_wmi *asus) | 454 | static void asus_wmi_led_exit(struct asus_wmi *asus) |
@@ -393,6 +459,48 @@ static void asus_wmi_led_exit(struct asus_wmi *asus) | |||
393 | destroy_workqueue(asus->led_workqueue); | 459 | destroy_workqueue(asus->led_workqueue); |
394 | } | 460 | } |
395 | 461 | ||
462 | static int asus_wmi_led_init(struct asus_wmi *asus) | ||
463 | { | ||
464 | int rv = 0; | ||
465 | |||
466 | asus->led_workqueue = create_singlethread_workqueue("led_workqueue"); | ||
467 | if (!asus->led_workqueue) | ||
468 | return -ENOMEM; | ||
469 | |||
470 | if (read_tpd_led_state(asus) >= 0) { | ||
471 | INIT_WORK(&asus->tpd_led_work, tpd_led_update); | ||
472 | |||
473 | asus->tpd_led.name = "asus::touchpad"; | ||
474 | asus->tpd_led.brightness_set = tpd_led_set; | ||
475 | asus->tpd_led.brightness_get = tpd_led_get; | ||
476 | asus->tpd_led.max_brightness = 1; | ||
477 | |||
478 | rv = led_classdev_register(&asus->platform_device->dev, | ||
479 | &asus->tpd_led); | ||
480 | if (rv) | ||
481 | goto error; | ||
482 | } | ||
483 | |||
484 | if (kbd_led_read(asus, NULL, NULL) >= 0) { | ||
485 | INIT_WORK(&asus->kbd_led_work, kbd_led_update); | ||
486 | |||
487 | asus->kbd_led.name = "asus::kbd_backlight"; | ||
488 | asus->kbd_led.brightness_set = kbd_led_set; | ||
489 | asus->kbd_led.brightness_get = kbd_led_get; | ||
490 | asus->kbd_led.max_brightness = 3; | ||
491 | |||
492 | rv = led_classdev_register(&asus->platform_device->dev, | ||
493 | &asus->kbd_led); | ||
494 | } | ||
495 | |||
496 | error: | ||
497 | if (rv) | ||
498 | asus_wmi_led_exit(asus); | ||
499 | |||
500 | return rv; | ||
501 | } | ||
502 | |||
503 | |||
396 | /* | 504 | /* |
397 | * PCI hotplug (for wlan rfkill) | 505 | * PCI hotplug (for wlan rfkill) |
398 | */ | 506 | */ |
@@ -729,6 +837,16 @@ static void asus_wmi_rfkill_exit(struct asus_wmi *asus) | |||
729 | rfkill_destroy(asus->wwan3g.rfkill); | 837 | rfkill_destroy(asus->wwan3g.rfkill); |
730 | asus->wwan3g.rfkill = NULL; | 838 | asus->wwan3g.rfkill = NULL; |
731 | } | 839 | } |
840 | if (asus->gps.rfkill) { | ||
841 | rfkill_unregister(asus->gps.rfkill); | ||
842 | rfkill_destroy(asus->gps.rfkill); | ||
843 | asus->gps.rfkill = NULL; | ||
844 | } | ||
845 | if (asus->uwb.rfkill) { | ||
846 | rfkill_unregister(asus->uwb.rfkill); | ||
847 | rfkill_destroy(asus->uwb.rfkill); | ||
848 | asus->uwb.rfkill = NULL; | ||
849 | } | ||
732 | } | 850 | } |
733 | 851 | ||
734 | static int asus_wmi_rfkill_init(struct asus_wmi *asus) | 852 | static int asus_wmi_rfkill_init(struct asus_wmi *asus) |
@@ -763,6 +881,18 @@ static int asus_wmi_rfkill_init(struct asus_wmi *asus) | |||
763 | if (result && result != -ENODEV) | 881 | if (result && result != -ENODEV) |
764 | goto exit; | 882 | goto exit; |
765 | 883 | ||
884 | result = asus_new_rfkill(asus, &asus->gps, "asus-gps", | ||
885 | RFKILL_TYPE_GPS, ASUS_WMI_DEVID_GPS); | ||
886 | |||
887 | if (result && result != -ENODEV) | ||
888 | goto exit; | ||
889 | |||
890 | result = asus_new_rfkill(asus, &asus->uwb, "asus-uwb", | ||
891 | RFKILL_TYPE_UWB, ASUS_WMI_DEVID_UWB); | ||
892 | |||
893 | if (result && result != -ENODEV) | ||
894 | goto exit; | ||
895 | |||
766 | if (!asus->driver->hotplug_wireless) | 896 | if (!asus->driver->hotplug_wireless) |
767 | goto exit; | 897 | goto exit; |
768 | 898 | ||
@@ -797,8 +927,8 @@ exit: | |||
797 | * Hwmon device | 927 | * Hwmon device |
798 | */ | 928 | */ |
799 | static ssize_t asus_hwmon_pwm1(struct device *dev, | 929 | static ssize_t asus_hwmon_pwm1(struct device *dev, |
800 | struct device_attribute *attr, | 930 | struct device_attribute *attr, |
801 | char *buf) | 931 | char *buf) |
802 | { | 932 | { |
803 | struct asus_wmi *asus = dev_get_drvdata(dev); | 933 | struct asus_wmi *asus = dev_get_drvdata(dev); |
804 | u32 value; | 934 | u32 value; |
@@ -809,7 +939,7 @@ static ssize_t asus_hwmon_pwm1(struct device *dev, | |||
809 | if (err < 0) | 939 | if (err < 0) |
810 | return err; | 940 | return err; |
811 | 941 | ||
812 | value |= 0xFF; | 942 | value &= 0xFF; |
813 | 943 | ||
814 | if (value == 1) /* Low Speed */ | 944 | if (value == 1) /* Low Speed */ |
815 | value = 85; | 945 | value = 85; |
@@ -825,7 +955,26 @@ static ssize_t asus_hwmon_pwm1(struct device *dev, | |||
825 | return sprintf(buf, "%d\n", value); | 955 | return sprintf(buf, "%d\n", value); |
826 | } | 956 | } |
827 | 957 | ||
958 | static ssize_t asus_hwmon_temp1(struct device *dev, | ||
959 | struct device_attribute *attr, | ||
960 | char *buf) | ||
961 | { | ||
962 | struct asus_wmi *asus = dev_get_drvdata(dev); | ||
963 | u32 value; | ||
964 | int err; | ||
965 | |||
966 | err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_THERMAL_CTRL, &value); | ||
967 | |||
968 | if (err < 0) | ||
969 | return err; | ||
970 | |||
971 | value = KELVIN_TO_CELSIUS((value & 0xFFFF)) * 1000; | ||
972 | |||
973 | return sprintf(buf, "%d\n", value); | ||
974 | } | ||
975 | |||
828 | static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO, asus_hwmon_pwm1, NULL, 0); | 976 | static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO, asus_hwmon_pwm1, NULL, 0); |
977 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, asus_hwmon_temp1, NULL, 0); | ||
829 | 978 | ||
830 | static ssize_t | 979 | static ssize_t |
831 | show_name(struct device *dev, struct device_attribute *attr, char *buf) | 980 | show_name(struct device *dev, struct device_attribute *attr, char *buf) |
@@ -836,12 +985,13 @@ static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, 0); | |||
836 | 985 | ||
837 | static struct attribute *hwmon_attributes[] = { | 986 | static struct attribute *hwmon_attributes[] = { |
838 | &sensor_dev_attr_pwm1.dev_attr.attr, | 987 | &sensor_dev_attr_pwm1.dev_attr.attr, |
988 | &sensor_dev_attr_temp1_input.dev_attr.attr, | ||
839 | &sensor_dev_attr_name.dev_attr.attr, | 989 | &sensor_dev_attr_name.dev_attr.attr, |
840 | NULL | 990 | NULL |
841 | }; | 991 | }; |
842 | 992 | ||
843 | static mode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj, | 993 | static mode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj, |
844 | struct attribute *attr, int idx) | 994 | struct attribute *attr, int idx) |
845 | { | 995 | { |
846 | struct device *dev = container_of(kobj, struct device, kobj); | 996 | struct device *dev = container_of(kobj, struct device, kobj); |
847 | struct platform_device *pdev = to_platform_device(dev->parent); | 997 | struct platform_device *pdev = to_platform_device(dev->parent); |
@@ -852,6 +1002,8 @@ static mode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj, | |||
852 | 1002 | ||
853 | if (attr == &sensor_dev_attr_pwm1.dev_attr.attr) | 1003 | if (attr == &sensor_dev_attr_pwm1.dev_attr.attr) |
854 | dev_id = ASUS_WMI_DEVID_FAN_CTRL; | 1004 | dev_id = ASUS_WMI_DEVID_FAN_CTRL; |
1005 | else if (attr == &sensor_dev_attr_temp1_input.dev_attr.attr) | ||
1006 | dev_id = ASUS_WMI_DEVID_THERMAL_CTRL; | ||
855 | 1007 | ||
856 | if (dev_id != -1) { | 1008 | if (dev_id != -1) { |
857 | int err = asus_wmi_get_devstate(asus, dev_id, &value); | 1009 | int err = asus_wmi_get_devstate(asus, dev_id, &value); |
@@ -869,9 +1021,13 @@ static mode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj, | |||
869 | * - reverved bits are non-zero | 1021 | * - reverved bits are non-zero |
870 | * - sfun and presence bit are not set | 1022 | * - sfun and presence bit are not set |
871 | */ | 1023 | */ |
872 | if (value != ASUS_WMI_UNSUPPORTED_METHOD || value & 0xFFF80000 | 1024 | if (value == ASUS_WMI_UNSUPPORTED_METHOD || value & 0xFFF80000 |
873 | || (!asus->sfun && !(value & ASUS_WMI_DSTS_PRESENCE_BIT))) | 1025 | || (!asus->sfun && !(value & ASUS_WMI_DSTS_PRESENCE_BIT))) |
874 | ok = false; | 1026 | ok = false; |
1027 | } else if (dev_id == ASUS_WMI_DEVID_THERMAL_CTRL) { | ||
1028 | /* If value is zero, something is clearly wrong */ | ||
1029 | if (value == 0) | ||
1030 | ok = false; | ||
875 | } | 1031 | } |
876 | 1032 | ||
877 | return ok ? attr->mode : 0; | 1033 | return ok ? attr->mode : 0; |
@@ -904,6 +1060,7 @@ static int asus_wmi_hwmon_init(struct asus_wmi *asus) | |||
904 | pr_err("Could not register asus hwmon device\n"); | 1060 | pr_err("Could not register asus hwmon device\n"); |
905 | return PTR_ERR(hwmon); | 1061 | return PTR_ERR(hwmon); |
906 | } | 1062 | } |
1063 | dev_set_drvdata(hwmon, asus); | ||
907 | asus->hwmon_device = hwmon; | 1064 | asus->hwmon_device = hwmon; |
908 | result = sysfs_create_group(&hwmon->kobj, &hwmon_attribute_group); | 1065 | result = sysfs_create_group(&hwmon->kobj, &hwmon_attribute_group); |
909 | if (result) | 1066 | if (result) |
@@ -1060,6 +1217,8 @@ static void asus_wmi_notify(u32 value, void *context) | |||
1060 | acpi_status status; | 1217 | acpi_status status; |
1061 | int code; | 1218 | int code; |
1062 | int orig_code; | 1219 | int orig_code; |
1220 | unsigned int key_value = 1; | ||
1221 | bool autorelease = 1; | ||
1063 | 1222 | ||
1064 | status = wmi_get_event_data(value, &response); | 1223 | status = wmi_get_event_data(value, &response); |
1065 | if (status != AE_OK) { | 1224 | if (status != AE_OK) { |
@@ -1075,6 +1234,13 @@ static void asus_wmi_notify(u32 value, void *context) | |||
1075 | code = obj->integer.value; | 1234 | code = obj->integer.value; |
1076 | orig_code = code; | 1235 | orig_code = code; |
1077 | 1236 | ||
1237 | if (asus->driver->key_filter) { | ||
1238 | asus->driver->key_filter(asus->driver, &code, &key_value, | ||
1239 | &autorelease); | ||
1240 | if (code == ASUS_WMI_KEY_IGNORE) | ||
1241 | goto exit; | ||
1242 | } | ||
1243 | |||
1078 | if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX) | 1244 | if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX) |
1079 | code = NOTIFY_BRNUP_MIN; | 1245 | code = NOTIFY_BRNUP_MIN; |
1080 | else if (code >= NOTIFY_BRNDOWN_MIN && | 1246 | else if (code >= NOTIFY_BRNDOWN_MIN && |
@@ -1084,7 +1250,8 @@ static void asus_wmi_notify(u32 value, void *context) | |||
1084 | if (code == NOTIFY_BRNUP_MIN || code == NOTIFY_BRNDOWN_MIN) { | 1250 | if (code == NOTIFY_BRNUP_MIN || code == NOTIFY_BRNDOWN_MIN) { |
1085 | if (!acpi_video_backlight_support()) | 1251 | if (!acpi_video_backlight_support()) |
1086 | asus_wmi_backlight_notify(asus, orig_code); | 1252 | asus_wmi_backlight_notify(asus, orig_code); |
1087 | } else if (!sparse_keymap_report_event(asus->inputdev, code, 1, true)) | 1253 | } else if (!sparse_keymap_report_event(asus->inputdev, code, |
1254 | key_value, autorelease)) | ||
1088 | pr_info("Unknown key %x pressed\n", code); | 1255 | pr_info("Unknown key %x pressed\n", code); |
1089 | 1256 | ||
1090 | exit: | 1257 | exit: |
@@ -1164,14 +1331,18 @@ ASUS_WMI_CREATE_DEVICE_ATTR(cardr, 0644, ASUS_WMI_DEVID_CARDREADER); | |||
1164 | static ssize_t store_cpufv(struct device *dev, struct device_attribute *attr, | 1331 | static ssize_t store_cpufv(struct device *dev, struct device_attribute *attr, |
1165 | const char *buf, size_t count) | 1332 | const char *buf, size_t count) |
1166 | { | 1333 | { |
1167 | int value; | 1334 | int value, rv; |
1168 | 1335 | ||
1169 | if (!count || sscanf(buf, "%i", &value) != 1) | 1336 | if (!count || sscanf(buf, "%i", &value) != 1) |
1170 | return -EINVAL; | 1337 | return -EINVAL; |
1171 | if (value < 0 || value > 2) | 1338 | if (value < 0 || value > 2) |
1172 | return -EINVAL; | 1339 | return -EINVAL; |
1173 | 1340 | ||
1174 | return asus_wmi_evaluate_method(ASUS_WMI_METHODID_CFVS, value, 0, NULL); | 1341 | rv = asus_wmi_evaluate_method(ASUS_WMI_METHODID_CFVS, value, 0, NULL); |
1342 | if (rv < 0) | ||
1343 | return rv; | ||
1344 | |||
1345 | return count; | ||
1175 | } | 1346 | } |
1176 | 1347 | ||
1177 | static DEVICE_ATTR(cpufv, S_IRUGO | S_IWUSR, NULL, store_cpufv); | 1348 | static DEVICE_ATTR(cpufv, S_IRUGO | S_IWUSR, NULL, store_cpufv); |
@@ -1234,7 +1405,7 @@ static int asus_wmi_platform_init(struct asus_wmi *asus) | |||
1234 | 1405 | ||
1235 | /* We don't know yet what to do with this version... */ | 1406 | /* We don't know yet what to do with this version... */ |
1236 | if (!asus_wmi_evaluate_method(ASUS_WMI_METHODID_SPEC, 0, 0x9, &rv)) { | 1407 | if (!asus_wmi_evaluate_method(ASUS_WMI_METHODID_SPEC, 0, 0x9, &rv)) { |
1237 | pr_info("BIOS WMI version: %d.%d", rv >> 8, rv & 0xFF); | 1408 | pr_info("BIOS WMI version: %d.%d", rv >> 16, rv & 0xFF); |
1238 | asus->spec = rv; | 1409 | asus->spec = rv; |
1239 | } | 1410 | } |
1240 | 1411 | ||
@@ -1266,6 +1437,12 @@ static int asus_wmi_platform_init(struct asus_wmi *asus) | |||
1266 | return -ENODEV; | 1437 | return -ENODEV; |
1267 | } | 1438 | } |
1268 | 1439 | ||
1440 | /* CWAP allow to define the behavior of the Fn+F2 key, | ||
1441 | * this method doesn't seems to be present on Eee PCs */ | ||
1442 | if (asus->driver->wapf >= 0) | ||
1443 | asus_wmi_set_devstate(ASUS_WMI_DEVID_CWAP, | ||
1444 | asus->driver->wapf, NULL); | ||
1445 | |||
1269 | return asus_wmi_sysfs_init(asus->platform_device); | 1446 | return asus_wmi_sysfs_init(asus->platform_device); |
1270 | } | 1447 | } |
1271 | 1448 | ||
@@ -1568,6 +1745,14 @@ static int asus_hotk_restore(struct device *device) | |||
1568 | bl = !asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_WWAN3G); | 1745 | bl = !asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_WWAN3G); |
1569 | rfkill_set_sw_state(asus->wwan3g.rfkill, bl); | 1746 | rfkill_set_sw_state(asus->wwan3g.rfkill, bl); |
1570 | } | 1747 | } |
1748 | if (asus->gps.rfkill) { | ||
1749 | bl = !asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPS); | ||
1750 | rfkill_set_sw_state(asus->gps.rfkill, bl); | ||
1751 | } | ||
1752 | if (asus->uwb.rfkill) { | ||
1753 | bl = !asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_UWB); | ||
1754 | rfkill_set_sw_state(asus->uwb.rfkill, bl); | ||
1755 | } | ||
1571 | 1756 | ||
1572 | return 0; | 1757 | return 0; |
1573 | } | 1758 | } |
@@ -1604,7 +1789,7 @@ static int asus_wmi_probe(struct platform_device *pdev) | |||
1604 | 1789 | ||
1605 | static bool used; | 1790 | static bool used; |
1606 | 1791 | ||
1607 | int asus_wmi_register_driver(struct asus_wmi_driver *driver) | 1792 | int __init_or_module asus_wmi_register_driver(struct asus_wmi_driver *driver) |
1608 | { | 1793 | { |
1609 | struct platform_driver *platform_driver; | 1794 | struct platform_driver *platform_driver; |
1610 | struct platform_device *platform_device; | 1795 | struct platform_device *platform_device; |