2 * Acer WMI Laptop Extras
4 * Copyright (C) 2007-2008 Carlos Corbacho <carlos@strangeworlds.co.uk>
7 * Copyright (C) 2005-2007 E.M. Smith
8 * Copyright (C) 2007-2008 Carlos Corbacho <cathectic@gmail.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #define ACER_WMI_VERSION "0.1"
27 #include <linux/kernel.h>
28 #include <linux/module.h>
29 #include <linux/init.h>
30 #include <linux/types.h>
31 #include <linux/dmi.h>
32 #include <linux/backlight.h>
33 #include <linux/leds.h>
34 #include <linux/platform_device.h>
35 #include <linux/acpi.h>
36 #include <linux/i8042.h>
38 #include <acpi/acpi_drivers.h>
40 MODULE_AUTHOR("Carlos Corbacho");
41 MODULE_DESCRIPTION("Acer Laptop WMI Extras Driver");
42 MODULE_LICENSE("GPL");
44 #define ACER_LOGPREFIX "acer-wmi: "
45 #define ACER_ERR KERN_ERR ACER_LOGPREFIX
46 #define ACER_NOTICE KERN_NOTICE ACER_LOGPREFIX
47 #define ACER_INFO KERN_INFO ACER_LOGPREFIX
50 * The following defines quirks to get some specific functions to work
51 * which are known to not be supported over ACPI-WMI (such as the mail LED
52 * on WMID based Acer's)
62 * Meaning is unknown - this number is required for writing to ACPI for AMW0
63 * (it's also used in acerhk when directly accessing the BIOS)
65 #define ACER_AMW0_WRITE 0x9610
68 * Bit masks for the AMW0 interface
70 #define ACER_AMW0_WIRELESS_MASK 0x35
71 #define ACER_AMW0_BLUETOOTH_MASK 0x34
72 #define ACER_AMW0_MAILLED_MASK 0x31
75 * Method IDs for WMID interface
77 #define ACER_WMID_GET_WIRELESS_METHODID 1
78 #define ACER_WMID_GET_BLUETOOTH_METHODID 2
79 #define ACER_WMID_GET_BRIGHTNESS_METHODID 3
80 #define ACER_WMID_SET_WIRELESS_METHODID 4
81 #define ACER_WMID_SET_BLUETOOTH_METHODID 5
82 #define ACER_WMID_SET_BRIGHTNESS_METHODID 6
83 #define ACER_WMID_GET_THREEG_METHODID 10
84 #define ACER_WMID_SET_THREEG_METHODID 11
87 * Acer ACPI method GUIDs
89 #define AMW0_GUID1 "67C3371D-95A3-4C37-BB61-DD47B491DAAB"
90 #define WMID_GUID1 "6AF4F258-B401-42fd-BE91-3D4AC2D7C0D3"
91 #define WMID_GUID2 "95764E09-FB56-4e83-B31A-37761F60994A"
93 MODULE_ALIAS("wmi:67C3371D-95A3-4C37-BB61-DD47B491DAAB");
94 MODULE_ALIAS("wmi:6AF4F258-B401-42fd-BE91-3D4AC2D7C0D3");
96 /* Temporary workaround until the WMI sysfs interface goes in */
97 MODULE_ALIAS("dmi:*:*Acer*:*:");
100 * Interface capability flags
102 #define ACER_CAP_MAILLED (1<<0)
103 #define ACER_CAP_WIRELESS (1<<1)
104 #define ACER_CAP_BLUETOOTH (1<<2)
105 #define ACER_CAP_BRIGHTNESS (1<<3)
106 #define ACER_CAP_THREEG (1<<4)
107 #define ACER_CAP_ANY (0xFFFFFFFF)
110 * Interface type flags
112 enum interface_flags
{
118 #define ACER_DEFAULT_WIRELESS 0
119 #define ACER_DEFAULT_BLUETOOTH 0
120 #define ACER_DEFAULT_MAILLED 0
121 #define ACER_DEFAULT_THREEG 0
123 static int max_brightness
= 0xF;
125 static int wireless
= -1;
126 static int bluetooth
= -1;
127 static int mailled
= -1;
128 static int brightness
= -1;
129 static int threeg
= -1;
130 static int force_series
;
132 module_param(mailled
, int, 0444);
133 module_param(wireless
, int, 0444);
134 module_param(bluetooth
, int, 0444);
135 module_param(brightness
, int, 0444);
136 module_param(threeg
, int, 0444);
137 module_param(force_series
, int, 0444);
138 MODULE_PARM_DESC(wireless
, "Set initial state of Wireless hardware");
139 MODULE_PARM_DESC(bluetooth
, "Set initial state of Bluetooth hardware");
140 MODULE_PARM_DESC(mailled
, "Set initial state of Mail LED");
141 MODULE_PARM_DESC(brightness
, "Set initial LCD backlight brightness");
142 MODULE_PARM_DESC(threeg
, "Set initial state of 3G hardware");
143 MODULE_PARM_DESC(force_series
, "Force a different laptop series");
153 /* Each low-level interface must define at least some of the following */
154 struct wmi_interface
{
155 /* The WMI device type */
158 /* The capabilities this interface provides */
161 /* Private data for the current interface */
162 struct acer_data data
;
165 /* The static interface pointer, points to the currently detected interface */
166 static struct wmi_interface
*interface
;
169 * Embedded Controller quirks
170 * Some laptops require us to directly access the EC to either enable or query
171 * features that are not available through WMI.
181 static struct quirk_entry
*quirks
;
183 static void set_quirks(void)
186 interface
->capability
|= ACER_CAP_MAILLED
;
188 if (quirks
->brightness
)
189 interface
->capability
|= ACER_CAP_BRIGHTNESS
;
192 static int dmi_matched(const struct dmi_system_id
*dmi
)
194 quirks
= dmi
->driver_data
;
198 static struct quirk_entry quirk_unknown
= {
201 static struct quirk_entry quirk_acer_travelmate_2490
= {
205 /* This AMW0 laptop has no bluetooth */
206 static struct quirk_entry quirk_medion_md_98300
= {
210 static struct dmi_system_id acer_quirks
[] = {
212 .callback
= dmi_matched
,
213 .ident
= "Acer Aspire 3100",
215 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
216 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 3100"),
218 .driver_data
= &quirk_acer_travelmate_2490
,
221 .callback
= dmi_matched
,
222 .ident
= "Acer Aspire 5100",
224 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
225 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 5100"),
227 .driver_data
= &quirk_acer_travelmate_2490
,
230 .callback
= dmi_matched
,
231 .ident
= "Acer Aspire 5630",
233 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
234 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 5630"),
236 .driver_data
= &quirk_acer_travelmate_2490
,
239 .callback
= dmi_matched
,
240 .ident
= "Acer Aspire 5650",
242 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
243 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 5650"),
245 .driver_data
= &quirk_acer_travelmate_2490
,
248 .callback
= dmi_matched
,
249 .ident
= "Acer Aspire 5680",
251 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
252 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 5680"),
254 .driver_data
= &quirk_acer_travelmate_2490
,
257 .callback
= dmi_matched
,
258 .ident
= "Acer Aspire 9110",
260 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
261 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 9110"),
263 .driver_data
= &quirk_acer_travelmate_2490
,
266 .callback
= dmi_matched
,
267 .ident
= "Acer TravelMate 2490",
269 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
270 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 2490"),
272 .driver_data
= &quirk_acer_travelmate_2490
,
275 .callback
= dmi_matched
,
276 .ident
= "Medion MD 98300",
278 DMI_MATCH(DMI_SYS_VENDOR
, "MEDION"),
279 DMI_MATCH(DMI_PRODUCT_NAME
, "WAM2030"),
281 .driver_data
= &quirk_medion_md_98300
,
286 /* Find which quirks are needed for a particular vendor/ model pair */
287 static void find_quirks(void)
290 dmi_check_system(acer_quirks
);
291 } else if (force_series
== 2490) {
292 quirks
= &quirk_acer_travelmate_2490
;
296 quirks
= &quirk_unknown
;
302 * General interface convenience methods
305 static bool has_cap(u32 cap
)
307 if ((interface
->capability
& cap
) != 0)
314 * AMW0 (V1) interface
331 static acpi_status
wmab_execute(struct wmab_args
*regbuf
,
332 struct acpi_buffer
*result
)
334 struct acpi_buffer input
;
336 input
.length
= sizeof(struct wmab_args
);
337 input
.pointer
= (u8
*)regbuf
;
339 status
= wmi_evaluate_method(AMW0_GUID1
, 1, 1, &input
, result
);
344 static acpi_status
AMW0_get_u32(u32
*value
, u32 cap
,
345 struct wmi_interface
*iface
)
351 case ACER_CAP_MAILLED
:
352 switch (quirks
->mailled
) {
354 err
= ec_read(0xA, &result
);
357 *value
= (result
>> 7) & 0x1;
361 case ACER_CAP_WIRELESS
:
362 switch (quirks
->wireless
) {
364 err
= ec_read(0x7B, &result
);
367 *value
= result
& 0x1;
370 err
= ec_read(0xA, &result
);
373 *value
= (result
>> 2) & 0x1;
377 case ACER_CAP_BLUETOOTH
:
378 switch (quirks
->bluetooth
) {
380 err
= ec_read(0xA, &result
);
383 *value
= (result
>> 4) & 0x1;
387 case ACER_CAP_BRIGHTNESS
:
388 switch (quirks
->brightness
) {
390 err
= ec_read(0x83, &result
);
398 return AE_BAD_ADDRESS
;
403 static acpi_status
AMW0_set_u32(u32 value
, u32 cap
, struct wmi_interface
*iface
)
405 struct wmab_args args
;
407 args
.eax
= ACER_AMW0_WRITE
;
408 args
.ebx
= value
? (1<<8) : 0;
409 args
.ecx
= args
.edx
= 0;
412 case ACER_CAP_MAILLED
:
414 return AE_BAD_PARAMETER
;
415 args
.ebx
|= ACER_AMW0_MAILLED_MASK
;
417 case ACER_CAP_WIRELESS
:
419 return AE_BAD_PARAMETER
;
420 args
.ebx
|= ACER_AMW0_WIRELESS_MASK
;
422 case ACER_CAP_BLUETOOTH
:
424 return AE_BAD_PARAMETER
;
425 args
.ebx
|= ACER_AMW0_BLUETOOTH_MASK
;
427 case ACER_CAP_BRIGHTNESS
:
428 if (value
> max_brightness
)
429 return AE_BAD_PARAMETER
;
430 switch (quirks
->brightness
) {
432 return ec_write(0x83, value
);
436 return AE_BAD_ADDRESS
;
439 /* Actually do the set */
440 return wmab_execute(&args
, NULL
);
443 static acpi_status
AMW0_find_mailled(void)
445 struct wmab_args args
;
447 acpi_status status
= AE_OK
;
448 struct acpi_buffer out
= { ACPI_ALLOCATE_BUFFER
, NULL
};
449 union acpi_object
*obj
;
452 args
.ebx
= args
.ecx
= args
.edx
= 0;
454 status
= wmab_execute(&args
, &out
);
455 if (ACPI_FAILURE(status
))
458 obj
= (union acpi_object
*) out
.pointer
;
459 if (obj
&& obj
->type
== ACPI_TYPE_BUFFER
&&
460 obj
->buffer
.length
== sizeof(struct wmab_ret
)) {
461 ret
= *((struct wmab_ret
*) obj
->buffer
.pointer
);
467 interface
->capability
|= ACER_CAP_MAILLED
;
474 static acpi_status
AMW0_set_capabilities(void)
476 struct wmab_args args
;
478 acpi_status status
= AE_OK
;
479 struct acpi_buffer out
= { ACPI_ALLOCATE_BUFFER
, NULL
};
480 union acpi_object
*obj
;
482 args
.eax
= ACER_AMW0_WRITE
;
483 args
.ecx
= args
.edx
= 0;
485 args
.ebx
= 0xa2 << 8;
486 args
.ebx
|= ACER_AMW0_WIRELESS_MASK
;
488 status
= wmab_execute(&args
, &out
);
489 if (ACPI_FAILURE(status
))
492 obj
= (union acpi_object
*) out
.pointer
;
493 if (obj
&& obj
->type
== ACPI_TYPE_BUFFER
&&
494 obj
->buffer
.length
== sizeof(struct wmab_ret
)) {
495 ret
= *((struct wmab_ret
*) obj
->buffer
.pointer
);
501 interface
->capability
|= ACER_CAP_WIRELESS
;
504 args
.ebx
|= ACER_AMW0_BLUETOOTH_MASK
;
506 status
= wmab_execute(&args
, &out
);
507 if (ACPI_FAILURE(status
))
510 obj
= (union acpi_object
*) out
.pointer
;
511 if (obj
&& obj
->type
== ACPI_TYPE_BUFFER
512 && obj
->buffer
.length
== sizeof(struct wmab_ret
)) {
513 ret
= *((struct wmab_ret
*) obj
->buffer
.pointer
);
519 interface
->capability
|= ACER_CAP_BLUETOOTH
;
524 * This appears to be safe to enable, since all Wistron based laptops
525 * appear to use the same EC register for brightness, even if they
526 * differ for wireless, etc
528 interface
->capability
|= ACER_CAP_BRIGHTNESS
;
533 static struct wmi_interface AMW0_interface
= {
537 static struct wmi_interface AMW0_V2_interface
= {
538 .type
= ACER_AMW0_V2
,
542 * New interface (The WMID interface)
545 WMI_execute_u32(u32 method_id
, u32 in
, u32
*out
)
547 struct acpi_buffer input
= { (acpi_size
) sizeof(u32
), (void *)(&in
) };
548 struct acpi_buffer result
= { ACPI_ALLOCATE_BUFFER
, NULL
};
549 union acpi_object
*obj
;
553 status
= wmi_evaluate_method(WMID_GUID1
, 1, method_id
, &input
, &result
);
555 if (ACPI_FAILURE(status
))
558 obj
= (union acpi_object
*) result
.pointer
;
559 if (obj
&& obj
->type
== ACPI_TYPE_BUFFER
&&
560 obj
->buffer
.length
== sizeof(u32
)) {
561 tmp
= *((u32
*) obj
->buffer
.pointer
);
569 kfree(result
.pointer
);
574 static acpi_status
WMID_get_u32(u32
*value
, u32 cap
,
575 struct wmi_interface
*iface
)
579 u32 result
, method_id
= 0;
582 case ACER_CAP_WIRELESS
:
583 method_id
= ACER_WMID_GET_WIRELESS_METHODID
;
585 case ACER_CAP_BLUETOOTH
:
586 method_id
= ACER_WMID_GET_BLUETOOTH_METHODID
;
588 case ACER_CAP_BRIGHTNESS
:
589 method_id
= ACER_WMID_GET_BRIGHTNESS_METHODID
;
591 case ACER_CAP_THREEG
:
592 method_id
= ACER_WMID_GET_THREEG_METHODID
;
594 case ACER_CAP_MAILLED
:
595 if (quirks
->mailled
== 1) {
601 return AE_BAD_ADDRESS
;
603 status
= WMI_execute_u32(method_id
, 0, &result
);
605 if (ACPI_SUCCESS(status
))
611 static acpi_status
WMID_set_u32(u32 value
, u32 cap
, struct wmi_interface
*iface
)
617 case ACER_CAP_BRIGHTNESS
:
618 if (value
> max_brightness
)
619 return AE_BAD_PARAMETER
;
620 method_id
= ACER_WMID_SET_BRIGHTNESS_METHODID
;
622 case ACER_CAP_WIRELESS
:
624 return AE_BAD_PARAMETER
;
625 method_id
= ACER_WMID_SET_WIRELESS_METHODID
;
627 case ACER_CAP_BLUETOOTH
:
629 return AE_BAD_PARAMETER
;
630 method_id
= ACER_WMID_SET_BLUETOOTH_METHODID
;
632 case ACER_CAP_THREEG
:
634 return AE_BAD_PARAMETER
;
635 method_id
= ACER_WMID_SET_THREEG_METHODID
;
637 case ACER_CAP_MAILLED
:
639 return AE_BAD_PARAMETER
;
640 if (quirks
->mailled
== 1) {
641 param
= value
? 0x92 : 0x93;
642 i8042_command(¶m
, 0x1059);
647 return AE_BAD_ADDRESS
;
649 return WMI_execute_u32(method_id
, (u32
)value
, NULL
);
652 static acpi_status
WMID_set_capabilities(void)
654 struct acpi_buffer out
= {ACPI_ALLOCATE_BUFFER
, NULL
};
655 union acpi_object
*obj
;
659 status
= wmi_query_block(WMID_GUID2
, 1, &out
);
660 if (ACPI_FAILURE(status
))
663 obj
= (union acpi_object
*) out
.pointer
;
664 if (obj
&& obj
->type
== ACPI_TYPE_BUFFER
&&
665 obj
->buffer
.length
== sizeof(u32
)) {
666 devices
= *((u32
*) obj
->buffer
.pointer
);
671 /* Not sure on the meaning of the relevant bits yet to detect these */
672 interface
->capability
|= ACER_CAP_WIRELESS
;
673 interface
->capability
|= ACER_CAP_THREEG
;
675 /* WMID always provides brightness methods */
676 interface
->capability
|= ACER_CAP_BRIGHTNESS
;
679 interface
->capability
|= ACER_CAP_BLUETOOTH
;
681 if (!(devices
& 0x20))
682 max_brightness
= 0x9;
687 static struct wmi_interface wmid_interface
= {
692 * Generic Device (interface-independent)
695 static acpi_status
get_u32(u32
*value
, u32 cap
)
697 acpi_status status
= AE_BAD_ADDRESS
;
699 switch (interface
->type
) {
701 status
= AMW0_get_u32(value
, cap
, interface
);
704 if (cap
== ACER_CAP_MAILLED
) {
705 status
= AMW0_get_u32(value
, cap
, interface
);
709 status
= WMID_get_u32(value
, cap
, interface
);
716 static acpi_status
set_u32(u32 value
, u32 cap
)
718 if (interface
->capability
& cap
) {
719 switch (interface
->type
) {
721 return AMW0_set_u32(value
, cap
, interface
);
724 return WMID_set_u32(value
, cap
, interface
);
726 return AE_BAD_PARAMETER
;
729 return AE_BAD_PARAMETER
;
732 static void __init
acer_commandline_init(void)
735 * These will all fail silently if the value given is invalid, or the
736 * capability isn't available on the given interface
738 set_u32(mailled
, ACER_CAP_MAILLED
);
739 set_u32(wireless
, ACER_CAP_WIRELESS
);
740 set_u32(bluetooth
, ACER_CAP_BLUETOOTH
);
741 set_u32(threeg
, ACER_CAP_THREEG
);
742 set_u32(brightness
, ACER_CAP_BRIGHTNESS
);
746 * LED device (Mail LED only, no other LEDs known yet)
748 static void mail_led_set(struct led_classdev
*led_cdev
,
749 enum led_brightness value
)
751 set_u32(value
, ACER_CAP_MAILLED
);
754 static struct led_classdev mail_led
= {
755 .name
= "acer-mail:green",
756 .brightness_set
= mail_led_set
,
759 static int __init
acer_led_init(struct device
*dev
)
761 return led_classdev_register(dev
, &mail_led
);
764 static void acer_led_exit(void)
766 led_classdev_unregister(&mail_led
);
772 static struct backlight_device
*acer_backlight_device
;
774 static int read_brightness(struct backlight_device
*bd
)
777 get_u32(&value
, ACER_CAP_BRIGHTNESS
);
781 static int update_bl_status(struct backlight_device
*bd
)
783 set_u32(bd
->props
.brightness
, ACER_CAP_BRIGHTNESS
);
787 static struct backlight_ops acer_bl_ops
= {
788 .get_brightness
= read_brightness
,
789 .update_status
= update_bl_status
,
792 static int __init
acer_backlight_init(struct device
*dev
)
794 struct backlight_device
*bd
;
796 bd
= backlight_device_register("acer-wmi", dev
, NULL
, &acer_bl_ops
);
798 printk(ACER_ERR
"Could not register Acer backlight device\n");
799 acer_backlight_device
= NULL
;
803 acer_backlight_device
= bd
;
805 bd
->props
.max_brightness
= max_brightness
;
806 bd
->props
.brightness
= read_brightness(NULL
);
807 backlight_update_status(bd
);
811 static void __exit
acer_backlight_exit(void)
813 backlight_device_unregister(acer_backlight_device
);
817 * Read/ write bool sysfs macro
819 #define show_set_bool(value, cap) \
821 show_bool_##value(struct device *dev, struct device_attribute *attr, \
825 acpi_status status = get_u32(&result, cap); \
826 if (ACPI_SUCCESS(status)) \
827 return sprintf(buf, "%u\n", result); \
828 return sprintf(buf, "Read error\n"); \
832 set_bool_##value(struct device *dev, struct device_attribute *attr, \
833 const char *buf, size_t count) \
835 u32 tmp = simple_strtoul(buf, NULL, 10); \
836 acpi_status status = set_u32(tmp, cap); \
837 if (ACPI_FAILURE(status)) \
841 static DEVICE_ATTR(value, S_IWUGO | S_IRUGO | S_IWUSR, \
842 show_bool_##value, set_bool_##value);
844 show_set_bool(wireless
, ACER_CAP_WIRELESS
);
845 show_set_bool(bluetooth
, ACER_CAP_BLUETOOTH
);
846 show_set_bool(threeg
, ACER_CAP_THREEG
);
849 * Read interface sysfs macro
851 static ssize_t
show_interface(struct device
*dev
, struct device_attribute
*attr
,
854 switch (interface
->type
) {
856 return sprintf(buf
, "AMW0\n");
858 return sprintf(buf
, "AMW0 v2\n");
860 return sprintf(buf
, "WMID\n");
862 return sprintf(buf
, "Error!\n");
866 static DEVICE_ATTR(interface
, S_IWUGO
| S_IRUGO
| S_IWUSR
,
867 show_interface
, NULL
);
872 static int __devinit
acer_platform_probe(struct platform_device
*device
)
876 if (has_cap(ACER_CAP_MAILLED
)) {
877 err
= acer_led_init(&device
->dev
);
882 if (has_cap(ACER_CAP_BRIGHTNESS
)) {
883 err
= acer_backlight_init(&device
->dev
);
885 goto error_brightness
;
896 static int acer_platform_remove(struct platform_device
*device
)
898 if (has_cap(ACER_CAP_MAILLED
))
900 if (has_cap(ACER_CAP_BRIGHTNESS
))
901 acer_backlight_exit();
905 static int acer_platform_suspend(struct platform_device
*dev
,
909 struct acer_data
*data
= &interface
->data
;
914 if (has_cap(ACER_CAP_WIRELESS
)) {
915 get_u32(&value
, ACER_CAP_WIRELESS
);
916 data
->wireless
= value
;
919 if (has_cap(ACER_CAP_BLUETOOTH
)) {
920 get_u32(&value
, ACER_CAP_BLUETOOTH
);
921 data
->bluetooth
= value
;
924 if (has_cap(ACER_CAP_MAILLED
)) {
925 get_u32(&value
, ACER_CAP_MAILLED
);
926 data
->mailled
= value
;
929 if (has_cap(ACER_CAP_BRIGHTNESS
)) {
930 get_u32(&value
, ACER_CAP_BRIGHTNESS
);
931 data
->brightness
= value
;
937 static int acer_platform_resume(struct platform_device
*device
)
939 struct acer_data
*data
= &interface
->data
;
944 if (has_cap(ACER_CAP_WIRELESS
))
945 set_u32(data
->wireless
, ACER_CAP_WIRELESS
);
947 if (has_cap(ACER_CAP_BLUETOOTH
))
948 set_u32(data
->bluetooth
, ACER_CAP_BLUETOOTH
);
950 if (has_cap(ACER_CAP_THREEG
))
951 set_u32(data
->threeg
, ACER_CAP_THREEG
);
953 if (has_cap(ACER_CAP_MAILLED
))
954 set_u32(data
->mailled
, ACER_CAP_MAILLED
);
956 if (has_cap(ACER_CAP_BRIGHTNESS
))
957 set_u32(data
->brightness
, ACER_CAP_BRIGHTNESS
);
962 static struct platform_driver acer_platform_driver
= {
965 .owner
= THIS_MODULE
,
967 .probe
= acer_platform_probe
,
968 .remove
= acer_platform_remove
,
969 .suspend
= acer_platform_suspend
,
970 .resume
= acer_platform_resume
,
973 static struct platform_device
*acer_platform_device
;
975 static int remove_sysfs(struct platform_device
*device
)
977 if (has_cap(ACER_CAP_WIRELESS
))
978 device_remove_file(&device
->dev
, &dev_attr_wireless
);
980 if (has_cap(ACER_CAP_BLUETOOTH
))
981 device_remove_file(&device
->dev
, &dev_attr_bluetooth
);
983 if (has_cap(ACER_CAP_THREEG
))
984 device_remove_file(&device
->dev
, &dev_attr_threeg
);
986 device_remove_file(&device
->dev
, &dev_attr_interface
);
991 static int create_sysfs(void)
993 int retval
= -ENOMEM
;
995 if (has_cap(ACER_CAP_WIRELESS
)) {
996 retval
= device_create_file(&acer_platform_device
->dev
,
1002 if (has_cap(ACER_CAP_BLUETOOTH
)) {
1003 retval
= device_create_file(&acer_platform_device
->dev
,
1004 &dev_attr_bluetooth
);
1009 if (has_cap(ACER_CAP_THREEG
)) {
1010 retval
= device_create_file(&acer_platform_device
->dev
,
1016 retval
= device_create_file(&acer_platform_device
->dev
,
1017 &dev_attr_interface
);
1024 remove_sysfs(acer_platform_device
);
1028 static int __init
acer_wmi_init(void)
1032 printk(ACER_INFO
"Acer Laptop ACPI-WMI Extras version %s\n",
1036 * Detect which ACPI-WMI interface we're using.
1038 if (wmi_has_guid(AMW0_GUID1
) && wmi_has_guid(WMID_GUID1
))
1039 interface
= &AMW0_V2_interface
;
1041 if (!wmi_has_guid(AMW0_GUID1
) && wmi_has_guid(WMID_GUID1
))
1042 interface
= &wmid_interface
;
1044 if (wmi_has_guid(WMID_GUID2
) && interface
) {
1045 if (ACPI_FAILURE(WMID_set_capabilities())) {
1046 printk(ACER_ERR
"Unable to detect available devices\n");
1049 } else if (!wmi_has_guid(WMID_GUID2
) && interface
) {
1050 printk(ACER_ERR
"Unable to detect available devices\n");
1054 if (wmi_has_guid(AMW0_GUID1
) && !wmi_has_guid(WMID_GUID1
)) {
1055 interface
= &AMW0_interface
;
1057 if (ACPI_FAILURE(AMW0_set_capabilities())) {
1058 printk(ACER_ERR
"Unable to detect available devices\n");
1063 if (wmi_has_guid(AMW0_GUID1
)) {
1064 if (ACPI_FAILURE(AMW0_find_mailled()))
1065 printk(ACER_ERR
"Unable to detect mail LED\n");
1071 printk(ACER_ERR
"No or unsupported WMI interface, unable to ");
1072 printk(KERN_CONT
"load.\n");
1076 if (platform_driver_register(&acer_platform_driver
)) {
1077 printk(ACER_ERR
"Unable to register platform driver.\n");
1078 goto error_platform_register
;
1080 acer_platform_device
= platform_device_alloc("acer-wmi", -1);
1081 platform_device_add(acer_platform_device
);
1083 err
= create_sysfs();
1087 /* Override any initial settings with values from the commandline */
1088 acer_commandline_init();
1092 error_platform_register
:
1096 static void __exit
acer_wmi_exit(void)
1098 remove_sysfs(acer_platform_device
);
1099 platform_device_del(acer_platform_device
);
1100 platform_driver_unregister(&acer_platform_driver
);
1102 printk(ACER_INFO
"Acer Laptop WMI Extras unloaded\n");
1106 module_init(acer_wmi_init
);
1107 module_exit(acer_wmi_exit
);