.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Asus PC WMI hotkey driver |
---|
3 | 4 | * |
---|
.. | .. |
---|
8 | 9 | * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz> |
---|
9 | 10 | * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org> |
---|
10 | 11 | * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru> |
---|
11 | | - * |
---|
12 | | - * This program is free software; you can redistribute it and/or modify |
---|
13 | | - * it under the terms of the GNU General Public License as published by |
---|
14 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
15 | | - * (at your option) any later version. |
---|
16 | | - * |
---|
17 | | - * This program is distributed in the hope that it will be useful, |
---|
18 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
19 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
20 | | - * GNU General Public License for more details. |
---|
21 | | - * |
---|
22 | | - * You should have received a copy of the GNU General Public License |
---|
23 | | - * along with this program; if not, write to the Free Software |
---|
24 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
25 | 12 | */ |
---|
26 | 13 | |
---|
27 | 14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
---|
.. | .. |
---|
39 | 26 | #include <linux/rfkill.h> |
---|
40 | 27 | #include <linux/pci.h> |
---|
41 | 28 | #include <linux/pci_hotplug.h> |
---|
| 29 | +#include <linux/power_supply.h> |
---|
42 | 30 | #include <linux/hwmon.h> |
---|
43 | 31 | #include <linux/hwmon-sysfs.h> |
---|
44 | 32 | #include <linux/debugfs.h> |
---|
45 | 33 | #include <linux/seq_file.h> |
---|
| 34 | +#include <linux/platform_data/x86/asus-wmi.h> |
---|
46 | 35 | #include <linux/platform_device.h> |
---|
47 | | -#include <linux/thermal.h> |
---|
48 | 36 | #include <linux/acpi.h> |
---|
49 | 37 | #include <linux/dmi.h> |
---|
| 38 | +#include <linux/units.h> |
---|
| 39 | + |
---|
| 40 | +#include <acpi/battery.h> |
---|
50 | 41 | #include <acpi/video.h> |
---|
51 | 42 | |
---|
52 | 43 | #include "asus-wmi.h" |
---|
.. | .. |
---|
65 | 56 | #define NOTIFY_BRNUP_MAX 0x1f |
---|
66 | 57 | #define NOTIFY_BRNDOWN_MIN 0x20 |
---|
67 | 58 | #define NOTIFY_BRNDOWN_MAX 0x2e |
---|
| 59 | +#define NOTIFY_FNLOCK_TOGGLE 0x4e |
---|
| 60 | +#define NOTIFY_KBD_DOCK_CHANGE 0x75 |
---|
68 | 61 | #define NOTIFY_KBD_BRTUP 0xc4 |
---|
69 | 62 | #define NOTIFY_KBD_BRTDWN 0xc5 |
---|
70 | 63 | #define NOTIFY_KBD_BRTTOGGLE 0xc7 |
---|
| 64 | +#define NOTIFY_KBD_FBM 0x99 |
---|
| 65 | +#define NOTIFY_KBD_TTP 0xae |
---|
71 | 66 | |
---|
72 | | -/* WMI Methods */ |
---|
73 | | -#define ASUS_WMI_METHODID_SPEC 0x43455053 /* BIOS SPECification */ |
---|
74 | | -#define ASUS_WMI_METHODID_SFBD 0x44424653 /* Set First Boot Device */ |
---|
75 | | -#define ASUS_WMI_METHODID_GLCD 0x44434C47 /* Get LCD status */ |
---|
76 | | -#define ASUS_WMI_METHODID_GPID 0x44495047 /* Get Panel ID?? (Resol) */ |
---|
77 | | -#define ASUS_WMI_METHODID_QMOD 0x444F4D51 /* Quiet MODe */ |
---|
78 | | -#define ASUS_WMI_METHODID_SPLV 0x4C425053 /* Set Panel Light Value */ |
---|
79 | | -#define ASUS_WMI_METHODID_AGFN 0x4E464741 /* FaN? */ |
---|
80 | | -#define ASUS_WMI_METHODID_SFUN 0x4E554653 /* FUNCtionalities */ |
---|
81 | | -#define ASUS_WMI_METHODID_SDSP 0x50534453 /* Set DiSPlay output */ |
---|
82 | | -#define ASUS_WMI_METHODID_GDSP 0x50534447 /* Get DiSPlay output */ |
---|
83 | | -#define ASUS_WMI_METHODID_DEVP 0x50564544 /* DEVice Policy */ |
---|
84 | | -#define ASUS_WMI_METHODID_OSVR 0x5256534F /* OS VeRsion */ |
---|
85 | | -#define ASUS_WMI_METHODID_DSTS 0x53544344 /* Device STatuS */ |
---|
86 | | -#define ASUS_WMI_METHODID_DSTS2 0x53545344 /* Device STatuS #2*/ |
---|
87 | | -#define ASUS_WMI_METHODID_BSTS 0x53545342 /* Bios STatuS ? */ |
---|
88 | | -#define ASUS_WMI_METHODID_DEVS 0x53564544 /* DEVice Set */ |
---|
89 | | -#define ASUS_WMI_METHODID_CFVS 0x53564643 /* CPU Frequency Volt Set */ |
---|
90 | | -#define ASUS_WMI_METHODID_KBFT 0x5446424B /* KeyBoard FilTer */ |
---|
91 | | -#define ASUS_WMI_METHODID_INIT 0x54494E49 /* INITialize */ |
---|
92 | | -#define ASUS_WMI_METHODID_HKEY 0x59454B48 /* Hot KEY ?? */ |
---|
93 | | - |
---|
94 | | -#define ASUS_WMI_UNSUPPORTED_METHOD 0xFFFFFFFE |
---|
95 | | - |
---|
96 | | -/* Wireless */ |
---|
97 | | -#define ASUS_WMI_DEVID_HW_SWITCH 0x00010001 |
---|
98 | | -#define ASUS_WMI_DEVID_WIRELESS_LED 0x00010002 |
---|
99 | | -#define ASUS_WMI_DEVID_CWAP 0x00010003 |
---|
100 | | -#define ASUS_WMI_DEVID_WLAN 0x00010011 |
---|
101 | | -#define ASUS_WMI_DEVID_WLAN_LED 0x00010012 |
---|
102 | | -#define ASUS_WMI_DEVID_BLUETOOTH 0x00010013 |
---|
103 | | -#define ASUS_WMI_DEVID_GPS 0x00010015 |
---|
104 | | -#define ASUS_WMI_DEVID_WIMAX 0x00010017 |
---|
105 | | -#define ASUS_WMI_DEVID_WWAN3G 0x00010019 |
---|
106 | | -#define ASUS_WMI_DEVID_UWB 0x00010021 |
---|
107 | | - |
---|
108 | | -/* Leds */ |
---|
109 | | -/* 0x000200XX and 0x000400XX */ |
---|
110 | | -#define ASUS_WMI_DEVID_LED1 0x00020011 |
---|
111 | | -#define ASUS_WMI_DEVID_LED2 0x00020012 |
---|
112 | | -#define ASUS_WMI_DEVID_LED3 0x00020013 |
---|
113 | | -#define ASUS_WMI_DEVID_LED4 0x00020014 |
---|
114 | | -#define ASUS_WMI_DEVID_LED5 0x00020015 |
---|
115 | | -#define ASUS_WMI_DEVID_LED6 0x00020016 |
---|
116 | | - |
---|
117 | | -/* Backlight and Brightness */ |
---|
118 | | -#define ASUS_WMI_DEVID_ALS_ENABLE 0x00050001 /* Ambient Light Sensor */ |
---|
119 | | -#define ASUS_WMI_DEVID_BACKLIGHT 0x00050011 |
---|
120 | | -#define ASUS_WMI_DEVID_BRIGHTNESS 0x00050012 |
---|
121 | | -#define ASUS_WMI_DEVID_KBD_BACKLIGHT 0x00050021 |
---|
122 | | -#define ASUS_WMI_DEVID_LIGHT_SENSOR 0x00050022 /* ?? */ |
---|
123 | | -#define ASUS_WMI_DEVID_LIGHTBAR 0x00050025 |
---|
124 | | - |
---|
125 | | -/* Misc */ |
---|
126 | | -#define ASUS_WMI_DEVID_CAMERA 0x00060013 |
---|
127 | | - |
---|
128 | | -/* Storage */ |
---|
129 | | -#define ASUS_WMI_DEVID_CARDREADER 0x00080013 |
---|
130 | | - |
---|
131 | | -/* Input */ |
---|
132 | | -#define ASUS_WMI_DEVID_TOUCHPAD 0x00100011 |
---|
133 | | -#define ASUS_WMI_DEVID_TOUCHPAD_LED 0x00100012 |
---|
134 | | - |
---|
135 | | -/* Fan, Thermal */ |
---|
136 | | -#define ASUS_WMI_DEVID_THERMAL_CTRL 0x00110011 |
---|
137 | | -#define ASUS_WMI_DEVID_FAN_CTRL 0x00110012 |
---|
138 | | - |
---|
139 | | -/* Power */ |
---|
140 | | -#define ASUS_WMI_DEVID_PROCESSOR_STATE 0x00120012 |
---|
141 | | - |
---|
142 | | -/* Deep S3 / Resume on LID open */ |
---|
143 | | -#define ASUS_WMI_DEVID_LID_RESUME 0x00120031 |
---|
144 | | - |
---|
145 | | -/* DSTS masks */ |
---|
146 | | -#define ASUS_WMI_DSTS_STATUS_BIT 0x00000001 |
---|
147 | | -#define ASUS_WMI_DSTS_UNKNOWN_BIT 0x00000002 |
---|
148 | | -#define ASUS_WMI_DSTS_PRESENCE_BIT 0x00010000 |
---|
149 | | -#define ASUS_WMI_DSTS_USER_BIT 0x00020000 |
---|
150 | | -#define ASUS_WMI_DSTS_BIOS_BIT 0x00040000 |
---|
151 | | -#define ASUS_WMI_DSTS_BRIGHTNESS_MASK 0x000000FF |
---|
152 | | -#define ASUS_WMI_DSTS_MAX_BRIGTH_MASK 0x0000FF00 |
---|
153 | | -#define ASUS_WMI_DSTS_LIGHTBAR_MASK 0x0000000F |
---|
| 67 | +#define ASUS_WMI_FNLOCK_BIOS_DISABLED BIT(0) |
---|
154 | 68 | |
---|
155 | 69 | #define ASUS_FAN_DESC "cpu_fan" |
---|
156 | 70 | #define ASUS_FAN_MFUN 0x13 |
---|
157 | 71 | #define ASUS_FAN_SFUN_READ 0x06 |
---|
158 | 72 | #define ASUS_FAN_SFUN_WRITE 0x07 |
---|
| 73 | + |
---|
| 74 | +/* Based on standard hwmon pwmX_enable values */ |
---|
| 75 | +#define ASUS_FAN_CTRL_FULLSPEED 0 |
---|
159 | 76 | #define ASUS_FAN_CTRL_MANUAL 1 |
---|
160 | 77 | #define ASUS_FAN_CTRL_AUTO 2 |
---|
161 | 78 | |
---|
| 79 | +#define ASUS_FAN_BOOST_MODE_NORMAL 0 |
---|
| 80 | +#define ASUS_FAN_BOOST_MODE_OVERBOOST 1 |
---|
| 81 | +#define ASUS_FAN_BOOST_MODE_OVERBOOST_MASK 0x01 |
---|
| 82 | +#define ASUS_FAN_BOOST_MODE_SILENT 2 |
---|
| 83 | +#define ASUS_FAN_BOOST_MODE_SILENT_MASK 0x02 |
---|
| 84 | +#define ASUS_FAN_BOOST_MODES_MASK 0x03 |
---|
| 85 | + |
---|
| 86 | +#define ASUS_THROTTLE_THERMAL_POLICY_DEFAULT 0 |
---|
| 87 | +#define ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST 1 |
---|
| 88 | +#define ASUS_THROTTLE_THERMAL_POLICY_SILENT 2 |
---|
| 89 | + |
---|
162 | 90 | #define USB_INTEL_XUSB2PR 0xD0 |
---|
163 | 91 | #define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31 |
---|
| 92 | + |
---|
| 93 | +#define ASUS_ACPI_UID_ASUSWMI "ASUSWMI" |
---|
| 94 | +#define ASUS_ACPI_UID_ATK "ATK" |
---|
| 95 | + |
---|
| 96 | +#define WMI_EVENT_QUEUE_SIZE 0x10 |
---|
| 97 | +#define WMI_EVENT_QUEUE_END 0x1 |
---|
| 98 | +#define WMI_EVENT_MASK 0xFFFF |
---|
| 99 | +/* The WMI hotkey event value is always the same. */ |
---|
| 100 | +#define WMI_EVENT_VALUE_ATK 0xFF |
---|
| 101 | + |
---|
| 102 | +#define WMI_EVENT_MASK 0xFFFF |
---|
164 | 103 | |
---|
165 | 104 | static const char * const ashs_ids[] = { "ATK4001", "ATK4002", NULL }; |
---|
166 | 105 | |
---|
.. | .. |
---|
177 | 116 | struct bios_args { |
---|
178 | 117 | u32 arg0; |
---|
179 | 118 | u32 arg1; |
---|
| 119 | + u32 arg2; /* At least TUF Gaming series uses 3 dword input buffer. */ |
---|
| 120 | + u32 arg4; |
---|
| 121 | + u32 arg5; |
---|
180 | 122 | } __packed; |
---|
181 | 123 | |
---|
182 | 124 | /* |
---|
.. | .. |
---|
192 | 134 | } __packed; |
---|
193 | 135 | |
---|
194 | 136 | /* struct used for calling fan read and write methods */ |
---|
195 | | -struct fan_args { |
---|
| 137 | +struct agfn_fan_args { |
---|
196 | 138 | struct agfn_args agfn; /* common fields */ |
---|
197 | 139 | u8 fan; /* fan number: 0: set auto mode 1: 1st fan */ |
---|
198 | 140 | u32 speed; /* read: RPM/100 - write: 0-255 */ |
---|
.. | .. |
---|
220 | 162 | u32 dev_id; |
---|
221 | 163 | }; |
---|
222 | 164 | |
---|
| 165 | +enum fan_type { |
---|
| 166 | + FAN_TYPE_NONE = 0, |
---|
| 167 | + FAN_TYPE_AGFN, /* deprecated on newer platforms */ |
---|
| 168 | + FAN_TYPE_SPEC83, /* starting in Spec 8.3, use CPU_FAN_CTRL */ |
---|
| 169 | +}; |
---|
| 170 | + |
---|
223 | 171 | struct asus_wmi { |
---|
224 | 172 | int dsts_id; |
---|
225 | 173 | int spec; |
---|
226 | 174 | int sfun; |
---|
| 175 | + bool wmi_event_queue; |
---|
227 | 176 | |
---|
228 | 177 | struct input_dev *inputdev; |
---|
229 | 178 | struct backlight_device *backlight_device; |
---|
.. | .. |
---|
239 | 188 | int lightbar_led_wk; |
---|
240 | 189 | struct workqueue_struct *led_workqueue; |
---|
241 | 190 | struct work_struct tpd_led_work; |
---|
242 | | - struct work_struct kbd_led_work; |
---|
243 | 191 | struct work_struct wlan_led_work; |
---|
244 | 192 | struct work_struct lightbar_led_work; |
---|
245 | 193 | |
---|
.. | .. |
---|
250 | 198 | struct asus_rfkill gps; |
---|
251 | 199 | struct asus_rfkill uwb; |
---|
252 | 200 | |
---|
253 | | - bool asus_hwmon_fan_manual_mode; |
---|
254 | | - int asus_hwmon_num_fans; |
---|
255 | | - int asus_hwmon_pwm; |
---|
| 201 | + enum fan_type fan_type; |
---|
| 202 | + int fan_pwm_mode; |
---|
| 203 | + int agfn_pwm; |
---|
256 | 204 | |
---|
257 | | - struct hotplug_slot *hotplug_slot; |
---|
| 205 | + bool fan_boost_mode_available; |
---|
| 206 | + u8 fan_boost_mode_mask; |
---|
| 207 | + u8 fan_boost_mode; |
---|
| 208 | + |
---|
| 209 | + bool throttle_thermal_policy_available; |
---|
| 210 | + u8 throttle_thermal_policy_mode; |
---|
| 211 | + |
---|
| 212 | + // The RSOC controls the maximum charging percentage. |
---|
| 213 | + bool battery_rsoc_available; |
---|
| 214 | + |
---|
| 215 | + struct hotplug_slot hotplug_slot; |
---|
258 | 216 | struct mutex hotplug_lock; |
---|
259 | 217 | struct mutex wmi_lock; |
---|
260 | 218 | struct workqueue_struct *hotplug_workqueue; |
---|
261 | 219 | struct work_struct hotplug_work; |
---|
| 220 | + |
---|
| 221 | + bool fnlock_locked; |
---|
262 | 222 | |
---|
263 | 223 | struct asus_wmi_debug debug; |
---|
264 | 224 | |
---|
265 | 225 | struct asus_wmi_driver *driver; |
---|
266 | 226 | }; |
---|
267 | 227 | |
---|
268 | | -static int asus_wmi_input_init(struct asus_wmi *asus) |
---|
269 | | -{ |
---|
270 | | - int err; |
---|
| 228 | +/* WMI ************************************************************************/ |
---|
271 | 229 | |
---|
272 | | - asus->inputdev = input_allocate_device(); |
---|
273 | | - if (!asus->inputdev) |
---|
274 | | - return -ENOMEM; |
---|
275 | | - |
---|
276 | | - asus->inputdev->name = asus->driver->input_name; |
---|
277 | | - asus->inputdev->phys = asus->driver->input_phys; |
---|
278 | | - asus->inputdev->id.bustype = BUS_HOST; |
---|
279 | | - asus->inputdev->dev.parent = &asus->platform_device->dev; |
---|
280 | | - set_bit(EV_REP, asus->inputdev->evbit); |
---|
281 | | - |
---|
282 | | - err = sparse_keymap_setup(asus->inputdev, asus->driver->keymap, NULL); |
---|
283 | | - if (err) |
---|
284 | | - goto err_free_dev; |
---|
285 | | - |
---|
286 | | - err = input_register_device(asus->inputdev); |
---|
287 | | - if (err) |
---|
288 | | - goto err_free_dev; |
---|
289 | | - |
---|
290 | | - return 0; |
---|
291 | | - |
---|
292 | | -err_free_dev: |
---|
293 | | - input_free_device(asus->inputdev); |
---|
294 | | - return err; |
---|
295 | | -} |
---|
296 | | - |
---|
297 | | -static void asus_wmi_input_exit(struct asus_wmi *asus) |
---|
298 | | -{ |
---|
299 | | - if (asus->inputdev) |
---|
300 | | - input_unregister_device(asus->inputdev); |
---|
301 | | - |
---|
302 | | - asus->inputdev = NULL; |
---|
303 | | -} |
---|
304 | | - |
---|
305 | | -static int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, |
---|
306 | | - u32 *retval) |
---|
| 230 | +static int asus_wmi_evaluate_method3(u32 method_id, |
---|
| 231 | + u32 arg0, u32 arg1, u32 arg2, u32 *retval) |
---|
307 | 232 | { |
---|
308 | 233 | struct bios_args args = { |
---|
309 | 234 | .arg0 = arg0, |
---|
310 | 235 | .arg1 = arg1, |
---|
| 236 | + .arg2 = arg2, |
---|
311 | 237 | }; |
---|
312 | 238 | struct acpi_buffer input = { (acpi_size) sizeof(args), &args }; |
---|
313 | 239 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; |
---|
.. | .. |
---|
319 | 245 | &input, &output); |
---|
320 | 246 | |
---|
321 | 247 | if (ACPI_FAILURE(status)) |
---|
322 | | - goto exit; |
---|
| 248 | + return -EIO; |
---|
323 | 249 | |
---|
324 | 250 | obj = (union acpi_object *)output.pointer; |
---|
325 | 251 | if (obj && obj->type == ACPI_TYPE_INTEGER) |
---|
.. | .. |
---|
330 | 256 | |
---|
331 | 257 | kfree(obj); |
---|
332 | 258 | |
---|
333 | | -exit: |
---|
334 | | - if (ACPI_FAILURE(status)) |
---|
335 | | - return -EIO; |
---|
336 | | - |
---|
337 | 259 | if (tmp == ASUS_WMI_UNSUPPORTED_METHOD) |
---|
338 | 260 | return -ENODEV; |
---|
339 | 261 | |
---|
340 | 262 | return 0; |
---|
341 | 263 | } |
---|
342 | 264 | |
---|
| 265 | +int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval) |
---|
| 266 | +{ |
---|
| 267 | + return asus_wmi_evaluate_method3(method_id, arg0, arg1, 0, retval); |
---|
| 268 | +} |
---|
| 269 | +EXPORT_SYMBOL_GPL(asus_wmi_evaluate_method); |
---|
| 270 | + |
---|
343 | 271 | static int asus_wmi_evaluate_method_agfn(const struct acpi_buffer args) |
---|
344 | 272 | { |
---|
345 | 273 | struct acpi_buffer input; |
---|
346 | 274 | u64 phys_addr; |
---|
347 | 275 | u32 retval; |
---|
348 | | - u32 status = -1; |
---|
| 276 | + u32 status; |
---|
349 | 277 | |
---|
350 | 278 | /* |
---|
351 | 279 | * Copy to dma capable address otherwise memory corruption occurs as |
---|
352 | 280 | * bios has to be able to access it. |
---|
353 | 281 | */ |
---|
354 | | - input.pointer = kzalloc(args.length, GFP_DMA | GFP_KERNEL); |
---|
| 282 | + input.pointer = kmemdup(args.pointer, args.length, GFP_DMA | GFP_KERNEL); |
---|
355 | 283 | input.length = args.length; |
---|
356 | 284 | if (!input.pointer) |
---|
357 | 285 | return -ENOMEM; |
---|
358 | 286 | phys_addr = virt_to_phys(input.pointer); |
---|
359 | | - memcpy(input.pointer, args.pointer, args.length); |
---|
360 | 287 | |
---|
361 | 288 | status = asus_wmi_evaluate_method(ASUS_WMI_METHODID_AGFN, |
---|
362 | 289 | phys_addr, 0, &retval); |
---|
.. | .. |
---|
390 | 317 | int err; |
---|
391 | 318 | |
---|
392 | 319 | err = asus_wmi_get_devstate(asus, dev_id, &retval); |
---|
393 | | - |
---|
394 | 320 | if (err < 0) |
---|
395 | 321 | return err; |
---|
396 | 322 | |
---|
.. | .. |
---|
411 | 337 | ASUS_WMI_DSTS_STATUS_BIT); |
---|
412 | 338 | } |
---|
413 | 339 | |
---|
414 | | -/* |
---|
415 | | - * LEDs |
---|
416 | | - */ |
---|
| 340 | +static bool asus_wmi_dev_is_present(struct asus_wmi *asus, u32 dev_id) |
---|
| 341 | +{ |
---|
| 342 | + u32 retval; |
---|
| 343 | + int status = asus_wmi_get_devstate(asus, dev_id, &retval); |
---|
| 344 | + |
---|
| 345 | + return status == 0 && (retval & ASUS_WMI_DSTS_PRESENCE_BIT); |
---|
| 346 | +} |
---|
| 347 | + |
---|
| 348 | +/* Input **********************************************************************/ |
---|
| 349 | + |
---|
| 350 | +static int asus_wmi_input_init(struct asus_wmi *asus) |
---|
| 351 | +{ |
---|
| 352 | + int err, result; |
---|
| 353 | + |
---|
| 354 | + asus->inputdev = input_allocate_device(); |
---|
| 355 | + if (!asus->inputdev) |
---|
| 356 | + return -ENOMEM; |
---|
| 357 | + |
---|
| 358 | + asus->inputdev->name = asus->driver->input_name; |
---|
| 359 | + asus->inputdev->phys = asus->driver->input_phys; |
---|
| 360 | + asus->inputdev->id.bustype = BUS_HOST; |
---|
| 361 | + asus->inputdev->dev.parent = &asus->platform_device->dev; |
---|
| 362 | + set_bit(EV_REP, asus->inputdev->evbit); |
---|
| 363 | + |
---|
| 364 | + err = sparse_keymap_setup(asus->inputdev, asus->driver->keymap, NULL); |
---|
| 365 | + if (err) |
---|
| 366 | + goto err_free_dev; |
---|
| 367 | + |
---|
| 368 | + if (asus->driver->quirks->use_kbd_dock_devid) { |
---|
| 369 | + result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_KBD_DOCK); |
---|
| 370 | + if (result >= 0) { |
---|
| 371 | + input_set_capability(asus->inputdev, EV_SW, SW_TABLET_MODE); |
---|
| 372 | + input_report_switch(asus->inputdev, SW_TABLET_MODE, !result); |
---|
| 373 | + } else if (result != -ENODEV) { |
---|
| 374 | + pr_err("Error checking for keyboard-dock: %d\n", result); |
---|
| 375 | + } |
---|
| 376 | + } |
---|
| 377 | + |
---|
| 378 | + err = input_register_device(asus->inputdev); |
---|
| 379 | + if (err) |
---|
| 380 | + goto err_free_dev; |
---|
| 381 | + |
---|
| 382 | + return 0; |
---|
| 383 | + |
---|
| 384 | +err_free_dev: |
---|
| 385 | + input_free_device(asus->inputdev); |
---|
| 386 | + return err; |
---|
| 387 | +} |
---|
| 388 | + |
---|
| 389 | +static void asus_wmi_input_exit(struct asus_wmi *asus) |
---|
| 390 | +{ |
---|
| 391 | + if (asus->inputdev) |
---|
| 392 | + input_unregister_device(asus->inputdev); |
---|
| 393 | + |
---|
| 394 | + asus->inputdev = NULL; |
---|
| 395 | +} |
---|
| 396 | + |
---|
| 397 | +/* Battery ********************************************************************/ |
---|
| 398 | + |
---|
| 399 | +/* The battery maximum charging percentage */ |
---|
| 400 | +static int charge_end_threshold; |
---|
| 401 | + |
---|
| 402 | +static ssize_t charge_control_end_threshold_store(struct device *dev, |
---|
| 403 | + struct device_attribute *attr, |
---|
| 404 | + const char *buf, size_t count) |
---|
| 405 | +{ |
---|
| 406 | + int value, ret, rv; |
---|
| 407 | + |
---|
| 408 | + ret = kstrtouint(buf, 10, &value); |
---|
| 409 | + if (ret) |
---|
| 410 | + return ret; |
---|
| 411 | + |
---|
| 412 | + if (value < 0 || value > 100) |
---|
| 413 | + return -EINVAL; |
---|
| 414 | + |
---|
| 415 | + ret = asus_wmi_set_devstate(ASUS_WMI_DEVID_RSOC, value, &rv); |
---|
| 416 | + if (ret) |
---|
| 417 | + return ret; |
---|
| 418 | + |
---|
| 419 | + if (rv != 1) |
---|
| 420 | + return -EIO; |
---|
| 421 | + |
---|
| 422 | + /* There isn't any method in the DSDT to read the threshold, so we |
---|
| 423 | + * save the threshold. |
---|
| 424 | + */ |
---|
| 425 | + charge_end_threshold = value; |
---|
| 426 | + return count; |
---|
| 427 | +} |
---|
| 428 | + |
---|
| 429 | +static ssize_t charge_control_end_threshold_show(struct device *device, |
---|
| 430 | + struct device_attribute *attr, |
---|
| 431 | + char *buf) |
---|
| 432 | +{ |
---|
| 433 | + return sprintf(buf, "%d\n", charge_end_threshold); |
---|
| 434 | +} |
---|
| 435 | + |
---|
| 436 | +static DEVICE_ATTR_RW(charge_control_end_threshold); |
---|
| 437 | + |
---|
| 438 | +static int asus_wmi_battery_add(struct power_supply *battery) |
---|
| 439 | +{ |
---|
| 440 | + /* The WMI method does not provide a way to specific a battery, so we |
---|
| 441 | + * just assume it is the first battery. |
---|
| 442 | + * Note: On some newer ASUS laptops (Zenbook UM431DA), the primary/first |
---|
| 443 | + * battery is named BATT. |
---|
| 444 | + */ |
---|
| 445 | + if (strcmp(battery->desc->name, "BAT0") != 0 && |
---|
| 446 | + strcmp(battery->desc->name, "BAT1") != 0 && |
---|
| 447 | + strcmp(battery->desc->name, "BATC") != 0 && |
---|
| 448 | + strcmp(battery->desc->name, "BATT") != 0) |
---|
| 449 | + return -ENODEV; |
---|
| 450 | + |
---|
| 451 | + if (device_create_file(&battery->dev, |
---|
| 452 | + &dev_attr_charge_control_end_threshold)) |
---|
| 453 | + return -ENODEV; |
---|
| 454 | + |
---|
| 455 | + /* The charge threshold is only reset when the system is power cycled, |
---|
| 456 | + * and we can't get the current threshold so let set it to 100% when |
---|
| 457 | + * a battery is added. |
---|
| 458 | + */ |
---|
| 459 | + asus_wmi_set_devstate(ASUS_WMI_DEVID_RSOC, 100, NULL); |
---|
| 460 | + charge_end_threshold = 100; |
---|
| 461 | + |
---|
| 462 | + return 0; |
---|
| 463 | +} |
---|
| 464 | + |
---|
| 465 | +static int asus_wmi_battery_remove(struct power_supply *battery) |
---|
| 466 | +{ |
---|
| 467 | + device_remove_file(&battery->dev, |
---|
| 468 | + &dev_attr_charge_control_end_threshold); |
---|
| 469 | + return 0; |
---|
| 470 | +} |
---|
| 471 | + |
---|
| 472 | +static struct acpi_battery_hook battery_hook = { |
---|
| 473 | + .add_battery = asus_wmi_battery_add, |
---|
| 474 | + .remove_battery = asus_wmi_battery_remove, |
---|
| 475 | + .name = "ASUS Battery Extension", |
---|
| 476 | +}; |
---|
| 477 | + |
---|
| 478 | +static void asus_wmi_battery_init(struct asus_wmi *asus) |
---|
| 479 | +{ |
---|
| 480 | + asus->battery_rsoc_available = false; |
---|
| 481 | + if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_RSOC)) { |
---|
| 482 | + asus->battery_rsoc_available = true; |
---|
| 483 | + battery_hook_register(&battery_hook); |
---|
| 484 | + } |
---|
| 485 | +} |
---|
| 486 | + |
---|
| 487 | +static void asus_wmi_battery_exit(struct asus_wmi *asus) |
---|
| 488 | +{ |
---|
| 489 | + if (asus->battery_rsoc_available) |
---|
| 490 | + battery_hook_unregister(&battery_hook); |
---|
| 491 | +} |
---|
| 492 | + |
---|
| 493 | +/* LEDs ***********************************************************************/ |
---|
| 494 | + |
---|
417 | 495 | /* |
---|
418 | 496 | * These functions actually update the LED's, and are called from a |
---|
419 | 497 | * workqueue. By doing this as separate work rather than when the LED |
---|
.. | .. |
---|
456 | 534 | return read_tpd_led_state(asus); |
---|
457 | 535 | } |
---|
458 | 536 | |
---|
459 | | -static void kbd_led_update(struct work_struct *work) |
---|
| 537 | +static void kbd_led_update(struct asus_wmi *asus) |
---|
460 | 538 | { |
---|
461 | 539 | int ctrl_param = 0; |
---|
462 | | - struct asus_wmi *asus; |
---|
463 | | - |
---|
464 | | - asus = container_of(work, struct asus_wmi, kbd_led_work); |
---|
465 | 540 | |
---|
466 | 541 | ctrl_param = 0x80 | (asus->kbd_led_wk & 0x7F); |
---|
467 | 542 | asus_wmi_set_devstate(ASUS_WMI_DEVID_KBD_BACKLIGHT, ctrl_param, NULL); |
---|
468 | | - led_classdev_notify_brightness_hw_changed(&asus->kbd_led, asus->kbd_led_wk); |
---|
469 | 543 | } |
---|
470 | 544 | |
---|
471 | 545 | static int kbd_led_read(struct asus_wmi *asus, int *level, int *env) |
---|
.. | .. |
---|
485 | 559 | if (retval == 0x8000) |
---|
486 | 560 | retval = 0; |
---|
487 | 561 | |
---|
488 | | - if (retval >= 0) { |
---|
489 | | - if (level) |
---|
490 | | - *level = retval & 0x7F; |
---|
491 | | - if (env) |
---|
492 | | - *env = (retval >> 8) & 0x7F; |
---|
493 | | - retval = 0; |
---|
494 | | - } |
---|
| 562 | + if (retval < 0) |
---|
| 563 | + return retval; |
---|
495 | 564 | |
---|
496 | | - return retval; |
---|
| 565 | + if (level) |
---|
| 566 | + *level = retval & 0x7F; |
---|
| 567 | + if (env) |
---|
| 568 | + *env = (retval >> 8) & 0x7F; |
---|
| 569 | + return 0; |
---|
497 | 570 | } |
---|
498 | 571 | |
---|
499 | 572 | static void do_kbd_led_set(struct led_classdev *led_cdev, int value) |
---|
.. | .. |
---|
504 | 577 | asus = container_of(led_cdev, struct asus_wmi, kbd_led); |
---|
505 | 578 | max_level = asus->kbd_led.max_brightness; |
---|
506 | 579 | |
---|
507 | | - if (value > max_level) |
---|
508 | | - value = max_level; |
---|
509 | | - else if (value < 0) |
---|
510 | | - value = 0; |
---|
511 | | - |
---|
512 | | - asus->kbd_led_wk = value; |
---|
513 | | - queue_work(asus->led_workqueue, &asus->kbd_led_work); |
---|
| 580 | + asus->kbd_led_wk = clamp_val(value, 0, max_level); |
---|
| 581 | + kbd_led_update(asus); |
---|
514 | 582 | } |
---|
515 | 583 | |
---|
516 | 584 | static void kbd_led_set(struct led_classdev *led_cdev, |
---|
517 | 585 | enum led_brightness value) |
---|
518 | 586 | { |
---|
| 587 | + /* Prevent disabling keyboard backlight on module unregister */ |
---|
| 588 | + if (led_cdev->flags & LED_UNREGISTERING) |
---|
| 589 | + return; |
---|
| 590 | + |
---|
519 | 591 | do_kbd_led_set(led_cdev, value); |
---|
| 592 | +} |
---|
| 593 | + |
---|
| 594 | +static void kbd_led_set_by_kbd(struct asus_wmi *asus, enum led_brightness value) |
---|
| 595 | +{ |
---|
| 596 | + struct led_classdev *led_cdev = &asus->kbd_led; |
---|
| 597 | + |
---|
| 598 | + do_kbd_led_set(led_cdev, value); |
---|
| 599 | + led_classdev_notify_brightness_hw_changed(led_cdev, asus->kbd_led_wk); |
---|
520 | 600 | } |
---|
521 | 601 | |
---|
522 | 602 | static enum led_brightness kbd_led_get(struct led_classdev *led_cdev) |
---|
.. | .. |
---|
527 | 607 | asus = container_of(led_cdev, struct asus_wmi, kbd_led); |
---|
528 | 608 | |
---|
529 | 609 | retval = kbd_led_read(asus, &value, NULL); |
---|
530 | | - |
---|
531 | 610 | if (retval < 0) |
---|
532 | 611 | return retval; |
---|
533 | 612 | |
---|
.. | .. |
---|
541 | 620 | asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_WIRELESS_LED, &result); |
---|
542 | 621 | |
---|
543 | 622 | return result & ASUS_WMI_DSTS_UNKNOWN_BIT; |
---|
544 | | -} |
---|
545 | | - |
---|
546 | | -static int wlan_led_presence(struct asus_wmi *asus) |
---|
547 | | -{ |
---|
548 | | - u32 result; |
---|
549 | | - |
---|
550 | | - asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_WIRELESS_LED, &result); |
---|
551 | | - |
---|
552 | | - return result & ASUS_WMI_DSTS_PRESENCE_BIT; |
---|
553 | 623 | } |
---|
554 | 624 | |
---|
555 | 625 | static void wlan_led_update(struct work_struct *work) |
---|
.. | .. |
---|
618 | 688 | return result & ASUS_WMI_DSTS_LIGHTBAR_MASK; |
---|
619 | 689 | } |
---|
620 | 690 | |
---|
621 | | -static int lightbar_led_presence(struct asus_wmi *asus) |
---|
622 | | -{ |
---|
623 | | - u32 result; |
---|
624 | | - |
---|
625 | | - asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_LIGHTBAR, &result); |
---|
626 | | - |
---|
627 | | - return result & ASUS_WMI_DSTS_PRESENCE_BIT; |
---|
628 | | -} |
---|
629 | | - |
---|
630 | 691 | static void asus_wmi_led_exit(struct asus_wmi *asus) |
---|
631 | 692 | { |
---|
632 | | - if (!IS_ERR_OR_NULL(asus->kbd_led.dev)) |
---|
633 | | - led_classdev_unregister(&asus->kbd_led); |
---|
634 | | - if (!IS_ERR_OR_NULL(asus->tpd_led.dev)) |
---|
635 | | - led_classdev_unregister(&asus->tpd_led); |
---|
636 | | - if (!IS_ERR_OR_NULL(asus->wlan_led.dev)) |
---|
637 | | - led_classdev_unregister(&asus->wlan_led); |
---|
638 | | - if (!IS_ERR_OR_NULL(asus->lightbar_led.dev)) |
---|
639 | | - led_classdev_unregister(&asus->lightbar_led); |
---|
| 693 | + led_classdev_unregister(&asus->kbd_led); |
---|
| 694 | + led_classdev_unregister(&asus->tpd_led); |
---|
| 695 | + led_classdev_unregister(&asus->wlan_led); |
---|
| 696 | + led_classdev_unregister(&asus->lightbar_led); |
---|
| 697 | + |
---|
640 | 698 | if (asus->led_workqueue) |
---|
641 | 699 | destroy_workqueue(asus->led_workqueue); |
---|
642 | 700 | } |
---|
.. | .. |
---|
663 | 721 | goto error; |
---|
664 | 722 | } |
---|
665 | 723 | |
---|
666 | | - led_val = kbd_led_read(asus, NULL, NULL); |
---|
667 | | - if (led_val >= 0) { |
---|
668 | | - INIT_WORK(&asus->kbd_led_work, kbd_led_update); |
---|
669 | | - |
---|
| 724 | + if (!kbd_led_read(asus, &led_val, NULL)) { |
---|
670 | 725 | asus->kbd_led_wk = led_val; |
---|
671 | 726 | asus->kbd_led.name = "asus::kbd_backlight"; |
---|
672 | 727 | asus->kbd_led.flags = LED_BRIGHT_HW_CHANGED; |
---|
.. | .. |
---|
680 | 735 | goto error; |
---|
681 | 736 | } |
---|
682 | 737 | |
---|
683 | | - if (wlan_led_presence(asus) && (asus->driver->quirks->wapf > 0)) { |
---|
| 738 | + if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_WIRELESS_LED) |
---|
| 739 | + && (asus->driver->quirks->wapf > 0)) { |
---|
684 | 740 | INIT_WORK(&asus->wlan_led_work, wlan_led_update); |
---|
685 | 741 | |
---|
686 | 742 | asus->wlan_led.name = "asus::wlan"; |
---|
.. | .. |
---|
697 | 753 | goto error; |
---|
698 | 754 | } |
---|
699 | 755 | |
---|
700 | | - if (lightbar_led_presence(asus)) { |
---|
| 756 | + if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_LIGHTBAR)) { |
---|
701 | 757 | INIT_WORK(&asus->lightbar_led_work, lightbar_led_update); |
---|
702 | 758 | |
---|
703 | 759 | asus->lightbar_led.name = "asus::lightbar"; |
---|
.. | .. |
---|
716 | 772 | return rv; |
---|
717 | 773 | } |
---|
718 | 774 | |
---|
| 775 | +/* RF *************************************************************************/ |
---|
719 | 776 | |
---|
720 | 777 | /* |
---|
721 | 778 | * PCI hotplug (for wlan rfkill) |
---|
.. | .. |
---|
747 | 804 | if (asus->wlan.rfkill) |
---|
748 | 805 | rfkill_set_sw_state(asus->wlan.rfkill, blocked); |
---|
749 | 806 | |
---|
750 | | - if (asus->hotplug_slot) { |
---|
| 807 | + if (asus->hotplug_slot.ops) { |
---|
751 | 808 | bus = pci_find_bus(0, 1); |
---|
752 | 809 | if (!bus) { |
---|
753 | 810 | pr_warn("Unable to find PCI bus 1?\n"); |
---|
.. | .. |
---|
819 | 876 | acpi_handle handle; |
---|
820 | 877 | |
---|
821 | 878 | status = acpi_get_handle(NULL, node, &handle); |
---|
822 | | - |
---|
823 | | - if (ACPI_SUCCESS(status)) { |
---|
824 | | - status = acpi_install_notify_handler(handle, |
---|
825 | | - ACPI_SYSTEM_NOTIFY, |
---|
826 | | - asus_rfkill_notify, asus); |
---|
827 | | - if (ACPI_FAILURE(status)) |
---|
828 | | - pr_warn("Failed to register notify on %s\n", node); |
---|
829 | | - } else |
---|
| 879 | + if (ACPI_FAILURE(status)) |
---|
830 | 880 | return -ENODEV; |
---|
| 881 | + |
---|
| 882 | + status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, |
---|
| 883 | + asus_rfkill_notify, asus); |
---|
| 884 | + if (ACPI_FAILURE(status)) |
---|
| 885 | + pr_warn("Failed to register notify on %s\n", node); |
---|
831 | 886 | |
---|
832 | 887 | return 0; |
---|
833 | 888 | } |
---|
.. | .. |
---|
838 | 893 | acpi_handle handle; |
---|
839 | 894 | |
---|
840 | 895 | status = acpi_get_handle(NULL, node, &handle); |
---|
| 896 | + if (ACPI_FAILURE(status)) |
---|
| 897 | + return; |
---|
841 | 898 | |
---|
842 | | - if (ACPI_SUCCESS(status)) { |
---|
843 | | - status = acpi_remove_notify_handler(handle, |
---|
844 | | - ACPI_SYSTEM_NOTIFY, |
---|
845 | | - asus_rfkill_notify); |
---|
846 | | - if (ACPI_FAILURE(status)) |
---|
847 | | - pr_err("Error removing rfkill notify handler %s\n", |
---|
848 | | - node); |
---|
849 | | - } |
---|
| 899 | + status = acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, |
---|
| 900 | + asus_rfkill_notify); |
---|
| 901 | + if (ACPI_FAILURE(status)) |
---|
| 902 | + pr_err("Error removing rfkill notify handler %s\n", node); |
---|
850 | 903 | } |
---|
851 | 904 | |
---|
852 | 905 | static int asus_get_adapter_status(struct hotplug_slot *hotplug_slot, |
---|
853 | 906 | u8 *value) |
---|
854 | 907 | { |
---|
855 | | - struct asus_wmi *asus = hotplug_slot->private; |
---|
| 908 | + struct asus_wmi *asus = container_of(hotplug_slot, |
---|
| 909 | + struct asus_wmi, hotplug_slot); |
---|
856 | 910 | int result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_WLAN); |
---|
857 | 911 | |
---|
858 | 912 | if (result < 0) |
---|
.. | .. |
---|
862 | 916 | return 0; |
---|
863 | 917 | } |
---|
864 | 918 | |
---|
865 | | -static struct hotplug_slot_ops asus_hotplug_slot_ops = { |
---|
866 | | - .owner = THIS_MODULE, |
---|
| 919 | +static const struct hotplug_slot_ops asus_hotplug_slot_ops = { |
---|
867 | 920 | .get_adapter_status = asus_get_adapter_status, |
---|
868 | 921 | .get_power_status = asus_get_adapter_status, |
---|
869 | 922 | }; |
---|
.. | .. |
---|
893 | 946 | |
---|
894 | 947 | INIT_WORK(&asus->hotplug_work, asus_hotplug_work); |
---|
895 | 948 | |
---|
896 | | - asus->hotplug_slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL); |
---|
897 | | - if (!asus->hotplug_slot) |
---|
898 | | - goto error_slot; |
---|
| 949 | + asus->hotplug_slot.ops = &asus_hotplug_slot_ops; |
---|
899 | 950 | |
---|
900 | | - asus->hotplug_slot->info = kzalloc(sizeof(struct hotplug_slot_info), |
---|
901 | | - GFP_KERNEL); |
---|
902 | | - if (!asus->hotplug_slot->info) |
---|
903 | | - goto error_info; |
---|
904 | | - |
---|
905 | | - asus->hotplug_slot->private = asus; |
---|
906 | | - asus->hotplug_slot->ops = &asus_hotplug_slot_ops; |
---|
907 | | - asus_get_adapter_status(asus->hotplug_slot, |
---|
908 | | - &asus->hotplug_slot->info->adapter_status); |
---|
909 | | - |
---|
910 | | - ret = pci_hp_register(asus->hotplug_slot, bus, 0, "asus-wifi"); |
---|
| 951 | + ret = pci_hp_register(&asus->hotplug_slot, bus, 0, "asus-wifi"); |
---|
911 | 952 | if (ret) { |
---|
912 | 953 | pr_err("Unable to register hotplug slot - %d\n", ret); |
---|
913 | 954 | goto error_register; |
---|
.. | .. |
---|
916 | 957 | return 0; |
---|
917 | 958 | |
---|
918 | 959 | error_register: |
---|
919 | | - kfree(asus->hotplug_slot->info); |
---|
920 | | -error_info: |
---|
921 | | - kfree(asus->hotplug_slot); |
---|
922 | | - asus->hotplug_slot = NULL; |
---|
923 | | -error_slot: |
---|
| 960 | + asus->hotplug_slot.ops = NULL; |
---|
924 | 961 | destroy_workqueue(asus->hotplug_workqueue); |
---|
925 | 962 | error_workqueue: |
---|
926 | 963 | return ret; |
---|
.. | .. |
---|
1048 | 1085 | * asus_unregister_rfkill_notifier() |
---|
1049 | 1086 | */ |
---|
1050 | 1087 | asus_rfkill_hotplug(asus); |
---|
1051 | | - if (asus->hotplug_slot) { |
---|
1052 | | - pci_hp_deregister(asus->hotplug_slot); |
---|
1053 | | - kfree(asus->hotplug_slot->info); |
---|
1054 | | - kfree(asus->hotplug_slot); |
---|
1055 | | - } |
---|
| 1088 | + if (asus->hotplug_slot.ops) |
---|
| 1089 | + pci_hp_deregister(&asus->hotplug_slot); |
---|
1056 | 1090 | if (asus->hotplug_workqueue) |
---|
1057 | 1091 | destroy_workqueue(asus->hotplug_workqueue); |
---|
1058 | 1092 | |
---|
.. | .. |
---|
1157 | 1191 | return result; |
---|
1158 | 1192 | } |
---|
1159 | 1193 | |
---|
| 1194 | +/* Quirks *********************************************************************/ |
---|
| 1195 | + |
---|
1160 | 1196 | static void asus_wmi_set_xusb2pr(struct asus_wmi *asus) |
---|
1161 | 1197 | { |
---|
1162 | 1198 | struct pci_dev *xhci_pdev; |
---|
.. | .. |
---|
1176 | 1212 | pci_write_config_dword(xhci_pdev, USB_INTEL_XUSB2PR, |
---|
1177 | 1213 | cpu_to_le32(ports_available)); |
---|
1178 | 1214 | |
---|
| 1215 | + pci_dev_put(xhci_pdev); |
---|
| 1216 | + |
---|
1179 | 1217 | pr_info("set USB_INTEL_XUSB2PR old: 0x%04x, new: 0x%04x\n", |
---|
1180 | 1218 | orig_ports_available, ports_available); |
---|
1181 | 1219 | } |
---|
.. | .. |
---|
1189 | 1227 | asus_wmi_set_devstate(ASUS_WMI_DEVID_ALS_ENABLE, 1, NULL); |
---|
1190 | 1228 | } |
---|
1191 | 1229 | |
---|
1192 | | -/* |
---|
1193 | | - * Hwmon device |
---|
1194 | | - */ |
---|
1195 | | -static int asus_hwmon_agfn_fan_speed_read(struct asus_wmi *asus, int fan, |
---|
| 1230 | +/* Hwmon device ***************************************************************/ |
---|
| 1231 | + |
---|
| 1232 | +static int asus_agfn_fan_speed_read(struct asus_wmi *asus, int fan, |
---|
1196 | 1233 | int *speed) |
---|
1197 | 1234 | { |
---|
1198 | | - struct fan_args args = { |
---|
| 1235 | + struct agfn_fan_args args = { |
---|
1199 | 1236 | .agfn.len = sizeof(args), |
---|
1200 | 1237 | .agfn.mfun = ASUS_FAN_MFUN, |
---|
1201 | 1238 | .agfn.sfun = ASUS_FAN_SFUN_READ, |
---|
.. | .. |
---|
1219 | 1256 | return 0; |
---|
1220 | 1257 | } |
---|
1221 | 1258 | |
---|
1222 | | -static int asus_hwmon_agfn_fan_speed_write(struct asus_wmi *asus, int fan, |
---|
| 1259 | +static int asus_agfn_fan_speed_write(struct asus_wmi *asus, int fan, |
---|
1223 | 1260 | int *speed) |
---|
1224 | 1261 | { |
---|
1225 | | - struct fan_args args = { |
---|
| 1262 | + struct agfn_fan_args args = { |
---|
1226 | 1263 | .agfn.len = sizeof(args), |
---|
1227 | 1264 | .agfn.mfun = ASUS_FAN_MFUN, |
---|
1228 | 1265 | .agfn.sfun = ASUS_FAN_SFUN_WRITE, |
---|
.. | .. |
---|
1242 | 1279 | return -ENXIO; |
---|
1243 | 1280 | |
---|
1244 | 1281 | if (speed && fan == 1) |
---|
1245 | | - asus->asus_hwmon_pwm = *speed; |
---|
| 1282 | + asus->agfn_pwm = *speed; |
---|
1246 | 1283 | |
---|
1247 | 1284 | return 0; |
---|
1248 | 1285 | } |
---|
.. | .. |
---|
1251 | 1288 | * Check if we can read the speed of one fan. If true we assume we can also |
---|
1252 | 1289 | * control it. |
---|
1253 | 1290 | */ |
---|
1254 | | -static int asus_hwmon_get_fan_number(struct asus_wmi *asus, int *num_fans) |
---|
| 1291 | +static bool asus_wmi_has_agfn_fan(struct asus_wmi *asus) |
---|
1255 | 1292 | { |
---|
1256 | 1293 | int status; |
---|
1257 | | - int speed = 0; |
---|
| 1294 | + int speed; |
---|
| 1295 | + u32 value; |
---|
1258 | 1296 | |
---|
1259 | | - *num_fans = 0; |
---|
| 1297 | + status = asus_agfn_fan_speed_read(asus, 1, &speed); |
---|
| 1298 | + if (status != 0) |
---|
| 1299 | + return false; |
---|
1260 | 1300 | |
---|
1261 | | - status = asus_hwmon_agfn_fan_speed_read(asus, 1, &speed); |
---|
1262 | | - if (!status) |
---|
1263 | | - *num_fans = 1; |
---|
| 1301 | + status = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FAN_CTRL, &value); |
---|
| 1302 | + if (status != 0) |
---|
| 1303 | + return false; |
---|
1264 | 1304 | |
---|
1265 | | - return 0; |
---|
| 1305 | + /* |
---|
| 1306 | + * We need to find a better way, probably using sfun, |
---|
| 1307 | + * bits or spec ... |
---|
| 1308 | + * Currently we disable it if: |
---|
| 1309 | + * - ASUS_WMI_UNSUPPORTED_METHOD is returned |
---|
| 1310 | + * - reverved bits are non-zero |
---|
| 1311 | + * - sfun and presence bit are not set |
---|
| 1312 | + */ |
---|
| 1313 | + return !(value == ASUS_WMI_UNSUPPORTED_METHOD || value & 0xFFF80000 |
---|
| 1314 | + || (!asus->sfun && !(value & ASUS_WMI_DSTS_PRESENCE_BIT))); |
---|
1266 | 1315 | } |
---|
1267 | 1316 | |
---|
1268 | | -static int asus_hwmon_fan_set_auto(struct asus_wmi *asus) |
---|
| 1317 | +static int asus_fan_set_auto(struct asus_wmi *asus) |
---|
1269 | 1318 | { |
---|
1270 | 1319 | int status; |
---|
| 1320 | + u32 retval; |
---|
1271 | 1321 | |
---|
1272 | | - status = asus_hwmon_agfn_fan_speed_write(asus, 0, NULL); |
---|
1273 | | - if (status) |
---|
| 1322 | + switch (asus->fan_type) { |
---|
| 1323 | + case FAN_TYPE_SPEC83: |
---|
| 1324 | + status = asus_wmi_set_devstate(ASUS_WMI_DEVID_CPU_FAN_CTRL, |
---|
| 1325 | + 0, &retval); |
---|
| 1326 | + if (status) |
---|
| 1327 | + return status; |
---|
| 1328 | + |
---|
| 1329 | + if (retval != 1) |
---|
| 1330 | + return -EIO; |
---|
| 1331 | + break; |
---|
| 1332 | + |
---|
| 1333 | + case FAN_TYPE_AGFN: |
---|
| 1334 | + status = asus_agfn_fan_speed_write(asus, 0, NULL); |
---|
| 1335 | + if (status) |
---|
| 1336 | + return -ENXIO; |
---|
| 1337 | + break; |
---|
| 1338 | + |
---|
| 1339 | + default: |
---|
1274 | 1340 | return -ENXIO; |
---|
| 1341 | + } |
---|
1275 | 1342 | |
---|
1276 | | - asus->asus_hwmon_fan_manual_mode = false; |
---|
1277 | 1343 | |
---|
1278 | 1344 | return 0; |
---|
1279 | | -} |
---|
1280 | | - |
---|
1281 | | -static int asus_hwmon_fan_rpm_show(struct device *dev, int fan) |
---|
1282 | | -{ |
---|
1283 | | - struct asus_wmi *asus = dev_get_drvdata(dev); |
---|
1284 | | - int value; |
---|
1285 | | - int ret; |
---|
1286 | | - |
---|
1287 | | - /* no speed readable on manual mode */ |
---|
1288 | | - if (asus->asus_hwmon_fan_manual_mode) |
---|
1289 | | - return -ENXIO; |
---|
1290 | | - |
---|
1291 | | - ret = asus_hwmon_agfn_fan_speed_read(asus, fan+1, &value); |
---|
1292 | | - if (ret) { |
---|
1293 | | - pr_warn("reading fan speed failed: %d\n", ret); |
---|
1294 | | - return -ENXIO; |
---|
1295 | | - } |
---|
1296 | | - |
---|
1297 | | - return value; |
---|
1298 | | -} |
---|
1299 | | - |
---|
1300 | | -static void asus_hwmon_pwm_show(struct asus_wmi *asus, int fan, int *value) |
---|
1301 | | -{ |
---|
1302 | | - int err; |
---|
1303 | | - |
---|
1304 | | - if (asus->asus_hwmon_pwm >= 0) { |
---|
1305 | | - *value = asus->asus_hwmon_pwm; |
---|
1306 | | - return; |
---|
1307 | | - } |
---|
1308 | | - |
---|
1309 | | - err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FAN_CTRL, value); |
---|
1310 | | - if (err < 0) |
---|
1311 | | - return; |
---|
1312 | | - |
---|
1313 | | - *value &= 0xFF; |
---|
1314 | | - |
---|
1315 | | - if (*value == 1) /* Low Speed */ |
---|
1316 | | - *value = 85; |
---|
1317 | | - else if (*value == 2) |
---|
1318 | | - *value = 170; |
---|
1319 | | - else if (*value == 3) |
---|
1320 | | - *value = 255; |
---|
1321 | | - else if (*value) { |
---|
1322 | | - pr_err("Unknown fan speed %#x\n", *value); |
---|
1323 | | - *value = -1; |
---|
1324 | | - } |
---|
1325 | 1345 | } |
---|
1326 | 1346 | |
---|
1327 | 1347 | static ssize_t pwm1_show(struct device *dev, |
---|
.. | .. |
---|
1329 | 1349 | char *buf) |
---|
1330 | 1350 | { |
---|
1331 | 1351 | struct asus_wmi *asus = dev_get_drvdata(dev); |
---|
| 1352 | + int err; |
---|
1332 | 1353 | int value; |
---|
1333 | 1354 | |
---|
1334 | | - asus_hwmon_pwm_show(asus, 0, &value); |
---|
| 1355 | + /* If we already set a value then just return it */ |
---|
| 1356 | + if (asus->agfn_pwm >= 0) |
---|
| 1357 | + return sprintf(buf, "%d\n", asus->agfn_pwm); |
---|
| 1358 | + |
---|
| 1359 | + /* |
---|
| 1360 | + * If we haven't set already set a value through the AGFN interface, |
---|
| 1361 | + * we read a current value through the (now-deprecated) FAN_CTRL device. |
---|
| 1362 | + */ |
---|
| 1363 | + err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FAN_CTRL, &value); |
---|
| 1364 | + if (err < 0) |
---|
| 1365 | + return err; |
---|
| 1366 | + |
---|
| 1367 | + value &= 0xFF; |
---|
| 1368 | + |
---|
| 1369 | + if (value == 1) /* Low Speed */ |
---|
| 1370 | + value = 85; |
---|
| 1371 | + else if (value == 2) |
---|
| 1372 | + value = 170; |
---|
| 1373 | + else if (value == 3) |
---|
| 1374 | + value = 255; |
---|
| 1375 | + else if (value) { |
---|
| 1376 | + pr_err("Unknown fan speed %#x\n", value); |
---|
| 1377 | + value = -1; |
---|
| 1378 | + } |
---|
1335 | 1379 | |
---|
1336 | 1380 | return sprintf(buf, "%d\n", value); |
---|
1337 | 1381 | } |
---|
.. | .. |
---|
1345 | 1389 | int ret; |
---|
1346 | 1390 | |
---|
1347 | 1391 | ret = kstrtouint(buf, 10, &value); |
---|
1348 | | - |
---|
1349 | 1392 | if (ret) |
---|
1350 | 1393 | return ret; |
---|
1351 | 1394 | |
---|
1352 | 1395 | value = clamp(value, 0, 255); |
---|
1353 | 1396 | |
---|
1354 | | - state = asus_hwmon_agfn_fan_speed_write(asus, 1, &value); |
---|
| 1397 | + state = asus_agfn_fan_speed_write(asus, 1, &value); |
---|
1355 | 1398 | if (state) |
---|
1356 | 1399 | pr_warn("Setting fan speed failed: %d\n", state); |
---|
1357 | 1400 | else |
---|
1358 | | - asus->asus_hwmon_fan_manual_mode = true; |
---|
| 1401 | + asus->fan_pwm_mode = ASUS_FAN_CTRL_MANUAL; |
---|
1359 | 1402 | |
---|
1360 | 1403 | return count; |
---|
1361 | 1404 | } |
---|
.. | .. |
---|
1364 | 1407 | struct device_attribute *attr, |
---|
1365 | 1408 | char *buf) |
---|
1366 | 1409 | { |
---|
1367 | | - int value = asus_hwmon_fan_rpm_show(dev, 0); |
---|
| 1410 | + struct asus_wmi *asus = dev_get_drvdata(dev); |
---|
| 1411 | + int value; |
---|
| 1412 | + int ret; |
---|
| 1413 | + |
---|
| 1414 | + switch (asus->fan_type) { |
---|
| 1415 | + case FAN_TYPE_SPEC83: |
---|
| 1416 | + ret = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_CPU_FAN_CTRL, |
---|
| 1417 | + &value); |
---|
| 1418 | + if (ret < 0) |
---|
| 1419 | + return ret; |
---|
| 1420 | + |
---|
| 1421 | + value &= 0xffff; |
---|
| 1422 | + break; |
---|
| 1423 | + |
---|
| 1424 | + case FAN_TYPE_AGFN: |
---|
| 1425 | + /* no speed readable on manual mode */ |
---|
| 1426 | + if (asus->fan_pwm_mode == ASUS_FAN_CTRL_MANUAL) |
---|
| 1427 | + return -ENXIO; |
---|
| 1428 | + |
---|
| 1429 | + ret = asus_agfn_fan_speed_read(asus, 1, &value); |
---|
| 1430 | + if (ret) { |
---|
| 1431 | + pr_warn("reading fan speed failed: %d\n", ret); |
---|
| 1432 | + return -ENXIO; |
---|
| 1433 | + } |
---|
| 1434 | + break; |
---|
| 1435 | + |
---|
| 1436 | + default: |
---|
| 1437 | + return -ENXIO; |
---|
| 1438 | + } |
---|
1368 | 1439 | |
---|
1369 | 1440 | return sprintf(buf, "%d\n", value < 0 ? -1 : value*100); |
---|
1370 | | - |
---|
1371 | 1441 | } |
---|
1372 | 1442 | |
---|
1373 | 1443 | static ssize_t pwm1_enable_show(struct device *dev, |
---|
.. | .. |
---|
1376 | 1446 | { |
---|
1377 | 1447 | struct asus_wmi *asus = dev_get_drvdata(dev); |
---|
1378 | 1448 | |
---|
1379 | | - if (asus->asus_hwmon_fan_manual_mode) |
---|
1380 | | - return sprintf(buf, "%d\n", ASUS_FAN_CTRL_MANUAL); |
---|
1381 | | - |
---|
1382 | | - return sprintf(buf, "%d\n", ASUS_FAN_CTRL_AUTO); |
---|
| 1449 | + /* |
---|
| 1450 | + * Just read back the cached pwm mode. |
---|
| 1451 | + * |
---|
| 1452 | + * For the CPU_FAN device, the spec indicates that we should be |
---|
| 1453 | + * able to read the device status and consult bit 19 to see if we |
---|
| 1454 | + * are in Full On or Automatic mode. However, this does not work |
---|
| 1455 | + * in practice on X532FL at least (the bit is always 0) and there's |
---|
| 1456 | + * also nothing in the DSDT to indicate that this behaviour exists. |
---|
| 1457 | + */ |
---|
| 1458 | + return sprintf(buf, "%d\n", asus->fan_pwm_mode); |
---|
1383 | 1459 | } |
---|
1384 | 1460 | |
---|
1385 | 1461 | static ssize_t pwm1_enable_store(struct device *dev, |
---|
.. | .. |
---|
1389 | 1465 | struct asus_wmi *asus = dev_get_drvdata(dev); |
---|
1390 | 1466 | int status = 0; |
---|
1391 | 1467 | int state; |
---|
| 1468 | + int value; |
---|
1392 | 1469 | int ret; |
---|
| 1470 | + u32 retval; |
---|
1393 | 1471 | |
---|
1394 | 1472 | ret = kstrtouint(buf, 10, &state); |
---|
1395 | | - |
---|
1396 | 1473 | if (ret) |
---|
1397 | 1474 | return ret; |
---|
1398 | 1475 | |
---|
1399 | | - if (state == ASUS_FAN_CTRL_MANUAL) |
---|
1400 | | - asus->asus_hwmon_fan_manual_mode = true; |
---|
1401 | | - else |
---|
1402 | | - status = asus_hwmon_fan_set_auto(asus); |
---|
| 1476 | + if (asus->fan_type == FAN_TYPE_SPEC83) { |
---|
| 1477 | + switch (state) { /* standard documented hwmon values */ |
---|
| 1478 | + case ASUS_FAN_CTRL_FULLSPEED: |
---|
| 1479 | + value = 1; |
---|
| 1480 | + break; |
---|
| 1481 | + case ASUS_FAN_CTRL_AUTO: |
---|
| 1482 | + value = 0; |
---|
| 1483 | + break; |
---|
| 1484 | + default: |
---|
| 1485 | + return -EINVAL; |
---|
| 1486 | + } |
---|
1403 | 1487 | |
---|
1404 | | - if (status) |
---|
1405 | | - return status; |
---|
| 1488 | + ret = asus_wmi_set_devstate(ASUS_WMI_DEVID_CPU_FAN_CTRL, |
---|
| 1489 | + value, &retval); |
---|
| 1490 | + if (ret) |
---|
| 1491 | + return ret; |
---|
1406 | 1492 | |
---|
| 1493 | + if (retval != 1) |
---|
| 1494 | + return -EIO; |
---|
| 1495 | + } else if (asus->fan_type == FAN_TYPE_AGFN) { |
---|
| 1496 | + switch (state) { |
---|
| 1497 | + case ASUS_FAN_CTRL_MANUAL: |
---|
| 1498 | + break; |
---|
| 1499 | + |
---|
| 1500 | + case ASUS_FAN_CTRL_AUTO: |
---|
| 1501 | + status = asus_fan_set_auto(asus); |
---|
| 1502 | + if (status) |
---|
| 1503 | + return status; |
---|
| 1504 | + break; |
---|
| 1505 | + |
---|
| 1506 | + default: |
---|
| 1507 | + return -EINVAL; |
---|
| 1508 | + } |
---|
| 1509 | + } |
---|
| 1510 | + |
---|
| 1511 | + asus->fan_pwm_mode = state; |
---|
1407 | 1512 | return count; |
---|
1408 | 1513 | } |
---|
1409 | 1514 | |
---|
.. | .. |
---|
1423 | 1528 | int err; |
---|
1424 | 1529 | |
---|
1425 | 1530 | err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_THERMAL_CTRL, &value); |
---|
1426 | | - |
---|
1427 | 1531 | if (err < 0) |
---|
1428 | 1532 | return err; |
---|
1429 | 1533 | |
---|
1430 | | - value = DECI_KELVIN_TO_CELSIUS((value & 0xFFFF)) * 1000; |
---|
1431 | | - |
---|
1432 | | - return sprintf(buf, "%d\n", value); |
---|
| 1534 | + return sprintf(buf, "%ld\n", |
---|
| 1535 | + deci_kelvin_to_millicelsius(value & 0xFFFF)); |
---|
1433 | 1536 | } |
---|
1434 | 1537 | |
---|
1435 | 1538 | /* Fan1 */ |
---|
.. | .. |
---|
1455 | 1558 | struct attribute *attr, int idx) |
---|
1456 | 1559 | { |
---|
1457 | 1560 | struct device *dev = container_of(kobj, struct device, kobj); |
---|
1458 | | - struct platform_device *pdev = to_platform_device(dev->parent); |
---|
1459 | | - struct asus_wmi *asus = platform_get_drvdata(pdev); |
---|
1460 | | - int dev_id = -1; |
---|
1461 | | - int fan_attr = -1; |
---|
| 1561 | + struct asus_wmi *asus = dev_get_drvdata(dev->parent); |
---|
1462 | 1562 | u32 value = ASUS_WMI_UNSUPPORTED_METHOD; |
---|
1463 | | - bool ok = true; |
---|
1464 | 1563 | |
---|
1465 | | - if (attr == &dev_attr_pwm1.attr) |
---|
1466 | | - dev_id = ASUS_WMI_DEVID_FAN_CTRL; |
---|
1467 | | - else if (attr == &dev_attr_temp1_input.attr) |
---|
1468 | | - dev_id = ASUS_WMI_DEVID_THERMAL_CTRL; |
---|
1469 | | - |
---|
1470 | | - |
---|
1471 | | - if (attr == &dev_attr_fan1_input.attr |
---|
| 1564 | + if (attr == &dev_attr_pwm1.attr) { |
---|
| 1565 | + if (asus->fan_type != FAN_TYPE_AGFN) |
---|
| 1566 | + return 0; |
---|
| 1567 | + } else if (attr == &dev_attr_fan1_input.attr |
---|
1472 | 1568 | || attr == &dev_attr_fan1_label.attr |
---|
1473 | | - || attr == &dev_attr_pwm1.attr |
---|
1474 | 1569 | || attr == &dev_attr_pwm1_enable.attr) { |
---|
1475 | | - fan_attr = 1; |
---|
1476 | | - } |
---|
| 1570 | + if (asus->fan_type == FAN_TYPE_NONE) |
---|
| 1571 | + return 0; |
---|
| 1572 | + } else if (attr == &dev_attr_temp1_input.attr) { |
---|
| 1573 | + int err = asus_wmi_get_devstate(asus, |
---|
| 1574 | + ASUS_WMI_DEVID_THERMAL_CTRL, |
---|
| 1575 | + &value); |
---|
1477 | 1576 | |
---|
1478 | | - if (dev_id != -1) { |
---|
1479 | | - int err = asus_wmi_get_devstate(asus, dev_id, &value); |
---|
1480 | | - |
---|
1481 | | - if (err < 0 && fan_attr == -1) |
---|
| 1577 | + if (err < 0) |
---|
1482 | 1578 | return 0; /* can't return negative here */ |
---|
1483 | | - } |
---|
1484 | 1579 | |
---|
1485 | | - if (dev_id == ASUS_WMI_DEVID_FAN_CTRL) { |
---|
1486 | 1580 | /* |
---|
1487 | | - * We need to find a better way, probably using sfun, |
---|
1488 | | - * bits or spec ... |
---|
1489 | | - * Currently we disable it if: |
---|
1490 | | - * - ASUS_WMI_UNSUPPORTED_METHOD is returned |
---|
1491 | | - * - reverved bits are non-zero |
---|
1492 | | - * - sfun and presence bit are not set |
---|
| 1581 | + * If the temperature value in deci-Kelvin is near the absolute |
---|
| 1582 | + * zero temperature, something is clearly wrong |
---|
1493 | 1583 | */ |
---|
1494 | | - if (value == ASUS_WMI_UNSUPPORTED_METHOD || value & 0xFFF80000 |
---|
1495 | | - || (!asus->sfun && !(value & ASUS_WMI_DSTS_PRESENCE_BIT))) |
---|
1496 | | - ok = false; |
---|
1497 | | - else |
---|
1498 | | - ok = fan_attr <= asus->asus_hwmon_num_fans; |
---|
1499 | | - } else if (dev_id == ASUS_WMI_DEVID_THERMAL_CTRL) { |
---|
1500 | | - /* If value is zero, something is clearly wrong */ |
---|
1501 | | - if (!value) |
---|
1502 | | - ok = false; |
---|
1503 | | - } else if (fan_attr <= asus->asus_hwmon_num_fans && fan_attr != -1) { |
---|
1504 | | - ok = true; |
---|
1505 | | - } else { |
---|
1506 | | - ok = false; |
---|
| 1584 | + if (value == 0 || value == 1) |
---|
| 1585 | + return 0; |
---|
1507 | 1586 | } |
---|
1508 | 1587 | |
---|
1509 | | - return ok ? attr->mode : 0; |
---|
| 1588 | + return attr->mode; |
---|
1510 | 1589 | } |
---|
1511 | 1590 | |
---|
1512 | 1591 | static const struct attribute_group hwmon_attribute_group = { |
---|
.. | .. |
---|
1517 | 1596 | |
---|
1518 | 1597 | static int asus_wmi_hwmon_init(struct asus_wmi *asus) |
---|
1519 | 1598 | { |
---|
| 1599 | + struct device *dev = &asus->platform_device->dev; |
---|
1520 | 1600 | struct device *hwmon; |
---|
1521 | 1601 | |
---|
1522 | | - hwmon = hwmon_device_register_with_groups(&asus->platform_device->dev, |
---|
1523 | | - "asus", asus, |
---|
1524 | | - hwmon_attribute_groups); |
---|
| 1602 | + hwmon = devm_hwmon_device_register_with_groups(dev, "asus", asus, |
---|
| 1603 | + hwmon_attribute_groups); |
---|
| 1604 | + |
---|
1525 | 1605 | if (IS_ERR(hwmon)) { |
---|
1526 | 1606 | pr_err("Could not register asus hwmon device\n"); |
---|
1527 | 1607 | return PTR_ERR(hwmon); |
---|
.. | .. |
---|
1529 | 1609 | return 0; |
---|
1530 | 1610 | } |
---|
1531 | 1611 | |
---|
1532 | | -/* |
---|
1533 | | - * Backlight |
---|
1534 | | - */ |
---|
| 1612 | +static int asus_wmi_fan_init(struct asus_wmi *asus) |
---|
| 1613 | +{ |
---|
| 1614 | + asus->fan_type = FAN_TYPE_NONE; |
---|
| 1615 | + asus->agfn_pwm = -1; |
---|
| 1616 | + |
---|
| 1617 | + if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CPU_FAN_CTRL)) |
---|
| 1618 | + asus->fan_type = FAN_TYPE_SPEC83; |
---|
| 1619 | + else if (asus_wmi_has_agfn_fan(asus)) |
---|
| 1620 | + asus->fan_type = FAN_TYPE_AGFN; |
---|
| 1621 | + |
---|
| 1622 | + if (asus->fan_type == FAN_TYPE_NONE) |
---|
| 1623 | + return -ENODEV; |
---|
| 1624 | + |
---|
| 1625 | + asus_fan_set_auto(asus); |
---|
| 1626 | + asus->fan_pwm_mode = ASUS_FAN_CTRL_AUTO; |
---|
| 1627 | + return 0; |
---|
| 1628 | +} |
---|
| 1629 | + |
---|
| 1630 | +/* Fan mode *******************************************************************/ |
---|
| 1631 | + |
---|
| 1632 | +static int fan_boost_mode_check_present(struct asus_wmi *asus) |
---|
| 1633 | +{ |
---|
| 1634 | + u32 result; |
---|
| 1635 | + int err; |
---|
| 1636 | + |
---|
| 1637 | + asus->fan_boost_mode_available = false; |
---|
| 1638 | + |
---|
| 1639 | + err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FAN_BOOST_MODE, |
---|
| 1640 | + &result); |
---|
| 1641 | + if (err) { |
---|
| 1642 | + if (err == -ENODEV) |
---|
| 1643 | + return 0; |
---|
| 1644 | + else |
---|
| 1645 | + return err; |
---|
| 1646 | + } |
---|
| 1647 | + |
---|
| 1648 | + if ((result & ASUS_WMI_DSTS_PRESENCE_BIT) && |
---|
| 1649 | + (result & ASUS_FAN_BOOST_MODES_MASK)) { |
---|
| 1650 | + asus->fan_boost_mode_available = true; |
---|
| 1651 | + asus->fan_boost_mode_mask = result & ASUS_FAN_BOOST_MODES_MASK; |
---|
| 1652 | + } |
---|
| 1653 | + |
---|
| 1654 | + return 0; |
---|
| 1655 | +} |
---|
| 1656 | + |
---|
| 1657 | +static int fan_boost_mode_write(struct asus_wmi *asus) |
---|
| 1658 | +{ |
---|
| 1659 | + int err; |
---|
| 1660 | + u8 value; |
---|
| 1661 | + u32 retval; |
---|
| 1662 | + |
---|
| 1663 | + value = asus->fan_boost_mode; |
---|
| 1664 | + |
---|
| 1665 | + pr_info("Set fan boost mode: %u\n", value); |
---|
| 1666 | + err = asus_wmi_set_devstate(ASUS_WMI_DEVID_FAN_BOOST_MODE, value, |
---|
| 1667 | + &retval); |
---|
| 1668 | + if (err) { |
---|
| 1669 | + pr_warn("Failed to set fan boost mode: %d\n", err); |
---|
| 1670 | + return err; |
---|
| 1671 | + } |
---|
| 1672 | + |
---|
| 1673 | + if (retval != 1) { |
---|
| 1674 | + pr_warn("Failed to set fan boost mode (retval): 0x%x\n", |
---|
| 1675 | + retval); |
---|
| 1676 | + return -EIO; |
---|
| 1677 | + } |
---|
| 1678 | + |
---|
| 1679 | + return 0; |
---|
| 1680 | +} |
---|
| 1681 | + |
---|
| 1682 | +static int fan_boost_mode_switch_next(struct asus_wmi *asus) |
---|
| 1683 | +{ |
---|
| 1684 | + u8 mask = asus->fan_boost_mode_mask; |
---|
| 1685 | + |
---|
| 1686 | + if (asus->fan_boost_mode == ASUS_FAN_BOOST_MODE_NORMAL) { |
---|
| 1687 | + if (mask & ASUS_FAN_BOOST_MODE_OVERBOOST_MASK) |
---|
| 1688 | + asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_OVERBOOST; |
---|
| 1689 | + else if (mask & ASUS_FAN_BOOST_MODE_SILENT_MASK) |
---|
| 1690 | + asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_SILENT; |
---|
| 1691 | + } else if (asus->fan_boost_mode == ASUS_FAN_BOOST_MODE_OVERBOOST) { |
---|
| 1692 | + if (mask & ASUS_FAN_BOOST_MODE_SILENT_MASK) |
---|
| 1693 | + asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_SILENT; |
---|
| 1694 | + else |
---|
| 1695 | + asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_NORMAL; |
---|
| 1696 | + } else { |
---|
| 1697 | + asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_NORMAL; |
---|
| 1698 | + } |
---|
| 1699 | + |
---|
| 1700 | + return fan_boost_mode_write(asus); |
---|
| 1701 | +} |
---|
| 1702 | + |
---|
| 1703 | +static ssize_t fan_boost_mode_show(struct device *dev, |
---|
| 1704 | + struct device_attribute *attr, char *buf) |
---|
| 1705 | +{ |
---|
| 1706 | + struct asus_wmi *asus = dev_get_drvdata(dev); |
---|
| 1707 | + |
---|
| 1708 | + return scnprintf(buf, PAGE_SIZE, "%d\n", asus->fan_boost_mode); |
---|
| 1709 | +} |
---|
| 1710 | + |
---|
| 1711 | +static ssize_t fan_boost_mode_store(struct device *dev, |
---|
| 1712 | + struct device_attribute *attr, |
---|
| 1713 | + const char *buf, size_t count) |
---|
| 1714 | +{ |
---|
| 1715 | + int result; |
---|
| 1716 | + u8 new_mode; |
---|
| 1717 | + struct asus_wmi *asus = dev_get_drvdata(dev); |
---|
| 1718 | + u8 mask = asus->fan_boost_mode_mask; |
---|
| 1719 | + |
---|
| 1720 | + result = kstrtou8(buf, 10, &new_mode); |
---|
| 1721 | + if (result < 0) { |
---|
| 1722 | + pr_warn("Trying to store invalid value\n"); |
---|
| 1723 | + return result; |
---|
| 1724 | + } |
---|
| 1725 | + |
---|
| 1726 | + if (new_mode == ASUS_FAN_BOOST_MODE_OVERBOOST) { |
---|
| 1727 | + if (!(mask & ASUS_FAN_BOOST_MODE_OVERBOOST_MASK)) |
---|
| 1728 | + return -EINVAL; |
---|
| 1729 | + } else if (new_mode == ASUS_FAN_BOOST_MODE_SILENT) { |
---|
| 1730 | + if (!(mask & ASUS_FAN_BOOST_MODE_SILENT_MASK)) |
---|
| 1731 | + return -EINVAL; |
---|
| 1732 | + } else if (new_mode != ASUS_FAN_BOOST_MODE_NORMAL) { |
---|
| 1733 | + return -EINVAL; |
---|
| 1734 | + } |
---|
| 1735 | + |
---|
| 1736 | + asus->fan_boost_mode = new_mode; |
---|
| 1737 | + fan_boost_mode_write(asus); |
---|
| 1738 | + |
---|
| 1739 | + return count; |
---|
| 1740 | +} |
---|
| 1741 | + |
---|
| 1742 | +// Fan boost mode: 0 - normal, 1 - overboost, 2 - silent |
---|
| 1743 | +static DEVICE_ATTR_RW(fan_boost_mode); |
---|
| 1744 | + |
---|
| 1745 | +/* Throttle thermal policy ****************************************************/ |
---|
| 1746 | + |
---|
| 1747 | +static int throttle_thermal_policy_check_present(struct asus_wmi *asus) |
---|
| 1748 | +{ |
---|
| 1749 | + u32 result; |
---|
| 1750 | + int err; |
---|
| 1751 | + |
---|
| 1752 | + asus->throttle_thermal_policy_available = false; |
---|
| 1753 | + |
---|
| 1754 | + err = asus_wmi_get_devstate(asus, |
---|
| 1755 | + ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY, |
---|
| 1756 | + &result); |
---|
| 1757 | + if (err) { |
---|
| 1758 | + if (err == -ENODEV) |
---|
| 1759 | + return 0; |
---|
| 1760 | + return err; |
---|
| 1761 | + } |
---|
| 1762 | + |
---|
| 1763 | + if (result & ASUS_WMI_DSTS_PRESENCE_BIT) |
---|
| 1764 | + asus->throttle_thermal_policy_available = true; |
---|
| 1765 | + |
---|
| 1766 | + return 0; |
---|
| 1767 | +} |
---|
| 1768 | + |
---|
| 1769 | +static int throttle_thermal_policy_write(struct asus_wmi *asus) |
---|
| 1770 | +{ |
---|
| 1771 | + int err; |
---|
| 1772 | + u8 value; |
---|
| 1773 | + u32 retval; |
---|
| 1774 | + |
---|
| 1775 | + value = asus->throttle_thermal_policy_mode; |
---|
| 1776 | + |
---|
| 1777 | + err = asus_wmi_set_devstate(ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY, |
---|
| 1778 | + value, &retval); |
---|
| 1779 | + if (err) { |
---|
| 1780 | + pr_warn("Failed to set throttle thermal policy: %d\n", err); |
---|
| 1781 | + return err; |
---|
| 1782 | + } |
---|
| 1783 | + |
---|
| 1784 | + if (retval != 1) { |
---|
| 1785 | + pr_warn("Failed to set throttle thermal policy (retval): 0x%x\n", |
---|
| 1786 | + retval); |
---|
| 1787 | + return -EIO; |
---|
| 1788 | + } |
---|
| 1789 | + |
---|
| 1790 | + return 0; |
---|
| 1791 | +} |
---|
| 1792 | + |
---|
| 1793 | +static int throttle_thermal_policy_set_default(struct asus_wmi *asus) |
---|
| 1794 | +{ |
---|
| 1795 | + if (!asus->throttle_thermal_policy_available) |
---|
| 1796 | + return 0; |
---|
| 1797 | + |
---|
| 1798 | + asus->throttle_thermal_policy_mode = ASUS_THROTTLE_THERMAL_POLICY_DEFAULT; |
---|
| 1799 | + return throttle_thermal_policy_write(asus); |
---|
| 1800 | +} |
---|
| 1801 | + |
---|
| 1802 | +static int throttle_thermal_policy_switch_next(struct asus_wmi *asus) |
---|
| 1803 | +{ |
---|
| 1804 | + u8 new_mode = asus->throttle_thermal_policy_mode + 1; |
---|
| 1805 | + |
---|
| 1806 | + if (new_mode > ASUS_THROTTLE_THERMAL_POLICY_SILENT) |
---|
| 1807 | + new_mode = ASUS_THROTTLE_THERMAL_POLICY_DEFAULT; |
---|
| 1808 | + |
---|
| 1809 | + asus->throttle_thermal_policy_mode = new_mode; |
---|
| 1810 | + return throttle_thermal_policy_write(asus); |
---|
| 1811 | +} |
---|
| 1812 | + |
---|
| 1813 | +static ssize_t throttle_thermal_policy_show(struct device *dev, |
---|
| 1814 | + struct device_attribute *attr, char *buf) |
---|
| 1815 | +{ |
---|
| 1816 | + struct asus_wmi *asus = dev_get_drvdata(dev); |
---|
| 1817 | + u8 mode = asus->throttle_thermal_policy_mode; |
---|
| 1818 | + |
---|
| 1819 | + return scnprintf(buf, PAGE_SIZE, "%d\n", mode); |
---|
| 1820 | +} |
---|
| 1821 | + |
---|
| 1822 | +static ssize_t throttle_thermal_policy_store(struct device *dev, |
---|
| 1823 | + struct device_attribute *attr, |
---|
| 1824 | + const char *buf, size_t count) |
---|
| 1825 | +{ |
---|
| 1826 | + int result; |
---|
| 1827 | + u8 new_mode; |
---|
| 1828 | + struct asus_wmi *asus = dev_get_drvdata(dev); |
---|
| 1829 | + |
---|
| 1830 | + result = kstrtou8(buf, 10, &new_mode); |
---|
| 1831 | + if (result < 0) |
---|
| 1832 | + return result; |
---|
| 1833 | + |
---|
| 1834 | + if (new_mode > ASUS_THROTTLE_THERMAL_POLICY_SILENT) |
---|
| 1835 | + return -EINVAL; |
---|
| 1836 | + |
---|
| 1837 | + asus->throttle_thermal_policy_mode = new_mode; |
---|
| 1838 | + throttle_thermal_policy_write(asus); |
---|
| 1839 | + |
---|
| 1840 | + return count; |
---|
| 1841 | +} |
---|
| 1842 | + |
---|
| 1843 | +// Throttle thermal policy: 0 - default, 1 - overboost, 2 - silent |
---|
| 1844 | +static DEVICE_ATTR_RW(throttle_thermal_policy); |
---|
| 1845 | + |
---|
| 1846 | +/* Backlight ******************************************************************/ |
---|
| 1847 | + |
---|
1535 | 1848 | static int read_backlight_power(struct asus_wmi *asus) |
---|
1536 | 1849 | { |
---|
1537 | 1850 | int ret; |
---|
| 1851 | + |
---|
1538 | 1852 | if (asus->driver->quirks->store_backlight_power) |
---|
1539 | 1853 | ret = !asus->driver->panel_power; |
---|
1540 | 1854 | else |
---|
.. | .. |
---|
1553 | 1867 | int err; |
---|
1554 | 1868 | |
---|
1555 | 1869 | err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_BRIGHTNESS, &retval); |
---|
1556 | | - |
---|
1557 | 1870 | if (err < 0) |
---|
1558 | 1871 | return err; |
---|
1559 | 1872 | |
---|
.. | .. |
---|
1573 | 1886 | int err; |
---|
1574 | 1887 | |
---|
1575 | 1888 | err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_BRIGHTNESS, &retval); |
---|
1576 | | - |
---|
1577 | 1889 | if (err < 0) |
---|
1578 | 1890 | return err; |
---|
1579 | 1891 | |
---|
.. | .. |
---|
1663 | 1975 | return max; |
---|
1664 | 1976 | |
---|
1665 | 1977 | power = read_backlight_power(asus); |
---|
1666 | | - |
---|
1667 | 1978 | if (power == -ENODEV) |
---|
1668 | 1979 | power = FB_BLANK_UNBLANK; |
---|
1669 | 1980 | else if (power < 0) |
---|
.. | .. |
---|
1713 | 2024 | return 0; |
---|
1714 | 2025 | } |
---|
1715 | 2026 | |
---|
1716 | | -static void asus_wmi_notify(u32 value, void *context) |
---|
| 2027 | +/* Fn-lock ********************************************************************/ |
---|
| 2028 | + |
---|
| 2029 | +static bool asus_wmi_has_fnlock_key(struct asus_wmi *asus) |
---|
1717 | 2030 | { |
---|
1718 | | - struct asus_wmi *asus = context; |
---|
| 2031 | + u32 result; |
---|
| 2032 | + |
---|
| 2033 | + asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FNLOCK, &result); |
---|
| 2034 | + |
---|
| 2035 | + return (result & ASUS_WMI_DSTS_PRESENCE_BIT) && |
---|
| 2036 | + !(result & ASUS_WMI_FNLOCK_BIOS_DISABLED); |
---|
| 2037 | +} |
---|
| 2038 | + |
---|
| 2039 | +static void asus_wmi_fnlock_update(struct asus_wmi *asus) |
---|
| 2040 | +{ |
---|
| 2041 | + int mode = asus->fnlock_locked; |
---|
| 2042 | + |
---|
| 2043 | + asus_wmi_set_devstate(ASUS_WMI_DEVID_FNLOCK, mode, NULL); |
---|
| 2044 | +} |
---|
| 2045 | + |
---|
| 2046 | +/* WMI events *****************************************************************/ |
---|
| 2047 | + |
---|
| 2048 | +static int asus_wmi_get_event_code(u32 value) |
---|
| 2049 | +{ |
---|
1719 | 2050 | struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; |
---|
1720 | 2051 | union acpi_object *obj; |
---|
1721 | 2052 | acpi_status status; |
---|
1722 | 2053 | int code; |
---|
1723 | | - int orig_code; |
---|
1724 | | - unsigned int key_value = 1; |
---|
1725 | | - bool autorelease = 1; |
---|
1726 | 2054 | |
---|
1727 | 2055 | status = wmi_get_event_data(value, &response); |
---|
1728 | | - if (status != AE_OK) { |
---|
1729 | | - pr_err("bad event status 0x%x\n", status); |
---|
1730 | | - return; |
---|
| 2056 | + if (ACPI_FAILURE(status)) { |
---|
| 2057 | + pr_warn("Failed to get WMI notify code: %s\n", |
---|
| 2058 | + acpi_format_exception(status)); |
---|
| 2059 | + return -EIO; |
---|
1731 | 2060 | } |
---|
1732 | 2061 | |
---|
1733 | 2062 | obj = (union acpi_object *)response.pointer; |
---|
1734 | 2063 | |
---|
1735 | | - if (!obj || obj->type != ACPI_TYPE_INTEGER) |
---|
1736 | | - goto exit; |
---|
| 2064 | + if (obj && obj->type == ACPI_TYPE_INTEGER) |
---|
| 2065 | + code = (int)(obj->integer.value & WMI_EVENT_MASK); |
---|
| 2066 | + else |
---|
| 2067 | + code = -EIO; |
---|
1737 | 2068 | |
---|
1738 | | - code = obj->integer.value; |
---|
| 2069 | + kfree(obj); |
---|
| 2070 | + return code; |
---|
| 2071 | +} |
---|
| 2072 | + |
---|
| 2073 | +static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus) |
---|
| 2074 | +{ |
---|
| 2075 | + unsigned int key_value = 1; |
---|
| 2076 | + bool autorelease = 1; |
---|
| 2077 | + int result, orig_code; |
---|
| 2078 | + |
---|
1739 | 2079 | orig_code = code; |
---|
1740 | 2080 | |
---|
1741 | 2081 | if (asus->driver->key_filter) { |
---|
1742 | 2082 | asus->driver->key_filter(asus->driver, &code, &key_value, |
---|
1743 | 2083 | &autorelease); |
---|
1744 | 2084 | if (code == ASUS_WMI_KEY_IGNORE) |
---|
1745 | | - goto exit; |
---|
| 2085 | + return; |
---|
1746 | 2086 | } |
---|
1747 | 2087 | |
---|
1748 | 2088 | if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX) |
---|
1749 | 2089 | code = ASUS_WMI_BRN_UP; |
---|
1750 | | - else if (code >= NOTIFY_BRNDOWN_MIN && |
---|
1751 | | - code <= NOTIFY_BRNDOWN_MAX) |
---|
| 2090 | + else if (code >= NOTIFY_BRNDOWN_MIN && code <= NOTIFY_BRNDOWN_MAX) |
---|
1752 | 2091 | code = ASUS_WMI_BRN_DOWN; |
---|
1753 | 2092 | |
---|
1754 | 2093 | if (code == ASUS_WMI_BRN_DOWN || code == ASUS_WMI_BRN_UP) { |
---|
1755 | 2094 | if (acpi_video_get_backlight_type() == acpi_backlight_vendor) { |
---|
1756 | 2095 | asus_wmi_backlight_notify(asus, orig_code); |
---|
1757 | | - goto exit; |
---|
| 2096 | + return; |
---|
1758 | 2097 | } |
---|
1759 | 2098 | } |
---|
1760 | 2099 | |
---|
1761 | 2100 | if (code == NOTIFY_KBD_BRTUP) { |
---|
1762 | | - do_kbd_led_set(&asus->kbd_led, asus->kbd_led_wk + 1); |
---|
1763 | | - goto exit; |
---|
| 2101 | + kbd_led_set_by_kbd(asus, asus->kbd_led_wk + 1); |
---|
| 2102 | + return; |
---|
1764 | 2103 | } |
---|
1765 | 2104 | if (code == NOTIFY_KBD_BRTDWN) { |
---|
1766 | | - do_kbd_led_set(&asus->kbd_led, asus->kbd_led_wk - 1); |
---|
1767 | | - goto exit; |
---|
| 2105 | + kbd_led_set_by_kbd(asus, asus->kbd_led_wk - 1); |
---|
| 2106 | + return; |
---|
1768 | 2107 | } |
---|
1769 | 2108 | if (code == NOTIFY_KBD_BRTTOGGLE) { |
---|
1770 | 2109 | if (asus->kbd_led_wk == asus->kbd_led.max_brightness) |
---|
1771 | | - do_kbd_led_set(&asus->kbd_led, 0); |
---|
| 2110 | + kbd_led_set_by_kbd(asus, 0); |
---|
1772 | 2111 | else |
---|
1773 | | - do_kbd_led_set(&asus->kbd_led, asus->kbd_led_wk + 1); |
---|
1774 | | - goto exit; |
---|
| 2112 | + kbd_led_set_by_kbd(asus, asus->kbd_led_wk + 1); |
---|
| 2113 | + return; |
---|
1775 | 2114 | } |
---|
1776 | 2115 | |
---|
1777 | | - if (is_display_toggle(code) && |
---|
1778 | | - asus->driver->quirks->no_display_toggle) |
---|
1779 | | - goto exit; |
---|
| 2116 | + if (code == NOTIFY_FNLOCK_TOGGLE) { |
---|
| 2117 | + asus->fnlock_locked = !asus->fnlock_locked; |
---|
| 2118 | + asus_wmi_fnlock_update(asus); |
---|
| 2119 | + return; |
---|
| 2120 | + } |
---|
| 2121 | + |
---|
| 2122 | + if (asus->driver->quirks->use_kbd_dock_devid && code == NOTIFY_KBD_DOCK_CHANGE) { |
---|
| 2123 | + result = asus_wmi_get_devstate_simple(asus, |
---|
| 2124 | + ASUS_WMI_DEVID_KBD_DOCK); |
---|
| 2125 | + if (result >= 0) { |
---|
| 2126 | + input_report_switch(asus->inputdev, SW_TABLET_MODE, |
---|
| 2127 | + !result); |
---|
| 2128 | + input_sync(asus->inputdev); |
---|
| 2129 | + } |
---|
| 2130 | + return; |
---|
| 2131 | + } |
---|
| 2132 | + |
---|
| 2133 | + if (asus->fan_boost_mode_available && code == NOTIFY_KBD_FBM) { |
---|
| 2134 | + fan_boost_mode_switch_next(asus); |
---|
| 2135 | + return; |
---|
| 2136 | + } |
---|
| 2137 | + |
---|
| 2138 | + if (asus->throttle_thermal_policy_available && code == NOTIFY_KBD_TTP) { |
---|
| 2139 | + throttle_thermal_policy_switch_next(asus); |
---|
| 2140 | + return; |
---|
| 2141 | + } |
---|
| 2142 | + |
---|
| 2143 | + if (is_display_toggle(code) && asus->driver->quirks->no_display_toggle) |
---|
| 2144 | + return; |
---|
1780 | 2145 | |
---|
1781 | 2146 | if (!sparse_keymap_report_event(asus->inputdev, code, |
---|
1782 | 2147 | key_value, autorelease)) |
---|
1783 | 2148 | pr_info("Unknown key %x pressed\n", code); |
---|
1784 | | - |
---|
1785 | | -exit: |
---|
1786 | | - kfree(obj); |
---|
1787 | 2149 | } |
---|
1788 | 2150 | |
---|
1789 | | -/* |
---|
1790 | | - * Sys helpers |
---|
1791 | | - */ |
---|
1792 | | -static int parse_arg(const char *buf, unsigned long count, int *val) |
---|
| 2151 | +static void asus_wmi_notify(u32 value, void *context) |
---|
1793 | 2152 | { |
---|
1794 | | - if (!count) |
---|
1795 | | - return 0; |
---|
1796 | | - if (sscanf(buf, "%i", val) != 1) |
---|
1797 | | - return -EINVAL; |
---|
1798 | | - return count; |
---|
| 2153 | + struct asus_wmi *asus = context; |
---|
| 2154 | + int code; |
---|
| 2155 | + int i; |
---|
| 2156 | + |
---|
| 2157 | + for (i = 0; i < WMI_EVENT_QUEUE_SIZE + 1; i++) { |
---|
| 2158 | + code = asus_wmi_get_event_code(value); |
---|
| 2159 | + if (code < 0) { |
---|
| 2160 | + pr_warn("Failed to get notify code: %d\n", code); |
---|
| 2161 | + return; |
---|
| 2162 | + } |
---|
| 2163 | + |
---|
| 2164 | + if (code == WMI_EVENT_QUEUE_END || code == WMI_EVENT_MASK) |
---|
| 2165 | + return; |
---|
| 2166 | + |
---|
| 2167 | + asus_wmi_handle_event_code(code, asus); |
---|
| 2168 | + |
---|
| 2169 | + /* |
---|
| 2170 | + * Double check that queue is present: |
---|
| 2171 | + * ATK (with queue) uses 0xff, ASUSWMI (without) 0xd2. |
---|
| 2172 | + */ |
---|
| 2173 | + if (!asus->wmi_event_queue || value != WMI_EVENT_VALUE_ATK) |
---|
| 2174 | + return; |
---|
| 2175 | + } |
---|
| 2176 | + |
---|
| 2177 | + pr_warn("Failed to process event queue, last code: 0x%x\n", code); |
---|
1799 | 2178 | } |
---|
| 2179 | + |
---|
| 2180 | +static int asus_wmi_notify_queue_flush(struct asus_wmi *asus) |
---|
| 2181 | +{ |
---|
| 2182 | + int code; |
---|
| 2183 | + int i; |
---|
| 2184 | + |
---|
| 2185 | + for (i = 0; i < WMI_EVENT_QUEUE_SIZE + 1; i++) { |
---|
| 2186 | + code = asus_wmi_get_event_code(WMI_EVENT_VALUE_ATK); |
---|
| 2187 | + if (code < 0) { |
---|
| 2188 | + pr_warn("Failed to get event during flush: %d\n", code); |
---|
| 2189 | + return code; |
---|
| 2190 | + } |
---|
| 2191 | + |
---|
| 2192 | + if (code == WMI_EVENT_QUEUE_END || code == WMI_EVENT_MASK) |
---|
| 2193 | + return 0; |
---|
| 2194 | + } |
---|
| 2195 | + |
---|
| 2196 | + pr_warn("Failed to flush event queue\n"); |
---|
| 2197 | + return -EIO; |
---|
| 2198 | +} |
---|
| 2199 | + |
---|
| 2200 | +/* Sysfs **********************************************************************/ |
---|
1800 | 2201 | |
---|
1801 | 2202 | static ssize_t store_sys_wmi(struct asus_wmi *asus, int devid, |
---|
1802 | 2203 | const char *buf, size_t count) |
---|
1803 | 2204 | { |
---|
1804 | 2205 | u32 retval; |
---|
1805 | | - int rv, err, value; |
---|
| 2206 | + int err, value; |
---|
1806 | 2207 | |
---|
1807 | 2208 | value = asus_wmi_get_devstate_simple(asus, devid); |
---|
1808 | 2209 | if (value < 0) |
---|
1809 | 2210 | return value; |
---|
1810 | 2211 | |
---|
1811 | | - rv = parse_arg(buf, count, &value); |
---|
1812 | | - err = asus_wmi_set_devstate(devid, value, &retval); |
---|
| 2212 | + err = kstrtoint(buf, 0, &value); |
---|
| 2213 | + if (err) |
---|
| 2214 | + return err; |
---|
1813 | 2215 | |
---|
| 2216 | + err = asus_wmi_set_devstate(devid, value, &retval); |
---|
1814 | 2217 | if (err < 0) |
---|
1815 | 2218 | return err; |
---|
1816 | 2219 | |
---|
1817 | | - return rv; |
---|
| 2220 | + return count; |
---|
1818 | 2221 | } |
---|
1819 | 2222 | |
---|
1820 | 2223 | static ssize_t show_sys_wmi(struct asus_wmi *asus, int devid, char *buf) |
---|
.. | .. |
---|
1863 | 2266 | { |
---|
1864 | 2267 | int value, rv; |
---|
1865 | 2268 | |
---|
1866 | | - if (!count || sscanf(buf, "%i", &value) != 1) |
---|
1867 | | - return -EINVAL; |
---|
| 2269 | + rv = kstrtoint(buf, 0, &value); |
---|
| 2270 | + if (rv) |
---|
| 2271 | + return rv; |
---|
| 2272 | + |
---|
1868 | 2273 | if (value < 0 || value > 2) |
---|
1869 | 2274 | return -EINVAL; |
---|
1870 | 2275 | |
---|
.. | .. |
---|
1884 | 2289 | &dev_attr_touchpad.attr, |
---|
1885 | 2290 | &dev_attr_lid_resume.attr, |
---|
1886 | 2291 | &dev_attr_als_enable.attr, |
---|
| 2292 | + &dev_attr_fan_boost_mode.attr, |
---|
| 2293 | + &dev_attr_throttle_thermal_policy.attr, |
---|
1887 | 2294 | NULL |
---|
1888 | 2295 | }; |
---|
1889 | 2296 | |
---|
.. | .. |
---|
1905 | 2312 | devid = ASUS_WMI_DEVID_LID_RESUME; |
---|
1906 | 2313 | else if (attr == &dev_attr_als_enable.attr) |
---|
1907 | 2314 | devid = ASUS_WMI_DEVID_ALS_ENABLE; |
---|
| 2315 | + else if (attr == &dev_attr_fan_boost_mode.attr) |
---|
| 2316 | + ok = asus->fan_boost_mode_available; |
---|
| 2317 | + else if (attr == &dev_attr_throttle_thermal_policy.attr) |
---|
| 2318 | + ok = asus->throttle_thermal_policy_available; |
---|
1908 | 2319 | |
---|
1909 | 2320 | if (devid != -1) |
---|
1910 | 2321 | ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0); |
---|
.. | .. |
---|
1927 | 2338 | return sysfs_create_group(&device->dev.kobj, &platform_attribute_group); |
---|
1928 | 2339 | } |
---|
1929 | 2340 | |
---|
1930 | | -/* |
---|
1931 | | - * Platform device |
---|
1932 | | - */ |
---|
| 2341 | +/* Platform device ************************************************************/ |
---|
| 2342 | + |
---|
1933 | 2343 | static int asus_wmi_platform_init(struct asus_wmi *asus) |
---|
1934 | 2344 | { |
---|
| 2345 | + struct device *dev = &asus->platform_device->dev; |
---|
| 2346 | + char *wmi_uid; |
---|
1935 | 2347 | int rv; |
---|
1936 | 2348 | |
---|
1937 | 2349 | /* INIT enable hotkeys on some models */ |
---|
.. | .. |
---|
1961 | 2373 | * Note, on most Eeepc, there is no way to check if a method exist |
---|
1962 | 2374 | * or note, while on notebooks, they returns 0xFFFFFFFE on failure, |
---|
1963 | 2375 | * but once again, SPEC may probably be used for that kind of things. |
---|
| 2376 | + * |
---|
| 2377 | + * Additionally at least TUF Gaming series laptops return nothing for |
---|
| 2378 | + * unknown methods, so the detection in this way is not possible. |
---|
| 2379 | + * |
---|
| 2380 | + * There is strong indication that only ACPI WMI devices that have _UID |
---|
| 2381 | + * equal to "ASUSWMI" use DCTS whereas those with "ATK" use DSTS. |
---|
1964 | 2382 | */ |
---|
1965 | | - if (!asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS, 0, 0, NULL)) |
---|
| 2383 | + wmi_uid = wmi_get_acpi_device_uid(ASUS_WMI_MGMT_GUID); |
---|
| 2384 | + if (!wmi_uid) |
---|
| 2385 | + return -ENODEV; |
---|
| 2386 | + |
---|
| 2387 | + if (!strcmp(wmi_uid, ASUS_ACPI_UID_ASUSWMI)) { |
---|
| 2388 | + dev_info(dev, "Detected ASUSWMI, use DCTS\n"); |
---|
| 2389 | + asus->dsts_id = ASUS_WMI_METHODID_DCTS; |
---|
| 2390 | + } else { |
---|
| 2391 | + dev_info(dev, "Detected %s, not ASUSWMI, use DSTS\n", wmi_uid); |
---|
1966 | 2392 | asus->dsts_id = ASUS_WMI_METHODID_DSTS; |
---|
1967 | | - else |
---|
1968 | | - asus->dsts_id = ASUS_WMI_METHODID_DSTS2; |
---|
| 2393 | + } |
---|
| 2394 | + |
---|
| 2395 | + /* |
---|
| 2396 | + * Some devices can have multiple event codes stored in a queue before |
---|
| 2397 | + * the module load if it was unloaded intermittently after calling |
---|
| 2398 | + * the INIT method (enables event handling). The WMI notify handler is |
---|
| 2399 | + * expected to retrieve all event codes until a retrieved code equals |
---|
| 2400 | + * queue end marker (One or Ones). Old codes are flushed from the queue |
---|
| 2401 | + * upon module load. Not enabling this when it should be has minimal |
---|
| 2402 | + * visible impact so fall back if anything goes wrong. |
---|
| 2403 | + */ |
---|
| 2404 | + wmi_uid = wmi_get_acpi_device_uid(asus->driver->event_guid); |
---|
| 2405 | + if (wmi_uid && !strcmp(wmi_uid, ASUS_ACPI_UID_ATK)) { |
---|
| 2406 | + dev_info(dev, "Detected ATK, enable event queue\n"); |
---|
| 2407 | + |
---|
| 2408 | + if (!asus_wmi_notify_queue_flush(asus)) |
---|
| 2409 | + asus->wmi_event_queue = true; |
---|
| 2410 | + } |
---|
1969 | 2411 | |
---|
1970 | 2412 | /* CWAP allow to define the behavior of the Fn+F2 key, |
---|
1971 | 2413 | * this method doesn't seems to be present on Eee PCs */ |
---|
.. | .. |
---|
1973 | 2415 | asus_wmi_set_devstate(ASUS_WMI_DEVID_CWAP, |
---|
1974 | 2416 | asus->driver->quirks->wapf, NULL); |
---|
1975 | 2417 | |
---|
1976 | | - return asus_wmi_sysfs_init(asus->platform_device); |
---|
| 2418 | + return 0; |
---|
1977 | 2419 | } |
---|
1978 | 2420 | |
---|
1979 | | -static void asus_wmi_platform_exit(struct asus_wmi *asus) |
---|
1980 | | -{ |
---|
1981 | | - asus_wmi_sysfs_exit(asus->platform_device); |
---|
1982 | | -} |
---|
| 2421 | +/* debugfs ********************************************************************/ |
---|
1983 | 2422 | |
---|
1984 | | -/* |
---|
1985 | | - * debugfs |
---|
1986 | | - */ |
---|
1987 | 2423 | struct asus_wmi_debugfs_node { |
---|
1988 | 2424 | struct asus_wmi *asus; |
---|
1989 | 2425 | char *name; |
---|
.. | .. |
---|
1997 | 2433 | u32 retval = -1; |
---|
1998 | 2434 | |
---|
1999 | 2435 | err = asus_wmi_get_devstate(asus, asus->debug.dev_id, &retval); |
---|
2000 | | - |
---|
2001 | 2436 | if (err < 0) |
---|
2002 | 2437 | return err; |
---|
2003 | 2438 | |
---|
.. | .. |
---|
2014 | 2449 | |
---|
2015 | 2450 | err = asus_wmi_set_devstate(asus->debug.dev_id, asus->debug.ctrl_param, |
---|
2016 | 2451 | &retval); |
---|
2017 | | - |
---|
2018 | 2452 | if (err < 0) |
---|
2019 | 2453 | return err; |
---|
2020 | 2454 | |
---|
.. | .. |
---|
2084 | 2518 | debugfs_remove_recursive(asus->debug.root); |
---|
2085 | 2519 | } |
---|
2086 | 2520 | |
---|
2087 | | -static int asus_wmi_debugfs_init(struct asus_wmi *asus) |
---|
| 2521 | +static void asus_wmi_debugfs_init(struct asus_wmi *asus) |
---|
2088 | 2522 | { |
---|
2089 | | - struct dentry *dent; |
---|
2090 | 2523 | int i; |
---|
2091 | 2524 | |
---|
2092 | 2525 | asus->debug.root = debugfs_create_dir(asus->driver->name, NULL); |
---|
2093 | | - if (!asus->debug.root) { |
---|
2094 | | - pr_err("failed to create debugfs directory\n"); |
---|
2095 | | - goto error_debugfs; |
---|
2096 | | - } |
---|
2097 | 2526 | |
---|
2098 | | - dent = debugfs_create_x32("method_id", S_IRUGO | S_IWUSR, |
---|
2099 | | - asus->debug.root, &asus->debug.method_id); |
---|
2100 | | - if (!dent) |
---|
2101 | | - goto error_debugfs; |
---|
| 2527 | + debugfs_create_x32("method_id", S_IRUGO | S_IWUSR, asus->debug.root, |
---|
| 2528 | + &asus->debug.method_id); |
---|
2102 | 2529 | |
---|
2103 | | - dent = debugfs_create_x32("dev_id", S_IRUGO | S_IWUSR, |
---|
2104 | | - asus->debug.root, &asus->debug.dev_id); |
---|
2105 | | - if (!dent) |
---|
2106 | | - goto error_debugfs; |
---|
| 2530 | + debugfs_create_x32("dev_id", S_IRUGO | S_IWUSR, asus->debug.root, |
---|
| 2531 | + &asus->debug.dev_id); |
---|
2107 | 2532 | |
---|
2108 | | - dent = debugfs_create_x32("ctrl_param", S_IRUGO | S_IWUSR, |
---|
2109 | | - asus->debug.root, &asus->debug.ctrl_param); |
---|
2110 | | - if (!dent) |
---|
2111 | | - goto error_debugfs; |
---|
| 2533 | + debugfs_create_x32("ctrl_param", S_IRUGO | S_IWUSR, asus->debug.root, |
---|
| 2534 | + &asus->debug.ctrl_param); |
---|
2112 | 2535 | |
---|
2113 | 2536 | for (i = 0; i < ARRAY_SIZE(asus_wmi_debug_files); i++) { |
---|
2114 | 2537 | struct asus_wmi_debugfs_node *node = &asus_wmi_debug_files[i]; |
---|
2115 | 2538 | |
---|
2116 | 2539 | node->asus = asus; |
---|
2117 | | - dent = debugfs_create_file(node->name, S_IFREG | S_IRUGO, |
---|
2118 | | - asus->debug.root, node, |
---|
2119 | | - &asus_wmi_debugfs_io_ops); |
---|
2120 | | - if (!dent) { |
---|
2121 | | - pr_err("failed to create debug file: %s\n", node->name); |
---|
2122 | | - goto error_debugfs; |
---|
2123 | | - } |
---|
| 2540 | + debugfs_create_file(node->name, S_IFREG | S_IRUGO, |
---|
| 2541 | + asus->debug.root, node, |
---|
| 2542 | + &asus_wmi_debugfs_io_ops); |
---|
2124 | 2543 | } |
---|
2125 | | - |
---|
2126 | | - return 0; |
---|
2127 | | - |
---|
2128 | | -error_debugfs: |
---|
2129 | | - asus_wmi_debugfs_exit(asus); |
---|
2130 | | - return -ENOMEM; |
---|
2131 | 2544 | } |
---|
2132 | 2545 | |
---|
2133 | | -static int asus_wmi_fan_init(struct asus_wmi *asus) |
---|
2134 | | -{ |
---|
2135 | | - int status; |
---|
| 2546 | +/* Init / exit ****************************************************************/ |
---|
2136 | 2547 | |
---|
2137 | | - asus->asus_hwmon_pwm = -1; |
---|
2138 | | - asus->asus_hwmon_num_fans = -1; |
---|
2139 | | - asus->asus_hwmon_fan_manual_mode = false; |
---|
2140 | | - |
---|
2141 | | - status = asus_hwmon_get_fan_number(asus, &asus->asus_hwmon_num_fans); |
---|
2142 | | - if (status) { |
---|
2143 | | - asus->asus_hwmon_num_fans = 0; |
---|
2144 | | - pr_warn("Could not determine number of fans: %d\n", status); |
---|
2145 | | - return -ENXIO; |
---|
2146 | | - } |
---|
2147 | | - |
---|
2148 | | - pr_info("Number of fans: %d\n", asus->asus_hwmon_num_fans); |
---|
2149 | | - return 0; |
---|
2150 | | -} |
---|
2151 | | - |
---|
2152 | | -/* |
---|
2153 | | - * WMI Driver |
---|
2154 | | - */ |
---|
2155 | 2548 | static int asus_wmi_add(struct platform_device *pdev) |
---|
2156 | 2549 | { |
---|
2157 | 2550 | struct platform_driver *pdrv = to_platform_driver(pdev->dev.driver); |
---|
.. | .. |
---|
2178 | 2571 | if (err) |
---|
2179 | 2572 | goto fail_platform; |
---|
2180 | 2573 | |
---|
| 2574 | + err = fan_boost_mode_check_present(asus); |
---|
| 2575 | + if (err) |
---|
| 2576 | + goto fail_fan_boost_mode; |
---|
| 2577 | + |
---|
| 2578 | + err = throttle_thermal_policy_check_present(asus); |
---|
| 2579 | + if (err) |
---|
| 2580 | + goto fail_throttle_thermal_policy; |
---|
| 2581 | + else |
---|
| 2582 | + throttle_thermal_policy_set_default(asus); |
---|
| 2583 | + |
---|
| 2584 | + err = asus_wmi_sysfs_init(asus->platform_device); |
---|
| 2585 | + if (err) |
---|
| 2586 | + goto fail_sysfs; |
---|
| 2587 | + |
---|
2181 | 2588 | err = asus_wmi_input_init(asus); |
---|
2182 | 2589 | if (err) |
---|
2183 | 2590 | goto fail_input; |
---|
2184 | 2591 | |
---|
2185 | 2592 | err = asus_wmi_fan_init(asus); /* probably no problems on error */ |
---|
2186 | | - asus_hwmon_fan_set_auto(asus); |
---|
2187 | 2593 | |
---|
2188 | 2594 | err = asus_wmi_hwmon_init(asus); |
---|
2189 | 2595 | if (err) |
---|
.. | .. |
---|
2228 | 2634 | } else if (asus->driver->quirks->wmi_backlight_set_devstate) |
---|
2229 | 2635 | err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BACKLIGHT, 2, NULL); |
---|
2230 | 2636 | |
---|
| 2637 | + if (asus_wmi_has_fnlock_key(asus)) { |
---|
| 2638 | + asus->fnlock_locked = true; |
---|
| 2639 | + asus_wmi_fnlock_update(asus); |
---|
| 2640 | + } |
---|
| 2641 | + |
---|
2231 | 2642 | status = wmi_install_notify_handler(asus->driver->event_guid, |
---|
2232 | 2643 | asus_wmi_notify, asus); |
---|
2233 | 2644 | if (ACPI_FAILURE(status)) { |
---|
.. | .. |
---|
2236 | 2647 | goto fail_wmi_handler; |
---|
2237 | 2648 | } |
---|
2238 | 2649 | |
---|
2239 | | - err = asus_wmi_debugfs_init(asus); |
---|
2240 | | - if (err) |
---|
2241 | | - goto fail_debugfs; |
---|
| 2650 | + asus_wmi_battery_init(asus); |
---|
| 2651 | + |
---|
| 2652 | + asus_wmi_debugfs_init(asus); |
---|
2242 | 2653 | |
---|
2243 | 2654 | return 0; |
---|
2244 | 2655 | |
---|
2245 | | -fail_debugfs: |
---|
2246 | | - wmi_remove_notify_handler(asus->driver->event_guid); |
---|
2247 | 2656 | fail_wmi_handler: |
---|
2248 | 2657 | asus_wmi_backlight_exit(asus); |
---|
2249 | 2658 | fail_backlight: |
---|
.. | .. |
---|
2254 | 2663 | fail_hwmon: |
---|
2255 | 2664 | asus_wmi_input_exit(asus); |
---|
2256 | 2665 | fail_input: |
---|
2257 | | - asus_wmi_platform_exit(asus); |
---|
| 2666 | + asus_wmi_sysfs_exit(asus->platform_device); |
---|
| 2667 | +fail_sysfs: |
---|
| 2668 | +fail_throttle_thermal_policy: |
---|
| 2669 | +fail_fan_boost_mode: |
---|
2258 | 2670 | fail_platform: |
---|
2259 | 2671 | kfree(asus); |
---|
2260 | 2672 | return err; |
---|
.. | .. |
---|
2271 | 2683 | asus_wmi_led_exit(asus); |
---|
2272 | 2684 | asus_wmi_rfkill_exit(asus); |
---|
2273 | 2685 | asus_wmi_debugfs_exit(asus); |
---|
2274 | | - asus_wmi_platform_exit(asus); |
---|
2275 | | - asus_hwmon_fan_set_auto(asus); |
---|
| 2686 | + asus_wmi_sysfs_exit(asus->platform_device); |
---|
| 2687 | + asus_fan_set_auto(asus); |
---|
| 2688 | + asus_wmi_battery_exit(asus); |
---|
2276 | 2689 | |
---|
2277 | 2690 | kfree(asus); |
---|
2278 | 2691 | return 0; |
---|
2279 | 2692 | } |
---|
2280 | 2693 | |
---|
2281 | | -/* |
---|
2282 | | - * Platform driver - hibernate/resume callbacks |
---|
2283 | | - */ |
---|
| 2694 | +/* Platform driver - hibernate/resume callbacks *******************************/ |
---|
| 2695 | + |
---|
2284 | 2696 | static int asus_hotk_thaw(struct device *device) |
---|
2285 | 2697 | { |
---|
2286 | 2698 | struct asus_wmi *asus = dev_get_drvdata(device); |
---|
.. | .. |
---|
2305 | 2717 | struct asus_wmi *asus = dev_get_drvdata(device); |
---|
2306 | 2718 | |
---|
2307 | 2719 | if (!IS_ERR_OR_NULL(asus->kbd_led.dev)) |
---|
2308 | | - queue_work(asus->led_workqueue, &asus->kbd_led_work); |
---|
| 2720 | + kbd_led_update(asus); |
---|
2309 | 2721 | |
---|
| 2722 | + if (asus_wmi_has_fnlock_key(asus)) |
---|
| 2723 | + asus_wmi_fnlock_update(asus); |
---|
2310 | 2724 | return 0; |
---|
2311 | 2725 | } |
---|
2312 | 2726 | |
---|
.. | .. |
---|
2341 | 2755 | rfkill_set_sw_state(asus->uwb.rfkill, bl); |
---|
2342 | 2756 | } |
---|
2343 | 2757 | if (!IS_ERR_OR_NULL(asus->kbd_led.dev)) |
---|
2344 | | - queue_work(asus->led_workqueue, &asus->kbd_led_work); |
---|
| 2758 | + kbd_led_update(asus); |
---|
2345 | 2759 | |
---|
| 2760 | + if (asus_wmi_has_fnlock_key(asus)) |
---|
| 2761 | + asus_wmi_fnlock_update(asus); |
---|
2346 | 2762 | return 0; |
---|
2347 | 2763 | } |
---|
2348 | 2764 | |
---|
.. | .. |
---|
2352 | 2768 | .resume = asus_hotk_resume, |
---|
2353 | 2769 | }; |
---|
2354 | 2770 | |
---|
| 2771 | +/* Registration ***************************************************************/ |
---|
| 2772 | + |
---|
2355 | 2773 | static int asus_wmi_probe(struct platform_device *pdev) |
---|
2356 | 2774 | { |
---|
2357 | 2775 | struct platform_driver *pdrv = to_platform_driver(pdev->dev.driver); |
---|
.. | .. |
---|
2359 | 2777 | int ret; |
---|
2360 | 2778 | |
---|
2361 | 2779 | if (!wmi_has_guid(ASUS_WMI_MGMT_GUID)) { |
---|
2362 | | - pr_warn("Management GUID not found\n"); |
---|
| 2780 | + pr_warn("ASUS Management GUID not found\n"); |
---|
2363 | 2781 | return -ENODEV; |
---|
2364 | 2782 | } |
---|
2365 | 2783 | |
---|
2366 | 2784 | if (wdrv->event_guid && !wmi_has_guid(wdrv->event_guid)) { |
---|
2367 | | - pr_warn("Event GUID not found\n"); |
---|
| 2785 | + pr_warn("ASUS Event GUID not found\n"); |
---|
2368 | 2786 | return -ENODEV; |
---|
2369 | 2787 | } |
---|
2370 | 2788 | |
---|
.. | .. |
---|
2414 | 2832 | |
---|
2415 | 2833 | static int __init asus_wmi_init(void) |
---|
2416 | 2834 | { |
---|
2417 | | - if (!wmi_has_guid(ASUS_WMI_MGMT_GUID)) { |
---|
2418 | | - pr_info("Asus Management GUID not found\n"); |
---|
2419 | | - return -ENODEV; |
---|
2420 | | - } |
---|
2421 | | - |
---|
2422 | 2835 | pr_info("ASUS WMI generic driver loaded\n"); |
---|
2423 | 2836 | return 0; |
---|
2424 | 2837 | } |
---|