Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Acer WMI Laptop Extras |
| 3 | * |
Carlos Corbacho | 4f0175d | 2009-04-04 09:33:39 +0100 | [diff] [blame] | 4 | * Copyright (C) 2007-2009 Carlos Corbacho <carlos@strangeworlds.co.uk> |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 5 | * |
| 6 | * Based on acer_acpi: |
| 7 | * Copyright (C) 2005-2007 E.M. Smith |
| 8 | * Copyright (C) 2007-2008 Carlos Corbacho <cathectic@gmail.com> |
| 9 | * |
| 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. |
| 14 | * |
| 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. |
| 19 | * |
| 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 |
| 23 | */ |
| 24 | |
Lee, Chun-Yi | cae1570 | 2011-03-16 18:52:36 +0800 | [diff] [blame] | 25 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 26 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 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> |
Carlos Corbacho | f2b585b | 2008-06-21 09:09:27 +0100 | [diff] [blame] | 32 | #include <linux/fb.h> |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 33 | #include <linux/backlight.h> |
| 34 | #include <linux/leds.h> |
| 35 | #include <linux/platform_device.h> |
| 36 | #include <linux/acpi.h> |
| 37 | #include <linux/i8042.h> |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 38 | #include <linux/rfkill.h> |
| 39 | #include <linux/workqueue.h> |
Carlos Corbacho | 8114352 | 2008-06-21 09:09:53 +0100 | [diff] [blame] | 40 | #include <linux/debugfs.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 41 | #include <linux/slab.h> |
Lee, Chun-Yi | 3fdca87 | 2010-12-07 10:29:20 +0800 | [diff] [blame] | 42 | #include <linux/input.h> |
| 43 | #include <linux/input/sparse-keymap.h> |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 44 | |
| 45 | #include <acpi/acpi_drivers.h> |
| 46 | |
| 47 | MODULE_AUTHOR("Carlos Corbacho"); |
| 48 | MODULE_DESCRIPTION("Acer Laptop WMI Extras Driver"); |
| 49 | MODULE_LICENSE("GPL"); |
| 50 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 51 | /* |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 52 | * Magic Number |
| 53 | * Meaning is unknown - this number is required for writing to ACPI for AMW0 |
| 54 | * (it's also used in acerhk when directly accessing the BIOS) |
| 55 | */ |
| 56 | #define ACER_AMW0_WRITE 0x9610 |
| 57 | |
| 58 | /* |
| 59 | * Bit masks for the AMW0 interface |
| 60 | */ |
| 61 | #define ACER_AMW0_WIRELESS_MASK 0x35 |
| 62 | #define ACER_AMW0_BLUETOOTH_MASK 0x34 |
| 63 | #define ACER_AMW0_MAILLED_MASK 0x31 |
| 64 | |
| 65 | /* |
| 66 | * Method IDs for WMID interface |
| 67 | */ |
| 68 | #define ACER_WMID_GET_WIRELESS_METHODID 1 |
| 69 | #define ACER_WMID_GET_BLUETOOTH_METHODID 2 |
| 70 | #define ACER_WMID_GET_BRIGHTNESS_METHODID 3 |
| 71 | #define ACER_WMID_SET_WIRELESS_METHODID 4 |
| 72 | #define ACER_WMID_SET_BLUETOOTH_METHODID 5 |
| 73 | #define ACER_WMID_SET_BRIGHTNESS_METHODID 6 |
| 74 | #define ACER_WMID_GET_THREEG_METHODID 10 |
| 75 | #define ACER_WMID_SET_THREEG_METHODID 11 |
| 76 | |
| 77 | /* |
| 78 | * Acer ACPI method GUIDs |
| 79 | */ |
| 80 | #define AMW0_GUID1 "67C3371D-95A3-4C37-BB61-DD47B491DAAB" |
Carlos Corbacho | 5753dd5 | 2008-06-21 09:09:48 +0100 | [diff] [blame] | 81 | #define AMW0_GUID2 "431F16ED-0C2B-444C-B267-27DEB140CF9C" |
Matthew Garrett | bbb7060 | 2011-02-09 16:39:40 -0500 | [diff] [blame] | 82 | #define WMID_GUID1 "6AF4F258-B401-42FD-BE91-3D4AC2D7C0D3" |
Pali Rohár | 298f19b | 2011-03-11 12:36:43 -0500 | [diff] [blame] | 83 | #define WMID_GUID2 "95764E09-FB56-4E83-B31A-37761F60994A" |
Lee, Chun-Yi | b3c9092 | 2010-12-07 10:29:22 +0800 | [diff] [blame] | 84 | #define WMID_GUID3 "61EF69EA-865C-4BC3-A502-A0DEBA0CB531" |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 85 | |
Lee, Chun-Yi | 3fdca87 | 2010-12-07 10:29:20 +0800 | [diff] [blame] | 86 | /* |
| 87 | * Acer ACPI event GUIDs |
| 88 | */ |
| 89 | #define ACERWMID_EVENT_GUID "676AA15E-6A47-4D9F-A2CC-1E6D18D14026" |
| 90 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 91 | MODULE_ALIAS("wmi:67C3371D-95A3-4C37-BB61-DD47B491DAAB"); |
Lee, Chun-Yi | 08a0799 | 2011-04-06 17:40:06 +0800 | [diff] [blame] | 92 | MODULE_ALIAS("wmi:6AF4F258-B401-42FD-BE91-3D4AC2D7C0D3"); |
Lee, Chun-Yi | 3fdca87 | 2010-12-07 10:29:20 +0800 | [diff] [blame] | 93 | MODULE_ALIAS("wmi:676AA15E-6A47-4D9F-A2CC-1E6D18D14026"); |
| 94 | |
| 95 | enum acer_wmi_event_ids { |
| 96 | WMID_HOTKEY_EVENT = 0x1, |
| 97 | }; |
| 98 | |
| 99 | static const struct key_entry acer_wmi_keymap[] = { |
| 100 | {KE_KEY, 0x01, {KEY_WLAN} }, /* WiFi */ |
Melchior FRANZ | 8ae68de | 2011-05-24 10:35:55 +0200 | [diff] [blame] | 101 | {KE_KEY, 0x03, {KEY_WLAN} }, /* WiFi */ |
Lee, Chun-Yi | 3fdca87 | 2010-12-07 10:29:20 +0800 | [diff] [blame] | 102 | {KE_KEY, 0x12, {KEY_BLUETOOTH} }, /* BT */ |
| 103 | {KE_KEY, 0x21, {KEY_PROG1} }, /* Backup */ |
| 104 | {KE_KEY, 0x22, {KEY_PROG2} }, /* Arcade */ |
| 105 | {KE_KEY, 0x23, {KEY_PROG3} }, /* P_Key */ |
| 106 | {KE_KEY, 0x24, {KEY_PROG4} }, /* Social networking_Key */ |
Melchior FRANZ | 8ae68de | 2011-05-24 10:35:55 +0200 | [diff] [blame] | 107 | {KE_IGNORE, 0x41, {KEY_MUTE} }, |
| 108 | {KE_IGNORE, 0x42, {KEY_PREVIOUSSONG} }, |
| 109 | {KE_IGNORE, 0x43, {KEY_NEXTSONG} }, |
| 110 | {KE_IGNORE, 0x44, {KEY_PLAYPAUSE} }, |
| 111 | {KE_IGNORE, 0x45, {KEY_STOP} }, |
| 112 | {KE_IGNORE, 0x48, {KEY_VOLUMEUP} }, |
| 113 | {KE_IGNORE, 0x49, {KEY_VOLUMEDOWN} }, |
| 114 | {KE_IGNORE, 0x61, {KEY_SWITCHVIDEOMODE} }, |
| 115 | {KE_IGNORE, 0x62, {KEY_BRIGHTNESSUP} }, |
| 116 | {KE_IGNORE, 0x63, {KEY_BRIGHTNESSDOWN} }, |
Lee, Chun-Yi | 3fdca87 | 2010-12-07 10:29:20 +0800 | [diff] [blame] | 117 | {KE_KEY, 0x64, {KEY_SWITCHVIDEOMODE} }, /* Display Switch */ |
Melchior FRANZ | 8ae68de | 2011-05-24 10:35:55 +0200 | [diff] [blame] | 118 | {KE_IGNORE, 0x81, {KEY_SLEEP} }, |
Lee, Chun-Yi | 8941178 | 2011-03-02 01:07:11 +0800 | [diff] [blame] | 119 | {KE_KEY, 0x82, {KEY_TOUCHPAD_TOGGLE} }, /* Touch Pad On/Off */ |
Melchior FRANZ | 8ae68de | 2011-05-24 10:35:55 +0200 | [diff] [blame] | 120 | {KE_IGNORE, 0x83, {KEY_TOUCHPAD_TOGGLE} }, |
Lee, Chun-Yi | 3fdca87 | 2010-12-07 10:29:20 +0800 | [diff] [blame] | 121 | {KE_END, 0} |
| 122 | }; |
| 123 | |
| 124 | static struct input_dev *acer_wmi_input_dev; |
| 125 | |
| 126 | struct event_return_value { |
| 127 | u8 function; |
| 128 | u8 key_num; |
| 129 | u16 device_state; |
| 130 | u32 reserved; |
| 131 | } __attribute__((packed)); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 132 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 133 | /* |
Lee, Chun-Yi | b3c9092 | 2010-12-07 10:29:22 +0800 | [diff] [blame] | 134 | * GUID3 Get Device Status device flags |
| 135 | */ |
Lee, Chun-Yi | 6c3df88 | 2010-12-07 10:29:23 +0800 | [diff] [blame] | 136 | #define ACER_WMID3_GDS_WIRELESS (1<<0) /* WiFi */ |
Lee, Chun-Yi | b3c9092 | 2010-12-07 10:29:22 +0800 | [diff] [blame] | 137 | #define ACER_WMID3_GDS_THREEG (1<<6) /* 3G */ |
Lee, Chun-Yi | 6d88ff0 | 2011-05-22 07:33:54 +0800 | [diff] [blame] | 138 | #define ACER_WMID3_GDS_WIMAX (1<<7) /* WiMAX */ |
Lee, Chun-Yi | 6c3df88 | 2010-12-07 10:29:23 +0800 | [diff] [blame] | 139 | #define ACER_WMID3_GDS_BLUETOOTH (1<<11) /* BT */ |
Lee, Chun-Yi | b3c9092 | 2010-12-07 10:29:22 +0800 | [diff] [blame] | 140 | |
From: Lee, Chun-Yi | 59ccf2f | 2011-01-07 17:25:14 -0500 | [diff] [blame] | 141 | struct lm_input_params { |
| 142 | u8 function_num; /* Function Number */ |
| 143 | u16 commun_devices; /* Communication type devices default status */ |
| 144 | u16 devices; /* Other type devices default status */ |
| 145 | u8 lm_status; /* Launch Manager Status */ |
| 146 | u16 reserved; |
| 147 | } __attribute__((packed)); |
| 148 | |
| 149 | struct lm_return_value { |
| 150 | u8 error_code; /* Error Code */ |
| 151 | u8 ec_return_value; /* EC Return Value */ |
| 152 | u16 reserved; |
| 153 | } __attribute__((packed)); |
| 154 | |
Lee, Chun-Yi | b3c9092 | 2010-12-07 10:29:22 +0800 | [diff] [blame] | 155 | struct wmid3_gds_input_param { /* Get Device Status input parameter */ |
| 156 | u8 function_num; /* Function Number */ |
| 157 | u8 hotkey_number; /* Hotkey Number */ |
| 158 | u16 devices; /* Get Device */ |
| 159 | } __attribute__((packed)); |
| 160 | |
| 161 | struct wmid3_gds_return_value { /* Get Device Status return value*/ |
| 162 | u8 error_code; /* Error Code */ |
| 163 | u8 ec_return_value; /* EC Return Value */ |
| 164 | u16 devices; /* Current Device Status */ |
| 165 | u32 reserved; |
| 166 | } __attribute__((packed)); |
| 167 | |
Lee, Chun-Yi | 6c3df88 | 2010-12-07 10:29:23 +0800 | [diff] [blame] | 168 | struct hotkey_function_type_aa { |
| 169 | u8 type; |
| 170 | u8 length; |
| 171 | u16 handle; |
| 172 | u16 commun_func_bitmap; |
| 173 | } __attribute__((packed)); |
| 174 | |
Lee, Chun-Yi | b3c9092 | 2010-12-07 10:29:22 +0800 | [diff] [blame] | 175 | /* |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 176 | * Interface capability flags |
| 177 | */ |
| 178 | #define ACER_CAP_MAILLED (1<<0) |
| 179 | #define ACER_CAP_WIRELESS (1<<1) |
| 180 | #define ACER_CAP_BLUETOOTH (1<<2) |
| 181 | #define ACER_CAP_BRIGHTNESS (1<<3) |
| 182 | #define ACER_CAP_THREEG (1<<4) |
| 183 | #define ACER_CAP_ANY (0xFFFFFFFF) |
| 184 | |
| 185 | /* |
| 186 | * Interface type flags |
| 187 | */ |
| 188 | enum interface_flags { |
| 189 | ACER_AMW0, |
| 190 | ACER_AMW0_V2, |
| 191 | ACER_WMID, |
| 192 | }; |
| 193 | |
| 194 | #define ACER_DEFAULT_WIRELESS 0 |
| 195 | #define ACER_DEFAULT_BLUETOOTH 0 |
| 196 | #define ACER_DEFAULT_MAILLED 0 |
| 197 | #define ACER_DEFAULT_THREEG 0 |
| 198 | |
| 199 | static int max_brightness = 0xF; |
| 200 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 201 | static int mailled = -1; |
| 202 | static int brightness = -1; |
| 203 | static int threeg = -1; |
| 204 | static int force_series; |
From: Lee, Chun-Yi | 59ccf2f | 2011-01-07 17:25:14 -0500 | [diff] [blame] | 205 | static bool ec_raw_mode; |
Lee, Chun-Yi | 6c3df88 | 2010-12-07 10:29:23 +0800 | [diff] [blame] | 206 | static bool has_type_aa; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 207 | |
| 208 | module_param(mailled, int, 0444); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 209 | module_param(brightness, int, 0444); |
| 210 | module_param(threeg, int, 0444); |
| 211 | module_param(force_series, int, 0444); |
From: Lee, Chun-Yi | 59ccf2f | 2011-01-07 17:25:14 -0500 | [diff] [blame] | 212 | module_param(ec_raw_mode, bool, 0444); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 213 | MODULE_PARM_DESC(mailled, "Set initial state of Mail LED"); |
| 214 | MODULE_PARM_DESC(brightness, "Set initial LCD backlight brightness"); |
| 215 | MODULE_PARM_DESC(threeg, "Set initial state of 3G hardware"); |
| 216 | MODULE_PARM_DESC(force_series, "Force a different laptop series"); |
From: Lee, Chun-Yi | 59ccf2f | 2011-01-07 17:25:14 -0500 | [diff] [blame] | 217 | MODULE_PARM_DESC(ec_raw_mode, "Enable EC raw mode"); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 218 | |
| 219 | struct acer_data { |
| 220 | int mailled; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 221 | int threeg; |
| 222 | int brightness; |
| 223 | }; |
| 224 | |
Carlos Corbacho | 8114352 | 2008-06-21 09:09:53 +0100 | [diff] [blame] | 225 | struct acer_debug { |
| 226 | struct dentry *root; |
| 227 | struct dentry *devices; |
| 228 | u32 wmid_devices; |
| 229 | }; |
| 230 | |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 231 | static struct rfkill *wireless_rfkill; |
| 232 | static struct rfkill *bluetooth_rfkill; |
Lee, Chun-Yi | b3c9092 | 2010-12-07 10:29:22 +0800 | [diff] [blame] | 233 | static struct rfkill *threeg_rfkill; |
Lee, Chun-Yi | 8215af0 | 2011-03-28 16:52:02 +0800 | [diff] [blame] | 234 | static bool rfkill_inited; |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 235 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 236 | /* Each low-level interface must define at least some of the following */ |
| 237 | struct wmi_interface { |
| 238 | /* The WMI device type */ |
| 239 | u32 type; |
| 240 | |
| 241 | /* The capabilities this interface provides */ |
| 242 | u32 capability; |
| 243 | |
| 244 | /* Private data for the current interface */ |
| 245 | struct acer_data data; |
Carlos Corbacho | 8114352 | 2008-06-21 09:09:53 +0100 | [diff] [blame] | 246 | |
| 247 | /* debugfs entries associated with this interface */ |
| 248 | struct acer_debug debug; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 249 | }; |
| 250 | |
| 251 | /* The static interface pointer, points to the currently detected interface */ |
| 252 | static struct wmi_interface *interface; |
| 253 | |
| 254 | /* |
| 255 | * Embedded Controller quirks |
| 256 | * Some laptops require us to directly access the EC to either enable or query |
| 257 | * features that are not available through WMI. |
| 258 | */ |
| 259 | |
| 260 | struct quirk_entry { |
| 261 | u8 wireless; |
| 262 | u8 mailled; |
Carlos Corbacho | 9991d9f | 2008-06-21 09:09:22 +0100 | [diff] [blame] | 263 | s8 brightness; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 264 | u8 bluetooth; |
| 265 | }; |
| 266 | |
| 267 | static struct quirk_entry *quirks; |
| 268 | |
| 269 | static void set_quirks(void) |
| 270 | { |
Arjan van de Ven | 83097ac | 2008-08-23 21:45:21 -0700 | [diff] [blame] | 271 | if (!interface) |
| 272 | return; |
| 273 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 274 | if (quirks->mailled) |
| 275 | interface->capability |= ACER_CAP_MAILLED; |
| 276 | |
| 277 | if (quirks->brightness) |
| 278 | interface->capability |= ACER_CAP_BRIGHTNESS; |
| 279 | } |
| 280 | |
| 281 | static int dmi_matched(const struct dmi_system_id *dmi) |
| 282 | { |
| 283 | quirks = dmi->driver_data; |
Axel Lin | d53bf0f | 2010-06-30 13:32:16 +0800 | [diff] [blame] | 284 | return 1; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | static struct quirk_entry quirk_unknown = { |
| 288 | }; |
| 289 | |
Carlos Corbacho | 9991d9f | 2008-06-21 09:09:22 +0100 | [diff] [blame] | 290 | static struct quirk_entry quirk_acer_aspire_1520 = { |
| 291 | .brightness = -1, |
| 292 | }; |
| 293 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 294 | static struct quirk_entry quirk_acer_travelmate_2490 = { |
| 295 | .mailled = 1, |
| 296 | }; |
| 297 | |
| 298 | /* This AMW0 laptop has no bluetooth */ |
| 299 | static struct quirk_entry quirk_medion_md_98300 = { |
| 300 | .wireless = 1, |
| 301 | }; |
| 302 | |
Carlos Corbacho | 6f061ab | 2008-06-21 09:09:38 +0100 | [diff] [blame] | 303 | static struct quirk_entry quirk_fujitsu_amilo_li_1718 = { |
| 304 | .wireless = 2, |
| 305 | }; |
| 306 | |
Carlos Corbacho | a74dd5f | 2009-04-04 09:33:29 +0100 | [diff] [blame] | 307 | /* The Aspire One has a dummy ACPI-WMI interface - disable it */ |
| 308 | static struct dmi_system_id __devinitdata acer_blacklist[] = { |
| 309 | { |
| 310 | .ident = "Acer Aspire One (SSD)", |
| 311 | .matches = { |
| 312 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 313 | DMI_MATCH(DMI_PRODUCT_NAME, "AOA110"), |
| 314 | }, |
| 315 | }, |
| 316 | { |
| 317 | .ident = "Acer Aspire One (HDD)", |
| 318 | .matches = { |
| 319 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 320 | DMI_MATCH(DMI_PRODUCT_NAME, "AOA150"), |
| 321 | }, |
| 322 | }, |
| 323 | {} |
| 324 | }; |
| 325 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 326 | static struct dmi_system_id acer_quirks[] = { |
| 327 | { |
| 328 | .callback = dmi_matched, |
Carlos Corbacho | 9991d9f | 2008-06-21 09:09:22 +0100 | [diff] [blame] | 329 | .ident = "Acer Aspire 1360", |
| 330 | .matches = { |
| 331 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 332 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1360"), |
| 333 | }, |
| 334 | .driver_data = &quirk_acer_aspire_1520, |
| 335 | }, |
| 336 | { |
| 337 | .callback = dmi_matched, |
| 338 | .ident = "Acer Aspire 1520", |
| 339 | .matches = { |
| 340 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 341 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1520"), |
| 342 | }, |
| 343 | .driver_data = &quirk_acer_aspire_1520, |
| 344 | }, |
| 345 | { |
| 346 | .callback = dmi_matched, |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 347 | .ident = "Acer Aspire 3100", |
| 348 | .matches = { |
| 349 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 350 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3100"), |
| 351 | }, |
| 352 | .driver_data = &quirk_acer_travelmate_2490, |
| 353 | }, |
| 354 | { |
| 355 | .callback = dmi_matched, |
Carlos Corbacho | ed9cfe9 | 2008-03-12 20:13:00 +0000 | [diff] [blame] | 356 | .ident = "Acer Aspire 3610", |
| 357 | .matches = { |
| 358 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 359 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3610"), |
| 360 | }, |
| 361 | .driver_data = &quirk_acer_travelmate_2490, |
| 362 | }, |
| 363 | { |
| 364 | .callback = dmi_matched, |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 365 | .ident = "Acer Aspire 5100", |
| 366 | .matches = { |
| 367 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 368 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5100"), |
| 369 | }, |
| 370 | .driver_data = &quirk_acer_travelmate_2490, |
| 371 | }, |
| 372 | { |
| 373 | .callback = dmi_matched, |
Carlos Corbacho | ed9cfe9 | 2008-03-12 20:13:00 +0000 | [diff] [blame] | 374 | .ident = "Acer Aspire 5610", |
| 375 | .matches = { |
| 376 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 377 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5610"), |
| 378 | }, |
| 379 | .driver_data = &quirk_acer_travelmate_2490, |
| 380 | }, |
| 381 | { |
| 382 | .callback = dmi_matched, |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 383 | .ident = "Acer Aspire 5630", |
| 384 | .matches = { |
| 385 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 386 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5630"), |
| 387 | }, |
| 388 | .driver_data = &quirk_acer_travelmate_2490, |
| 389 | }, |
| 390 | { |
| 391 | .callback = dmi_matched, |
| 392 | .ident = "Acer Aspire 5650", |
| 393 | .matches = { |
| 394 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 395 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5650"), |
| 396 | }, |
| 397 | .driver_data = &quirk_acer_travelmate_2490, |
| 398 | }, |
| 399 | { |
| 400 | .callback = dmi_matched, |
| 401 | .ident = "Acer Aspire 5680", |
| 402 | .matches = { |
| 403 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 404 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5680"), |
| 405 | }, |
| 406 | .driver_data = &quirk_acer_travelmate_2490, |
| 407 | }, |
| 408 | { |
| 409 | .callback = dmi_matched, |
| 410 | .ident = "Acer Aspire 9110", |
| 411 | .matches = { |
| 412 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 413 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 9110"), |
| 414 | }, |
| 415 | .driver_data = &quirk_acer_travelmate_2490, |
| 416 | }, |
| 417 | { |
| 418 | .callback = dmi_matched, |
| 419 | .ident = "Acer TravelMate 2490", |
| 420 | .matches = { |
| 421 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 422 | DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2490"), |
| 423 | }, |
| 424 | .driver_data = &quirk_acer_travelmate_2490, |
| 425 | }, |
| 426 | { |
| 427 | .callback = dmi_matched, |
Carlos Corbacho | 262ee35 | 2008-02-16 00:02:56 +0000 | [diff] [blame] | 428 | .ident = "Acer TravelMate 4200", |
| 429 | .matches = { |
| 430 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 431 | DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 4200"), |
| 432 | }, |
| 433 | .driver_data = &quirk_acer_travelmate_2490, |
| 434 | }, |
| 435 | { |
| 436 | .callback = dmi_matched, |
Carlos Corbacho | 6f061ab | 2008-06-21 09:09:38 +0100 | [diff] [blame] | 437 | .ident = "Fujitsu Siemens Amilo Li 1718", |
| 438 | .matches = { |
| 439 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), |
| 440 | DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Li 1718"), |
| 441 | }, |
| 442 | .driver_data = &quirk_fujitsu_amilo_li_1718, |
| 443 | }, |
| 444 | { |
| 445 | .callback = dmi_matched, |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 446 | .ident = "Medion MD 98300", |
| 447 | .matches = { |
| 448 | DMI_MATCH(DMI_SYS_VENDOR, "MEDION"), |
| 449 | DMI_MATCH(DMI_PRODUCT_NAME, "WAM2030"), |
| 450 | }, |
| 451 | .driver_data = &quirk_medion_md_98300, |
| 452 | }, |
| 453 | {} |
| 454 | }; |
| 455 | |
| 456 | /* Find which quirks are needed for a particular vendor/ model pair */ |
| 457 | static void find_quirks(void) |
| 458 | { |
| 459 | if (!force_series) { |
| 460 | dmi_check_system(acer_quirks); |
| 461 | } else if (force_series == 2490) { |
| 462 | quirks = &quirk_acer_travelmate_2490; |
| 463 | } |
| 464 | |
| 465 | if (quirks == NULL) |
| 466 | quirks = &quirk_unknown; |
| 467 | |
| 468 | set_quirks(); |
| 469 | } |
| 470 | |
| 471 | /* |
| 472 | * General interface convenience methods |
| 473 | */ |
| 474 | |
| 475 | static bool has_cap(u32 cap) |
| 476 | { |
| 477 | if ((interface->capability & cap) != 0) |
| 478 | return 1; |
| 479 | |
| 480 | return 0; |
| 481 | } |
| 482 | |
| 483 | /* |
| 484 | * AMW0 (V1) interface |
| 485 | */ |
| 486 | struct wmab_args { |
| 487 | u32 eax; |
| 488 | u32 ebx; |
| 489 | u32 ecx; |
| 490 | u32 edx; |
| 491 | }; |
| 492 | |
| 493 | struct wmab_ret { |
| 494 | u32 eax; |
| 495 | u32 ebx; |
| 496 | u32 ecx; |
| 497 | u32 edx; |
| 498 | u32 eex; |
| 499 | }; |
| 500 | |
| 501 | static acpi_status wmab_execute(struct wmab_args *regbuf, |
| 502 | struct acpi_buffer *result) |
| 503 | { |
| 504 | struct acpi_buffer input; |
| 505 | acpi_status status; |
| 506 | input.length = sizeof(struct wmab_args); |
| 507 | input.pointer = (u8 *)regbuf; |
| 508 | |
| 509 | status = wmi_evaluate_method(AMW0_GUID1, 1, 1, &input, result); |
| 510 | |
| 511 | return status; |
| 512 | } |
| 513 | |
| 514 | static acpi_status AMW0_get_u32(u32 *value, u32 cap, |
| 515 | struct wmi_interface *iface) |
| 516 | { |
| 517 | int err; |
| 518 | u8 result; |
| 519 | |
| 520 | switch (cap) { |
| 521 | case ACER_CAP_MAILLED: |
| 522 | switch (quirks->mailled) { |
| 523 | default: |
| 524 | err = ec_read(0xA, &result); |
| 525 | if (err) |
| 526 | return AE_ERROR; |
| 527 | *value = (result >> 7) & 0x1; |
| 528 | return AE_OK; |
| 529 | } |
| 530 | break; |
| 531 | case ACER_CAP_WIRELESS: |
| 532 | switch (quirks->wireless) { |
| 533 | case 1: |
| 534 | err = ec_read(0x7B, &result); |
| 535 | if (err) |
| 536 | return AE_ERROR; |
| 537 | *value = result & 0x1; |
| 538 | return AE_OK; |
Carlos Corbacho | 6f061ab | 2008-06-21 09:09:38 +0100 | [diff] [blame] | 539 | case 2: |
| 540 | err = ec_read(0x71, &result); |
| 541 | if (err) |
| 542 | return AE_ERROR; |
| 543 | *value = result & 0x1; |
| 544 | return AE_OK; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 545 | default: |
| 546 | err = ec_read(0xA, &result); |
| 547 | if (err) |
| 548 | return AE_ERROR; |
| 549 | *value = (result >> 2) & 0x1; |
| 550 | return AE_OK; |
| 551 | } |
| 552 | break; |
| 553 | case ACER_CAP_BLUETOOTH: |
| 554 | switch (quirks->bluetooth) { |
| 555 | default: |
| 556 | err = ec_read(0xA, &result); |
| 557 | if (err) |
| 558 | return AE_ERROR; |
| 559 | *value = (result >> 4) & 0x1; |
| 560 | return AE_OK; |
| 561 | } |
| 562 | break; |
| 563 | case ACER_CAP_BRIGHTNESS: |
| 564 | switch (quirks->brightness) { |
| 565 | default: |
| 566 | err = ec_read(0x83, &result); |
| 567 | if (err) |
| 568 | return AE_ERROR; |
| 569 | *value = result; |
| 570 | return AE_OK; |
| 571 | } |
| 572 | break; |
| 573 | default: |
Lin Ming | 0823797 | 2008-08-08 11:57:11 +0800 | [diff] [blame] | 574 | return AE_ERROR; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 575 | } |
| 576 | return AE_OK; |
| 577 | } |
| 578 | |
| 579 | static acpi_status AMW0_set_u32(u32 value, u32 cap, struct wmi_interface *iface) |
| 580 | { |
| 581 | struct wmab_args args; |
| 582 | |
| 583 | args.eax = ACER_AMW0_WRITE; |
| 584 | args.ebx = value ? (1<<8) : 0; |
| 585 | args.ecx = args.edx = 0; |
| 586 | |
| 587 | switch (cap) { |
| 588 | case ACER_CAP_MAILLED: |
| 589 | if (value > 1) |
| 590 | return AE_BAD_PARAMETER; |
| 591 | args.ebx |= ACER_AMW0_MAILLED_MASK; |
| 592 | break; |
| 593 | case ACER_CAP_WIRELESS: |
| 594 | if (value > 1) |
| 595 | return AE_BAD_PARAMETER; |
| 596 | args.ebx |= ACER_AMW0_WIRELESS_MASK; |
| 597 | break; |
| 598 | case ACER_CAP_BLUETOOTH: |
| 599 | if (value > 1) |
| 600 | return AE_BAD_PARAMETER; |
| 601 | args.ebx |= ACER_AMW0_BLUETOOTH_MASK; |
| 602 | break; |
| 603 | case ACER_CAP_BRIGHTNESS: |
| 604 | if (value > max_brightness) |
| 605 | return AE_BAD_PARAMETER; |
| 606 | switch (quirks->brightness) { |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 607 | default: |
Carlos Corbacho | 4609d02 | 2008-02-08 23:51:49 +0000 | [diff] [blame] | 608 | return ec_write(0x83, value); |
| 609 | break; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 610 | } |
| 611 | default: |
Lin Ming | 0823797 | 2008-08-08 11:57:11 +0800 | [diff] [blame] | 612 | return AE_ERROR; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | /* Actually do the set */ |
| 616 | return wmab_execute(&args, NULL); |
| 617 | } |
| 618 | |
| 619 | static acpi_status AMW0_find_mailled(void) |
| 620 | { |
| 621 | struct wmab_args args; |
| 622 | struct wmab_ret ret; |
| 623 | acpi_status status = AE_OK; |
| 624 | struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 625 | union acpi_object *obj; |
| 626 | |
| 627 | args.eax = 0x86; |
| 628 | args.ebx = args.ecx = args.edx = 0; |
| 629 | |
| 630 | status = wmab_execute(&args, &out); |
| 631 | if (ACPI_FAILURE(status)) |
| 632 | return status; |
| 633 | |
| 634 | obj = (union acpi_object *) out.pointer; |
| 635 | if (obj && obj->type == ACPI_TYPE_BUFFER && |
| 636 | obj->buffer.length == sizeof(struct wmab_ret)) { |
| 637 | ret = *((struct wmab_ret *) obj->buffer.pointer); |
| 638 | } else { |
Axel Lin | 7677fbd | 2010-07-20 15:19:53 -0700 | [diff] [blame] | 639 | kfree(out.pointer); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 640 | return AE_ERROR; |
| 641 | } |
| 642 | |
| 643 | if (ret.eex & 0x1) |
| 644 | interface->capability |= ACER_CAP_MAILLED; |
| 645 | |
| 646 | kfree(out.pointer); |
| 647 | |
| 648 | return AE_OK; |
| 649 | } |
| 650 | |
| 651 | static acpi_status AMW0_set_capabilities(void) |
| 652 | { |
| 653 | struct wmab_args args; |
| 654 | struct wmab_ret ret; |
Axel Lin | 7677fbd | 2010-07-20 15:19:53 -0700 | [diff] [blame] | 655 | acpi_status status; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 656 | struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 657 | union acpi_object *obj; |
| 658 | |
Carlos Corbacho | 5753dd5 | 2008-06-21 09:09:48 +0100 | [diff] [blame] | 659 | /* |
| 660 | * On laptops with this strange GUID (non Acer), normal probing doesn't |
| 661 | * work. |
| 662 | */ |
| 663 | if (wmi_has_guid(AMW0_GUID2)) { |
| 664 | interface->capability |= ACER_CAP_WIRELESS; |
| 665 | return AE_OK; |
| 666 | } |
| 667 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 668 | args.eax = ACER_AMW0_WRITE; |
| 669 | args.ecx = args.edx = 0; |
| 670 | |
| 671 | args.ebx = 0xa2 << 8; |
| 672 | args.ebx |= ACER_AMW0_WIRELESS_MASK; |
| 673 | |
| 674 | status = wmab_execute(&args, &out); |
| 675 | if (ACPI_FAILURE(status)) |
| 676 | return status; |
| 677 | |
Axel Lin | 7677fbd | 2010-07-20 15:19:53 -0700 | [diff] [blame] | 678 | obj = out.pointer; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 679 | if (obj && obj->type == ACPI_TYPE_BUFFER && |
| 680 | obj->buffer.length == sizeof(struct wmab_ret)) { |
| 681 | ret = *((struct wmab_ret *) obj->buffer.pointer); |
| 682 | } else { |
Axel Lin | 7677fbd | 2010-07-20 15:19:53 -0700 | [diff] [blame] | 683 | status = AE_ERROR; |
| 684 | goto out; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 685 | } |
| 686 | |
| 687 | if (ret.eax & 0x1) |
| 688 | interface->capability |= ACER_CAP_WIRELESS; |
| 689 | |
| 690 | args.ebx = 2 << 8; |
| 691 | args.ebx |= ACER_AMW0_BLUETOOTH_MASK; |
| 692 | |
Axel Lin | 7677fbd | 2010-07-20 15:19:53 -0700 | [diff] [blame] | 693 | /* |
| 694 | * It's ok to use existing buffer for next wmab_execute call. |
| 695 | * But we need to kfree(out.pointer) if next wmab_execute fail. |
| 696 | */ |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 697 | status = wmab_execute(&args, &out); |
| 698 | if (ACPI_FAILURE(status)) |
Axel Lin | 7677fbd | 2010-07-20 15:19:53 -0700 | [diff] [blame] | 699 | goto out; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 700 | |
| 701 | obj = (union acpi_object *) out.pointer; |
| 702 | if (obj && obj->type == ACPI_TYPE_BUFFER |
| 703 | && obj->buffer.length == sizeof(struct wmab_ret)) { |
| 704 | ret = *((struct wmab_ret *) obj->buffer.pointer); |
| 705 | } else { |
Axel Lin | 7677fbd | 2010-07-20 15:19:53 -0700 | [diff] [blame] | 706 | status = AE_ERROR; |
| 707 | goto out; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 708 | } |
| 709 | |
| 710 | if (ret.eax & 0x1) |
| 711 | interface->capability |= ACER_CAP_BLUETOOTH; |
| 712 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 713 | /* |
| 714 | * This appears to be safe to enable, since all Wistron based laptops |
| 715 | * appear to use the same EC register for brightness, even if they |
| 716 | * differ for wireless, etc |
| 717 | */ |
Carlos Corbacho | 9991d9f | 2008-06-21 09:09:22 +0100 | [diff] [blame] | 718 | if (quirks->brightness >= 0) |
| 719 | interface->capability |= ACER_CAP_BRIGHTNESS; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 720 | |
Axel Lin | 7677fbd | 2010-07-20 15:19:53 -0700 | [diff] [blame] | 721 | status = AE_OK; |
| 722 | out: |
| 723 | kfree(out.pointer); |
| 724 | return status; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | static struct wmi_interface AMW0_interface = { |
| 728 | .type = ACER_AMW0, |
| 729 | }; |
| 730 | |
| 731 | static struct wmi_interface AMW0_V2_interface = { |
| 732 | .type = ACER_AMW0_V2, |
| 733 | }; |
| 734 | |
| 735 | /* |
| 736 | * New interface (The WMID interface) |
| 737 | */ |
| 738 | static acpi_status |
| 739 | WMI_execute_u32(u32 method_id, u32 in, u32 *out) |
| 740 | { |
| 741 | struct acpi_buffer input = { (acpi_size) sizeof(u32), (void *)(&in) }; |
| 742 | struct acpi_buffer result = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 743 | union acpi_object *obj; |
| 744 | u32 tmp; |
| 745 | acpi_status status; |
| 746 | |
| 747 | status = wmi_evaluate_method(WMID_GUID1, 1, method_id, &input, &result); |
| 748 | |
| 749 | if (ACPI_FAILURE(status)) |
| 750 | return status; |
| 751 | |
| 752 | obj = (union acpi_object *) result.pointer; |
| 753 | if (obj && obj->type == ACPI_TYPE_BUFFER && |
Lee, Chun-Yi | ab6a931 | 2011-05-22 07:33:53 +0800 | [diff] [blame] | 754 | (obj->buffer.length == sizeof(u32) || |
| 755 | obj->buffer.length == sizeof(u64))) { |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 756 | tmp = *((u32 *) obj->buffer.pointer); |
Lee, Chun-Yi | 987dfba | 2011-05-27 14:52:14 +0800 | [diff] [blame] | 757 | } else if (obj->type == ACPI_TYPE_INTEGER) { |
| 758 | tmp = (u32) obj->integer.value; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 759 | } else { |
| 760 | tmp = 0; |
| 761 | } |
| 762 | |
| 763 | if (out) |
| 764 | *out = tmp; |
| 765 | |
| 766 | kfree(result.pointer); |
| 767 | |
| 768 | return status; |
| 769 | } |
| 770 | |
| 771 | static acpi_status WMID_get_u32(u32 *value, u32 cap, |
| 772 | struct wmi_interface *iface) |
| 773 | { |
| 774 | acpi_status status; |
| 775 | u8 tmp; |
| 776 | u32 result, method_id = 0; |
| 777 | |
| 778 | switch (cap) { |
| 779 | case ACER_CAP_WIRELESS: |
| 780 | method_id = ACER_WMID_GET_WIRELESS_METHODID; |
| 781 | break; |
| 782 | case ACER_CAP_BLUETOOTH: |
| 783 | method_id = ACER_WMID_GET_BLUETOOTH_METHODID; |
| 784 | break; |
| 785 | case ACER_CAP_BRIGHTNESS: |
| 786 | method_id = ACER_WMID_GET_BRIGHTNESS_METHODID; |
| 787 | break; |
| 788 | case ACER_CAP_THREEG: |
| 789 | method_id = ACER_WMID_GET_THREEG_METHODID; |
| 790 | break; |
| 791 | case ACER_CAP_MAILLED: |
| 792 | if (quirks->mailled == 1) { |
| 793 | ec_read(0x9f, &tmp); |
| 794 | *value = tmp & 0x1; |
| 795 | return 0; |
| 796 | } |
| 797 | default: |
Lin Ming | 0823797 | 2008-08-08 11:57:11 +0800 | [diff] [blame] | 798 | return AE_ERROR; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 799 | } |
| 800 | status = WMI_execute_u32(method_id, 0, &result); |
| 801 | |
| 802 | if (ACPI_SUCCESS(status)) |
| 803 | *value = (u8)result; |
| 804 | |
| 805 | return status; |
| 806 | } |
| 807 | |
| 808 | static acpi_status WMID_set_u32(u32 value, u32 cap, struct wmi_interface *iface) |
| 809 | { |
| 810 | u32 method_id = 0; |
| 811 | char param; |
| 812 | |
| 813 | switch (cap) { |
| 814 | case ACER_CAP_BRIGHTNESS: |
| 815 | if (value > max_brightness) |
| 816 | return AE_BAD_PARAMETER; |
| 817 | method_id = ACER_WMID_SET_BRIGHTNESS_METHODID; |
| 818 | break; |
| 819 | case ACER_CAP_WIRELESS: |
| 820 | if (value > 1) |
| 821 | return AE_BAD_PARAMETER; |
| 822 | method_id = ACER_WMID_SET_WIRELESS_METHODID; |
| 823 | break; |
| 824 | case ACER_CAP_BLUETOOTH: |
| 825 | if (value > 1) |
| 826 | return AE_BAD_PARAMETER; |
| 827 | method_id = ACER_WMID_SET_BLUETOOTH_METHODID; |
| 828 | break; |
| 829 | case ACER_CAP_THREEG: |
| 830 | if (value > 1) |
| 831 | return AE_BAD_PARAMETER; |
| 832 | method_id = ACER_WMID_SET_THREEG_METHODID; |
| 833 | break; |
| 834 | case ACER_CAP_MAILLED: |
| 835 | if (value > 1) |
| 836 | return AE_BAD_PARAMETER; |
| 837 | if (quirks->mailled == 1) { |
| 838 | param = value ? 0x92 : 0x93; |
Dmitry Torokhov | 181d683 | 2009-09-16 01:06:43 -0700 | [diff] [blame] | 839 | i8042_lock_chip(); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 840 | i8042_command(¶m, 0x1059); |
Dmitry Torokhov | 181d683 | 2009-09-16 01:06:43 -0700 | [diff] [blame] | 841 | i8042_unlock_chip(); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 842 | return 0; |
| 843 | } |
| 844 | break; |
| 845 | default: |
Lin Ming | 0823797 | 2008-08-08 11:57:11 +0800 | [diff] [blame] | 846 | return AE_ERROR; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 847 | } |
| 848 | return WMI_execute_u32(method_id, (u32)value, NULL); |
| 849 | } |
| 850 | |
Lee, Chun-Yi | 6c3df88 | 2010-12-07 10:29:23 +0800 | [diff] [blame] | 851 | static void type_aa_dmi_decode(const struct dmi_header *header, void *dummy) |
| 852 | { |
| 853 | struct hotkey_function_type_aa *type_aa; |
| 854 | |
| 855 | /* We are looking for OEM-specific Type AAh */ |
| 856 | if (header->type != 0xAA) |
| 857 | return; |
| 858 | |
| 859 | has_type_aa = true; |
| 860 | type_aa = (struct hotkey_function_type_aa *) header; |
| 861 | |
Lee, Chun-Yi | cae1570 | 2011-03-16 18:52:36 +0800 | [diff] [blame] | 862 | pr_info("Function bitmap for Communication Button: 0x%x\n", |
Lee, Chun-Yi | 6c3df88 | 2010-12-07 10:29:23 +0800 | [diff] [blame] | 863 | type_aa->commun_func_bitmap); |
| 864 | |
| 865 | if (type_aa->commun_func_bitmap & ACER_WMID3_GDS_WIRELESS) |
| 866 | interface->capability |= ACER_CAP_WIRELESS; |
| 867 | if (type_aa->commun_func_bitmap & ACER_WMID3_GDS_THREEG) |
| 868 | interface->capability |= ACER_CAP_THREEG; |
| 869 | if (type_aa->commun_func_bitmap & ACER_WMID3_GDS_BLUETOOTH) |
| 870 | interface->capability |= ACER_CAP_BLUETOOTH; |
| 871 | } |
| 872 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 873 | static acpi_status WMID_set_capabilities(void) |
| 874 | { |
| 875 | struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL}; |
| 876 | union acpi_object *obj; |
| 877 | acpi_status status; |
| 878 | u32 devices; |
| 879 | |
| 880 | status = wmi_query_block(WMID_GUID2, 1, &out); |
| 881 | if (ACPI_FAILURE(status)) |
| 882 | return status; |
| 883 | |
| 884 | obj = (union acpi_object *) out.pointer; |
| 885 | if (obj && obj->type == ACPI_TYPE_BUFFER && |
Lee, Chun-Yi | ab6a931 | 2011-05-22 07:33:53 +0800 | [diff] [blame] | 886 | (obj->buffer.length == sizeof(u32) || |
| 887 | obj->buffer.length == sizeof(u64))) { |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 888 | devices = *((u32 *) obj->buffer.pointer); |
Lee, Chun-Yi | 987dfba | 2011-05-27 14:52:14 +0800 | [diff] [blame] | 889 | } else if (obj->type == ACPI_TYPE_INTEGER) { |
| 890 | devices = (u32) obj->integer.value; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 891 | } else { |
Axel Lin | 6690486 | 2010-07-20 15:19:52 -0700 | [diff] [blame] | 892 | kfree(out.pointer); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 893 | return AE_ERROR; |
| 894 | } |
| 895 | |
Lee, Chun-Yi | 6c3df88 | 2010-12-07 10:29:23 +0800 | [diff] [blame] | 896 | dmi_walk(type_aa_dmi_decode, NULL); |
| 897 | if (!has_type_aa) { |
| 898 | interface->capability |= ACER_CAP_WIRELESS; |
Lee, Chun-Yi | a8d1a26 | 2011-05-22 07:33:52 +0800 | [diff] [blame] | 899 | if (devices & 0x40) |
| 900 | interface->capability |= ACER_CAP_THREEG; |
Lee, Chun-Yi | 6c3df88 | 2010-12-07 10:29:23 +0800 | [diff] [blame] | 901 | if (devices & 0x10) |
| 902 | interface->capability |= ACER_CAP_BLUETOOTH; |
| 903 | } |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 904 | |
| 905 | /* WMID always provides brightness methods */ |
| 906 | interface->capability |= ACER_CAP_BRIGHTNESS; |
| 907 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 908 | if (!(devices & 0x20)) |
| 909 | max_brightness = 0x9; |
| 910 | |
Axel Lin | 6690486 | 2010-07-20 15:19:52 -0700 | [diff] [blame] | 911 | kfree(out.pointer); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 912 | return status; |
| 913 | } |
| 914 | |
| 915 | static struct wmi_interface wmid_interface = { |
| 916 | .type = ACER_WMID, |
| 917 | }; |
| 918 | |
| 919 | /* |
| 920 | * Generic Device (interface-independent) |
| 921 | */ |
| 922 | |
| 923 | static acpi_status get_u32(u32 *value, u32 cap) |
| 924 | { |
Lin Ming | 0823797 | 2008-08-08 11:57:11 +0800 | [diff] [blame] | 925 | acpi_status status = AE_ERROR; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 926 | |
| 927 | switch (interface->type) { |
| 928 | case ACER_AMW0: |
| 929 | status = AMW0_get_u32(value, cap, interface); |
| 930 | break; |
| 931 | case ACER_AMW0_V2: |
| 932 | if (cap == ACER_CAP_MAILLED) { |
| 933 | status = AMW0_get_u32(value, cap, interface); |
| 934 | break; |
| 935 | } |
| 936 | case ACER_WMID: |
| 937 | status = WMID_get_u32(value, cap, interface); |
| 938 | break; |
| 939 | } |
| 940 | |
| 941 | return status; |
| 942 | } |
| 943 | |
| 944 | static acpi_status set_u32(u32 value, u32 cap) |
| 945 | { |
Carlos Corbacho | 5c742b4 | 2008-08-06 19:13:56 +0100 | [diff] [blame] | 946 | acpi_status status; |
| 947 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 948 | if (interface->capability & cap) { |
| 949 | switch (interface->type) { |
| 950 | case ACER_AMW0: |
| 951 | return AMW0_set_u32(value, cap, interface); |
| 952 | case ACER_AMW0_V2: |
Carlos Corbacho | 5c742b4 | 2008-08-06 19:13:56 +0100 | [diff] [blame] | 953 | if (cap == ACER_CAP_MAILLED) |
| 954 | return AMW0_set_u32(value, cap, interface); |
| 955 | |
| 956 | /* |
| 957 | * On some models, some WMID methods don't toggle |
| 958 | * properly. For those cases, we want to run the AMW0 |
| 959 | * method afterwards to be certain we've really toggled |
| 960 | * the device state. |
| 961 | */ |
| 962 | if (cap == ACER_CAP_WIRELESS || |
| 963 | cap == ACER_CAP_BLUETOOTH) { |
| 964 | status = WMID_set_u32(value, cap, interface); |
| 965 | if (ACPI_FAILURE(status)) |
| 966 | return status; |
| 967 | |
| 968 | return AMW0_set_u32(value, cap, interface); |
| 969 | } |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 970 | case ACER_WMID: |
| 971 | return WMID_set_u32(value, cap, interface); |
| 972 | default: |
| 973 | return AE_BAD_PARAMETER; |
| 974 | } |
| 975 | } |
| 976 | return AE_BAD_PARAMETER; |
| 977 | } |
| 978 | |
| 979 | static void __init acer_commandline_init(void) |
| 980 | { |
| 981 | /* |
| 982 | * These will all fail silently if the value given is invalid, or the |
| 983 | * capability isn't available on the given interface |
| 984 | */ |
Lee, Chun-Yi | c2647b5 | 2011-04-15 18:42:47 +0800 | [diff] [blame] | 985 | if (mailled >= 0) |
| 986 | set_u32(mailled, ACER_CAP_MAILLED); |
| 987 | if (!has_type_aa && threeg >= 0) |
Lee, Chun-Yi | 6c3df88 | 2010-12-07 10:29:23 +0800 | [diff] [blame] | 988 | set_u32(threeg, ACER_CAP_THREEG); |
Lee, Chun-Yi | c2647b5 | 2011-04-15 18:42:47 +0800 | [diff] [blame] | 989 | if (brightness >= 0) |
| 990 | set_u32(brightness, ACER_CAP_BRIGHTNESS); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 991 | } |
| 992 | |
| 993 | /* |
| 994 | * LED device (Mail LED only, no other LEDs known yet) |
| 995 | */ |
| 996 | static void mail_led_set(struct led_classdev *led_cdev, |
| 997 | enum led_brightness value) |
| 998 | { |
| 999 | set_u32(value, ACER_CAP_MAILLED); |
| 1000 | } |
| 1001 | |
| 1002 | static struct led_classdev mail_led = { |
Carlos Corbacho | 343c004 | 2008-02-24 13:34:18 +0000 | [diff] [blame] | 1003 | .name = "acer-wmi::mail", |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1004 | .brightness_set = mail_led_set, |
| 1005 | }; |
| 1006 | |
Sam Ravnborg | 7560e38 | 2008-02-17 13:22:54 +0100 | [diff] [blame] | 1007 | static int __devinit acer_led_init(struct device *dev) |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1008 | { |
| 1009 | return led_classdev_register(dev, &mail_led); |
| 1010 | } |
| 1011 | |
| 1012 | static void acer_led_exit(void) |
| 1013 | { |
Pali Rohár | 9a0b74f | 2011-02-26 21:18:58 +0100 | [diff] [blame] | 1014 | set_u32(LED_OFF, ACER_CAP_MAILLED); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1015 | led_classdev_unregister(&mail_led); |
| 1016 | } |
| 1017 | |
| 1018 | /* |
| 1019 | * Backlight device |
| 1020 | */ |
| 1021 | static struct backlight_device *acer_backlight_device; |
| 1022 | |
| 1023 | static int read_brightness(struct backlight_device *bd) |
| 1024 | { |
| 1025 | u32 value; |
| 1026 | get_u32(&value, ACER_CAP_BRIGHTNESS); |
| 1027 | return value; |
| 1028 | } |
| 1029 | |
| 1030 | static int update_bl_status(struct backlight_device *bd) |
| 1031 | { |
Carlos Corbacho | f2b585b | 2008-06-21 09:09:27 +0100 | [diff] [blame] | 1032 | int intensity = bd->props.brightness; |
| 1033 | |
| 1034 | if (bd->props.power != FB_BLANK_UNBLANK) |
| 1035 | intensity = 0; |
| 1036 | if (bd->props.fb_blank != FB_BLANK_UNBLANK) |
| 1037 | intensity = 0; |
| 1038 | |
| 1039 | set_u32(intensity, ACER_CAP_BRIGHTNESS); |
| 1040 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1041 | return 0; |
| 1042 | } |
| 1043 | |
Lionel Debroux | acc2472 | 2010-11-16 14:14:02 +0100 | [diff] [blame] | 1044 | static const struct backlight_ops acer_bl_ops = { |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1045 | .get_brightness = read_brightness, |
| 1046 | .update_status = update_bl_status, |
| 1047 | }; |
| 1048 | |
Sam Ravnborg | 7560e38 | 2008-02-17 13:22:54 +0100 | [diff] [blame] | 1049 | static int __devinit acer_backlight_init(struct device *dev) |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1050 | { |
Matthew Garrett | a19a6ee | 2010-02-17 16:39:44 -0500 | [diff] [blame] | 1051 | struct backlight_properties props; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1052 | struct backlight_device *bd; |
| 1053 | |
Matthew Garrett | a19a6ee | 2010-02-17 16:39:44 -0500 | [diff] [blame] | 1054 | memset(&props, 0, sizeof(struct backlight_properties)); |
Matthew Garrett | bb7ca74 | 2011-03-22 16:30:21 -0700 | [diff] [blame] | 1055 | props.type = BACKLIGHT_PLATFORM; |
Matthew Garrett | a19a6ee | 2010-02-17 16:39:44 -0500 | [diff] [blame] | 1056 | props.max_brightness = max_brightness; |
| 1057 | bd = backlight_device_register("acer-wmi", dev, NULL, &acer_bl_ops, |
| 1058 | &props); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1059 | if (IS_ERR(bd)) { |
Lee, Chun-Yi | cae1570 | 2011-03-16 18:52:36 +0800 | [diff] [blame] | 1060 | pr_err("Could not register Acer backlight device\n"); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1061 | acer_backlight_device = NULL; |
| 1062 | return PTR_ERR(bd); |
| 1063 | } |
| 1064 | |
| 1065 | acer_backlight_device = bd; |
| 1066 | |
Carlos Corbacho | f2b585b | 2008-06-21 09:09:27 +0100 | [diff] [blame] | 1067 | bd->props.power = FB_BLANK_UNBLANK; |
Carlos Corbacho | 6f6ef82 | 2009-12-26 19:24:31 +0000 | [diff] [blame] | 1068 | bd->props.brightness = read_brightness(bd); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1069 | backlight_update_status(bd); |
| 1070 | return 0; |
| 1071 | } |
| 1072 | |
Sam Ravnborg | 7560e38 | 2008-02-17 13:22:54 +0100 | [diff] [blame] | 1073 | static void acer_backlight_exit(void) |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1074 | { |
| 1075 | backlight_device_unregister(acer_backlight_device); |
| 1076 | } |
| 1077 | |
Lee, Chun-Yi | b3c9092 | 2010-12-07 10:29:22 +0800 | [diff] [blame] | 1078 | static acpi_status wmid3_get_device_status(u32 *value, u16 device) |
| 1079 | { |
| 1080 | struct wmid3_gds_return_value return_value; |
| 1081 | acpi_status status; |
| 1082 | union acpi_object *obj; |
| 1083 | struct wmid3_gds_input_param params = { |
| 1084 | .function_num = 0x1, |
| 1085 | .hotkey_number = 0x01, |
| 1086 | .devices = device, |
| 1087 | }; |
| 1088 | struct acpi_buffer input = { |
| 1089 | sizeof(struct wmid3_gds_input_param), |
| 1090 | ¶ms |
| 1091 | }; |
| 1092 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 1093 | |
| 1094 | status = wmi_evaluate_method(WMID_GUID3, 0, 0x2, &input, &output); |
| 1095 | if (ACPI_FAILURE(status)) |
| 1096 | return status; |
| 1097 | |
| 1098 | obj = output.pointer; |
| 1099 | |
| 1100 | if (!obj) |
| 1101 | return AE_ERROR; |
| 1102 | else if (obj->type != ACPI_TYPE_BUFFER) { |
| 1103 | kfree(obj); |
| 1104 | return AE_ERROR; |
| 1105 | } |
| 1106 | if (obj->buffer.length != 8) { |
Joe Perches | 249c720 | 2011-03-29 15:21:34 -0700 | [diff] [blame] | 1107 | pr_warn("Unknown buffer length %d\n", obj->buffer.length); |
Lee, Chun-Yi | b3c9092 | 2010-12-07 10:29:22 +0800 | [diff] [blame] | 1108 | kfree(obj); |
| 1109 | return AE_ERROR; |
| 1110 | } |
| 1111 | |
| 1112 | return_value = *((struct wmid3_gds_return_value *)obj->buffer.pointer); |
| 1113 | kfree(obj); |
| 1114 | |
| 1115 | if (return_value.error_code || return_value.ec_return_value) |
Joe Perches | 249c720 | 2011-03-29 15:21:34 -0700 | [diff] [blame] | 1116 | pr_warn("Get Device Status failed: 0x%x - 0x%x\n", |
| 1117 | return_value.error_code, |
Lee, Chun-Yi | b3c9092 | 2010-12-07 10:29:22 +0800 | [diff] [blame] | 1118 | return_value.ec_return_value); |
| 1119 | else |
| 1120 | *value = !!(return_value.devices & device); |
| 1121 | |
| 1122 | return status; |
| 1123 | } |
| 1124 | |
Lee, Chun-Yi | 466449c | 2010-12-13 10:02:41 +0800 | [diff] [blame] | 1125 | static acpi_status get_device_status(u32 *value, u32 cap) |
| 1126 | { |
| 1127 | if (wmi_has_guid(WMID_GUID3)) { |
| 1128 | u16 device; |
| 1129 | |
| 1130 | switch (cap) { |
| 1131 | case ACER_CAP_WIRELESS: |
| 1132 | device = ACER_WMID3_GDS_WIRELESS; |
| 1133 | break; |
| 1134 | case ACER_CAP_BLUETOOTH: |
| 1135 | device = ACER_WMID3_GDS_BLUETOOTH; |
| 1136 | break; |
| 1137 | case ACER_CAP_THREEG: |
| 1138 | device = ACER_WMID3_GDS_THREEG; |
| 1139 | break; |
| 1140 | default: |
| 1141 | return AE_ERROR; |
| 1142 | } |
| 1143 | return wmid3_get_device_status(value, device); |
| 1144 | |
| 1145 | } else { |
| 1146 | return get_u32(value, cap); |
| 1147 | } |
| 1148 | } |
| 1149 | |
Lee, Chun-Yi | 6d88ff0 | 2011-05-22 07:33:54 +0800 | [diff] [blame] | 1150 | static acpi_status wmid3_set_device_status(u32 value, u16 device) |
| 1151 | { |
| 1152 | struct wmid3_gds_return_value return_value; |
| 1153 | acpi_status status; |
| 1154 | union acpi_object *obj; |
| 1155 | u16 devices; |
| 1156 | struct wmid3_gds_input_param params = { |
| 1157 | .function_num = 0x1, |
| 1158 | .hotkey_number = 0x01, |
| 1159 | .devices = ACER_WMID3_GDS_WIRELESS & |
| 1160 | ACER_WMID3_GDS_THREEG & |
| 1161 | ACER_WMID3_GDS_WIMAX & |
| 1162 | ACER_WMID3_GDS_BLUETOOTH, |
| 1163 | }; |
| 1164 | struct acpi_buffer input = { |
| 1165 | sizeof(struct wmid3_gds_input_param), |
| 1166 | ¶ms |
| 1167 | }; |
| 1168 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 1169 | struct acpi_buffer output2 = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 1170 | |
| 1171 | status = wmi_evaluate_method(WMID_GUID3, 0, 0x2, &input, &output); |
| 1172 | if (ACPI_FAILURE(status)) |
| 1173 | return status; |
| 1174 | |
| 1175 | obj = output.pointer; |
| 1176 | |
| 1177 | if (!obj) |
| 1178 | return AE_ERROR; |
| 1179 | else if (obj->type != ACPI_TYPE_BUFFER) { |
| 1180 | kfree(obj); |
| 1181 | return AE_ERROR; |
| 1182 | } |
| 1183 | if (obj->buffer.length != 8) { |
| 1184 | pr_warning("Unknown buffer length %d\n", obj->buffer.length); |
| 1185 | kfree(obj); |
| 1186 | return AE_ERROR; |
| 1187 | } |
| 1188 | |
| 1189 | return_value = *((struct wmid3_gds_return_value *)obj->buffer.pointer); |
| 1190 | kfree(obj); |
| 1191 | |
| 1192 | if (return_value.error_code || return_value.ec_return_value) { |
| 1193 | pr_warning("Get Current Device Status failed: " |
| 1194 | "0x%x - 0x%x\n", return_value.error_code, |
| 1195 | return_value.ec_return_value); |
| 1196 | return status; |
| 1197 | } |
| 1198 | |
| 1199 | devices = return_value.devices; |
| 1200 | params.function_num = 0x2; |
| 1201 | params.hotkey_number = 0x01; |
| 1202 | params.devices = (value) ? (devices | device) : (devices & ~device); |
| 1203 | |
| 1204 | status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &input, &output2); |
| 1205 | if (ACPI_FAILURE(status)) |
| 1206 | return status; |
| 1207 | |
| 1208 | obj = output2.pointer; |
| 1209 | |
| 1210 | if (!obj) |
| 1211 | return AE_ERROR; |
| 1212 | else if (obj->type != ACPI_TYPE_BUFFER) { |
| 1213 | kfree(obj); |
| 1214 | return AE_ERROR; |
| 1215 | } |
| 1216 | if (obj->buffer.length != 4) { |
| 1217 | pr_warning("Unknown buffer length %d\n", obj->buffer.length); |
| 1218 | kfree(obj); |
| 1219 | return AE_ERROR; |
| 1220 | } |
| 1221 | |
| 1222 | return_value = *((struct wmid3_gds_return_value *)obj->buffer.pointer); |
| 1223 | kfree(obj); |
| 1224 | |
| 1225 | if (return_value.error_code || return_value.ec_return_value) |
| 1226 | pr_warning("Set Device Status failed: " |
| 1227 | "0x%x - 0x%x\n", return_value.error_code, |
| 1228 | return_value.ec_return_value); |
| 1229 | |
| 1230 | return status; |
| 1231 | } |
| 1232 | |
| 1233 | static acpi_status set_device_status(u32 value, u32 cap) |
| 1234 | { |
| 1235 | if (wmi_has_guid(WMID_GUID3)) { |
| 1236 | u16 device; |
| 1237 | |
| 1238 | switch (cap) { |
| 1239 | case ACER_CAP_WIRELESS: |
| 1240 | device = ACER_WMID3_GDS_WIRELESS; |
| 1241 | break; |
| 1242 | case ACER_CAP_BLUETOOTH: |
| 1243 | device = ACER_WMID3_GDS_BLUETOOTH; |
| 1244 | break; |
| 1245 | case ACER_CAP_THREEG: |
| 1246 | device = ACER_WMID3_GDS_THREEG; |
| 1247 | break; |
| 1248 | default: |
| 1249 | return AE_ERROR; |
| 1250 | } |
| 1251 | return wmid3_set_device_status(value, device); |
| 1252 | |
| 1253 | } else { |
| 1254 | return set_u32(value, cap); |
| 1255 | } |
| 1256 | } |
| 1257 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1258 | /* |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1259 | * Rfkill devices |
| 1260 | */ |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1261 | static void acer_rfkill_update(struct work_struct *ignored); |
| 1262 | static DECLARE_DELAYED_WORK(acer_rfkill_work, acer_rfkill_update); |
| 1263 | static void acer_rfkill_update(struct work_struct *ignored) |
| 1264 | { |
| 1265 | u32 state; |
| 1266 | acpi_status status; |
| 1267 | |
| 1268 | status = get_u32(&state, ACER_CAP_WIRELESS); |
| 1269 | if (ACPI_SUCCESS(status)) |
Troy Moure | a878417 | 2009-06-17 11:51:56 +0100 | [diff] [blame] | 1270 | rfkill_set_sw_state(wireless_rfkill, !state); |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1271 | |
| 1272 | if (has_cap(ACER_CAP_BLUETOOTH)) { |
| 1273 | status = get_u32(&state, ACER_CAP_BLUETOOTH); |
| 1274 | if (ACPI_SUCCESS(status)) |
Troy Moure | a878417 | 2009-06-17 11:51:56 +0100 | [diff] [blame] | 1275 | rfkill_set_sw_state(bluetooth_rfkill, !state); |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1276 | } |
| 1277 | |
Lee, Chun-Yi | b3c9092 | 2010-12-07 10:29:22 +0800 | [diff] [blame] | 1278 | if (has_cap(ACER_CAP_THREEG) && wmi_has_guid(WMID_GUID3)) { |
| 1279 | status = wmid3_get_device_status(&state, |
| 1280 | ACER_WMID3_GDS_THREEG); |
| 1281 | if (ACPI_SUCCESS(status)) |
| 1282 | rfkill_set_sw_state(threeg_rfkill, !state); |
| 1283 | } |
| 1284 | |
Carlos Corbacho | ae3a1b4 | 2008-10-10 17:33:35 +0100 | [diff] [blame] | 1285 | schedule_delayed_work(&acer_rfkill_work, round_jiffies_relative(HZ)); |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1286 | } |
| 1287 | |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 1288 | static int acer_rfkill_set(void *data, bool blocked) |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1289 | { |
| 1290 | acpi_status status; |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 1291 | u32 cap = (unsigned long)data; |
Lee, Chun-Yi | 8215af0 | 2011-03-28 16:52:02 +0800 | [diff] [blame] | 1292 | |
| 1293 | if (rfkill_inited) { |
Lee, Chun-Yi | 6d88ff0 | 2011-05-22 07:33:54 +0800 | [diff] [blame] | 1294 | status = set_device_status(!blocked, cap); |
Lee, Chun-Yi | 8215af0 | 2011-03-28 16:52:02 +0800 | [diff] [blame] | 1295 | if (ACPI_FAILURE(status)) |
| 1296 | return -ENODEV; |
| 1297 | } |
| 1298 | |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1299 | return 0; |
| 1300 | } |
| 1301 | |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 1302 | static const struct rfkill_ops acer_rfkill_ops = { |
| 1303 | .set_block = acer_rfkill_set, |
| 1304 | }; |
| 1305 | |
| 1306 | static struct rfkill *acer_rfkill_register(struct device *dev, |
| 1307 | enum rfkill_type type, |
| 1308 | char *name, u32 cap) |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1309 | { |
| 1310 | int err; |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1311 | struct rfkill *rfkill_dev; |
Lee, Chun-Yi | 466449c | 2010-12-13 10:02:41 +0800 | [diff] [blame] | 1312 | u32 state; |
| 1313 | acpi_status status; |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1314 | |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 1315 | rfkill_dev = rfkill_alloc(name, dev, type, |
| 1316 | &acer_rfkill_ops, |
| 1317 | (void *)(unsigned long)cap); |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1318 | if (!rfkill_dev) |
| 1319 | return ERR_PTR(-ENOMEM); |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1320 | |
Lee, Chun-Yi | 466449c | 2010-12-13 10:02:41 +0800 | [diff] [blame] | 1321 | status = get_device_status(&state, cap); |
Lee, Chun-Yi | 466449c | 2010-12-13 10:02:41 +0800 | [diff] [blame] | 1322 | |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1323 | err = rfkill_register(rfkill_dev); |
| 1324 | if (err) { |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 1325 | rfkill_destroy(rfkill_dev); |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1326 | return ERR_PTR(err); |
| 1327 | } |
Lee, Chun-Yi | 8215af0 | 2011-03-28 16:52:02 +0800 | [diff] [blame] | 1328 | |
| 1329 | if (ACPI_SUCCESS(status)) |
| 1330 | rfkill_set_sw_state(rfkill_dev, !state); |
| 1331 | |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1332 | return rfkill_dev; |
| 1333 | } |
| 1334 | |
| 1335 | static int acer_rfkill_init(struct device *dev) |
| 1336 | { |
| 1337 | wireless_rfkill = acer_rfkill_register(dev, RFKILL_TYPE_WLAN, |
| 1338 | "acer-wireless", ACER_CAP_WIRELESS); |
| 1339 | if (IS_ERR(wireless_rfkill)) |
| 1340 | return PTR_ERR(wireless_rfkill); |
| 1341 | |
| 1342 | if (has_cap(ACER_CAP_BLUETOOTH)) { |
| 1343 | bluetooth_rfkill = acer_rfkill_register(dev, |
| 1344 | RFKILL_TYPE_BLUETOOTH, "acer-bluetooth", |
| 1345 | ACER_CAP_BLUETOOTH); |
| 1346 | if (IS_ERR(bluetooth_rfkill)) { |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1347 | rfkill_unregister(wireless_rfkill); |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 1348 | rfkill_destroy(wireless_rfkill); |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1349 | return PTR_ERR(bluetooth_rfkill); |
| 1350 | } |
| 1351 | } |
| 1352 | |
Lee, Chun-Yi | b3c9092 | 2010-12-07 10:29:22 +0800 | [diff] [blame] | 1353 | if (has_cap(ACER_CAP_THREEG)) { |
| 1354 | threeg_rfkill = acer_rfkill_register(dev, |
| 1355 | RFKILL_TYPE_WWAN, "acer-threeg", |
| 1356 | ACER_CAP_THREEG); |
| 1357 | if (IS_ERR(threeg_rfkill)) { |
| 1358 | rfkill_unregister(wireless_rfkill); |
| 1359 | rfkill_destroy(wireless_rfkill); |
| 1360 | rfkill_unregister(bluetooth_rfkill); |
| 1361 | rfkill_destroy(bluetooth_rfkill); |
| 1362 | return PTR_ERR(threeg_rfkill); |
| 1363 | } |
| 1364 | } |
| 1365 | |
Lee, Chun-Yi | 8215af0 | 2011-03-28 16:52:02 +0800 | [diff] [blame] | 1366 | rfkill_inited = true; |
| 1367 | |
Lee, Chun-Yi | 70a9b90 | 2011-03-28 06:34:13 -0400 | [diff] [blame] | 1368 | if (ec_raw_mode || !wmi_has_guid(ACERWMID_EVENT_GUID)) |
| 1369 | schedule_delayed_work(&acer_rfkill_work, |
| 1370 | round_jiffies_relative(HZ)); |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1371 | |
| 1372 | return 0; |
| 1373 | } |
| 1374 | |
| 1375 | static void acer_rfkill_exit(void) |
| 1376 | { |
Lee, Chun-Yi | 70a9b90 | 2011-03-28 06:34:13 -0400 | [diff] [blame] | 1377 | if (ec_raw_mode || !wmi_has_guid(ACERWMID_EVENT_GUID)) |
| 1378 | cancel_delayed_work_sync(&acer_rfkill_work); |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 1379 | |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1380 | rfkill_unregister(wireless_rfkill); |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 1381 | rfkill_destroy(wireless_rfkill); |
| 1382 | |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1383 | if (has_cap(ACER_CAP_BLUETOOTH)) { |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1384 | rfkill_unregister(bluetooth_rfkill); |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 1385 | rfkill_destroy(bluetooth_rfkill); |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1386 | } |
Lee, Chun-Yi | b3c9092 | 2010-12-07 10:29:22 +0800 | [diff] [blame] | 1387 | |
| 1388 | if (has_cap(ACER_CAP_THREEG)) { |
| 1389 | rfkill_unregister(threeg_rfkill); |
| 1390 | rfkill_destroy(threeg_rfkill); |
| 1391 | } |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1392 | return; |
| 1393 | } |
| 1394 | |
| 1395 | /* |
Carlos Corbacho | 7d9a06d | 2008-10-08 21:40:26 +0100 | [diff] [blame] | 1396 | * sysfs interface |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1397 | */ |
Carlos Corbacho | 7d9a06d | 2008-10-08 21:40:26 +0100 | [diff] [blame] | 1398 | static ssize_t show_bool_threeg(struct device *dev, |
| 1399 | struct device_attribute *attr, char *buf) |
| 1400 | { |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1401 | u32 result; \ |
Lee, Chun-Yi | b3c9092 | 2010-12-07 10:29:22 +0800 | [diff] [blame] | 1402 | acpi_status status; |
| 1403 | if (wmi_has_guid(WMID_GUID3)) |
| 1404 | status = wmid3_get_device_status(&result, |
| 1405 | ACER_WMID3_GDS_THREEG); |
| 1406 | else |
| 1407 | status = get_u32(&result, ACER_CAP_THREEG); |
Carlos Corbacho | 7d9a06d | 2008-10-08 21:40:26 +0100 | [diff] [blame] | 1408 | if (ACPI_SUCCESS(status)) |
| 1409 | return sprintf(buf, "%u\n", result); |
| 1410 | return sprintf(buf, "Read error\n"); |
| 1411 | } |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1412 | |
Carlos Corbacho | 7d9a06d | 2008-10-08 21:40:26 +0100 | [diff] [blame] | 1413 | static ssize_t set_bool_threeg(struct device *dev, |
| 1414 | struct device_attribute *attr, const char *buf, size_t count) |
| 1415 | { |
| 1416 | u32 tmp = simple_strtoul(buf, NULL, 10); |
| 1417 | acpi_status status = set_u32(tmp, ACER_CAP_THREEG); |
| 1418 | if (ACPI_FAILURE(status)) |
| 1419 | return -EINVAL; |
| 1420 | return count; |
| 1421 | } |
Vasiliy Kulikov | b80b168 | 2011-02-04 15:23:56 +0300 | [diff] [blame] | 1422 | static DEVICE_ATTR(threeg, S_IRUGO | S_IWUSR, show_bool_threeg, |
Carlos Corbacho | 7d9a06d | 2008-10-08 21:40:26 +0100 | [diff] [blame] | 1423 | set_bool_threeg); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1424 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1425 | static ssize_t show_interface(struct device *dev, struct device_attribute *attr, |
| 1426 | char *buf) |
| 1427 | { |
| 1428 | switch (interface->type) { |
| 1429 | case ACER_AMW0: |
| 1430 | return sprintf(buf, "AMW0\n"); |
| 1431 | case ACER_AMW0_V2: |
| 1432 | return sprintf(buf, "AMW0 v2\n"); |
| 1433 | case ACER_WMID: |
| 1434 | return sprintf(buf, "WMID\n"); |
| 1435 | default: |
| 1436 | return sprintf(buf, "Error!\n"); |
| 1437 | } |
| 1438 | } |
| 1439 | |
Axel Lin | 370525d | 2010-06-30 10:20:23 +0800 | [diff] [blame] | 1440 | static DEVICE_ATTR(interface, S_IRUGO, show_interface, NULL); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1441 | |
Lee, Chun-Yi | 3fdca87 | 2010-12-07 10:29:20 +0800 | [diff] [blame] | 1442 | static void acer_wmi_notify(u32 value, void *context) |
| 1443 | { |
| 1444 | struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 1445 | union acpi_object *obj; |
| 1446 | struct event_return_value return_value; |
| 1447 | acpi_status status; |
| 1448 | |
| 1449 | status = wmi_get_event_data(value, &response); |
| 1450 | if (status != AE_OK) { |
Joe Perches | 249c720 | 2011-03-29 15:21:34 -0700 | [diff] [blame] | 1451 | pr_warn("bad event status 0x%x\n", status); |
Lee, Chun-Yi | 3fdca87 | 2010-12-07 10:29:20 +0800 | [diff] [blame] | 1452 | return; |
| 1453 | } |
| 1454 | |
| 1455 | obj = (union acpi_object *)response.pointer; |
| 1456 | |
| 1457 | if (!obj) |
| 1458 | return; |
| 1459 | if (obj->type != ACPI_TYPE_BUFFER) { |
Joe Perches | 249c720 | 2011-03-29 15:21:34 -0700 | [diff] [blame] | 1460 | pr_warn("Unknown response received %d\n", obj->type); |
Lee, Chun-Yi | 3fdca87 | 2010-12-07 10:29:20 +0800 | [diff] [blame] | 1461 | kfree(obj); |
| 1462 | return; |
| 1463 | } |
| 1464 | if (obj->buffer.length != 8) { |
Joe Perches | 249c720 | 2011-03-29 15:21:34 -0700 | [diff] [blame] | 1465 | pr_warn("Unknown buffer length %d\n", obj->buffer.length); |
Lee, Chun-Yi | 3fdca87 | 2010-12-07 10:29:20 +0800 | [diff] [blame] | 1466 | kfree(obj); |
| 1467 | return; |
| 1468 | } |
| 1469 | |
| 1470 | return_value = *((struct event_return_value *)obj->buffer.pointer); |
| 1471 | kfree(obj); |
| 1472 | |
| 1473 | switch (return_value.function) { |
| 1474 | case WMID_HOTKEY_EVENT: |
Lee, Chun-Yi | 70a9b90 | 2011-03-28 06:34:13 -0400 | [diff] [blame] | 1475 | if (return_value.device_state) { |
| 1476 | u16 device_state = return_value.device_state; |
Melchior FRANZ | 8ae68de | 2011-05-24 10:35:55 +0200 | [diff] [blame] | 1477 | pr_debug("device state: 0x%x\n", device_state); |
Lee, Chun-Yi | 70a9b90 | 2011-03-28 06:34:13 -0400 | [diff] [blame] | 1478 | if (has_cap(ACER_CAP_WIRELESS)) |
| 1479 | rfkill_set_sw_state(wireless_rfkill, |
| 1480 | !(device_state & ACER_WMID3_GDS_WIRELESS)); |
| 1481 | if (has_cap(ACER_CAP_BLUETOOTH)) |
| 1482 | rfkill_set_sw_state(bluetooth_rfkill, |
| 1483 | !(device_state & ACER_WMID3_GDS_BLUETOOTH)); |
| 1484 | if (has_cap(ACER_CAP_THREEG)) |
| 1485 | rfkill_set_sw_state(threeg_rfkill, |
| 1486 | !(device_state & ACER_WMID3_GDS_THREEG)); |
| 1487 | } |
Lee, Chun-Yi | 3fdca87 | 2010-12-07 10:29:20 +0800 | [diff] [blame] | 1488 | if (!sparse_keymap_report_event(acer_wmi_input_dev, |
| 1489 | return_value.key_num, 1, true)) |
Joe Perches | 249c720 | 2011-03-29 15:21:34 -0700 | [diff] [blame] | 1490 | pr_warn("Unknown key number - 0x%x\n", |
Lee, Chun-Yi | 3fdca87 | 2010-12-07 10:29:20 +0800 | [diff] [blame] | 1491 | return_value.key_num); |
| 1492 | break; |
| 1493 | default: |
Joe Perches | 249c720 | 2011-03-29 15:21:34 -0700 | [diff] [blame] | 1494 | pr_warn("Unknown function number - %d - %d\n", |
Lee, Chun-Yi | 3fdca87 | 2010-12-07 10:29:20 +0800 | [diff] [blame] | 1495 | return_value.function, return_value.key_num); |
| 1496 | break; |
| 1497 | } |
| 1498 | } |
| 1499 | |
From: Lee, Chun-Yi | 59ccf2f | 2011-01-07 17:25:14 -0500 | [diff] [blame] | 1500 | static acpi_status |
| 1501 | wmid3_set_lm_mode(struct lm_input_params *params, |
| 1502 | struct lm_return_value *return_value) |
| 1503 | { |
| 1504 | acpi_status status; |
| 1505 | union acpi_object *obj; |
| 1506 | |
| 1507 | struct acpi_buffer input = { sizeof(struct lm_input_params), params }; |
| 1508 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 1509 | |
| 1510 | status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &input, &output); |
| 1511 | if (ACPI_FAILURE(status)) |
| 1512 | return status; |
| 1513 | |
| 1514 | obj = output.pointer; |
| 1515 | |
| 1516 | if (!obj) |
| 1517 | return AE_ERROR; |
| 1518 | else if (obj->type != ACPI_TYPE_BUFFER) { |
| 1519 | kfree(obj); |
| 1520 | return AE_ERROR; |
| 1521 | } |
| 1522 | if (obj->buffer.length != 4) { |
Joe Perches | 249c720 | 2011-03-29 15:21:34 -0700 | [diff] [blame] | 1523 | pr_warn("Unknown buffer length %d\n", obj->buffer.length); |
From: Lee, Chun-Yi | 59ccf2f | 2011-01-07 17:25:14 -0500 | [diff] [blame] | 1524 | kfree(obj); |
| 1525 | return AE_ERROR; |
| 1526 | } |
| 1527 | |
| 1528 | *return_value = *((struct lm_return_value *)obj->buffer.pointer); |
| 1529 | kfree(obj); |
| 1530 | |
| 1531 | return status; |
| 1532 | } |
| 1533 | |
| 1534 | static int acer_wmi_enable_ec_raw(void) |
| 1535 | { |
| 1536 | struct lm_return_value return_value; |
| 1537 | acpi_status status; |
| 1538 | struct lm_input_params params = { |
| 1539 | .function_num = 0x1, |
| 1540 | .commun_devices = 0xFFFF, |
| 1541 | .devices = 0xFFFF, |
| 1542 | .lm_status = 0x00, /* Launch Manager Deactive */ |
| 1543 | }; |
| 1544 | |
| 1545 | status = wmid3_set_lm_mode(¶ms, &return_value); |
| 1546 | |
| 1547 | if (return_value.error_code || return_value.ec_return_value) |
Joe Perches | 249c720 | 2011-03-29 15:21:34 -0700 | [diff] [blame] | 1548 | pr_warn("Enabling EC raw mode failed: 0x%x - 0x%x\n", |
| 1549 | return_value.error_code, |
| 1550 | return_value.ec_return_value); |
From: Lee, Chun-Yi | 59ccf2f | 2011-01-07 17:25:14 -0500 | [diff] [blame] | 1551 | else |
Joe Perches | 249c720 | 2011-03-29 15:21:34 -0700 | [diff] [blame] | 1552 | pr_info("Enabled EC raw mode\n"); |
From: Lee, Chun-Yi | 59ccf2f | 2011-01-07 17:25:14 -0500 | [diff] [blame] | 1553 | |
| 1554 | return status; |
| 1555 | } |
| 1556 | |
| 1557 | static int acer_wmi_enable_lm(void) |
| 1558 | { |
| 1559 | struct lm_return_value return_value; |
| 1560 | acpi_status status; |
| 1561 | struct lm_input_params params = { |
| 1562 | .function_num = 0x1, |
| 1563 | .commun_devices = 0xFFFF, |
| 1564 | .devices = 0xFFFF, |
| 1565 | .lm_status = 0x01, /* Launch Manager Active */ |
| 1566 | }; |
| 1567 | |
| 1568 | status = wmid3_set_lm_mode(¶ms, &return_value); |
| 1569 | |
| 1570 | if (return_value.error_code || return_value.ec_return_value) |
Joe Perches | 249c720 | 2011-03-29 15:21:34 -0700 | [diff] [blame] | 1571 | pr_warn("Enabling Launch Manager failed: 0x%x - 0x%x\n", |
| 1572 | return_value.error_code, |
| 1573 | return_value.ec_return_value); |
From: Lee, Chun-Yi | 59ccf2f | 2011-01-07 17:25:14 -0500 | [diff] [blame] | 1574 | |
| 1575 | return status; |
| 1576 | } |
| 1577 | |
Lee, Chun-Yi | 3fdca87 | 2010-12-07 10:29:20 +0800 | [diff] [blame] | 1578 | static int __init acer_wmi_input_setup(void) |
| 1579 | { |
| 1580 | acpi_status status; |
| 1581 | int err; |
| 1582 | |
| 1583 | acer_wmi_input_dev = input_allocate_device(); |
| 1584 | if (!acer_wmi_input_dev) |
| 1585 | return -ENOMEM; |
| 1586 | |
| 1587 | acer_wmi_input_dev->name = "Acer WMI hotkeys"; |
| 1588 | acer_wmi_input_dev->phys = "wmi/input0"; |
| 1589 | acer_wmi_input_dev->id.bustype = BUS_HOST; |
| 1590 | |
| 1591 | err = sparse_keymap_setup(acer_wmi_input_dev, acer_wmi_keymap, NULL); |
| 1592 | if (err) |
| 1593 | goto err_free_dev; |
| 1594 | |
| 1595 | status = wmi_install_notify_handler(ACERWMID_EVENT_GUID, |
| 1596 | acer_wmi_notify, NULL); |
| 1597 | if (ACPI_FAILURE(status)) { |
| 1598 | err = -EIO; |
| 1599 | goto err_free_keymap; |
| 1600 | } |
| 1601 | |
| 1602 | err = input_register_device(acer_wmi_input_dev); |
| 1603 | if (err) |
| 1604 | goto err_uninstall_notifier; |
| 1605 | |
| 1606 | return 0; |
| 1607 | |
| 1608 | err_uninstall_notifier: |
| 1609 | wmi_remove_notify_handler(ACERWMID_EVENT_GUID); |
| 1610 | err_free_keymap: |
| 1611 | sparse_keymap_free(acer_wmi_input_dev); |
| 1612 | err_free_dev: |
| 1613 | input_free_device(acer_wmi_input_dev); |
| 1614 | return err; |
| 1615 | } |
| 1616 | |
| 1617 | static void acer_wmi_input_destroy(void) |
| 1618 | { |
| 1619 | wmi_remove_notify_handler(ACERWMID_EVENT_GUID); |
| 1620 | sparse_keymap_free(acer_wmi_input_dev); |
| 1621 | input_unregister_device(acer_wmi_input_dev); |
| 1622 | } |
| 1623 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1624 | /* |
Carlos Corbacho | 8114352 | 2008-06-21 09:09:53 +0100 | [diff] [blame] | 1625 | * debugfs functions |
| 1626 | */ |
| 1627 | static u32 get_wmid_devices(void) |
| 1628 | { |
| 1629 | struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL}; |
| 1630 | union acpi_object *obj; |
| 1631 | acpi_status status; |
Axel Lin | 6690486 | 2010-07-20 15:19:52 -0700 | [diff] [blame] | 1632 | u32 devices = 0; |
Carlos Corbacho | 8114352 | 2008-06-21 09:09:53 +0100 | [diff] [blame] | 1633 | |
| 1634 | status = wmi_query_block(WMID_GUID2, 1, &out); |
| 1635 | if (ACPI_FAILURE(status)) |
| 1636 | return 0; |
| 1637 | |
| 1638 | obj = (union acpi_object *) out.pointer; |
| 1639 | if (obj && obj->type == ACPI_TYPE_BUFFER && |
Lee, Chun-Yi | ab6a931 | 2011-05-22 07:33:53 +0800 | [diff] [blame] | 1640 | (obj->buffer.length == sizeof(u32) || |
| 1641 | obj->buffer.length == sizeof(u64))) { |
Axel Lin | 6690486 | 2010-07-20 15:19:52 -0700 | [diff] [blame] | 1642 | devices = *((u32 *) obj->buffer.pointer); |
Lee, Chun-Yi | 987dfba | 2011-05-27 14:52:14 +0800 | [diff] [blame] | 1643 | } else if (obj->type == ACPI_TYPE_INTEGER) { |
| 1644 | devices = (u32) obj->integer.value; |
Carlos Corbacho | 8114352 | 2008-06-21 09:09:53 +0100 | [diff] [blame] | 1645 | } |
Axel Lin | 6690486 | 2010-07-20 15:19:52 -0700 | [diff] [blame] | 1646 | |
| 1647 | kfree(out.pointer); |
| 1648 | return devices; |
Carlos Corbacho | 8114352 | 2008-06-21 09:09:53 +0100 | [diff] [blame] | 1649 | } |
| 1650 | |
| 1651 | /* |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1652 | * Platform device |
| 1653 | */ |
| 1654 | static int __devinit acer_platform_probe(struct platform_device *device) |
| 1655 | { |
| 1656 | int err; |
| 1657 | |
| 1658 | if (has_cap(ACER_CAP_MAILLED)) { |
| 1659 | err = acer_led_init(&device->dev); |
| 1660 | if (err) |
| 1661 | goto error_mailled; |
| 1662 | } |
| 1663 | |
| 1664 | if (has_cap(ACER_CAP_BRIGHTNESS)) { |
| 1665 | err = acer_backlight_init(&device->dev); |
| 1666 | if (err) |
| 1667 | goto error_brightness; |
| 1668 | } |
| 1669 | |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1670 | err = acer_rfkill_init(&device->dev); |
Andy Whitcroft | 350e329 | 2009-04-04 09:33:34 +0100 | [diff] [blame] | 1671 | if (err) |
| 1672 | goto error_rfkill; |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1673 | |
| 1674 | return err; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1675 | |
Andy Whitcroft | 350e329 | 2009-04-04 09:33:34 +0100 | [diff] [blame] | 1676 | error_rfkill: |
| 1677 | if (has_cap(ACER_CAP_BRIGHTNESS)) |
| 1678 | acer_backlight_exit(); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1679 | error_brightness: |
Andy Whitcroft | 350e329 | 2009-04-04 09:33:34 +0100 | [diff] [blame] | 1680 | if (has_cap(ACER_CAP_MAILLED)) |
| 1681 | acer_led_exit(); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1682 | error_mailled: |
| 1683 | return err; |
| 1684 | } |
| 1685 | |
| 1686 | static int acer_platform_remove(struct platform_device *device) |
| 1687 | { |
| 1688 | if (has_cap(ACER_CAP_MAILLED)) |
| 1689 | acer_led_exit(); |
| 1690 | if (has_cap(ACER_CAP_BRIGHTNESS)) |
| 1691 | acer_backlight_exit(); |
Carlos Corbacho | 0606e1a | 2008-10-08 21:40:21 +0100 | [diff] [blame] | 1692 | |
| 1693 | acer_rfkill_exit(); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1694 | return 0; |
| 1695 | } |
| 1696 | |
| 1697 | static int acer_platform_suspend(struct platform_device *dev, |
| 1698 | pm_message_t state) |
| 1699 | { |
| 1700 | u32 value; |
| 1701 | struct acer_data *data = &interface->data; |
| 1702 | |
| 1703 | if (!data) |
| 1704 | return -ENOMEM; |
| 1705 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1706 | if (has_cap(ACER_CAP_MAILLED)) { |
| 1707 | get_u32(&value, ACER_CAP_MAILLED); |
Pali Rohár | 9a0b74f | 2011-02-26 21:18:58 +0100 | [diff] [blame] | 1708 | set_u32(LED_OFF, ACER_CAP_MAILLED); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1709 | data->mailled = value; |
| 1710 | } |
| 1711 | |
| 1712 | if (has_cap(ACER_CAP_BRIGHTNESS)) { |
| 1713 | get_u32(&value, ACER_CAP_BRIGHTNESS); |
| 1714 | data->brightness = value; |
| 1715 | } |
| 1716 | |
| 1717 | return 0; |
| 1718 | } |
| 1719 | |
| 1720 | static int acer_platform_resume(struct platform_device *device) |
| 1721 | { |
| 1722 | struct acer_data *data = &interface->data; |
| 1723 | |
| 1724 | if (!data) |
| 1725 | return -ENOMEM; |
| 1726 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1727 | if (has_cap(ACER_CAP_MAILLED)) |
| 1728 | set_u32(data->mailled, ACER_CAP_MAILLED); |
| 1729 | |
| 1730 | if (has_cap(ACER_CAP_BRIGHTNESS)) |
| 1731 | set_u32(data->brightness, ACER_CAP_BRIGHTNESS); |
| 1732 | |
| 1733 | return 0; |
| 1734 | } |
| 1735 | |
Pali Rohár | 9a0b74f | 2011-02-26 21:18:58 +0100 | [diff] [blame] | 1736 | static void acer_platform_shutdown(struct platform_device *device) |
| 1737 | { |
| 1738 | struct acer_data *data = &interface->data; |
| 1739 | |
| 1740 | if (!data) |
| 1741 | return; |
| 1742 | |
| 1743 | if (has_cap(ACER_CAP_MAILLED)) |
| 1744 | set_u32(LED_OFF, ACER_CAP_MAILLED); |
| 1745 | } |
| 1746 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1747 | static struct platform_driver acer_platform_driver = { |
| 1748 | .driver = { |
| 1749 | .name = "acer-wmi", |
| 1750 | .owner = THIS_MODULE, |
| 1751 | }, |
| 1752 | .probe = acer_platform_probe, |
| 1753 | .remove = acer_platform_remove, |
| 1754 | .suspend = acer_platform_suspend, |
| 1755 | .resume = acer_platform_resume, |
Pali Rohár | 9a0b74f | 2011-02-26 21:18:58 +0100 | [diff] [blame] | 1756 | .shutdown = acer_platform_shutdown, |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1757 | }; |
| 1758 | |
| 1759 | static struct platform_device *acer_platform_device; |
| 1760 | |
| 1761 | static int remove_sysfs(struct platform_device *device) |
| 1762 | { |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1763 | if (has_cap(ACER_CAP_THREEG)) |
| 1764 | device_remove_file(&device->dev, &dev_attr_threeg); |
| 1765 | |
| 1766 | device_remove_file(&device->dev, &dev_attr_interface); |
| 1767 | |
| 1768 | return 0; |
| 1769 | } |
| 1770 | |
| 1771 | static int create_sysfs(void) |
| 1772 | { |
| 1773 | int retval = -ENOMEM; |
| 1774 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1775 | if (has_cap(ACER_CAP_THREEG)) { |
| 1776 | retval = device_create_file(&acer_platform_device->dev, |
| 1777 | &dev_attr_threeg); |
| 1778 | if (retval) |
| 1779 | goto error_sysfs; |
| 1780 | } |
| 1781 | |
| 1782 | retval = device_create_file(&acer_platform_device->dev, |
| 1783 | &dev_attr_interface); |
| 1784 | if (retval) |
| 1785 | goto error_sysfs; |
| 1786 | |
| 1787 | return 0; |
| 1788 | |
| 1789 | error_sysfs: |
| 1790 | remove_sysfs(acer_platform_device); |
| 1791 | return retval; |
| 1792 | } |
| 1793 | |
Carlos Corbacho | 8114352 | 2008-06-21 09:09:53 +0100 | [diff] [blame] | 1794 | static void remove_debugfs(void) |
| 1795 | { |
| 1796 | debugfs_remove(interface->debug.devices); |
| 1797 | debugfs_remove(interface->debug.root); |
| 1798 | } |
| 1799 | |
| 1800 | static int create_debugfs(void) |
| 1801 | { |
| 1802 | interface->debug.root = debugfs_create_dir("acer-wmi", NULL); |
| 1803 | if (!interface->debug.root) { |
Lee, Chun-Yi | cae1570 | 2011-03-16 18:52:36 +0800 | [diff] [blame] | 1804 | pr_err("Failed to create debugfs directory"); |
Carlos Corbacho | 8114352 | 2008-06-21 09:09:53 +0100 | [diff] [blame] | 1805 | return -ENOMEM; |
| 1806 | } |
| 1807 | |
| 1808 | interface->debug.devices = debugfs_create_u32("devices", S_IRUGO, |
| 1809 | interface->debug.root, |
| 1810 | &interface->debug.wmid_devices); |
| 1811 | if (!interface->debug.devices) |
| 1812 | goto error_debugfs; |
| 1813 | |
| 1814 | return 0; |
| 1815 | |
| 1816 | error_debugfs: |
Russ Dill | 39dbbb4 | 2008-09-02 14:35:40 -0700 | [diff] [blame] | 1817 | remove_debugfs(); |
Carlos Corbacho | 8114352 | 2008-06-21 09:09:53 +0100 | [diff] [blame] | 1818 | return -ENOMEM; |
| 1819 | } |
| 1820 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1821 | static int __init acer_wmi_init(void) |
| 1822 | { |
| 1823 | int err; |
| 1824 | |
Lee, Chun-Yi | cae1570 | 2011-03-16 18:52:36 +0800 | [diff] [blame] | 1825 | pr_info("Acer Laptop ACPI-WMI Extras\n"); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1826 | |
Carlos Corbacho | a74dd5f | 2009-04-04 09:33:29 +0100 | [diff] [blame] | 1827 | if (dmi_check_system(acer_blacklist)) { |
Lee, Chun-Yi | cae1570 | 2011-03-16 18:52:36 +0800 | [diff] [blame] | 1828 | pr_info("Blacklisted hardware detected - not loading\n"); |
Carlos Corbacho | a74dd5f | 2009-04-04 09:33:29 +0100 | [diff] [blame] | 1829 | return -ENODEV; |
| 1830 | } |
| 1831 | |
Carlos Corbacho | 9991d9f | 2008-06-21 09:09:22 +0100 | [diff] [blame] | 1832 | find_quirks(); |
| 1833 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1834 | /* |
| 1835 | * Detect which ACPI-WMI interface we're using. |
| 1836 | */ |
| 1837 | if (wmi_has_guid(AMW0_GUID1) && wmi_has_guid(WMID_GUID1)) |
| 1838 | interface = &AMW0_V2_interface; |
| 1839 | |
| 1840 | if (!wmi_has_guid(AMW0_GUID1) && wmi_has_guid(WMID_GUID1)) |
| 1841 | interface = &wmid_interface; |
| 1842 | |
| 1843 | if (wmi_has_guid(WMID_GUID2) && interface) { |
| 1844 | if (ACPI_FAILURE(WMID_set_capabilities())) { |
Lee, Chun-Yi | cae1570 | 2011-03-16 18:52:36 +0800 | [diff] [blame] | 1845 | pr_err("Unable to detect available WMID devices\n"); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1846 | return -ENODEV; |
| 1847 | } |
| 1848 | } else if (!wmi_has_guid(WMID_GUID2) && interface) { |
Lee, Chun-Yi | cae1570 | 2011-03-16 18:52:36 +0800 | [diff] [blame] | 1849 | pr_err("No WMID device detection method found\n"); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1850 | return -ENODEV; |
| 1851 | } |
| 1852 | |
| 1853 | if (wmi_has_guid(AMW0_GUID1) && !wmi_has_guid(WMID_GUID1)) { |
| 1854 | interface = &AMW0_interface; |
| 1855 | |
| 1856 | if (ACPI_FAILURE(AMW0_set_capabilities())) { |
Lee, Chun-Yi | cae1570 | 2011-03-16 18:52:36 +0800 | [diff] [blame] | 1857 | pr_err("Unable to detect available AMW0 devices\n"); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1858 | return -ENODEV; |
| 1859 | } |
| 1860 | } |
| 1861 | |
Carlos Corbacho | 9b963c4 | 2008-02-24 13:34:29 +0000 | [diff] [blame] | 1862 | if (wmi_has_guid(AMW0_GUID1)) |
| 1863 | AMW0_find_mailled(); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1864 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1865 | if (!interface) { |
Lee, Chun-Yi | cae1570 | 2011-03-16 18:52:36 +0800 | [diff] [blame] | 1866 | pr_err("No or unsupported WMI interface, unable to load\n"); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1867 | return -ENODEV; |
| 1868 | } |
| 1869 | |
Arjan van de Ven | 83097ac | 2008-08-23 21:45:21 -0700 | [diff] [blame] | 1870 | set_quirks(); |
| 1871 | |
Michael Spang | 1ba869e | 2009-03-12 14:31:34 -0700 | [diff] [blame] | 1872 | if (acpi_video_backlight_support() && has_cap(ACER_CAP_BRIGHTNESS)) { |
Thomas Renninger | febf2d9 | 2008-08-01 17:37:56 +0200 | [diff] [blame] | 1873 | interface->capability &= ~ACER_CAP_BRIGHTNESS; |
Lee, Chun-Yi | cae1570 | 2011-03-16 18:52:36 +0800 | [diff] [blame] | 1874 | pr_info("Brightness must be controlled by " |
Thomas Renninger | febf2d9 | 2008-08-01 17:37:56 +0200 | [diff] [blame] | 1875 | "generic video driver\n"); |
| 1876 | } |
| 1877 | |
From: Lee, Chun-Yi | 59ccf2f | 2011-01-07 17:25:14 -0500 | [diff] [blame] | 1878 | if (wmi_has_guid(WMID_GUID3)) { |
| 1879 | if (ec_raw_mode) { |
| 1880 | if (ACPI_FAILURE(acer_wmi_enable_ec_raw())) { |
Lee, Chun-Yi | cae1570 | 2011-03-16 18:52:36 +0800 | [diff] [blame] | 1881 | pr_err("Cannot enable EC raw mode\n"); |
From: Lee, Chun-Yi | 59ccf2f | 2011-01-07 17:25:14 -0500 | [diff] [blame] | 1882 | return -ENODEV; |
| 1883 | } |
| 1884 | } else if (ACPI_FAILURE(acer_wmi_enable_lm())) { |
Lee, Chun-Yi | cae1570 | 2011-03-16 18:52:36 +0800 | [diff] [blame] | 1885 | pr_err("Cannot enable Launch Manager mode\n"); |
From: Lee, Chun-Yi | 59ccf2f | 2011-01-07 17:25:14 -0500 | [diff] [blame] | 1886 | return -ENODEV; |
| 1887 | } |
| 1888 | } else if (ec_raw_mode) { |
Lee, Chun-Yi | cae1570 | 2011-03-16 18:52:36 +0800 | [diff] [blame] | 1889 | pr_info("No WMID EC raw mode enable method\n"); |
From: Lee, Chun-Yi | 59ccf2f | 2011-01-07 17:25:14 -0500 | [diff] [blame] | 1890 | } |
| 1891 | |
Lee, Chun-Yi | 3fdca87 | 2010-12-07 10:29:20 +0800 | [diff] [blame] | 1892 | if (wmi_has_guid(ACERWMID_EVENT_GUID)) { |
| 1893 | err = acer_wmi_input_setup(); |
| 1894 | if (err) |
| 1895 | return err; |
| 1896 | } |
| 1897 | |
Axel Lin | 1c79632 | 2010-06-22 16:17:38 +0800 | [diff] [blame] | 1898 | err = platform_driver_register(&acer_platform_driver); |
| 1899 | if (err) { |
Lee, Chun-Yi | cae1570 | 2011-03-16 18:52:36 +0800 | [diff] [blame] | 1900 | pr_err("Unable to register platform driver.\n"); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1901 | goto error_platform_register; |
| 1902 | } |
Axel Lin | 1c79632 | 2010-06-22 16:17:38 +0800 | [diff] [blame] | 1903 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1904 | acer_platform_device = platform_device_alloc("acer-wmi", -1); |
Axel Lin | 1c79632 | 2010-06-22 16:17:38 +0800 | [diff] [blame] | 1905 | if (!acer_platform_device) { |
| 1906 | err = -ENOMEM; |
| 1907 | goto error_device_alloc; |
| 1908 | } |
| 1909 | |
| 1910 | err = platform_device_add(acer_platform_device); |
| 1911 | if (err) |
| 1912 | goto error_device_add; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1913 | |
| 1914 | err = create_sysfs(); |
| 1915 | if (err) |
Axel Lin | 1c79632 | 2010-06-22 16:17:38 +0800 | [diff] [blame] | 1916 | goto error_create_sys; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1917 | |
Carlos Corbacho | 8114352 | 2008-06-21 09:09:53 +0100 | [diff] [blame] | 1918 | if (wmi_has_guid(WMID_GUID2)) { |
| 1919 | interface->debug.wmid_devices = get_wmid_devices(); |
| 1920 | err = create_debugfs(); |
| 1921 | if (err) |
Axel Lin | 1c79632 | 2010-06-22 16:17:38 +0800 | [diff] [blame] | 1922 | goto error_create_debugfs; |
Carlos Corbacho | 8114352 | 2008-06-21 09:09:53 +0100 | [diff] [blame] | 1923 | } |
| 1924 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1925 | /* Override any initial settings with values from the commandline */ |
| 1926 | acer_commandline_init(); |
| 1927 | |
| 1928 | return 0; |
| 1929 | |
Axel Lin | 1c79632 | 2010-06-22 16:17:38 +0800 | [diff] [blame] | 1930 | error_create_debugfs: |
| 1931 | remove_sysfs(acer_platform_device); |
| 1932 | error_create_sys: |
| 1933 | platform_device_del(acer_platform_device); |
| 1934 | error_device_add: |
| 1935 | platform_device_put(acer_platform_device); |
| 1936 | error_device_alloc: |
| 1937 | platform_driver_unregister(&acer_platform_driver); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1938 | error_platform_register: |
Lee, Chun-Yi | 3fdca87 | 2010-12-07 10:29:20 +0800 | [diff] [blame] | 1939 | if (wmi_has_guid(ACERWMID_EVENT_GUID)) |
| 1940 | acer_wmi_input_destroy(); |
| 1941 | |
Axel Lin | 1c79632 | 2010-06-22 16:17:38 +0800 | [diff] [blame] | 1942 | return err; |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1943 | } |
| 1944 | |
| 1945 | static void __exit acer_wmi_exit(void) |
| 1946 | { |
Lee, Chun-Yi | 3fdca87 | 2010-12-07 10:29:20 +0800 | [diff] [blame] | 1947 | if (wmi_has_guid(ACERWMID_EVENT_GUID)) |
| 1948 | acer_wmi_input_destroy(); |
| 1949 | |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1950 | remove_sysfs(acer_platform_device); |
Russ Dill | 39dbbb4 | 2008-09-02 14:35:40 -0700 | [diff] [blame] | 1951 | remove_debugfs(); |
Axel Lin | 97ba0af | 2010-06-03 15:18:03 +0800 | [diff] [blame] | 1952 | platform_device_unregister(acer_platform_device); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1953 | platform_driver_unregister(&acer_platform_driver); |
| 1954 | |
Lee, Chun-Yi | cae1570 | 2011-03-16 18:52:36 +0800 | [diff] [blame] | 1955 | pr_info("Acer Laptop WMI Extras unloaded\n"); |
Carlos Corbacho | 745a5d2 | 2008-02-05 02:17:10 +0000 | [diff] [blame] | 1956 | return; |
| 1957 | } |
| 1958 | |
| 1959 | module_init(acer_wmi_init); |
| 1960 | module_exit(acer_wmi_exit); |