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