aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/platform/x86')
-rw-r--r--drivers/platform/x86/Kconfig11
-rw-r--r--drivers/platform/x86/Makefile1
-rw-r--r--drivers/platform/x86/asus-laptop.c5
-rw-r--r--drivers/platform/x86/chromeos_laptop.c408
-rw-r--r--drivers/platform/x86/dell-laptop.c288
-rw-r--r--drivers/platform/x86/dell-wmi.c7
-rw-r--r--drivers/platform/x86/eeepc-laptop.c4
-rw-r--r--drivers/platform/x86/hp-wmi.c14
-rw-r--r--drivers/platform/x86/ideapad-laptop.c4
-rw-r--r--drivers/platform/x86/intel_mid_powerbtn.c4
-rw-r--r--drivers/platform/x86/intel_scu_ipc.c117
-rw-r--r--drivers/platform/x86/panasonic-laptop.c5
-rw-r--r--drivers/platform/x86/sony-laptop.c47
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c8
-rw-r--r--drivers/platform/x86/topstar-laptop.c4
-rw-r--r--drivers/platform/x86/toshiba_acpi.c4
-rw-r--r--drivers/platform/x86/wmi.c6
17 files changed, 440 insertions, 497 deletions
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index b51a7460cc49..d9dcd37b5a52 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -79,17 +79,6 @@ config ASUS_LAPTOP
79 79
80 If you have an ACPI-compatible ASUS laptop, say Y or M here. 80 If you have an ACPI-compatible ASUS laptop, say Y or M here.
81 81
82config CHROMEOS_LAPTOP
83 tristate "Chrome OS Laptop"
84 depends on I2C
85 depends on DMI
86 ---help---
87 This driver instantiates i2c and smbus devices such as
88 light sensors and touchpads.
89
90 If you have a supported Chromebook, choose Y or M here.
91 The module will be called chromeos_laptop.
92
93config DELL_LAPTOP 82config DELL_LAPTOP
94 tristate "Dell Laptop Extras" 83 tristate "Dell Laptop Extras"
95 depends on X86 84 depends on X86
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 5dbe19324351..f0e6aa407ffb 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -50,7 +50,6 @@ obj-$(CONFIG_INTEL_MID_POWER_BUTTON) += intel_mid_powerbtn.o
50obj-$(CONFIG_INTEL_OAKTRAIL) += intel_oaktrail.o 50obj-$(CONFIG_INTEL_OAKTRAIL) += intel_oaktrail.o
51obj-$(CONFIG_SAMSUNG_Q10) += samsung-q10.o 51obj-$(CONFIG_SAMSUNG_Q10) += samsung-q10.o
52obj-$(CONFIG_APPLE_GMUX) += apple-gmux.o 52obj-$(CONFIG_APPLE_GMUX) += apple-gmux.o
53obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o
54obj-$(CONFIG_INTEL_RST) += intel-rst.o 53obj-$(CONFIG_INTEL_RST) += intel-rst.o
55obj-$(CONFIG_INTEL_SMARTCONNECT) += intel-smartconnect.o 54obj-$(CONFIG_INTEL_SMARTCONNECT) += intel-smartconnect.o
56 55
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 0e9c169b42f8..594323a926cf 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -1494,10 +1494,9 @@ static int asus_input_init(struct asus_laptop *asus)
1494 int error; 1494 int error;
1495 1495
1496 input = input_allocate_device(); 1496 input = input_allocate_device();
1497 if (!input) { 1497 if (!input)
1498 pr_warn("Unable to allocate input device\n");
1499 return -ENOMEM; 1498 return -ENOMEM;
1500 } 1499
1501 input->name = "Asus Laptop extra buttons"; 1500 input->name = "Asus Laptop extra buttons";
1502 input->phys = ASUS_LAPTOP_FILE "/input0"; 1501 input->phys = ASUS_LAPTOP_FILE "/input0";
1503 input->id.bustype = BUS_HOST; 1502 input->id.bustype = BUS_HOST;
diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
deleted file mode 100644
index 3e5b4497a1d0..000000000000
--- a/drivers/platform/x86/chromeos_laptop.c
+++ /dev/null
@@ -1,408 +0,0 @@
1/*
2 * chromeos_laptop.c - Driver to instantiate Chromebook i2c/smbus devices.
3 *
4 * Author : Benson Leung <bleung@chromium.org>
5 *
6 * Copyright (C) 2012 Google, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#include <linux/dmi.h>
25#include <linux/i2c.h>
26#include <linux/i2c/atmel_mxt_ts.h>
27#include <linux/input.h>
28#include <linux/interrupt.h>
29#include <linux/module.h>
30
31#define ATMEL_TP_I2C_ADDR 0x4b
32#define ATMEL_TP_I2C_BL_ADDR 0x25
33#define ATMEL_TS_I2C_ADDR 0x4a
34#define ATMEL_TS_I2C_BL_ADDR 0x26
35#define CYAPA_TP_I2C_ADDR 0x67
36#define ISL_ALS_I2C_ADDR 0x44
37#define TAOS_ALS_I2C_ADDR 0x29
38
39static struct i2c_client *als;
40static struct i2c_client *tp;
41static struct i2c_client *ts;
42
43const char *i2c_adapter_names[] = {
44 "SMBus I801 adapter",
45 "i915 gmbus vga",
46 "i915 gmbus panel",
47};
48
49/* Keep this enum consistent with i2c_adapter_names */
50enum i2c_adapter_type {
51 I2C_ADAPTER_SMBUS = 0,
52 I2C_ADAPTER_VGADDC,
53 I2C_ADAPTER_PANEL,
54};
55
56static struct i2c_board_info __initdata cyapa_device = {
57 I2C_BOARD_INFO("cyapa", CYAPA_TP_I2C_ADDR),
58 .flags = I2C_CLIENT_WAKE,
59};
60
61static struct i2c_board_info __initdata isl_als_device = {
62 I2C_BOARD_INFO("isl29018", ISL_ALS_I2C_ADDR),
63};
64
65static struct i2c_board_info __initdata tsl2583_als_device = {
66 I2C_BOARD_INFO("tsl2583", TAOS_ALS_I2C_ADDR),
67};
68
69static struct i2c_board_info __initdata tsl2563_als_device = {
70 I2C_BOARD_INFO("tsl2563", TAOS_ALS_I2C_ADDR),
71};
72
73static struct mxt_platform_data atmel_224s_tp_platform_data = {
74 .x_line = 18,
75 .y_line = 12,
76 .x_size = 102*20,
77 .y_size = 68*20,
78 .blen = 0x80, /* Gain setting is in upper 4 bits */
79 .threshold = 0x32,
80 .voltage = 0, /* 3.3V */
81 .orient = MXT_VERTICAL_FLIP,
82 .irqflags = IRQF_TRIGGER_FALLING,
83 .is_tp = true,
84 .key_map = { KEY_RESERVED,
85 KEY_RESERVED,
86 KEY_RESERVED,
87 BTN_LEFT },
88 .config = NULL,
89 .config_length = 0,
90};
91
92static struct i2c_board_info __initdata atmel_224s_tp_device = {
93 I2C_BOARD_INFO("atmel_mxt_tp", ATMEL_TP_I2C_ADDR),
94 .platform_data = &atmel_224s_tp_platform_data,
95 .flags = I2C_CLIENT_WAKE,
96};
97
98static struct mxt_platform_data atmel_1664s_platform_data = {
99 .x_line = 32,
100 .y_line = 50,
101 .x_size = 1700,
102 .y_size = 2560,
103 .blen = 0x89, /* Gain setting is in upper 4 bits */
104 .threshold = 0x28,
105 .voltage = 0, /* 3.3V */
106 .orient = MXT_ROTATED_90_COUNTER,
107 .irqflags = IRQF_TRIGGER_FALLING,
108 .is_tp = false,
109 .config = NULL,
110 .config_length = 0,
111};
112
113static struct i2c_board_info __initdata atmel_1664s_device = {
114 I2C_BOARD_INFO("atmel_mxt_ts", ATMEL_TS_I2C_ADDR),
115 .platform_data = &atmel_1664s_platform_data,
116 .flags = I2C_CLIENT_WAKE,
117};
118
119static struct i2c_client __init *__add_probed_i2c_device(
120 const char *name,
121 int bus,
122 struct i2c_board_info *info,
123 const unsigned short *addrs)
124{
125 const struct dmi_device *dmi_dev;
126 const struct dmi_dev_onboard *dev_data;
127 struct i2c_adapter *adapter;
128 struct i2c_client *client;
129
130 if (bus < 0)
131 return NULL;
132 /*
133 * If a name is specified, look for irq platform information stashed
134 * in DMI_DEV_TYPE_DEV_ONBOARD by the Chrome OS custom system firmware.
135 */
136 if (name) {
137 dmi_dev = dmi_find_device(DMI_DEV_TYPE_DEV_ONBOARD, name, NULL);
138 if (!dmi_dev) {
139 pr_err("%s failed to dmi find device %s.\n",
140 __func__,
141 name);
142 return NULL;
143 }
144 dev_data = (struct dmi_dev_onboard *)dmi_dev->device_data;
145 if (!dev_data) {
146 pr_err("%s failed to get data from dmi for %s.\n",
147 __func__, name);
148 return NULL;
149 }
150 info->irq = dev_data->instance;
151 }
152
153 adapter = i2c_get_adapter(bus);
154 if (!adapter) {
155 pr_err("%s failed to get i2c adapter %d.\n", __func__, bus);
156 return NULL;
157 }
158
159 /* add the i2c device */
160 client = i2c_new_probed_device(adapter, info, addrs, NULL);
161 if (!client)
162 pr_err("%s failed to register device %d-%02x\n",
163 __func__, bus, info->addr);
164 else
165 pr_debug("%s added i2c device %d-%02x\n",
166 __func__, bus, info->addr);
167
168 i2c_put_adapter(adapter);
169 return client;
170}
171
172static int __init __find_i2c_adap(struct device *dev, void *data)
173{
174 const char *name = data;
175 static const char *prefix = "i2c-";
176 struct i2c_adapter *adapter;
177 if (strncmp(dev_name(dev), prefix, strlen(prefix)) != 0)
178 return 0;
179 adapter = to_i2c_adapter(dev);
180 return (strncmp(adapter->name, name, strlen(name)) == 0);
181}
182
183static int __init find_i2c_adapter_num(enum i2c_adapter_type type)
184{
185 struct device *dev = NULL;
186 struct i2c_adapter *adapter;
187 const char *name = i2c_adapter_names[type];
188 /* find the adapter by name */
189 dev = bus_find_device(&i2c_bus_type, NULL, (void *)name,
190 __find_i2c_adap);
191 if (!dev) {
192 pr_err("%s: i2c adapter %s not found on system.\n", __func__,
193 name);
194 return -ENODEV;
195 }
196 adapter = to_i2c_adapter(dev);
197 return adapter->nr;
198}
199
200/*
201 * Takes a list of addresses in addrs as such :
202 * { addr1, ... , addrn, I2C_CLIENT_END };
203 * add_probed_i2c_device will use i2c_new_probed_device
204 * and probe for devices at all of the addresses listed.
205 * Returns NULL if no devices found.
206 * See Documentation/i2c/instantiating-devices for more information.
207 */
208static __init struct i2c_client *add_probed_i2c_device(
209 const char *name,
210 enum i2c_adapter_type type,
211 struct i2c_board_info *info,
212 const unsigned short *addrs)
213{
214 return __add_probed_i2c_device(name,
215 find_i2c_adapter_num(type),
216 info,
217 addrs);
218}
219
220/*
221 * Probes for a device at a single address, the one provided by
222 * info->addr.
223 * Returns NULL if no device found.
224 */
225static __init struct i2c_client *add_i2c_device(const char *name,
226 enum i2c_adapter_type type,
227 struct i2c_board_info *info)
228{
229 const unsigned short addr_list[] = { info->addr, I2C_CLIENT_END };
230 return __add_probed_i2c_device(name,
231 find_i2c_adapter_num(type),
232 info,
233 addr_list);
234}
235
236
237static struct i2c_client __init *add_smbus_device(const char *name,
238 struct i2c_board_info *info)
239{
240 return add_i2c_device(name, I2C_ADAPTER_SMBUS, info);
241}
242
243static int __init setup_cyapa_smbus_tp(const struct dmi_system_id *id)
244{
245 /* add cyapa touchpad on smbus */
246 tp = add_smbus_device("trackpad", &cyapa_device);
247 return 0;
248}
249
250static int __init setup_atmel_224s_tp(const struct dmi_system_id *id)
251{
252 const unsigned short addr_list[] = { ATMEL_TP_I2C_BL_ADDR,
253 ATMEL_TP_I2C_ADDR,
254 I2C_CLIENT_END };
255
256 /* add atmel mxt touchpad on VGA DDC GMBus */
257 tp = add_probed_i2c_device("trackpad", I2C_ADAPTER_VGADDC,
258 &atmel_224s_tp_device, addr_list);
259 return 0;
260}
261
262static int __init setup_atmel_1664s_ts(const struct dmi_system_id *id)
263{
264 const unsigned short addr_list[] = { ATMEL_TS_I2C_BL_ADDR,
265 ATMEL_TS_I2C_ADDR,
266 I2C_CLIENT_END };
267
268 /* add atmel mxt touch device on PANEL GMBus */
269 ts = add_probed_i2c_device("touchscreen", I2C_ADAPTER_PANEL,
270 &atmel_1664s_device, addr_list);
271 return 0;
272}
273
274
275static int __init setup_isl29018_als(const struct dmi_system_id *id)
276{
277 /* add isl29018 light sensor */
278 als = add_smbus_device("lightsensor", &isl_als_device);
279 return 0;
280}
281
282static int __init setup_isl29023_als(const struct dmi_system_id *id)
283{
284 /* add isl29023 light sensor on Panel GMBus */
285 als = add_i2c_device("lightsensor", I2C_ADAPTER_PANEL,
286 &isl_als_device);
287 return 0;
288}
289
290static int __init setup_tsl2583_als(const struct dmi_system_id *id)
291{
292 /* add tsl2583 light sensor on smbus */
293 als = add_smbus_device(NULL, &tsl2583_als_device);
294 return 0;
295}
296
297static int __init setup_tsl2563_als(const struct dmi_system_id *id)
298{
299 /* add tsl2563 light sensor on smbus */
300 als = add_smbus_device(NULL, &tsl2563_als_device);
301 return 0;
302}
303
304static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
305 {
306 .ident = "Samsung Series 5 550 - Touchpad",
307 .matches = {
308 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG"),
309 DMI_MATCH(DMI_PRODUCT_NAME, "Lumpy"),
310 },
311 .callback = setup_cyapa_smbus_tp,
312 },
313 {
314 .ident = "Chromebook Pixel - Touchscreen",
315 .matches = {
316 DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"),
317 DMI_MATCH(DMI_PRODUCT_NAME, "Link"),
318 },
319 .callback = setup_atmel_1664s_ts,
320 },
321 {
322 .ident = "Chromebook Pixel - Touchpad",
323 .matches = {
324 DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"),
325 DMI_MATCH(DMI_PRODUCT_NAME, "Link"),
326 },
327 .callback = setup_atmel_224s_tp,
328 },
329 {
330 .ident = "Samsung Series 5 550 - Light Sensor",
331 .matches = {
332 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG"),
333 DMI_MATCH(DMI_PRODUCT_NAME, "Lumpy"),
334 },
335 .callback = setup_isl29018_als,
336 },
337 {
338 .ident = "Chromebook Pixel - Light Sensor",
339 .matches = {
340 DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"),
341 DMI_MATCH(DMI_PRODUCT_NAME, "Link"),
342 },
343 .callback = setup_isl29023_als,
344 },
345 {
346 .ident = "Acer C7 Chromebook - Touchpad",
347 .matches = {
348 DMI_MATCH(DMI_PRODUCT_NAME, "Parrot"),
349 },
350 .callback = setup_cyapa_smbus_tp,
351 },
352 {
353 .ident = "HP Pavilion 14 Chromebook - Touchpad",
354 .matches = {
355 DMI_MATCH(DMI_PRODUCT_NAME, "Butterfly"),
356 },
357 .callback = setup_cyapa_smbus_tp,
358 },
359 {
360 .ident = "Samsung Series 5 - Light Sensor",
361 .matches = {
362 DMI_MATCH(DMI_PRODUCT_NAME, "Alex"),
363 },
364 .callback = setup_tsl2583_als,
365 },
366 {
367 .ident = "Cr-48 - Light Sensor",
368 .matches = {
369 DMI_MATCH(DMI_PRODUCT_NAME, "Mario"),
370 },
371 .callback = setup_tsl2563_als,
372 },
373 {
374 .ident = "Acer AC700 - Light Sensor",
375 .matches = {
376 DMI_MATCH(DMI_PRODUCT_NAME, "ZGB"),
377 },
378 .callback = setup_tsl2563_als,
379 },
380 { }
381};
382MODULE_DEVICE_TABLE(dmi, chromeos_laptop_dmi_table);
383
384static int __init chromeos_laptop_init(void)
385{
386 if (!dmi_check_system(chromeos_laptop_dmi_table)) {
387 pr_debug("%s unsupported system.\n", __func__);
388 return -ENODEV;
389 }
390 return 0;
391}
392
393static void __exit chromeos_laptop_exit(void)
394{
395 if (als)
396 i2c_unregister_device(als);
397 if (tp)
398 i2c_unregister_device(tp);
399 if (ts)
400 i2c_unregister_device(ts);
401}
402
403module_init(chromeos_laptop_init);
404module_exit(chromeos_laptop_exit);
405
406MODULE_DESCRIPTION("Chrome OS Laptop driver");
407MODULE_AUTHOR("Benson Leung <bleung@chromium.org>");
408MODULE_LICENSE("GPL");
diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index bb77e18b3dd4..c608b1d33f4a 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -21,6 +21,7 @@
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/dmi.h> 22#include <linux/dmi.h>
23#include <linux/io.h> 23#include <linux/io.h>
24#include <linux/rfkill.h>
24#include <linux/power_supply.h> 25#include <linux/power_supply.h>
25#include <linux/acpi.h> 26#include <linux/acpi.h>
26#include <linux/mm.h> 27#include <linux/mm.h>
@@ -89,6 +90,13 @@ static struct platform_driver platform_driver = {
89 90
90static struct platform_device *platform_device; 91static struct platform_device *platform_device;
91static struct backlight_device *dell_backlight_device; 92static struct backlight_device *dell_backlight_device;
93static struct rfkill *wifi_rfkill;
94static struct rfkill *bluetooth_rfkill;
95static struct rfkill *wwan_rfkill;
96static bool force_rfkill;
97
98module_param(force_rfkill, bool, 0444);
99MODULE_PARM_DESC(force_rfkill, "enable rfkill on non whitelisted models");
92 100
93static const struct dmi_system_id dell_device_table[] __initconst = { 101static const struct dmi_system_id dell_device_table[] __initconst = {
94 { 102 {
@@ -355,6 +363,108 @@ dell_send_request(struct calling_interface_buffer *buffer, int class,
355 return buffer; 363 return buffer;
356} 364}
357 365
366/* Derived from information in DellWirelessCtl.cpp:
367 Class 17, select 11 is radio control. It returns an array of 32-bit values.
368
369 Input byte 0 = 0: Wireless information
370
371 result[0]: return code
372 result[1]:
373 Bit 0: Hardware switch supported
374 Bit 1: Wifi locator supported
375 Bit 2: Wifi is supported
376 Bit 3: Bluetooth is supported
377 Bit 4: WWAN is supported
378 Bit 5: Wireless keyboard supported
379 Bits 6-7: Reserved
380 Bit 8: Wifi is installed
381 Bit 9: Bluetooth is installed
382 Bit 10: WWAN is installed
383 Bits 11-15: Reserved
384 Bit 16: Hardware switch is on
385 Bit 17: Wifi is blocked
386 Bit 18: Bluetooth is blocked
387 Bit 19: WWAN is blocked
388 Bits 20-31: Reserved
389 result[2]: NVRAM size in bytes
390 result[3]: NVRAM format version number
391
392 Input byte 0 = 2: Wireless switch configuration
393 result[0]: return code
394 result[1]:
395 Bit 0: Wifi controlled by switch
396 Bit 1: Bluetooth controlled by switch
397 Bit 2: WWAN controlled by switch
398 Bits 3-6: Reserved
399 Bit 7: Wireless switch config locked
400 Bit 8: Wifi locator enabled
401 Bits 9-14: Reserved
402 Bit 15: Wifi locator setting locked
403 Bits 16-31: Reserved
404*/
405
406static int dell_rfkill_set(void *data, bool blocked)
407{
408 int disable = blocked ? 1 : 0;
409 unsigned long radio = (unsigned long)data;
410 int hwswitch_bit = (unsigned long)data - 1;
411
412 get_buffer();
413 dell_send_request(buffer, 17, 11);
414
415 /* If the hardware switch controls this radio, and the hardware
416 switch is disabled, always disable the radio */
417 if ((hwswitch_state & BIT(hwswitch_bit)) &&
418 !(buffer->output[1] & BIT(16)))
419 disable = 1;
420
421 buffer->input[0] = (1 | (radio<<8) | (disable << 16));
422 dell_send_request(buffer, 17, 11);
423
424 release_buffer();
425 return 0;
426}
427
428/* Must be called with the buffer held */
429static void dell_rfkill_update_sw_state(struct rfkill *rfkill, int radio,
430 int status)
431{
432 if (status & BIT(0)) {
433 /* Has hw-switch, sync sw_state to BIOS */
434 int block = rfkill_blocked(rfkill);
435 buffer->input[0] = (1 | (radio << 8) | (block << 16));
436 dell_send_request(buffer, 17, 11);
437 } else {
438 /* No hw-switch, sync BIOS state to sw_state */
439 rfkill_set_sw_state(rfkill, !!(status & BIT(radio + 16)));
440 }
441}
442
443static void dell_rfkill_update_hw_state(struct rfkill *rfkill, int radio,
444 int status)
445{
446 if (hwswitch_state & (BIT(radio - 1)))
447 rfkill_set_hw_state(rfkill, !(status & BIT(16)));
448}
449
450static void dell_rfkill_query(struct rfkill *rfkill, void *data)
451{
452 int status;
453
454 get_buffer();
455 dell_send_request(buffer, 17, 11);
456 status = buffer->output[1];
457
458 dell_rfkill_update_hw_state(rfkill, (unsigned long)data, status);
459
460 release_buffer();
461}
462
463static const struct rfkill_ops dell_rfkill_ops = {
464 .set_block = dell_rfkill_set,
465 .query = dell_rfkill_query,
466};
467
358static struct dentry *dell_laptop_dir; 468static struct dentry *dell_laptop_dir;
359 469
360static int dell_debugfs_show(struct seq_file *s, void *data) 470static int dell_debugfs_show(struct seq_file *s, void *data)
@@ -424,6 +534,136 @@ static const struct file_operations dell_debugfs_fops = {
424 .release = single_release, 534 .release = single_release,
425}; 535};
426 536
537static void dell_update_rfkill(struct work_struct *ignored)
538{
539 int status;
540
541 get_buffer();
542 dell_send_request(buffer, 17, 11);
543 status = buffer->output[1];
544
545 if (wifi_rfkill) {
546 dell_rfkill_update_hw_state(wifi_rfkill, 1, status);
547 dell_rfkill_update_sw_state(wifi_rfkill, 1, status);
548 }
549 if (bluetooth_rfkill) {
550 dell_rfkill_update_hw_state(bluetooth_rfkill, 2, status);
551 dell_rfkill_update_sw_state(bluetooth_rfkill, 2, status);
552 }
553 if (wwan_rfkill) {
554 dell_rfkill_update_hw_state(wwan_rfkill, 3, status);
555 dell_rfkill_update_sw_state(wwan_rfkill, 3, status);
556 }
557
558 release_buffer();
559}
560static DECLARE_DELAYED_WORK(dell_rfkill_work, dell_update_rfkill);
561
562
563static int __init dell_setup_rfkill(void)
564{
565 int status;
566 int ret;
567 const char *product;
568
569 /*
570 * rfkill causes trouble on various non Latitudes, according to Dell
571 * actually testing the rfkill functionality is only done on Latitudes.
572 */
573 product = dmi_get_system_info(DMI_PRODUCT_NAME);
574 if (!force_rfkill && (!product || strncmp(product, "Latitude", 8)))
575 return 0;
576
577 get_buffer();
578 dell_send_request(buffer, 17, 11);
579 status = buffer->output[1];
580 buffer->input[0] = 0x2;
581 dell_send_request(buffer, 17, 11);
582 hwswitch_state = buffer->output[1];
583 release_buffer();
584
585 if (!(status & BIT(0))) {
586 if (force_rfkill) {
587 /* No hwsitch, clear all hw-controlled bits */
588 hwswitch_state &= ~7;
589 } else {
590 /* rfkill is only tested on laptops with a hwswitch */
591 return 0;
592 }
593 }
594
595 if ((status & (1<<2|1<<8)) == (1<<2|1<<8)) {
596 wifi_rfkill = rfkill_alloc("dell-wifi", &platform_device->dev,
597 RFKILL_TYPE_WLAN,
598 &dell_rfkill_ops, (void *) 1);
599 if (!wifi_rfkill) {
600 ret = -ENOMEM;
601 goto err_wifi;
602 }
603 ret = rfkill_register(wifi_rfkill);
604 if (ret)
605 goto err_wifi;
606 }
607
608 if ((status & (1<<3|1<<9)) == (1<<3|1<<9)) {
609 bluetooth_rfkill = rfkill_alloc("dell-bluetooth",
610 &platform_device->dev,
611 RFKILL_TYPE_BLUETOOTH,
612 &dell_rfkill_ops, (void *) 2);
613 if (!bluetooth_rfkill) {
614 ret = -ENOMEM;
615 goto err_bluetooth;
616 }
617 ret = rfkill_register(bluetooth_rfkill);
618 if (ret)
619 goto err_bluetooth;
620 }
621
622 if ((status & (1<<4|1<<10)) == (1<<4|1<<10)) {
623 wwan_rfkill = rfkill_alloc("dell-wwan",
624 &platform_device->dev,
625 RFKILL_TYPE_WWAN,
626 &dell_rfkill_ops, (void *) 3);
627 if (!wwan_rfkill) {
628 ret = -ENOMEM;
629 goto err_wwan;
630 }
631 ret = rfkill_register(wwan_rfkill);
632 if (ret)
633 goto err_wwan;
634 }
635
636 return 0;
637err_wwan:
638 rfkill_destroy(wwan_rfkill);
639 if (bluetooth_rfkill)
640 rfkill_unregister(bluetooth_rfkill);
641err_bluetooth:
642 rfkill_destroy(bluetooth_rfkill);
643 if (wifi_rfkill)
644 rfkill_unregister(wifi_rfkill);
645err_wifi:
646 rfkill_destroy(wifi_rfkill);
647
648 return ret;
649}
650
651static void dell_cleanup_rfkill(void)
652{
653 if (wifi_rfkill) {
654 rfkill_unregister(wifi_rfkill);
655 rfkill_destroy(wifi_rfkill);
656 }
657 if (bluetooth_rfkill) {
658 rfkill_unregister(bluetooth_rfkill);
659 rfkill_destroy(bluetooth_rfkill);
660 }
661 if (wwan_rfkill) {
662 rfkill_unregister(wwan_rfkill);
663 rfkill_destroy(wwan_rfkill);
664 }
665}
666
427static int dell_send_intensity(struct backlight_device *bd) 667static int dell_send_intensity(struct backlight_device *bd)
428{ 668{
429 int ret = 0; 669 int ret = 0;
@@ -515,6 +755,30 @@ static void touchpad_led_exit(void)
515 led_classdev_unregister(&touchpad_led); 755 led_classdev_unregister(&touchpad_led);
516} 756}
517 757
758static bool dell_laptop_i8042_filter(unsigned char data, unsigned char str,
759 struct serio *port)
760{
761 static bool extended;
762
763 if (str & 0x20)
764 return false;
765
766 if (unlikely(data == 0xe0)) {
767 extended = true;
768 return false;
769 } else if (unlikely(extended)) {
770 switch (data) {
771 case 0x8:
772 schedule_delayed_work(&dell_rfkill_work,
773 round_jiffies_relative(HZ / 4));
774 break;
775 }
776 extended = false;
777 }
778
779 return false;
780}
781
518static int __init dell_init(void) 782static int __init dell_init(void)
519{ 783{
520 int max_intensity = 0; 784 int max_intensity = 0;
@@ -557,10 +821,26 @@ static int __init dell_init(void)
557 } 821 }
558 buffer = page_address(bufferpage); 822 buffer = page_address(bufferpage);
559 823
824 ret = dell_setup_rfkill();
825
826 if (ret) {
827 pr_warn("Unable to setup rfkill\n");
828 goto fail_rfkill;
829 }
830
831 ret = i8042_install_filter(dell_laptop_i8042_filter);
832 if (ret) {
833 pr_warn("Unable to install key filter\n");
834 goto fail_filter;
835 }
836
560 if (quirks && quirks->touchpad_led) 837 if (quirks && quirks->touchpad_led)
561 touchpad_led_init(&platform_device->dev); 838 touchpad_led_init(&platform_device->dev);
562 839
563 dell_laptop_dir = debugfs_create_dir("dell_laptop", NULL); 840 dell_laptop_dir = debugfs_create_dir("dell_laptop", NULL);
841 if (dell_laptop_dir != NULL)
842 debugfs_create_file("rfkill", 0444, dell_laptop_dir, NULL,
843 &dell_debugfs_fops);
564 844
565#ifdef CONFIG_ACPI 845#ifdef CONFIG_ACPI
566 /* In the event of an ACPI backlight being available, don't 846 /* In the event of an ACPI backlight being available, don't
@@ -603,6 +883,11 @@ static int __init dell_init(void)
603 return 0; 883 return 0;
604 884
605fail_backlight: 885fail_backlight:
886 i8042_remove_filter(dell_laptop_i8042_filter);
887 cancel_delayed_work_sync(&dell_rfkill_work);
888fail_filter:
889 dell_cleanup_rfkill();
890fail_rfkill:
606 free_page((unsigned long)bufferpage); 891 free_page((unsigned long)bufferpage);
607fail_buffer: 892fail_buffer:
608 platform_device_del(platform_device); 893 platform_device_del(platform_device);
@@ -620,7 +905,10 @@ static void __exit dell_exit(void)
620 debugfs_remove_recursive(dell_laptop_dir); 905 debugfs_remove_recursive(dell_laptop_dir);
621 if (quirks && quirks->touchpad_led) 906 if (quirks && quirks->touchpad_led)
622 touchpad_led_exit(); 907 touchpad_led_exit();
908 i8042_remove_filter(dell_laptop_i8042_filter);
909 cancel_delayed_work_sync(&dell_rfkill_work);
623 backlight_device_unregister(dell_backlight_device); 910 backlight_device_unregister(dell_backlight_device);
911 dell_cleanup_rfkill();
624 if (platform_device) { 912 if (platform_device) {
625 platform_device_unregister(platform_device); 913 platform_device_unregister(platform_device);
626 platform_driver_unregister(&platform_driver); 914 platform_driver_unregister(&platform_driver);
diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c
index fa9a2171cc13..60e0900bc117 100644
--- a/drivers/platform/x86/dell-wmi.c
+++ b/drivers/platform/x86/dell-wmi.c
@@ -130,7 +130,8 @@ static const u16 bios_to_linux_keycode[256] __initconst = {
130 KEY_BRIGHTNESSUP, KEY_UNKNOWN, KEY_KBDILLUMTOGGLE, 130 KEY_BRIGHTNESSUP, KEY_UNKNOWN, KEY_KBDILLUMTOGGLE,
131 KEY_UNKNOWN, KEY_SWITCHVIDEOMODE, KEY_UNKNOWN, KEY_UNKNOWN, 131 KEY_UNKNOWN, KEY_SWITCHVIDEOMODE, KEY_UNKNOWN, KEY_UNKNOWN,
132 KEY_SWITCHVIDEOMODE, KEY_UNKNOWN, KEY_UNKNOWN, KEY_PROG2, 132 KEY_SWITCHVIDEOMODE, KEY_UNKNOWN, KEY_UNKNOWN, KEY_PROG2,
133 KEY_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
134 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_MICMUTE,
134 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 135 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
135 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 136 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
136 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 137 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -139,8 +140,8 @@ static const u16 bios_to_linux_keycode[256] __initconst = {
139 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 140 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
140 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 141 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
141 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 142 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
142 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 143 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
143 KEY_PROG3 144 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_PROG3
144}; 145};
145 146
146static struct input_dev *dell_wmi_input_dev; 147static struct input_dev *dell_wmi_input_dev;
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 538521b00948..7029cba7025b 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -1205,10 +1205,8 @@ static int eeepc_input_init(struct eeepc_laptop *eeepc)
1205 int error; 1205 int error;
1206 1206
1207 input = input_allocate_device(); 1207 input = input_allocate_device();
1208 if (!input) { 1208 if (!input)
1209 pr_info("Unable to allocate input device\n");
1210 return -ENOMEM; 1209 return -ENOMEM;
1211 }
1212 1210
1213 input->name = "Asus EeePC extra buttons"; 1211 input->name = "Asus EeePC extra buttons";
1214 input->phys = EEEPC_LAPTOP_FILE "/input0"; 1212 input->phys = EEEPC_LAPTOP_FILE "/input0";
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 1c86fa0857c8..8ba8956b5a48 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -54,6 +54,7 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");
54#define HPWMI_HARDWARE_QUERY 0x4 54#define HPWMI_HARDWARE_QUERY 0x4
55#define HPWMI_WIRELESS_QUERY 0x5 55#define HPWMI_WIRELESS_QUERY 0x5
56#define HPWMI_HOTKEY_QUERY 0xc 56#define HPWMI_HOTKEY_QUERY 0xc
57#define HPWMI_FEATURE_QUERY 0xd
57#define HPWMI_WIRELESS2_QUERY 0x1b 58#define HPWMI_WIRELESS2_QUERY 0x1b
58#define HPWMI_POSTCODEERROR_QUERY 0x2a 59#define HPWMI_POSTCODEERROR_QUERY 0x2a
59 60
@@ -292,6 +293,17 @@ static int hp_wmi_tablet_state(void)
292 return (state & 0x4) ? 1 : 0; 293 return (state & 0x4) ? 1 : 0;
293} 294}
294 295
296static int hp_wmi_bios_2009_later(void)
297{
298 int state = 0;
299 int ret = hp_wmi_perform_query(HPWMI_FEATURE_QUERY, 0, &state,
300 sizeof(state), sizeof(state));
301 if (ret)
302 return ret;
303
304 return (state & 0x10) ? 1 : 0;
305}
306
295static int hp_wmi_set_block(void *data, bool blocked) 307static int hp_wmi_set_block(void *data, bool blocked)
296{ 308{
297 enum hp_wmi_radio r = (enum hp_wmi_radio) data; 309 enum hp_wmi_radio r = (enum hp_wmi_radio) data;
@@ -871,7 +883,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
871 gps_rfkill = NULL; 883 gps_rfkill = NULL;
872 rfkill2_count = 0; 884 rfkill2_count = 0;
873 885
874 if (hp_wmi_rfkill_setup(device)) 886 if (hp_wmi_bios_2009_later() || hp_wmi_rfkill_setup(device))
875 hp_wmi_rfkill2_setup(device); 887 hp_wmi_rfkill2_setup(device);
876 888
877 err = device_create_file(&device->dev, &dev_attr_display); 889 err = device_create_file(&device->dev, &dev_attr_display);
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 6788acc22ab9..19ec95147f69 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -570,10 +570,8 @@ static int ideapad_input_init(struct ideapad_private *priv)
570 int error; 570 int error;
571 571
572 inputdev = input_allocate_device(); 572 inputdev = input_allocate_device();
573 if (!inputdev) { 573 if (!inputdev)
574 pr_info("Unable to allocate input device\n");
575 return -ENOMEM; 574 return -ENOMEM;
576 }
577 575
578 inputdev->name = "Ideapad extra buttons"; 576 inputdev->name = "Ideapad extra buttons";
579 inputdev->phys = "ideapad/input0"; 577 inputdev->phys = "ideapad/input0";
diff --git a/drivers/platform/x86/intel_mid_powerbtn.c b/drivers/platform/x86/intel_mid_powerbtn.c
index 6b18aba82cfa..8d6775266d66 100644
--- a/drivers/platform/x86/intel_mid_powerbtn.c
+++ b/drivers/platform/x86/intel_mid_powerbtn.c
@@ -66,10 +66,8 @@ static int mfld_pb_probe(struct platform_device *pdev)
66 return -EINVAL; 66 return -EINVAL;
67 67
68 input = input_allocate_device(); 68 input = input_allocate_device();
69 if (!input) { 69 if (!input)
70 dev_err(&pdev->dev, "Input device allocation error\n");
71 return -ENOMEM; 70 return -ENOMEM;
72 }
73 71
74 input->name = pdev->name; 72 input->name = pdev->name;
75 input->phys = "power-button/input0"; 73 input->phys = "power-button/input0";
diff --git a/drivers/platform/x86/intel_scu_ipc.c b/drivers/platform/x86/intel_scu_ipc.c
index d654f831410d..60ea476a9130 100644
--- a/drivers/platform/x86/intel_scu_ipc.c
+++ b/drivers/platform/x86/intel_scu_ipc.c
@@ -58,12 +58,56 @@
58 * message handler is called within firmware. 58 * message handler is called within firmware.
59 */ 59 */
60 60
61#define IPC_BASE_ADDR 0xFF11C000 /* IPC1 base register address */
62#define IPC_MAX_ADDR 0x100 /* Maximum IPC regisers */
63#define IPC_WWBUF_SIZE 20 /* IPC Write buffer Size */ 61#define IPC_WWBUF_SIZE 20 /* IPC Write buffer Size */
64#define IPC_RWBUF_SIZE 20 /* IPC Read buffer Size */ 62#define IPC_RWBUF_SIZE 20 /* IPC Read buffer Size */
65#define IPC_I2C_BASE 0xFF12B000 /* I2C control register base address */ 63#define IPC_IOC 0x100 /* IPC command register IOC bit */
66#define IPC_I2C_MAX_ADDR 0x10 /* Maximum I2C regisers */ 64
65enum {
66 SCU_IPC_LINCROFT,
67 SCU_IPC_PENWELL,
68 SCU_IPC_CLOVERVIEW,
69 SCU_IPC_TANGIER,
70};
71
72/* intel scu ipc driver data*/
73struct intel_scu_ipc_pdata_t {
74 u32 ipc_base;
75 u32 i2c_base;
76 u32 ipc_len;
77 u32 i2c_len;
78 u8 irq_mode;
79};
80
81static struct intel_scu_ipc_pdata_t intel_scu_ipc_pdata[] = {
82 [SCU_IPC_LINCROFT] = {
83 .ipc_base = 0xff11c000,
84 .i2c_base = 0xff12b000,
85 .ipc_len = 0x100,
86 .i2c_len = 0x10,
87 .irq_mode = 0,
88 },
89 [SCU_IPC_PENWELL] = {
90 .ipc_base = 0xff11c000,
91 .i2c_base = 0xff12b000,
92 .ipc_len = 0x100,
93 .i2c_len = 0x10,
94 .irq_mode = 1,
95 },
96 [SCU_IPC_CLOVERVIEW] = {
97 .ipc_base = 0xff11c000,
98 .i2c_base = 0xff12b000,
99 .ipc_len = 0x100,
100 .i2c_len = 0x10,
101 .irq_mode = 1,
102 },
103 [SCU_IPC_TANGIER] = {
104 .ipc_base = 0xff009000,
105 .i2c_base = 0xff00d000,
106 .ipc_len = 0x100,
107 .i2c_len = 0x10,
108 .irq_mode = 0,
109 },
110};
67 111
68static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id); 112static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id);
69static void ipc_remove(struct pci_dev *pdev); 113static void ipc_remove(struct pci_dev *pdev);
@@ -72,6 +116,8 @@ struct intel_scu_ipc_dev {
72 struct pci_dev *pdev; 116 struct pci_dev *pdev;
73 void __iomem *ipc_base; 117 void __iomem *ipc_base;
74 void __iomem *i2c_base; 118 void __iomem *i2c_base;
119 struct completion cmd_complete;
120 u8 irq_mode;
75}; 121};
76 122
77static struct intel_scu_ipc_dev ipcdev; /* Only one for now */ 123static struct intel_scu_ipc_dev ipcdev; /* Only one for now */
@@ -98,6 +144,10 @@ static DEFINE_MUTEX(ipclock); /* lock used to prevent multiple call to SCU */
98 */ 144 */
99static inline void ipc_command(u32 cmd) /* Send ipc command */ 145static inline void ipc_command(u32 cmd) /* Send ipc command */
100{ 146{
147 if (ipcdev.irq_mode) {
148 reinit_completion(&ipcdev.cmd_complete);
149 writel(cmd | IPC_IOC, ipcdev.ipc_base);
150 }
101 writel(cmd, ipcdev.ipc_base); 151 writel(cmd, ipcdev.ipc_base);
102} 152}
103 153
@@ -156,6 +206,30 @@ static inline int busy_loop(void) /* Wait till scu status is busy */
156 return 0; 206 return 0;
157} 207}
158 208
209/* Wait till ipc ioc interrupt is received or timeout in 3 HZ */
210static inline int ipc_wait_for_interrupt(void)
211{
212 int status;
213
214 if (!wait_for_completion_timeout(&ipcdev.cmd_complete, 3 * HZ)) {
215 struct device *dev = &ipcdev.pdev->dev;
216 dev_err(dev, "IPC timed out\n");
217 return -ETIMEDOUT;
218 }
219
220 status = ipc_read_status();
221
222 if ((status >> 1) & 1)
223 return -EIO;
224
225 return 0;
226}
227
228int intel_scu_ipc_check_status(void)
229{
230 return ipcdev.irq_mode ? ipc_wait_for_interrupt() : busy_loop();
231}
232
159/* Read/Write power control(PMIC in Langwell, MSIC in PenWell) registers */ 233/* Read/Write power control(PMIC in Langwell, MSIC in PenWell) registers */
160static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id) 234static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id)
161{ 235{
@@ -196,8 +270,8 @@ static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id)
196 ipc_command(4 << 16 | id << 12 | 0 << 8 | op); 270 ipc_command(4 << 16 | id << 12 | 0 << 8 | op);
197 } 271 }
198 272
199 err = busy_loop(); 273 err = intel_scu_ipc_check_status();
200 if (id == IPC_CMD_PCNTRL_R) { /* Read rbuf */ 274 if (!err && id == IPC_CMD_PCNTRL_R) { /* Read rbuf */
201 /* Workaround: values are read as 0 without memcpy_fromio */ 275 /* Workaround: values are read as 0 without memcpy_fromio */
202 memcpy_fromio(cbuf, ipcdev.ipc_base + 0x90, 16); 276 memcpy_fromio(cbuf, ipcdev.ipc_base + 0x90, 16);
203 for (nc = 0; nc < count; nc++) 277 for (nc = 0; nc < count; nc++)
@@ -391,7 +465,7 @@ int intel_scu_ipc_simple_command(int cmd, int sub)
391 return -ENODEV; 465 return -ENODEV;
392 } 466 }
393 ipc_command(sub << 12 | cmd); 467 ipc_command(sub << 12 | cmd);
394 err = busy_loop(); 468 err = intel_scu_ipc_check_status();
395 mutex_unlock(&ipclock); 469 mutex_unlock(&ipclock);
396 return err; 470 return err;
397} 471}
@@ -425,10 +499,12 @@ int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen,
425 ipc_data_writel(*in++, 4 * i); 499 ipc_data_writel(*in++, 4 * i);
426 500
427 ipc_command((inlen << 16) | (sub << 12) | cmd); 501 ipc_command((inlen << 16) | (sub << 12) | cmd);
428 err = busy_loop(); 502 err = intel_scu_ipc_check_status();
429 503
430 for (i = 0; i < outlen; i++) 504 if (!err) {
431 *out++ = ipc_data_readl(4 * i); 505 for (i = 0; i < outlen; i++)
506 *out++ = ipc_data_readl(4 * i);
507 }
432 508
433 mutex_unlock(&ipclock); 509 mutex_unlock(&ipclock);
434 return err; 510 return err;
@@ -491,6 +567,9 @@ EXPORT_SYMBOL(intel_scu_ipc_i2c_cntrl);
491 */ 567 */
492static irqreturn_t ioc(int irq, void *dev_id) 568static irqreturn_t ioc(int irq, void *dev_id)
493{ 569{
570 if (ipcdev.irq_mode)
571 complete(&ipcdev.cmd_complete);
572
494 return IRQ_HANDLED; 573 return IRQ_HANDLED;
495} 574}
496 575
@@ -504,13 +583,18 @@ static irqreturn_t ioc(int irq, void *dev_id)
504 */ 583 */
505static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id) 584static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id)
506{ 585{
507 int err; 586 int err, pid;
587 struct intel_scu_ipc_pdata_t *pdata;
508 resource_size_t pci_resource; 588 resource_size_t pci_resource;
509 589
510 if (ipcdev.pdev) /* We support only one SCU */ 590 if (ipcdev.pdev) /* We support only one SCU */
511 return -EBUSY; 591 return -EBUSY;
512 592
593 pid = id->driver_data;
594 pdata = &intel_scu_ipc_pdata[pid];
595
513 ipcdev.pdev = pci_dev_get(dev); 596 ipcdev.pdev = pci_dev_get(dev);
597 ipcdev.irq_mode = pdata->irq_mode;
514 598
515 err = pci_enable_device(dev); 599 err = pci_enable_device(dev);
516 if (err) 600 if (err)
@@ -524,14 +608,16 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id)
524 if (!pci_resource) 608 if (!pci_resource)
525 return -ENOMEM; 609 return -ENOMEM;
526 610
611 init_completion(&ipcdev.cmd_complete);
612
527 if (request_irq(dev->irq, ioc, 0, "intel_scu_ipc", &ipcdev)) 613 if (request_irq(dev->irq, ioc, 0, "intel_scu_ipc", &ipcdev))
528 return -EBUSY; 614 return -EBUSY;
529 615
530 ipcdev.ipc_base = ioremap_nocache(IPC_BASE_ADDR, IPC_MAX_ADDR); 616 ipcdev.ipc_base = ioremap_nocache(pdata->ipc_base, pdata->ipc_len);
531 if (!ipcdev.ipc_base) 617 if (!ipcdev.ipc_base)
532 return -ENOMEM; 618 return -ENOMEM;
533 619
534 ipcdev.i2c_base = ioremap_nocache(IPC_I2C_BASE, IPC_I2C_MAX_ADDR); 620 ipcdev.i2c_base = ioremap_nocache(pdata->i2c_base, pdata->i2c_len);
535 if (!ipcdev.i2c_base) { 621 if (!ipcdev.i2c_base) {
536 iounmap(ipcdev.ipc_base); 622 iounmap(ipcdev.ipc_base);
537 return -ENOMEM; 623 return -ENOMEM;
@@ -564,7 +650,10 @@ static void ipc_remove(struct pci_dev *pdev)
564} 650}
565 651
566static DEFINE_PCI_DEVICE_TABLE(pci_ids) = { 652static DEFINE_PCI_DEVICE_TABLE(pci_ids) = {
567 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x082a)}, 653 {PCI_VDEVICE(INTEL, 0x082a), SCU_IPC_LINCROFT},
654 {PCI_VDEVICE(INTEL, 0x080e), SCU_IPC_PENWELL},
655 {PCI_VDEVICE(INTEL, 0x08ea), SCU_IPC_CLOVERVIEW},
656 {PCI_VDEVICE(INTEL, 0x11a0), SCU_IPC_TANGIER},
568 { 0,} 657 { 0,}
569}; 658};
570MODULE_DEVICE_TABLE(pci, pci_ids); 659MODULE_DEVICE_TABLE(pci, pci_ids);
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index 10d12b221601..3008fd20572e 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -490,11 +490,8 @@ static int acpi_pcc_init_input(struct pcc_acpi *pcc)
490 int error; 490 int error;
491 491
492 input_dev = input_allocate_device(); 492 input_dev = input_allocate_device();
493 if (!input_dev) { 493 if (!input_dev)
494 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
495 "Couldn't allocate input device for hotkey"));
496 return -ENOMEM; 494 return -ENOMEM;
497 }
498 495
499 input_dev->name = ACPI_PCC_DRIVER_NAME; 496 input_dev->name = ACPI_PCC_DRIVER_NAME;
500 input_dev->phys = ACPI_PCC_INPUT_PHYS; 497 input_dev->phys = ACPI_PCC_INPUT_PHYS;
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 47caab0ea7a1..fb233ae7bb0e 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -140,12 +140,12 @@ MODULE_PARM_DESC(kbd_backlight_timeout,
140 "on the model (default: no change from current value)"); 140 "on the model (default: no change from current value)");
141 141
142#ifdef CONFIG_PM_SLEEP 142#ifdef CONFIG_PM_SLEEP
143static void sony_nc_kbd_backlight_resume(void);
144static void sony_nc_thermal_resume(void); 143static void sony_nc_thermal_resume(void);
145#endif 144#endif
146static int sony_nc_kbd_backlight_setup(struct platform_device *pd, 145static int sony_nc_kbd_backlight_setup(struct platform_device *pd,
147 unsigned int handle); 146 unsigned int handle);
148static void sony_nc_kbd_backlight_cleanup(struct platform_device *pd); 147static void sony_nc_kbd_backlight_cleanup(struct platform_device *pd,
148 unsigned int handle);
149 149
150static int sony_nc_battery_care_setup(struct platform_device *pd, 150static int sony_nc_battery_care_setup(struct platform_device *pd,
151 unsigned int handle); 151 unsigned int handle);
@@ -304,8 +304,8 @@ static int sony_laptop_input_keycode_map[] = {
304 KEY_FN_F10, /* 14 SONYPI_EVENT_FNKEY_F10 */ 304 KEY_FN_F10, /* 14 SONYPI_EVENT_FNKEY_F10 */
305 KEY_FN_F11, /* 15 SONYPI_EVENT_FNKEY_F11 */ 305 KEY_FN_F11, /* 15 SONYPI_EVENT_FNKEY_F11 */
306 KEY_FN_F12, /* 16 SONYPI_EVENT_FNKEY_F12 */ 306 KEY_FN_F12, /* 16 SONYPI_EVENT_FNKEY_F12 */
307 KEY_FN_F1, /* 17 SONYPI_EVENT_FNKEY_1 */ 307 KEY_FN_1, /* 17 SONYPI_EVENT_FNKEY_1 */
308 KEY_FN_F2, /* 18 SONYPI_EVENT_FNKEY_2 */ 308 KEY_FN_2, /* 18 SONYPI_EVENT_FNKEY_2 */
309 KEY_FN_D, /* 19 SONYPI_EVENT_FNKEY_D */ 309 KEY_FN_D, /* 19 SONYPI_EVENT_FNKEY_D */
310 KEY_FN_E, /* 20 SONYPI_EVENT_FNKEY_E */ 310 KEY_FN_E, /* 20 SONYPI_EVENT_FNKEY_E */
311 KEY_FN_F, /* 21 SONYPI_EVENT_FNKEY_F */ 311 KEY_FN_F, /* 21 SONYPI_EVENT_FNKEY_F */
@@ -1444,7 +1444,7 @@ static void sony_nc_function_cleanup(struct platform_device *pd)
1444 case 0x014b: 1444 case 0x014b:
1445 case 0x014c: 1445 case 0x014c:
1446 case 0x0163: 1446 case 0x0163:
1447 sony_nc_kbd_backlight_cleanup(pd); 1447 sony_nc_kbd_backlight_cleanup(pd, handle);
1448 break; 1448 break;
1449 default: 1449 default:
1450 continue; 1450 continue;
@@ -1486,13 +1486,6 @@ static void sony_nc_function_resume(void)
1486 case 0x0135: 1486 case 0x0135:
1487 sony_nc_rfkill_update(); 1487 sony_nc_rfkill_update();
1488 break; 1488 break;
1489 case 0x0137:
1490 case 0x0143:
1491 case 0x014b:
1492 case 0x014c:
1493 case 0x0163:
1494 sony_nc_kbd_backlight_resume();
1495 break;
1496 default: 1489 default:
1497 continue; 1490 continue;
1498 } 1491 }
@@ -1822,6 +1815,12 @@ static int sony_nc_kbd_backlight_setup(struct platform_device *pd,
1822 int result; 1815 int result;
1823 int ret = 0; 1816 int ret = 0;
1824 1817
1818 if (kbdbl_ctl) {
1819 pr_warn("handle 0x%.4x: keyboard backlight setup already done for 0x%.4x\n",
1820 handle, kbdbl_ctl->handle);
1821 return -EBUSY;
1822 }
1823
1825 /* verify the kbd backlight presence, these handles are not used for 1824 /* verify the kbd backlight presence, these handles are not used for
1826 * keyboard backlight only 1825 * keyboard backlight only
1827 */ 1826 */
@@ -1881,9 +1880,10 @@ outkzalloc:
1881 return ret; 1880 return ret;
1882} 1881}
1883 1882
1884static void sony_nc_kbd_backlight_cleanup(struct platform_device *pd) 1883static void sony_nc_kbd_backlight_cleanup(struct platform_device *pd,
1884 unsigned int handle)
1885{ 1885{
1886 if (kbdbl_ctl) { 1886 if (kbdbl_ctl && handle == kbdbl_ctl->handle) {
1887 device_remove_file(&pd->dev, &kbdbl_ctl->mode_attr); 1887 device_remove_file(&pd->dev, &kbdbl_ctl->mode_attr);
1888 device_remove_file(&pd->dev, &kbdbl_ctl->timeout_attr); 1888 device_remove_file(&pd->dev, &kbdbl_ctl->timeout_attr);
1889 kfree(kbdbl_ctl); 1889 kfree(kbdbl_ctl);
@@ -1891,25 +1891,6 @@ static void sony_nc_kbd_backlight_cleanup(struct platform_device *pd)
1891 } 1891 }
1892} 1892}
1893 1893
1894#ifdef CONFIG_PM_SLEEP
1895static void sony_nc_kbd_backlight_resume(void)
1896{
1897 int ignore = 0;
1898
1899 if (!kbdbl_ctl)
1900 return;
1901
1902 if (kbdbl_ctl->mode == 0)
1903 sony_call_snc_handle(kbdbl_ctl->handle, kbdbl_ctl->base,
1904 &ignore);
1905
1906 if (kbdbl_ctl->timeout != 0)
1907 sony_call_snc_handle(kbdbl_ctl->handle,
1908 (kbdbl_ctl->base + 0x200) |
1909 (kbdbl_ctl->timeout << 0x10), &ignore);
1910}
1911#endif
1912
1913struct battery_care_control { 1894struct battery_care_control {
1914 struct device_attribute attrs[2]; 1895 struct device_attribute attrs[2];
1915 unsigned int handle; 1896 unsigned int handle;
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 05e046aa5e31..58b0274d24cc 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -6438,7 +6438,12 @@ static struct ibm_struct brightness_driver_data = {
6438#define TPACPI_ALSA_SHRTNAME "ThinkPad Console Audio Control" 6438#define TPACPI_ALSA_SHRTNAME "ThinkPad Console Audio Control"
6439#define TPACPI_ALSA_MIXERNAME TPACPI_ALSA_SHRTNAME 6439#define TPACPI_ALSA_MIXERNAME TPACPI_ALSA_SHRTNAME
6440 6440
6441static int alsa_index = ~((1 << (SNDRV_CARDS - 3)) - 1); /* last three slots */ 6441#if SNDRV_CARDS <= 32
6442#define DEFAULT_ALSA_IDX ~((1 << (SNDRV_CARDS - 3)) - 1)
6443#else
6444#define DEFAULT_ALSA_IDX ~((1 << (32 - 3)) - 1)
6445#endif
6446static int alsa_index = DEFAULT_ALSA_IDX; /* last three slots */
6442static char *alsa_id = "ThinkPadEC"; 6447static char *alsa_id = "ThinkPadEC";
6443static bool alsa_enable = SNDRV_DEFAULT_ENABLE1; 6448static bool alsa_enable = SNDRV_DEFAULT_ENABLE1;
6444 6449
@@ -9163,7 +9168,6 @@ static int __init thinkpad_acpi_module_init(void)
9163 mutex_init(&tpacpi_inputdev_send_mutex); 9168 mutex_init(&tpacpi_inputdev_send_mutex);
9164 tpacpi_inputdev = input_allocate_device(); 9169 tpacpi_inputdev = input_allocate_device();
9165 if (!tpacpi_inputdev) { 9170 if (!tpacpi_inputdev) {
9166 pr_err("unable to allocate input device\n");
9167 thinkpad_acpi_module_exit(); 9171 thinkpad_acpi_module_exit();
9168 return -ENOMEM; 9172 return -ENOMEM;
9169 } else { 9173 } else {
diff --git a/drivers/platform/x86/topstar-laptop.c b/drivers/platform/x86/topstar-laptop.c
index 67897c8740ba..e597de05e6c2 100644
--- a/drivers/platform/x86/topstar-laptop.c
+++ b/drivers/platform/x86/topstar-laptop.c
@@ -97,10 +97,8 @@ static int acpi_topstar_init_hkey(struct topstar_hkey *hkey)
97 int error; 97 int error;
98 98
99 input = input_allocate_device(); 99 input = input_allocate_device();
100 if (!input) { 100 if (!input)
101 pr_err("Unable to allocate input device\n");
102 return -ENOMEM; 101 return -ENOMEM;
103 }
104 102
105 input->name = "Topstar Laptop extra buttons"; 103 input->name = "Topstar Laptop extra buttons";
106 input->phys = "topstar/input0"; 104 input->phys = "topstar/input0";
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 0cfadb65f7c6..7fce391818d3 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -975,10 +975,8 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
975 u32 hci_result; 975 u32 hci_result;
976 976
977 dev->hotkey_dev = input_allocate_device(); 977 dev->hotkey_dev = input_allocate_device();
978 if (!dev->hotkey_dev) { 978 if (!dev->hotkey_dev)
979 pr_info("Unable to register input device\n");
980 return -ENOMEM; 979 return -ENOMEM;
981 }
982 980
983 dev->hotkey_dev->name = "Toshiba input device"; 981 dev->hotkey_dev->name = "Toshiba input device";
984 dev->hotkey_dev->phys = "toshiba_acpi/input0"; 982 dev->hotkey_dev->phys = "toshiba_acpi/input0";
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 62e8c221d01e..c2e7b2657aeb 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -672,8 +672,10 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
672 struct wmi_block *wblock; 672 struct wmi_block *wblock;
673 673
674 wblock = dev_get_drvdata(dev); 674 wblock = dev_get_drvdata(dev);
675 if (!wblock) 675 if (!wblock) {
676 return -ENOMEM; 676 strcat(buf, "\n");
677 return strlen(buf);
678 }
677 679
678 wmi_gtoa(wblock->gblock.guid, guid_string); 680 wmi_gtoa(wblock->gblock.guid, guid_string);
679 681