2 * asus-laptop.c - Asus Laptop Support
5 * Copyright (C) 2002-2005 Julien Lerouge, 2003-2006 Karol Kozimor
6 * Copyright (C) 2006-2007 Corentin Chary
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * The development page for this driver is located at
24 * http://sourceforge.net/projects/acpi4asus/
27 * Pontus Fuchs - Helper functions, cleanup
28 * Johann Wiesner - Small compile fixes
29 * John Belmonte - ACPI code for Toshiba laptop was a good starting point.
30 * Eric Burghard - LED display support for W1N
31 * Josh Green - Light Sens support
32 * Thomas Tuttle - His first patch for led support was very helpfull
33 * Sam Lin - GPS support
36 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
38 #include <linux/kernel.h>
39 #include <linux/module.h>
40 #include <linux/init.h>
41 #include <linux/types.h>
42 #include <linux/err.h>
43 #include <linux/proc_fs.h>
44 #include <linux/backlight.h>
46 #include <linux/leds.h>
47 #include <linux/platform_device.h>
48 #include <linux/uaccess.h>
49 #include <linux/input.h>
50 #include <linux/input/sparse-keymap.h>
51 #include <linux/rfkill.h>
52 #include <linux/slab.h>
53 #include <acpi/acpi_drivers.h>
54 #include <acpi/acpi_bus.h>
56 #define ASUS_LAPTOP_VERSION "0.42"
58 #define ASUS_LAPTOP_NAME "Asus Laptop Support"
59 #define ASUS_LAPTOP_CLASS "hotkey"
60 #define ASUS_LAPTOP_DEVICE_NAME "Hotkey"
61 #define ASUS_LAPTOP_FILE KBUILD_MODNAME
62 #define ASUS_LAPTOP_PREFIX "\\_SB.ATKD."
64 MODULE_AUTHOR("Julien Lerouge, Karol Kozimor, Corentin Chary");
65 MODULE_DESCRIPTION(ASUS_LAPTOP_NAME);
66 MODULE_LICENSE("GPL");
69 * WAPF defines the behavior of the Fn+Fx wlan key
70 * The significance of values is yet to be found, but
73 * 0x1 will allow to control the device with Fn+Fx key.
74 * 0x4 will send an ACPI event (0x88) while pressing the Fn+Fx key
76 * So, if something doesn't work as you want, just try other values =)
79 module_param(wapf, uint, 0444);
80 MODULE_PARM_DESC(wapf, "WAPF value");
82 static int wlan_status = 1;
83 static int bluetooth_status = 1;
84 static int wimax_status = -1;
85 static int wwan_status = -1;
87 module_param(wlan_status, int, 0444);
88 MODULE_PARM_DESC(wlan_status, "Set the wireless status on boot "
89 "(0 = disabled, 1 = enabled, -1 = don't do anything). "
92 module_param(bluetooth_status, int, 0444);
93 MODULE_PARM_DESC(bluetooth_status, "Set the wireless status on boot "
94 "(0 = disabled, 1 = enabled, -1 = don't do anything). "
97 module_param(wimax_status, int, 0444);
98 MODULE_PARM_DESC(wimax_status, "Set the wireless status on boot "
99 "(0 = disabled, 1 = enabled, -1 = don't do anything). "
102 module_param(wwan_status, int, 0444);
103 MODULE_PARM_DESC(wwan_status, "Set the wireless status on boot "
104 "(0 = disabled, 1 = enabled, -1 = don't do anything). "
108 * Some events we use, same for all Asus
110 #define ATKD_BR_UP 0x10 /* (event & ~ATKD_BR_UP) = brightness level */
111 #define ATKD_BR_DOWN 0x20 /* (event & ~ATKD_BR_DOWN) = britghness level */
112 #define ATKD_BR_MIN ATKD_BR_UP
113 #define ATKD_BR_MAX (ATKD_BR_DOWN | 0xF) /* 0x2f */
114 #define ATKD_LCD_ON 0x33
115 #define ATKD_LCD_OFF 0x34
118 * Known bits returned by \_SB.ATKD.HWRS
121 #define BT_HWRS 0x100
124 * Flags for hotk status
125 * WL_ON and BT_ON are also used for wireless_status()
127 #define WL_RSTS 0x01 /* internal Wifi */
128 #define BT_RSTS 0x02 /* internal Bluetooth */
129 #define WM_RSTS 0x08 /* internal wimax */
130 #define WW_RSTS 0x20 /* internal wwan */
133 #define METHOD_MLED "MLED"
134 #define METHOD_TLED "TLED"
135 #define METHOD_RLED "RLED" /* W1JC */
136 #define METHOD_PLED "PLED" /* A7J */
137 #define METHOD_GLED "GLED" /* G1, G2 (probably) */
140 #define METHOD_LEDD "SLCM"
144 * WLED and BLED are not handled like other XLED, because in some dsdt
145 * they also control the WLAN/Bluetooth device.
147 #define METHOD_WLAN "WLED"
148 #define METHOD_BLUETOOTH "BLED"
151 #define METHOD_WWAN "GSMC"
152 #define METHOD_WIMAX "WMXC"
154 #define METHOD_WL_STATUS "RSTS"
157 #define METHOD_BRIGHTNESS_SET "SPLV"
158 #define METHOD_BRIGHTNESS_GET "GPLV"
161 static acpi_handle lcd_switch_handle;
162 static char *lcd_switch_paths[] = {
163 "\\_SB.PCI0.SBRG.EC0._Q10", /* All new models */
164 "\\_SB.PCI0.ISA.EC0._Q10", /* A1x */
165 "\\_SB.PCI0.PX40.ECD0._Q10", /* L3C */
166 "\\_SB.PCI0.PX40.EC0.Q10", /* M1A */
167 "\\_SB.PCI0.LPCB.EC0._Q10", /* P30 */
168 "\\_SB.PCI0.LPCB.EC0._Q0E", /* P30/P35 */
169 "\\_SB.PCI0.PX40.Q10", /* S1x */
170 "\\Q10"}; /* A2x, L2D, L3D, M2E */
173 #define METHOD_SWITCH_DISPLAY "SDSP"
175 static acpi_handle display_get_handle;
176 static char *display_get_paths[] = {
177 /* A6B, A6K A6R A7D F3JM L4R M6R A3G M6A M6V VX-1 V6J V6V W3Z */
178 "\\_SB.PCI0.P0P1.VGA.GETD",
179 /* A3E A4K, A4D A4L A6J A7J A8J Z71V M9V S5A M5A z33A W1Jc W2V G1 */
180 "\\_SB.PCI0.P0P2.VGA.GETD",
182 "\\_SB.PCI0.P0P3.VGA.GETD",
184 "\\_SB.PCI0.P0PA.VGA.GETD",
186 "\\_SB.PCI0.PCI1.VGAC.NMAP",
188 "\\_SB.PCI0.VGA.GETD",
191 /* A4G Z71A W1N W5A W5F M2N M3N M5N M6N S1N S5N */
195 /* A2H D1 L2D L3D L3H L2E L5D L5C M1A M2E L4L W3V */
197 /* A3F A6F A3N A3L M6N W3N W6A */
200 #define METHOD_ALS_CONTROL "ALSC" /* Z71A Z71V */
201 #define METHOD_ALS_LEVEL "ALSL" /* Z71A Z71V */
204 /* R2H use different handle for GPS on/off */
205 #define METHOD_GPS_ON "SDON"
206 #define METHOD_GPS_OFF "SDOF"
207 #define METHOD_GPS_STATUS "GPST"
210 #define METHOD_KBD_LIGHT_SET "SLKB"
211 #define METHOD_KBD_LIGHT_GET "GLKB"
214 * Define a specific led structure to keep the main structure clean
218 struct work_struct work;
219 struct led_classdev led;
220 struct asus_laptop *asus;
225 * This is the main structure, we can use it to store anything interesting
226 * about the hotk device
229 char *name; /* laptop name */
231 struct acpi_table_header *dsdt_info;
232 struct platform_device *platform_device;
233 struct acpi_device *device; /* the device we are in */
234 struct backlight_device *backlight_device;
236 struct input_dev *inputdev;
237 struct key_entry *keymap;
239 struct asus_led mled;
240 struct asus_led tled;
241 struct asus_led rled;
242 struct asus_led pled;
243 struct asus_led gled;
244 struct asus_led kled;
245 struct workqueue_struct *led_workqueue;
251 struct rfkill *gps_rfkill;
253 acpi_handle handle; /* the handle of the hotk device */
254 u32 ledd_status; /* status of the LED display */
255 u8 light_level; /* light sensor level */
256 u8 light_switch; /* light sensor switch value */
257 u16 event_count[128]; /* count for each event TODO make this better */
260 static const struct key_entry asus_keymap[] = {
261 /* Lenovo SL Specific keycodes */
262 {KE_KEY, 0x02, { KEY_SCREENLOCK } },
263 {KE_KEY, 0x05, { KEY_WLAN } },
264 {KE_KEY, 0x08, { KEY_F13 } },
265 {KE_KEY, 0x17, { KEY_ZOOM } },
266 {KE_KEY, 0x1f, { KEY_BATTERY } },
267 /* End of Lenovo SL Specific keycodes */
268 {KE_KEY, 0x30, { KEY_VOLUMEUP } },
269 {KE_KEY, 0x31, { KEY_VOLUMEDOWN } },
270 {KE_KEY, 0x32, { KEY_MUTE } },
271 {KE_KEY, 0x33, { KEY_SWITCHVIDEOMODE } },
272 {KE_KEY, 0x34, { KEY_SWITCHVIDEOMODE } },
273 {KE_KEY, 0x40, { KEY_PREVIOUSSONG } },
274 {KE_KEY, 0x41, { KEY_NEXTSONG } },
275 {KE_KEY, 0x43, { KEY_STOPCD } },
276 {KE_KEY, 0x45, { KEY_PLAYPAUSE } },
277 {KE_KEY, 0x4c, { KEY_MEDIA } },
278 {KE_KEY, 0x50, { KEY_EMAIL } },
279 {KE_KEY, 0x51, { KEY_WWW } },
280 {KE_KEY, 0x55, { KEY_CALC } },
281 {KE_KEY, 0x5C, { KEY_SCREENLOCK } }, /* Screenlock */
282 {KE_KEY, 0x5D, { KEY_WLAN } },
283 {KE_KEY, 0x5E, { KEY_WLAN } },
284 {KE_KEY, 0x5F, { KEY_WLAN } },
285 {KE_KEY, 0x60, { KEY_SWITCHVIDEOMODE } },
286 {KE_KEY, 0x61, { KEY_SWITCHVIDEOMODE } },
287 {KE_KEY, 0x62, { KEY_SWITCHVIDEOMODE } },
288 {KE_KEY, 0x63, { KEY_SWITCHVIDEOMODE } },
289 {KE_KEY, 0x6B, { KEY_F13 } }, /* Lock Touchpad */
290 {KE_KEY, 0x7E, { KEY_BLUETOOTH } },
291 {KE_KEY, 0x7D, { KEY_BLUETOOTH } },
292 {KE_KEY, 0x82, { KEY_CAMERA } },
293 {KE_KEY, 0x88, { KEY_WLAN } },
294 {KE_KEY, 0x8A, { KEY_PROG1 } },
295 {KE_KEY, 0x95, { KEY_MEDIA } },
296 {KE_KEY, 0x99, { KEY_PHONE } },
297 {KE_KEY, 0xc4, { KEY_KBDILLUMUP } },
298 {KE_KEY, 0xc5, { KEY_KBDILLUMDOWN } },
299 {KE_KEY, 0xb5, { KEY_CALC } },
305 * This function evaluates an ACPI method, given an int as parameter, the
306 * method is searched within the scope of the handle, can be NULL. The output
307 * of the method is written is output, which can also be NULL
309 * returns 0 if write is successful, -1 else.
311 static int write_acpi_int_ret(acpi_handle handle, const char *method, int val,
312 struct acpi_buffer *output)
314 struct acpi_object_list params; /* list of input parameters (an int) */
315 union acpi_object in_obj; /* the only param we use */
322 params.pointer = &in_obj;
323 in_obj.type = ACPI_TYPE_INTEGER;
324 in_obj.integer.value = val;
326 status = acpi_evaluate_object(handle, (char *)method, ¶ms, output);
333 static int write_acpi_int(acpi_handle handle, const char *method, int val)
335 return write_acpi_int_ret(handle, method, val, NULL);
338 static int acpi_check_handle(acpi_handle handle, const char *method,
347 status = acpi_get_handle(handle, (char *)method,
352 status = acpi_get_handle(handle, (char *)method,
356 if (status != AE_OK) {
358 pr_warning("Error finding %s\n", method);
364 /* Generic LED function */
365 static int asus_led_set(struct asus_laptop *asus, const char *method,
368 if (!strcmp(method, METHOD_MLED))
370 else if (!strcmp(method, METHOD_GLED))
375 return write_acpi_int(asus->handle, method, value);
381 /* /sys/class/led handlers */
382 static void asus_led_cdev_set(struct led_classdev *led_cdev,
383 enum led_brightness value)
385 struct asus_led *led = container_of(led_cdev, struct asus_led, led);
386 struct asus_laptop *asus = led->asus;
389 queue_work(asus->led_workqueue, &led->work);
392 static void asus_led_cdev_update(struct work_struct *work)
394 struct asus_led *led = container_of(work, struct asus_led, work);
395 struct asus_laptop *asus = led->asus;
397 asus_led_set(asus, led->method, led->wk);
400 static enum led_brightness asus_led_cdev_get(struct led_classdev *led_cdev)
402 return led_cdev->brightness;
406 * Keyboard backlight (also a LED)
408 static int asus_kled_lvl(struct asus_laptop *asus)
410 unsigned long long kblv;
411 struct acpi_object_list params;
412 union acpi_object in_obj;
416 params.pointer = &in_obj;
417 in_obj.type = ACPI_TYPE_INTEGER;
418 in_obj.integer.value = 2;
420 rv = acpi_evaluate_integer(asus->handle, METHOD_KBD_LIGHT_GET,
422 if (ACPI_FAILURE(rv)) {
423 pr_warning("Error reading kled level\n");
429 static int asus_kled_set(struct asus_laptop *asus, int kblv)
432 kblv = (1 << 7) | (kblv & 0x7F);
436 if (write_acpi_int(asus->handle, METHOD_KBD_LIGHT_SET, kblv)) {
437 pr_warning("Keyboard LED display write failed\n");
443 static void asus_kled_cdev_set(struct led_classdev *led_cdev,
444 enum led_brightness value)
446 struct asus_led *led = container_of(led_cdev, struct asus_led, led);
447 struct asus_laptop *asus = led->asus;
450 queue_work(asus->led_workqueue, &led->work);
453 static void asus_kled_cdev_update(struct work_struct *work)
455 struct asus_led *led = container_of(work, struct asus_led, work);
456 struct asus_laptop *asus = led->asus;
458 asus_kled_set(asus, led->wk);
461 static enum led_brightness asus_kled_cdev_get(struct led_classdev *led_cdev)
463 struct asus_led *led = container_of(led_cdev, struct asus_led, led);
464 struct asus_laptop *asus = led->asus;
466 return asus_kled_lvl(asus);
469 static void asus_led_exit(struct asus_laptop *asus)
471 if (asus->mled.led.dev)
472 led_classdev_unregister(&asus->mled.led);
473 if (asus->tled.led.dev)
474 led_classdev_unregister(&asus->tled.led);
475 if (asus->pled.led.dev)
476 led_classdev_unregister(&asus->pled.led);
477 if (asus->rled.led.dev)
478 led_classdev_unregister(&asus->rled.led);
479 if (asus->gled.led.dev)
480 led_classdev_unregister(&asus->gled.led);
481 if (asus->kled.led.dev)
482 led_classdev_unregister(&asus->kled.led);
483 if (asus->led_workqueue) {
484 destroy_workqueue(asus->led_workqueue);
485 asus->led_workqueue = NULL;
489 /* Ugly macro, need to fix that later */
490 static int asus_led_register(struct asus_laptop *asus,
491 struct asus_led *led,
492 const char *name, const char *method)
494 struct led_classdev *led_cdev = &led->led;
496 if (!method || acpi_check_handle(asus->handle, method, NULL))
497 return 0; /* Led not present */
500 led->method = method;
502 INIT_WORK(&led->work, asus_led_cdev_update);
503 led_cdev->name = name;
504 led_cdev->brightness_set = asus_led_cdev_set;
505 led_cdev->brightness_get = asus_led_cdev_get;
506 led_cdev->max_brightness = 1;
507 return led_classdev_register(&asus->platform_device->dev, led_cdev);
510 static int asus_led_init(struct asus_laptop *asus)
515 * Functions that actually update the LED's are called from a
516 * workqueue. By doing this as separate work rather than when the LED
517 * subsystem asks, we avoid messing with the Asus ACPI stuff during a
518 * potentially bad time, such as a timer interrupt.
520 asus->led_workqueue = create_singlethread_workqueue("led_workqueue");
521 if (!asus->led_workqueue)
524 r = asus_led_register(asus, &asus->mled, "asus::mail", METHOD_MLED);
527 r = asus_led_register(asus, &asus->tled, "asus::touchpad", METHOD_TLED);
530 r = asus_led_register(asus, &asus->rled, "asus::record", METHOD_RLED);
533 r = asus_led_register(asus, &asus->pled, "asus::phone", METHOD_PLED);
536 r = asus_led_register(asus, &asus->gled, "asus::gaming", METHOD_GLED);
539 if (!acpi_check_handle(asus->handle, METHOD_KBD_LIGHT_SET, NULL) &&
540 !acpi_check_handle(asus->handle, METHOD_KBD_LIGHT_GET, NULL)) {
541 struct asus_led *led = &asus->kled;
542 struct led_classdev *cdev = &led->led;
546 INIT_WORK(&led->work, asus_kled_cdev_update);
547 cdev->name = "asus::kbd_backlight";
548 cdev->brightness_set = asus_kled_cdev_set;
549 cdev->brightness_get = asus_kled_cdev_get;
550 cdev->max_brightness = 3;
551 r = led_classdev_register(&asus->platform_device->dev, cdev);
562 static int asus_lcd_status(struct asus_laptop *asus)
564 return asus->lcd_state;
567 static int asus_lcd_set(struct asus_laptop *asus, int value)
570 acpi_status status = 0;
574 if (lcd == asus_lcd_status(asus))
577 if (!lcd_switch_handle)
580 status = acpi_evaluate_object(lcd_switch_handle,
583 if (ACPI_FAILURE(status)) {
584 pr_warning("Error switching LCD\n");
588 asus->lcd_state = lcd;
592 static void lcd_blank(struct asus_laptop *asus, int blank)
594 struct backlight_device *bd = asus->backlight_device;
596 asus->lcd_state = (blank == FB_BLANK_UNBLANK);
599 bd->props.power = blank;
600 backlight_update_status(bd);
604 static int asus_read_brightness(struct backlight_device *bd)
606 struct asus_laptop *asus = bl_get_data(bd);
607 unsigned long long value;
608 acpi_status rv = AE_OK;
610 rv = acpi_evaluate_integer(asus->handle, METHOD_BRIGHTNESS_GET,
612 if (ACPI_FAILURE(rv))
613 pr_warning("Error reading brightness\n");
618 static int asus_set_brightness(struct backlight_device *bd, int value)
620 struct asus_laptop *asus = bl_get_data(bd);
622 if (write_acpi_int(asus->handle, METHOD_BRIGHTNESS_SET, value)) {
623 pr_warning("Error changing brightness\n");
629 static int update_bl_status(struct backlight_device *bd)
631 struct asus_laptop *asus = bl_get_data(bd);
633 int value = bd->props.brightness;
635 rv = asus_set_brightness(bd, value);
639 value = (bd->props.power == FB_BLANK_UNBLANK) ? 1 : 0;
640 return asus_lcd_set(asus, value);
643 static const struct backlight_ops asusbl_ops = {
644 .get_brightness = asus_read_brightness,
645 .update_status = update_bl_status,
648 static int asus_backlight_notify(struct asus_laptop *asus)
650 struct backlight_device *bd = asus->backlight_device;
651 int old = bd->props.brightness;
653 backlight_force_update(bd, BACKLIGHT_UPDATE_HOTKEY);
658 static int asus_backlight_init(struct asus_laptop *asus)
660 struct backlight_device *bd;
661 struct backlight_properties props;
663 if (acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_GET, NULL) ||
664 acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_SET, NULL) ||
668 memset(&props, 0, sizeof(struct backlight_properties));
669 props.max_brightness = 15;
670 props.type = BACKLIGHT_PLATFORM;
672 bd = backlight_device_register(ASUS_LAPTOP_FILE,
673 &asus->platform_device->dev, asus,
674 &asusbl_ops, &props);
676 pr_err("Could not register asus backlight device\n");
677 asus->backlight_device = NULL;
681 asus->backlight_device = bd;
682 bd->props.brightness = asus_read_brightness(bd);
683 bd->props.power = FB_BLANK_UNBLANK;
684 backlight_update_status(bd);
688 static void asus_backlight_exit(struct asus_laptop *asus)
690 if (asus->backlight_device)
691 backlight_device_unregister(asus->backlight_device);
692 asus->backlight_device = NULL;
696 * Platform device handlers
700 * We write our info in page, we begin at offset off and cannot write more
701 * than count bytes. We set eof to 1 if we handle those 2 values. We return the
702 * number of bytes written in page
704 static ssize_t show_infos(struct device *dev,
705 struct device_attribute *attr, char *page)
707 struct asus_laptop *asus = dev_get_drvdata(dev);
709 unsigned long long temp;
710 char buf[16]; /* enough for all info */
711 acpi_status rv = AE_OK;
714 * We use the easy way, we don't care of off and count,
715 * so we don't set eof to 1
718 len += sprintf(page, ASUS_LAPTOP_NAME " " ASUS_LAPTOP_VERSION "\n");
719 len += sprintf(page + len, "Model reference : %s\n", asus->name);
721 * The SFUN method probably allows the original driver to get the list
722 * of features supported by a given model. For now, 0x0100 or 0x0800
723 * bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card.
724 * The significance of others is yet to be found.
726 rv = acpi_evaluate_integer(asus->handle, "SFUN", NULL, &temp);
727 if (!ACPI_FAILURE(rv))
728 len += sprintf(page + len, "SFUN value : %#x\n",
731 * The HWRS method return informations about the hardware.
732 * 0x80 bit is for WLAN, 0x100 for Bluetooth.
733 * The significance of others is yet to be found.
734 * If we don't find the method, we assume the device are present.
736 rv = acpi_evaluate_integer(asus->handle, "HRWS", NULL, &temp);
737 if (!ACPI_FAILURE(rv))
738 len += sprintf(page + len, "HRWS value : %#x\n",
741 * Another value for userspace: the ASYM method returns 0x02 for
742 * battery low and 0x04 for battery critical, its readings tend to be
743 * more accurate than those provided by _BST.
744 * Note: since not all the laptops provide this method, errors are
747 rv = acpi_evaluate_integer(asus->handle, "ASYM", NULL, &temp);
748 if (!ACPI_FAILURE(rv))
749 len += sprintf(page + len, "ASYM value : %#x\n",
751 if (asus->dsdt_info) {
752 snprintf(buf, 16, "%d", asus->dsdt_info->length);
753 len += sprintf(page + len, "DSDT length : %s\n", buf);
754 snprintf(buf, 16, "%d", asus->dsdt_info->checksum);
755 len += sprintf(page + len, "DSDT checksum : %s\n", buf);
756 snprintf(buf, 16, "%d", asus->dsdt_info->revision);
757 len += sprintf(page + len, "DSDT revision : %s\n", buf);
758 snprintf(buf, 7, "%s", asus->dsdt_info->oem_id);
759 len += sprintf(page + len, "OEM id : %s\n", buf);
760 snprintf(buf, 9, "%s", asus->dsdt_info->oem_table_id);
761 len += sprintf(page + len, "OEM table id : %s\n", buf);
762 snprintf(buf, 16, "%x", asus->dsdt_info->oem_revision);
763 len += sprintf(page + len, "OEM revision : 0x%s\n", buf);
764 snprintf(buf, 5, "%s", asus->dsdt_info->asl_compiler_id);
765 len += sprintf(page + len, "ASL comp vendor id : %s\n", buf);
766 snprintf(buf, 16, "%x", asus->dsdt_info->asl_compiler_revision);
767 len += sprintf(page + len, "ASL comp revision : 0x%s\n", buf);
773 static int parse_arg(const char *buf, unsigned long count, int *val)
779 if (sscanf(buf, "%i", val) != 1)
784 static ssize_t sysfs_acpi_set(struct asus_laptop *asus,
785 const char *buf, size_t count,
791 rv = parse_arg(buf, count, &value);
795 if (write_acpi_int(asus->handle, method, value))
803 static ssize_t show_ledd(struct device *dev,
804 struct device_attribute *attr, char *buf)
806 struct asus_laptop *asus = dev_get_drvdata(dev);
808 return sprintf(buf, "0x%08x\n", asus->ledd_status);
811 static ssize_t store_ledd(struct device *dev, struct device_attribute *attr,
812 const char *buf, size_t count)
814 struct asus_laptop *asus = dev_get_drvdata(dev);
817 rv = parse_arg(buf, count, &value);
819 if (write_acpi_int(asus->handle, METHOD_LEDD, value)) {
820 pr_warning("LED display write failed\n");
823 asus->ledd_status = (u32) value;
831 static int asus_wireless_status(struct asus_laptop *asus, int mask)
833 unsigned long long status;
834 acpi_status rv = AE_OK;
836 if (!asus->have_rsts)
837 return (asus->wireless_status & mask) ? 1 : 0;
839 rv = acpi_evaluate_integer(asus->handle, METHOD_WL_STATUS,
841 if (ACPI_FAILURE(rv)) {
842 pr_warning("Error reading Wireless status\n");
845 return !!(status & mask);
851 static int asus_wlan_set(struct asus_laptop *asus, int status)
853 if (write_acpi_int(asus->handle, METHOD_WLAN, !!status)) {
854 pr_warning("Error setting wlan status to %d", status);
860 static ssize_t show_wlan(struct device *dev,
861 struct device_attribute *attr, char *buf)
863 struct asus_laptop *asus = dev_get_drvdata(dev);
865 return sprintf(buf, "%d\n", asus_wireless_status(asus, WL_RSTS));
868 static ssize_t store_wlan(struct device *dev, struct device_attribute *attr,
869 const char *buf, size_t count)
871 struct asus_laptop *asus = dev_get_drvdata(dev);
873 return sysfs_acpi_set(asus, buf, count, METHOD_WLAN);
879 static int asus_bluetooth_set(struct asus_laptop *asus, int status)
881 if (write_acpi_int(asus->handle, METHOD_BLUETOOTH, !!status)) {
882 pr_warning("Error setting bluetooth status to %d", status);
888 static ssize_t show_bluetooth(struct device *dev,
889 struct device_attribute *attr, char *buf)
891 struct asus_laptop *asus = dev_get_drvdata(dev);
893 return sprintf(buf, "%d\n", asus_wireless_status(asus, BT_RSTS));
896 static ssize_t store_bluetooth(struct device *dev,
897 struct device_attribute *attr, const char *buf,
900 struct asus_laptop *asus = dev_get_drvdata(dev);
902 return sysfs_acpi_set(asus, buf, count, METHOD_BLUETOOTH);
908 static int asus_wimax_set(struct asus_laptop *asus, int status)
910 if (write_acpi_int(asus->handle, METHOD_WIMAX, !!status)) {
911 pr_warning("Error setting wimax status to %d", status);
917 static ssize_t show_wimax(struct device *dev,
918 struct device_attribute *attr, char *buf)
920 struct asus_laptop *asus = dev_get_drvdata(dev);
922 return sprintf(buf, "%d\n", asus_wireless_status(asus, WM_RSTS));
925 static ssize_t store_wimax(struct device *dev,
926 struct device_attribute *attr, const char *buf,
929 struct asus_laptop *asus = dev_get_drvdata(dev);
931 return sysfs_acpi_set(asus, buf, count, METHOD_WIMAX);
937 static int asus_wwan_set(struct asus_laptop *asus, int status)
939 if (write_acpi_int(asus->handle, METHOD_WWAN, !!status)) {
940 pr_warning("Error setting wwan status to %d", status);
946 static ssize_t show_wwan(struct device *dev,
947 struct device_attribute *attr, char *buf)
949 struct asus_laptop *asus = dev_get_drvdata(dev);
951 return sprintf(buf, "%d\n", asus_wireless_status(asus, WW_RSTS));
954 static ssize_t store_wwan(struct device *dev,
955 struct device_attribute *attr, const char *buf,
958 struct asus_laptop *asus = dev_get_drvdata(dev);
960 return sysfs_acpi_set(asus, buf, count, METHOD_WWAN);
966 static void asus_set_display(struct asus_laptop *asus, int value)
968 /* no sanity check needed for now */
969 if (write_acpi_int(asus->handle, METHOD_SWITCH_DISPLAY, value))
970 pr_warning("Error setting display\n");
974 static int read_display(struct asus_laptop *asus)
976 unsigned long long value = 0;
977 acpi_status rv = AE_OK;
980 * In most of the case, we know how to set the display, but sometime
983 if (display_get_handle) {
984 rv = acpi_evaluate_integer(display_get_handle, NULL,
986 if (ACPI_FAILURE(rv))
987 pr_warning("Error reading display status\n");
990 value &= 0x0F; /* needed for some models, shouldn't hurt others */
996 * Now, *this* one could be more user-friendly, but so far, no-one has
997 * complained. The significance of bits is the same as in store_disp()
999 static ssize_t show_disp(struct device *dev,
1000 struct device_attribute *attr, char *buf)
1002 struct asus_laptop *asus = dev_get_drvdata(dev);
1004 if (!display_get_handle)
1006 return sprintf(buf, "%d\n", read_display(asus));
1010 * Experimental support for display switching. As of now: 1 should activate
1011 * the LCD output, 2 should do for CRT, 4 for TV-Out and 8 for DVI.
1012 * Any combination (bitwise) of these will suffice. I never actually tested 4
1013 * displays hooked up simultaneously, so be warned. See the acpi4asus README
1016 static ssize_t store_disp(struct device *dev, struct device_attribute *attr,
1017 const char *buf, size_t count)
1019 struct asus_laptop *asus = dev_get_drvdata(dev);
1022 rv = parse_arg(buf, count, &value);
1024 asus_set_display(asus, value);
1031 static void asus_als_switch(struct asus_laptop *asus, int value)
1033 if (write_acpi_int(asus->handle, METHOD_ALS_CONTROL, value))
1034 pr_warning("Error setting light sensor switch\n");
1035 asus->light_switch = value;
1038 static ssize_t show_lssw(struct device *dev,
1039 struct device_attribute *attr, char *buf)
1041 struct asus_laptop *asus = dev_get_drvdata(dev);
1043 return sprintf(buf, "%d\n", asus->light_switch);
1046 static ssize_t store_lssw(struct device *dev, struct device_attribute *attr,
1047 const char *buf, size_t count)
1049 struct asus_laptop *asus = dev_get_drvdata(dev);
1052 rv = parse_arg(buf, count, &value);
1054 asus_als_switch(asus, value ? 1 : 0);
1059 static void asus_als_level(struct asus_laptop *asus, int value)
1061 if (write_acpi_int(asus->handle, METHOD_ALS_LEVEL, value))
1062 pr_warning("Error setting light sensor level\n");
1063 asus->light_level = value;
1066 static ssize_t show_lslvl(struct device *dev,
1067 struct device_attribute *attr, char *buf)
1069 struct asus_laptop *asus = dev_get_drvdata(dev);
1071 return sprintf(buf, "%d\n", asus->light_level);
1074 static ssize_t store_lslvl(struct device *dev, struct device_attribute *attr,
1075 const char *buf, size_t count)
1077 struct asus_laptop *asus = dev_get_drvdata(dev);
1080 rv = parse_arg(buf, count, &value);
1082 value = (0 < value) ? ((15 < value) ? 15 : value) : 0;
1083 /* 0 <= value <= 15 */
1084 asus_als_level(asus, value);
1093 static int asus_gps_status(struct asus_laptop *asus)
1095 unsigned long long status;
1096 acpi_status rv = AE_OK;
1098 rv = acpi_evaluate_integer(asus->handle, METHOD_GPS_STATUS,
1100 if (ACPI_FAILURE(rv)) {
1101 pr_warning("Error reading GPS status\n");
1107 static int asus_gps_switch(struct asus_laptop *asus, int status)
1109 const char *meth = status ? METHOD_GPS_ON : METHOD_GPS_OFF;
1111 if (write_acpi_int(asus->handle, meth, 0x02))
1116 static ssize_t show_gps(struct device *dev,
1117 struct device_attribute *attr, char *buf)
1119 struct asus_laptop *asus = dev_get_drvdata(dev);
1121 return sprintf(buf, "%d\n", asus_gps_status(asus));
1124 static ssize_t store_gps(struct device *dev, struct device_attribute *attr,
1125 const char *buf, size_t count)
1127 struct asus_laptop *asus = dev_get_drvdata(dev);
1131 rv = parse_arg(buf, count, &value);
1134 ret = asus_gps_switch(asus, !!value);
1137 rfkill_set_sw_state(asus->gps_rfkill, !value);
1144 static int asus_gps_rfkill_set(void *data, bool blocked)
1146 struct asus_laptop *asus = data;
1148 return asus_gps_switch(asus, !blocked);
1151 static const struct rfkill_ops asus_gps_rfkill_ops = {
1152 .set_block = asus_gps_rfkill_set,
1155 static void asus_rfkill_exit(struct asus_laptop *asus)
1157 if (asus->gps_rfkill) {
1158 rfkill_unregister(asus->gps_rfkill);
1159 rfkill_destroy(asus->gps_rfkill);
1160 asus->gps_rfkill = NULL;
1164 static int asus_rfkill_init(struct asus_laptop *asus)
1168 if (acpi_check_handle(asus->handle, METHOD_GPS_ON, NULL) ||
1169 acpi_check_handle(asus->handle, METHOD_GPS_OFF, NULL) ||
1170 acpi_check_handle(asus->handle, METHOD_GPS_STATUS, NULL))
1173 asus->gps_rfkill = rfkill_alloc("asus-gps", &asus->platform_device->dev,
1175 &asus_gps_rfkill_ops, asus);
1176 if (!asus->gps_rfkill)
1179 result = rfkill_register(asus->gps_rfkill);
1181 rfkill_destroy(asus->gps_rfkill);
1182 asus->gps_rfkill = NULL;
1189 * Input device (i.e. hotkeys)
1191 static void asus_input_notify(struct asus_laptop *asus, int event)
1194 sparse_keymap_report_event(asus->inputdev, event, 1, true);
1197 static int asus_input_init(struct asus_laptop *asus)
1199 struct input_dev *input;
1202 input = input_allocate_device();
1204 pr_info("Unable to allocate input device\n");
1207 input->name = "Asus Laptop extra buttons";
1208 input->phys = ASUS_LAPTOP_FILE "/input0";
1209 input->id.bustype = BUS_HOST;
1210 input->dev.parent = &asus->platform_device->dev;
1212 error = sparse_keymap_setup(input, asus_keymap, NULL);
1214 pr_err("Unable to setup input device keymap\n");
1217 error = input_register_device(input);
1219 pr_info("Unable to register input device\n");
1220 goto err_free_keymap;
1223 asus->inputdev = input;
1227 sparse_keymap_free(input);
1229 input_free_device(input);
1233 static void asus_input_exit(struct asus_laptop *asus)
1235 if (asus->inputdev) {
1236 sparse_keymap_free(asus->inputdev);
1237 input_unregister_device(asus->inputdev);
1239 asus->inputdev = NULL;
1245 static void asus_acpi_notify(struct acpi_device *device, u32 event)
1247 struct asus_laptop *asus = acpi_driver_data(device);
1251 * We need to tell the backlight device when the backlight power is
1254 if (event == ATKD_LCD_ON)
1255 lcd_blank(asus, FB_BLANK_UNBLANK);
1256 else if (event == ATKD_LCD_OFF)
1257 lcd_blank(asus, FB_BLANK_POWERDOWN);
1259 /* TODO Find a better way to handle events count. */
1260 count = asus->event_count[event % 128]++;
1261 acpi_bus_generate_proc_event(asus->device, event, count);
1262 acpi_bus_generate_netlink_event(asus->device->pnp.device_class,
1263 dev_name(&asus->device->dev), event,
1266 /* Brightness events are special */
1267 if (event >= ATKD_BR_MIN && event <= ATKD_BR_MAX) {
1269 /* Ignore them completely if the acpi video driver is used */
1270 if (asus->backlight_device != NULL) {
1271 /* Update the backlight device. */
1272 asus_backlight_notify(asus);
1276 asus_input_notify(asus, event);
1279 static DEVICE_ATTR(infos, S_IRUGO, show_infos, NULL);
1280 static DEVICE_ATTR(wlan, S_IRUGO | S_IWUSR, show_wlan, store_wlan);
1281 static DEVICE_ATTR(bluetooth, S_IRUGO | S_IWUSR,
1282 show_bluetooth, store_bluetooth);
1283 static DEVICE_ATTR(wimax, S_IRUGO | S_IWUSR, show_wimax, store_wimax);
1284 static DEVICE_ATTR(wwan, S_IRUGO | S_IWUSR, show_wwan, store_wwan);
1285 static DEVICE_ATTR(display, S_IRUGO | S_IWUSR, show_disp, store_disp);
1286 static DEVICE_ATTR(ledd, S_IRUGO | S_IWUSR, show_ledd, store_ledd);
1287 static DEVICE_ATTR(ls_level, S_IRUGO | S_IWUSR, show_lslvl, store_lslvl);
1288 static DEVICE_ATTR(ls_switch, S_IRUGO | S_IWUSR, show_lssw, store_lssw);
1289 static DEVICE_ATTR(gps, S_IRUGO | S_IWUSR, show_gps, store_gps);
1291 static struct attribute *asus_attributes[] = {
1292 &dev_attr_infos.attr,
1293 &dev_attr_wlan.attr,
1294 &dev_attr_bluetooth.attr,
1295 &dev_attr_wimax.attr,
1296 &dev_attr_wwan.attr,
1297 &dev_attr_display.attr,
1298 &dev_attr_ledd.attr,
1299 &dev_attr_ls_level.attr,
1300 &dev_attr_ls_switch.attr,
1305 static mode_t asus_sysfs_is_visible(struct kobject *kobj,
1306 struct attribute *attr,
1309 struct device *dev = container_of(kobj, struct device, kobj);
1310 struct platform_device *pdev = to_platform_device(dev);
1311 struct asus_laptop *asus = platform_get_drvdata(pdev);
1312 acpi_handle handle = asus->handle;
1315 if (attr == &dev_attr_wlan.attr) {
1316 supported = !acpi_check_handle(handle, METHOD_WLAN, NULL);
1318 } else if (attr == &dev_attr_bluetooth.attr) {
1319 supported = !acpi_check_handle(handle, METHOD_BLUETOOTH, NULL);
1321 } else if (attr == &dev_attr_display.attr) {
1322 supported = !acpi_check_handle(handle, METHOD_SWITCH_DISPLAY, NULL);
1324 } else if (attr == &dev_attr_wimax.attr) {
1326 !acpi_check_handle(asus->handle, METHOD_WIMAX, NULL);
1328 } else if (attr == &dev_attr_wwan.attr) {
1329 supported = !acpi_check_handle(asus->handle, METHOD_WWAN, NULL);
1331 } else if (attr == &dev_attr_ledd.attr) {
1332 supported = !acpi_check_handle(handle, METHOD_LEDD, NULL);
1334 } else if (attr == &dev_attr_ls_switch.attr ||
1335 attr == &dev_attr_ls_level.attr) {
1336 supported = !acpi_check_handle(handle, METHOD_ALS_CONTROL, NULL) &&
1337 !acpi_check_handle(handle, METHOD_ALS_LEVEL, NULL);
1339 } else if (attr == &dev_attr_gps.attr) {
1340 supported = !acpi_check_handle(handle, METHOD_GPS_ON, NULL) &&
1341 !acpi_check_handle(handle, METHOD_GPS_OFF, NULL) &&
1342 !acpi_check_handle(handle, METHOD_GPS_STATUS, NULL);
1347 return supported ? attr->mode : 0;
1351 static const struct attribute_group asus_attr_group = {
1352 .is_visible = asus_sysfs_is_visible,
1353 .attrs = asus_attributes,
1356 static int asus_platform_init(struct asus_laptop *asus)
1360 asus->platform_device = platform_device_alloc(ASUS_LAPTOP_FILE, -1);
1361 if (!asus->platform_device)
1363 platform_set_drvdata(asus->platform_device, asus);
1365 result = platform_device_add(asus->platform_device);
1367 goto fail_platform_device;
1369 result = sysfs_create_group(&asus->platform_device->dev.kobj,
1377 platform_device_del(asus->platform_device);
1378 fail_platform_device:
1379 platform_device_put(asus->platform_device);
1383 static void asus_platform_exit(struct asus_laptop *asus)
1385 sysfs_remove_group(&asus->platform_device->dev.kobj, &asus_attr_group);
1386 platform_device_unregister(asus->platform_device);
1389 static struct platform_driver platform_driver = {
1391 .name = ASUS_LAPTOP_FILE,
1392 .owner = THIS_MODULE,
1396 static int asus_handle_init(char *name, acpi_handle * handle,
1397 char **paths, int num_paths)
1402 for (i = 0; i < num_paths; i++) {
1403 status = acpi_get_handle(NULL, paths[i], handle);
1404 if (ACPI_SUCCESS(status))
1412 #define ASUS_HANDLE_INIT(object) \
1413 asus_handle_init(#object, &object##_handle, object##_paths, \
1414 ARRAY_SIZE(object##_paths))
1417 * This function is used to initialize the context with right values. In this
1418 * method, we can make all the detection we want, and modify the asus_laptop
1421 static int asus_laptop_get_info(struct asus_laptop *asus)
1423 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
1424 union acpi_object *model = NULL;
1425 unsigned long long bsts_result, hwrs_result;
1426 char *string = NULL;
1430 * Get DSDT headers early enough to allow for differentiating between
1431 * models, but late enough to allow acpi_bus_register_driver() to fail
1432 * before doing anything ACPI-specific. Should we encounter a machine,
1433 * which needs special handling (i.e. its hotkey device has a different
1434 * HID), this bit will be moved.
1436 status = acpi_get_table(ACPI_SIG_DSDT, 1, &asus->dsdt_info);
1437 if (ACPI_FAILURE(status))
1438 pr_warning("Couldn't get the DSDT table header\n");
1440 /* We have to write 0 on init this far for all ASUS models */
1441 if (write_acpi_int_ret(asus->handle, "INIT", 0, &buffer)) {
1442 pr_err("Hotkey initialization failed\n");
1446 /* This needs to be called for some laptops to init properly */
1448 acpi_evaluate_integer(asus->handle, "BSTS", NULL, &bsts_result);
1449 if (ACPI_FAILURE(status))
1450 pr_warning("Error calling BSTS\n");
1451 else if (bsts_result)
1452 pr_notice("BSTS called, 0x%02x returned\n",
1453 (uint) bsts_result);
1456 if (write_acpi_int(asus->handle, "CWAP", wapf))
1457 pr_err("Error calling CWAP(%d)\n", wapf);
1459 * Try to match the object returned by INIT to the specific model.
1460 * Handle every possible object (or the lack of thereof) the DSDT
1461 * writers might throw at us. When in trouble, we pass NULL to
1462 * asus_model_match() and try something completely different.
1464 if (buffer.pointer) {
1465 model = buffer.pointer;
1466 switch (model->type) {
1467 case ACPI_TYPE_STRING:
1468 string = model->string.pointer;
1470 case ACPI_TYPE_BUFFER:
1471 string = model->buffer.pointer;
1478 asus->name = kstrdup(string, GFP_KERNEL);
1480 kfree(buffer.pointer);
1485 pr_notice(" %s model detected\n", string);
1488 * The HWRS method return informations about the hardware.
1489 * 0x80 bit is for WLAN, 0x100 for Bluetooth,
1490 * 0x40 for WWAN, 0x10 for WIMAX.
1491 * The significance of others is yet to be found.
1494 acpi_evaluate_integer(asus->handle, "HRWS", NULL, &hwrs_result);
1495 if (!ACPI_FAILURE(status))
1496 pr_notice(" HRWS returned %x", (int)hwrs_result);
1498 if (!acpi_check_handle(asus->handle, METHOD_WL_STATUS, NULL))
1499 asus->have_rsts = true;
1501 /* Scheduled for removal */
1502 ASUS_HANDLE_INIT(lcd_switch);
1503 ASUS_HANDLE_INIT(display_get);
1510 static int __devinit asus_acpi_init(struct asus_laptop *asus)
1514 result = acpi_bus_get_status(asus->device);
1517 if (!asus->device->status.present) {
1518 pr_err("Hotkey device not present, aborting\n");
1522 result = asus_laptop_get_info(asus);
1526 /* WLED and BLED are on by default */
1527 if (bluetooth_status >= 0)
1528 asus_bluetooth_set(asus, !!bluetooth_status);
1530 if (wlan_status >= 0)
1531 asus_wlan_set(asus, !!wlan_status);
1533 if (wimax_status >= 0)
1534 asus_wimax_set(asus, !!wimax_status);
1536 if (wwan_status >= 0)
1537 asus_wwan_set(asus, !!wwan_status);
1539 /* Keyboard Backlight is on by default */
1540 if (!acpi_check_handle(asus->handle, METHOD_KBD_LIGHT_SET, NULL))
1541 asus_kled_set(asus, 1);
1543 /* LED display is off by default */
1544 asus->ledd_status = 0xFFF;
1546 /* Set initial values of light sensor and level */
1547 asus->light_switch = 0; /* Default to light sensor disabled */
1548 asus->light_level = 5; /* level 5 for sensor sensitivity */
1550 if (!acpi_check_handle(asus->handle, METHOD_ALS_CONTROL, NULL) &&
1551 !acpi_check_handle(asus->handle, METHOD_ALS_LEVEL, NULL)) {
1552 asus_als_switch(asus, asus->light_switch);
1553 asus_als_level(asus, asus->light_level);
1556 asus->lcd_state = 1; /* LCD should be on when the module load */
1560 static bool asus_device_present;
1562 static int __devinit asus_acpi_add(struct acpi_device *device)
1564 struct asus_laptop *asus;
1567 pr_notice("Asus Laptop Support version %s\n",
1568 ASUS_LAPTOP_VERSION);
1569 asus = kzalloc(sizeof(struct asus_laptop), GFP_KERNEL);
1572 asus->handle = device->handle;
1573 strcpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
1574 strcpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
1575 device->driver_data = asus;
1576 asus->device = device;
1578 result = asus_acpi_init(asus);
1583 * Register the platform device first. It is used as a parent for the
1584 * sub-devices below.
1586 result = asus_platform_init(asus);
1590 if (!acpi_video_backlight_support()) {
1591 result = asus_backlight_init(asus);
1593 goto fail_backlight;
1595 pr_info("Backlight controlled by ACPI video driver\n");
1597 result = asus_input_init(asus);
1601 result = asus_led_init(asus);
1605 result = asus_rfkill_init(asus);
1609 asus_device_present = true;
1613 asus_led_exit(asus);
1615 asus_input_exit(asus);
1617 asus_backlight_exit(asus);
1619 asus_platform_exit(asus);
1627 static int asus_acpi_remove(struct acpi_device *device, int type)
1629 struct asus_laptop *asus = acpi_driver_data(device);
1631 asus_backlight_exit(asus);
1632 asus_rfkill_exit(asus);
1633 asus_led_exit(asus);
1634 asus_input_exit(asus);
1635 asus_platform_exit(asus);
1642 static const struct acpi_device_id asus_device_ids[] = {
1647 MODULE_DEVICE_TABLE(acpi, asus_device_ids);
1649 static struct acpi_driver asus_acpi_driver = {
1650 .name = ASUS_LAPTOP_NAME,
1651 .class = ASUS_LAPTOP_CLASS,
1652 .owner = THIS_MODULE,
1653 .ids = asus_device_ids,
1654 .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
1656 .add = asus_acpi_add,
1657 .remove = asus_acpi_remove,
1658 .notify = asus_acpi_notify,
1662 static int __init asus_laptop_init(void)
1666 result = platform_driver_register(&platform_driver);
1670 result = acpi_bus_register_driver(&asus_acpi_driver);
1672 goto fail_acpi_driver;
1673 if (!asus_device_present) {
1675 goto fail_no_device;
1680 acpi_bus_unregister_driver(&asus_acpi_driver);
1682 platform_driver_unregister(&platform_driver);
1686 static void __exit asus_laptop_exit(void)
1688 acpi_bus_unregister_driver(&asus_acpi_driver);
1689 platform_driver_unregister(&platform_driver);
1692 module_init(asus_laptop_init);
1693 module_exit(asus_laptop_exit);