Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Driver for Dell laptop extras |
| 3 | * |
| 4 | * Copyright (c) Red Hat <mjg@redhat.com> |
| 5 | * |
| 6 | * Based on documentation in the libsmbios package, Copyright (C) 2005 Dell |
| 7 | * Inc. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | |
Joe Perches | eb88952 | 2011-03-29 15:21:37 -0700 | [diff] [blame] | 14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 15 | |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 16 | #include <linux/module.h> |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/platform_device.h> |
| 20 | #include <linux/backlight.h> |
| 21 | #include <linux/err.h> |
| 22 | #include <linux/dmi.h> |
| 23 | #include <linux/io.h> |
| 24 | #include <linux/rfkill.h> |
| 25 | #include <linux/power_supply.h> |
| 26 | #include <linux/acpi.h> |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 27 | #include <linux/mm.h> |
Matthew Garrett | 814cb8a | 2009-12-09 18:23:36 +0000 | [diff] [blame] | 28 | #include <linux/i8042.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 29 | #include <linux/slab.h> |
Keng-Yu Lin | 037accf | 2010-09-28 11:43:31 +0800 | [diff] [blame] | 30 | #include <linux/debugfs.h> |
| 31 | #include <linux/seq_file.h> |
Len Brown | cad7312 | 2009-01-09 17:23:38 -0500 | [diff] [blame] | 32 | #include "../../firmware/dcdbas.h" |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 33 | |
| 34 | #define BRIGHTNESS_TOKEN 0x7d |
| 35 | |
| 36 | /* This structure will be modified by the firmware when we enter |
| 37 | * system management mode, hence the volatiles */ |
| 38 | |
| 39 | struct calling_interface_buffer { |
| 40 | u16 class; |
| 41 | u16 select; |
| 42 | volatile u32 input[4]; |
| 43 | volatile u32 output[4]; |
| 44 | } __packed; |
| 45 | |
| 46 | struct calling_interface_token { |
| 47 | u16 tokenID; |
| 48 | u16 location; |
| 49 | union { |
| 50 | u16 value; |
| 51 | u16 stringlength; |
| 52 | }; |
| 53 | }; |
| 54 | |
| 55 | struct calling_interface_structure { |
| 56 | struct dmi_header header; |
| 57 | u16 cmdIOAddress; |
| 58 | u8 cmdIOCode; |
| 59 | u32 supportedCmds; |
| 60 | struct calling_interface_token tokens[]; |
| 61 | } __packed; |
| 62 | |
AceLan Kao | 2d8b90b | 2011-10-04 16:25:44 +0800 | [diff] [blame] | 63 | struct quirk_entry { |
| 64 | u8 touchpad_led; |
| 65 | }; |
| 66 | |
| 67 | static struct quirk_entry *quirks; |
| 68 | |
| 69 | static struct quirk_entry quirk_dell_vostro_v130 = { |
| 70 | .touchpad_led = 1, |
| 71 | }; |
| 72 | |
| 73 | static int dmi_matched(const struct dmi_system_id *dmi) |
| 74 | { |
| 75 | quirks = dmi->driver_data; |
| 76 | return 1; |
| 77 | } |
| 78 | |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 79 | static int da_command_address; |
| 80 | static int da_command_code; |
| 81 | static int da_num_tokens; |
| 82 | static struct calling_interface_token *da_tokens; |
| 83 | |
Alan Jenkins | ada3248 | 2009-08-19 15:06:49 +0100 | [diff] [blame] | 84 | static struct platform_driver platform_driver = { |
| 85 | .driver = { |
| 86 | .name = "dell-laptop", |
| 87 | .owner = THIS_MODULE, |
| 88 | } |
| 89 | }; |
| 90 | |
| 91 | static struct platform_device *platform_device; |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 92 | static struct backlight_device *dell_backlight_device; |
| 93 | static struct rfkill *wifi_rfkill; |
| 94 | static struct rfkill *bluetooth_rfkill; |
| 95 | static struct rfkill *wwan_rfkill; |
| 96 | |
| 97 | static const struct dmi_system_id __initdata dell_device_table[] = { |
| 98 | { |
| 99 | .ident = "Dell laptop", |
| 100 | .matches = { |
| 101 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 102 | DMI_MATCH(DMI_CHASSIS_TYPE, "8"), |
| 103 | }, |
| 104 | }, |
Erik Andren | cb6a793 | 2010-02-14 11:53:23 -0500 | [diff] [blame] | 105 | { |
Rezwanul Kabir | 410d44c | 2010-06-23 12:02:43 -0500 | [diff] [blame] | 106 | .matches = { |
| 107 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 108 | DMI_MATCH(DMI_CHASSIS_TYPE, "9"), /*Laptop*/ |
| 109 | }, |
| 110 | }, |
| 111 | { |
Erik Andren | cb6a793 | 2010-02-14 11:53:23 -0500 | [diff] [blame] | 112 | .ident = "Dell Computer Corporation", |
| 113 | .matches = { |
| 114 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"), |
| 115 | DMI_MATCH(DMI_CHASSIS_TYPE, "8"), |
| 116 | }, |
| 117 | }, |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 118 | { } |
| 119 | }; |
Dmitry Torokhov | 35ae64f | 2011-11-14 00:25:00 -0800 | [diff] [blame^] | 120 | MODULE_DEVICE_TABLE(dmi, dell_device_table); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 121 | |
Mario Limonciello | e5fefd0 | 2010-02-09 17:41:03 -0500 | [diff] [blame] | 122 | static struct dmi_system_id __devinitdata dell_blacklist[] = { |
| 123 | /* Supported by compal-laptop */ |
| 124 | { |
| 125 | .ident = "Dell Mini 9", |
| 126 | .matches = { |
| 127 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 128 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 910"), |
| 129 | }, |
| 130 | }, |
| 131 | { |
| 132 | .ident = "Dell Mini 10", |
| 133 | .matches = { |
| 134 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 135 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1010"), |
| 136 | }, |
| 137 | }, |
| 138 | { |
| 139 | .ident = "Dell Mini 10v", |
| 140 | .matches = { |
| 141 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 142 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1011"), |
| 143 | }, |
| 144 | }, |
| 145 | { |
Victor van den Elzen | c3f755e | 2010-08-15 01:19:33 +0200 | [diff] [blame] | 146 | .ident = "Dell Mini 1012", |
| 147 | .matches = { |
| 148 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 149 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1012"), |
| 150 | }, |
| 151 | }, |
| 152 | { |
Mario Limonciello | e5fefd0 | 2010-02-09 17:41:03 -0500 | [diff] [blame] | 153 | .ident = "Dell Inspiron 11z", |
| 154 | .matches = { |
| 155 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 156 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1110"), |
| 157 | }, |
| 158 | }, |
| 159 | { |
| 160 | .ident = "Dell Mini 12", |
| 161 | .matches = { |
| 162 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 163 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1210"), |
| 164 | }, |
| 165 | }, |
| 166 | {} |
| 167 | }; |
| 168 | |
AceLan Kao | 2d8b90b | 2011-10-04 16:25:44 +0800 | [diff] [blame] | 169 | static struct dmi_system_id __devinitdata dell_quirks[] = { |
| 170 | { |
| 171 | .callback = dmi_matched, |
| 172 | .ident = "Dell Vostro V130", |
| 173 | .matches = { |
| 174 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 175 | DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V130"), |
| 176 | }, |
| 177 | .driver_data = &quirk_dell_vostro_v130, |
| 178 | }, |
| 179 | { |
| 180 | .callback = dmi_matched, |
| 181 | .ident = "Dell Vostro V131", |
| 182 | .matches = { |
| 183 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 184 | DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V131"), |
| 185 | }, |
| 186 | .driver_data = &quirk_dell_vostro_v130, |
| 187 | }, |
| 188 | }; |
| 189 | |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 190 | static struct calling_interface_buffer *buffer; |
Ingo Molnar | 94d8f78 | 2010-03-01 09:43:52 -0500 | [diff] [blame] | 191 | static struct page *bufferpage; |
| 192 | static DEFINE_MUTEX(buffer_mutex); |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 193 | |
Matthew Garrett | c6760ac | 2010-02-10 14:44:03 -0500 | [diff] [blame] | 194 | static int hwswitch_state; |
| 195 | |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 196 | static void get_buffer(void) |
| 197 | { |
| 198 | mutex_lock(&buffer_mutex); |
| 199 | memset(buffer, 0, sizeof(struct calling_interface_buffer)); |
| 200 | } |
| 201 | |
| 202 | static void release_buffer(void) |
| 203 | { |
| 204 | mutex_unlock(&buffer_mutex); |
| 205 | } |
| 206 | |
Alan Jenkins | 4788df4 | 2009-08-19 15:06:50 +0100 | [diff] [blame] | 207 | static void __init parse_da_table(const struct dmi_header *dm) |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 208 | { |
| 209 | /* Final token is a terminator, so we don't want to copy it */ |
| 210 | int tokens = (dm->length-11)/sizeof(struct calling_interface_token)-1; |
| 211 | struct calling_interface_structure *table = |
| 212 | container_of(dm, struct calling_interface_structure, header); |
| 213 | |
| 214 | /* 4 bytes of table header, plus 7 bytes of Dell header, plus at least |
| 215 | 6 bytes of entry */ |
| 216 | |
| 217 | if (dm->length < 17) |
| 218 | return; |
| 219 | |
| 220 | da_command_address = table->cmdIOAddress; |
| 221 | da_command_code = table->cmdIOCode; |
| 222 | |
| 223 | da_tokens = krealloc(da_tokens, (da_num_tokens + tokens) * |
| 224 | sizeof(struct calling_interface_token), |
| 225 | GFP_KERNEL); |
| 226 | |
| 227 | if (!da_tokens) |
| 228 | return; |
| 229 | |
| 230 | memcpy(da_tokens+da_num_tokens, table->tokens, |
| 231 | sizeof(struct calling_interface_token) * tokens); |
| 232 | |
| 233 | da_num_tokens += tokens; |
| 234 | } |
| 235 | |
Alan Jenkins | 4788df4 | 2009-08-19 15:06:50 +0100 | [diff] [blame] | 236 | static void __init find_tokens(const struct dmi_header *dm, void *dummy) |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 237 | { |
| 238 | switch (dm->type) { |
| 239 | case 0xd4: /* Indexed IO */ |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 240 | case 0xd5: /* Protected Area Type 1 */ |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 241 | case 0xd6: /* Protected Area Type 2 */ |
| 242 | break; |
| 243 | case 0xda: /* Calling interface */ |
| 244 | parse_da_table(dm); |
| 245 | break; |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | static int find_token_location(int tokenid) |
| 250 | { |
| 251 | int i; |
| 252 | for (i = 0; i < da_num_tokens; i++) { |
| 253 | if (da_tokens[i].tokenID == tokenid) |
| 254 | return da_tokens[i].location; |
| 255 | } |
| 256 | |
| 257 | return -1; |
| 258 | } |
| 259 | |
| 260 | static struct calling_interface_buffer * |
| 261 | dell_send_request(struct calling_interface_buffer *buffer, int class, |
| 262 | int select) |
| 263 | { |
| 264 | struct smi_cmd command; |
| 265 | |
| 266 | command.magic = SMI_CMD_MAGIC; |
| 267 | command.command_address = da_command_address; |
| 268 | command.command_code = da_command_code; |
| 269 | command.ebx = virt_to_phys(buffer); |
| 270 | command.ecx = 0x42534931; |
| 271 | |
| 272 | buffer->class = class; |
| 273 | buffer->select = select; |
| 274 | |
| 275 | dcdbas_smi_request(&command); |
| 276 | |
| 277 | return buffer; |
| 278 | } |
| 279 | |
| 280 | /* Derived from information in DellWirelessCtl.cpp: |
| 281 | Class 17, select 11 is radio control. It returns an array of 32-bit values. |
| 282 | |
Matthew Garrett | c6760ac | 2010-02-10 14:44:03 -0500 | [diff] [blame] | 283 | Input byte 0 = 0: Wireless information |
| 284 | |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 285 | result[0]: return code |
| 286 | result[1]: |
| 287 | Bit 0: Hardware switch supported |
| 288 | Bit 1: Wifi locator supported |
| 289 | Bit 2: Wifi is supported |
| 290 | Bit 3: Bluetooth is supported |
| 291 | Bit 4: WWAN is supported |
| 292 | Bit 5: Wireless keyboard supported |
| 293 | Bits 6-7: Reserved |
| 294 | Bit 8: Wifi is installed |
| 295 | Bit 9: Bluetooth is installed |
| 296 | Bit 10: WWAN is installed |
| 297 | Bits 11-15: Reserved |
| 298 | Bit 16: Hardware switch is on |
| 299 | Bit 17: Wifi is blocked |
| 300 | Bit 18: Bluetooth is blocked |
| 301 | Bit 19: WWAN is blocked |
| 302 | Bits 20-31: Reserved |
| 303 | result[2]: NVRAM size in bytes |
| 304 | result[3]: NVRAM format version number |
Matthew Garrett | c6760ac | 2010-02-10 14:44:03 -0500 | [diff] [blame] | 305 | |
| 306 | Input byte 0 = 2: Wireless switch configuration |
| 307 | result[0]: return code |
| 308 | result[1]: |
| 309 | Bit 0: Wifi controlled by switch |
| 310 | Bit 1: Bluetooth controlled by switch |
| 311 | Bit 2: WWAN controlled by switch |
| 312 | Bits 3-6: Reserved |
| 313 | Bit 7: Wireless switch config locked |
| 314 | Bit 8: Wifi locator enabled |
| 315 | Bits 9-14: Reserved |
| 316 | Bit 15: Wifi locator setting locked |
| 317 | Bits 16-31: Reserved |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 318 | */ |
| 319 | |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 320 | static int dell_rfkill_set(void *data, bool blocked) |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 321 | { |
Johannes Berg | 624f0de | 2009-06-15 16:26:47 +0200 | [diff] [blame] | 322 | int disable = blocked ? 1 : 0; |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 323 | unsigned long radio = (unsigned long)data; |
Matthew Garrett | c6760ac | 2010-02-10 14:44:03 -0500 | [diff] [blame] | 324 | int hwswitch_bit = (unsigned long)data - 1; |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 325 | int ret = 0; |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 326 | |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 327 | get_buffer(); |
| 328 | dell_send_request(buffer, 17, 11); |
Mario Limonciello | ec1722a | 2010-02-09 14:11:05 -0500 | [diff] [blame] | 329 | |
Matthew Garrett | c6760ac | 2010-02-10 14:44:03 -0500 | [diff] [blame] | 330 | /* If the hardware switch controls this radio, and the hardware |
Keng-Yu Lin | be65dde8 | 2011-06-27 11:19:03 +0100 | [diff] [blame] | 331 | switch is disabled, don't allow changing the software state */ |
Matthew Garrett | c6760ac | 2010-02-10 14:44:03 -0500 | [diff] [blame] | 332 | if ((hwswitch_state & BIT(hwswitch_bit)) && |
Keng-Yu Lin | be65dde8 | 2011-06-27 11:19:03 +0100 | [diff] [blame] | 333 | !(buffer->output[1] & BIT(16))) { |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 334 | ret = -EINVAL; |
| 335 | goto out; |
| 336 | } |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 337 | |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 338 | buffer->input[0] = (1 | (radio<<8) | (disable << 16)); |
| 339 | dell_send_request(buffer, 17, 11); |
| 340 | |
| 341 | out: |
| 342 | release_buffer(); |
| 343 | return ret; |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 344 | } |
| 345 | |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 346 | static void dell_rfkill_query(struct rfkill *rfkill, void *data) |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 347 | { |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 348 | int status; |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 349 | int bit = (unsigned long)data + 16; |
Matthew Garrett | c6760ac | 2010-02-10 14:44:03 -0500 | [diff] [blame] | 350 | int hwswitch_bit = (unsigned long)data - 1; |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 351 | |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 352 | get_buffer(); |
| 353 | dell_send_request(buffer, 17, 11); |
| 354 | status = buffer->output[1]; |
| 355 | release_buffer(); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 356 | |
Matthew Garrett | e1fbf34 | 2009-07-31 03:25:38 +0100 | [diff] [blame] | 357 | rfkill_set_sw_state(rfkill, !!(status & BIT(bit))); |
Matthew Garrett | c6760ac | 2010-02-10 14:44:03 -0500 | [diff] [blame] | 358 | |
| 359 | if (hwswitch_state & (BIT(hwswitch_bit))) |
| 360 | rfkill_set_hw_state(rfkill, !(status & BIT(16))); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 361 | } |
| 362 | |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 363 | static const struct rfkill_ops dell_rfkill_ops = { |
| 364 | .set_block = dell_rfkill_set, |
| 365 | .query = dell_rfkill_query, |
| 366 | }; |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 367 | |
Keng-Yu Lin | 037accf | 2010-09-28 11:43:31 +0800 | [diff] [blame] | 368 | static struct dentry *dell_laptop_dir; |
| 369 | |
| 370 | static int dell_debugfs_show(struct seq_file *s, void *data) |
| 371 | { |
| 372 | int status; |
| 373 | |
| 374 | get_buffer(); |
| 375 | dell_send_request(buffer, 17, 11); |
| 376 | status = buffer->output[1]; |
| 377 | release_buffer(); |
| 378 | |
| 379 | seq_printf(s, "status:\t0x%X\n", status); |
| 380 | seq_printf(s, "Bit 0 : Hardware switch supported: %lu\n", |
| 381 | status & BIT(0)); |
| 382 | seq_printf(s, "Bit 1 : Wifi locator supported: %lu\n", |
| 383 | (status & BIT(1)) >> 1); |
| 384 | seq_printf(s, "Bit 2 : Wifi is supported: %lu\n", |
| 385 | (status & BIT(2)) >> 2); |
| 386 | seq_printf(s, "Bit 3 : Bluetooth is supported: %lu\n", |
| 387 | (status & BIT(3)) >> 3); |
| 388 | seq_printf(s, "Bit 4 : WWAN is supported: %lu\n", |
| 389 | (status & BIT(4)) >> 4); |
| 390 | seq_printf(s, "Bit 5 : Wireless keyboard supported: %lu\n", |
| 391 | (status & BIT(5)) >> 5); |
| 392 | seq_printf(s, "Bit 8 : Wifi is installed: %lu\n", |
| 393 | (status & BIT(8)) >> 8); |
| 394 | seq_printf(s, "Bit 9 : Bluetooth is installed: %lu\n", |
| 395 | (status & BIT(9)) >> 9); |
| 396 | seq_printf(s, "Bit 10: WWAN is installed: %lu\n", |
| 397 | (status & BIT(10)) >> 10); |
| 398 | seq_printf(s, "Bit 16: Hardware switch is on: %lu\n", |
| 399 | (status & BIT(16)) >> 16); |
| 400 | seq_printf(s, "Bit 17: Wifi is blocked: %lu\n", |
| 401 | (status & BIT(17)) >> 17); |
| 402 | seq_printf(s, "Bit 18: Bluetooth is blocked: %lu\n", |
| 403 | (status & BIT(18)) >> 18); |
| 404 | seq_printf(s, "Bit 19: WWAN is blocked: %lu\n", |
| 405 | (status & BIT(19)) >> 19); |
| 406 | |
| 407 | seq_printf(s, "\nhwswitch_state:\t0x%X\n", hwswitch_state); |
| 408 | seq_printf(s, "Bit 0 : Wifi controlled by switch: %lu\n", |
| 409 | hwswitch_state & BIT(0)); |
| 410 | seq_printf(s, "Bit 1 : Bluetooth controlled by switch: %lu\n", |
| 411 | (hwswitch_state & BIT(1)) >> 1); |
| 412 | seq_printf(s, "Bit 2 : WWAN controlled by switch: %lu\n", |
| 413 | (hwswitch_state & BIT(2)) >> 2); |
| 414 | seq_printf(s, "Bit 7 : Wireless switch config locked: %lu\n", |
| 415 | (hwswitch_state & BIT(7)) >> 7); |
| 416 | seq_printf(s, "Bit 8 : Wifi locator enabled: %lu\n", |
| 417 | (hwswitch_state & BIT(8)) >> 8); |
| 418 | seq_printf(s, "Bit 15: Wifi locator setting locked: %lu\n", |
| 419 | (hwswitch_state & BIT(15)) >> 15); |
| 420 | |
| 421 | return 0; |
| 422 | } |
| 423 | |
| 424 | static int dell_debugfs_open(struct inode *inode, struct file *file) |
| 425 | { |
| 426 | return single_open(file, dell_debugfs_show, inode->i_private); |
| 427 | } |
| 428 | |
| 429 | static const struct file_operations dell_debugfs_fops = { |
| 430 | .owner = THIS_MODULE, |
| 431 | .open = dell_debugfs_open, |
| 432 | .read = seq_read, |
| 433 | .llseek = seq_lseek, |
| 434 | .release = single_release, |
| 435 | }; |
| 436 | |
Matthew Garrett | 814cb8a | 2009-12-09 18:23:36 +0000 | [diff] [blame] | 437 | static void dell_update_rfkill(struct work_struct *ignored) |
| 438 | { |
| 439 | if (wifi_rfkill) |
| 440 | dell_rfkill_query(wifi_rfkill, (void *)1); |
| 441 | if (bluetooth_rfkill) |
| 442 | dell_rfkill_query(bluetooth_rfkill, (void *)2); |
| 443 | if (wwan_rfkill) |
| 444 | dell_rfkill_query(wwan_rfkill, (void *)3); |
| 445 | } |
| 446 | static DECLARE_DELAYED_WORK(dell_rfkill_work, dell_update_rfkill); |
| 447 | |
| 448 | |
Alan Jenkins | 4788df4 | 2009-08-19 15:06:50 +0100 | [diff] [blame] | 449 | static int __init dell_setup_rfkill(void) |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 450 | { |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 451 | int status; |
| 452 | int ret; |
| 453 | |
Mario Limonciello | e5fefd0 | 2010-02-09 17:41:03 -0500 | [diff] [blame] | 454 | if (dmi_check_system(dell_blacklist)) { |
Joe Perches | eb88952 | 2011-03-29 15:21:37 -0700 | [diff] [blame] | 455 | pr_info("Blacklisted hardware detected - not enabling rfkill\n"); |
Mario Limonciello | e5fefd0 | 2010-02-09 17:41:03 -0500 | [diff] [blame] | 456 | return 0; |
| 457 | } |
| 458 | |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 459 | get_buffer(); |
| 460 | dell_send_request(buffer, 17, 11); |
| 461 | status = buffer->output[1]; |
Matthew Garrett | c6760ac | 2010-02-10 14:44:03 -0500 | [diff] [blame] | 462 | buffer->input[0] = 0x2; |
| 463 | dell_send_request(buffer, 17, 11); |
| 464 | hwswitch_state = buffer->output[1]; |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 465 | release_buffer(); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 466 | |
| 467 | if ((status & (1<<2|1<<8)) == (1<<2|1<<8)) { |
Alan Jenkins | ada3248 | 2009-08-19 15:06:49 +0100 | [diff] [blame] | 468 | wifi_rfkill = rfkill_alloc("dell-wifi", &platform_device->dev, |
| 469 | RFKILL_TYPE_WLAN, |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 470 | &dell_rfkill_ops, (void *) 1); |
| 471 | if (!wifi_rfkill) { |
| 472 | ret = -ENOMEM; |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 473 | goto err_wifi; |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 474 | } |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 475 | ret = rfkill_register(wifi_rfkill); |
| 476 | if (ret) |
| 477 | goto err_wifi; |
| 478 | } |
| 479 | |
| 480 | if ((status & (1<<3|1<<9)) == (1<<3|1<<9)) { |
Alan Jenkins | ada3248 | 2009-08-19 15:06:49 +0100 | [diff] [blame] | 481 | bluetooth_rfkill = rfkill_alloc("dell-bluetooth", |
| 482 | &platform_device->dev, |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 483 | RFKILL_TYPE_BLUETOOTH, |
| 484 | &dell_rfkill_ops, (void *) 2); |
| 485 | if (!bluetooth_rfkill) { |
| 486 | ret = -ENOMEM; |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 487 | goto err_bluetooth; |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 488 | } |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 489 | ret = rfkill_register(bluetooth_rfkill); |
| 490 | if (ret) |
| 491 | goto err_bluetooth; |
| 492 | } |
| 493 | |
| 494 | if ((status & (1<<4|1<<10)) == (1<<4|1<<10)) { |
Alan Jenkins | ada3248 | 2009-08-19 15:06:49 +0100 | [diff] [blame] | 495 | wwan_rfkill = rfkill_alloc("dell-wwan", |
| 496 | &platform_device->dev, |
| 497 | RFKILL_TYPE_WWAN, |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 498 | &dell_rfkill_ops, (void *) 3); |
| 499 | if (!wwan_rfkill) { |
| 500 | ret = -ENOMEM; |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 501 | goto err_wwan; |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 502 | } |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 503 | ret = rfkill_register(wwan_rfkill); |
| 504 | if (ret) |
| 505 | goto err_wwan; |
| 506 | } |
| 507 | |
| 508 | return 0; |
| 509 | err_wwan: |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 510 | rfkill_destroy(wwan_rfkill); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 511 | if (bluetooth_rfkill) |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 512 | rfkill_unregister(bluetooth_rfkill); |
| 513 | err_bluetooth: |
| 514 | rfkill_destroy(bluetooth_rfkill); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 515 | if (wifi_rfkill) |
Johannes Berg | 19d337d | 2009-06-02 13:01:37 +0200 | [diff] [blame] | 516 | rfkill_unregister(wifi_rfkill); |
| 517 | err_wifi: |
| 518 | rfkill_destroy(wifi_rfkill); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 519 | |
| 520 | return ret; |
| 521 | } |
| 522 | |
Alan Jenkins | 4311bb2 | 2009-08-19 15:06:48 +0100 | [diff] [blame] | 523 | static void dell_cleanup_rfkill(void) |
| 524 | { |
| 525 | if (wifi_rfkill) { |
| 526 | rfkill_unregister(wifi_rfkill); |
| 527 | rfkill_destroy(wifi_rfkill); |
| 528 | } |
| 529 | if (bluetooth_rfkill) { |
| 530 | rfkill_unregister(bluetooth_rfkill); |
| 531 | rfkill_destroy(bluetooth_rfkill); |
| 532 | } |
| 533 | if (wwan_rfkill) { |
| 534 | rfkill_unregister(wwan_rfkill); |
| 535 | rfkill_destroy(wwan_rfkill); |
| 536 | } |
| 537 | } |
| 538 | |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 539 | static int dell_send_intensity(struct backlight_device *bd) |
| 540 | { |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 541 | int ret = 0; |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 542 | |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 543 | get_buffer(); |
| 544 | buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN); |
| 545 | buffer->input[1] = bd->props.brightness; |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 546 | |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 547 | if (buffer->input[0] == -1) { |
| 548 | ret = -ENODEV; |
| 549 | goto out; |
| 550 | } |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 551 | |
| 552 | if (power_supply_is_system_supplied() > 0) |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 553 | dell_send_request(buffer, 1, 2); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 554 | else |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 555 | dell_send_request(buffer, 1, 1); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 556 | |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 557 | out: |
| 558 | release_buffer(); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 559 | return 0; |
| 560 | } |
| 561 | |
| 562 | static int dell_get_intensity(struct backlight_device *bd) |
| 563 | { |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 564 | int ret = 0; |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 565 | |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 566 | get_buffer(); |
| 567 | buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 568 | |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 569 | if (buffer->input[0] == -1) { |
| 570 | ret = -ENODEV; |
| 571 | goto out; |
| 572 | } |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 573 | |
| 574 | if (power_supply_is_system_supplied() > 0) |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 575 | dell_send_request(buffer, 0, 2); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 576 | else |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 577 | dell_send_request(buffer, 0, 1); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 578 | |
Jose Alonso | b486742 | 2011-07-10 15:46:51 -0300 | [diff] [blame] | 579 | ret = buffer->output[1]; |
| 580 | |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 581 | out: |
| 582 | release_buffer(); |
Jose Alonso | b486742 | 2011-07-10 15:46:51 -0300 | [diff] [blame] | 583 | return ret; |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 584 | } |
| 585 | |
Lionel Debroux | acc2472 | 2010-11-16 14:14:02 +0100 | [diff] [blame] | 586 | static const struct backlight_ops dell_ops = { |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 587 | .get_brightness = dell_get_intensity, |
| 588 | .update_status = dell_send_intensity, |
| 589 | }; |
| 590 | |
Randy Dunlap | 869f8df | 2011-11-16 18:20:51 -0800 | [diff] [blame] | 591 | static void touchpad_led_on(void) |
AceLan Kao | 2d8b90b | 2011-10-04 16:25:44 +0800 | [diff] [blame] | 592 | { |
| 593 | int command = 0x97; |
| 594 | char data = 1; |
| 595 | i8042_command(&data, command | 1 << 12); |
| 596 | } |
| 597 | |
Randy Dunlap | 869f8df | 2011-11-16 18:20:51 -0800 | [diff] [blame] | 598 | static void touchpad_led_off(void) |
AceLan Kao | 2d8b90b | 2011-10-04 16:25:44 +0800 | [diff] [blame] | 599 | { |
| 600 | int command = 0x97; |
| 601 | char data = 2; |
| 602 | i8042_command(&data, command | 1 << 12); |
| 603 | } |
| 604 | |
| 605 | static void touchpad_led_set(struct led_classdev *led_cdev, |
| 606 | enum led_brightness value) |
| 607 | { |
| 608 | if (value > 0) |
| 609 | touchpad_led_on(); |
| 610 | else |
| 611 | touchpad_led_off(); |
| 612 | } |
| 613 | |
| 614 | static struct led_classdev touchpad_led = { |
| 615 | .name = "dell-laptop::touchpad", |
| 616 | .brightness_set = touchpad_led_set, |
| 617 | }; |
| 618 | |
| 619 | static int __devinit touchpad_led_init(struct device *dev) |
| 620 | { |
| 621 | return led_classdev_register(dev, &touchpad_led); |
| 622 | } |
| 623 | |
| 624 | static void touchpad_led_exit(void) |
| 625 | { |
| 626 | led_classdev_unregister(&touchpad_led); |
| 627 | } |
| 628 | |
Axel Lin | 4519169 | 2010-07-05 17:21:10 +0800 | [diff] [blame] | 629 | static bool dell_laptop_i8042_filter(unsigned char data, unsigned char str, |
Matthew Garrett | 814cb8a | 2009-12-09 18:23:36 +0000 | [diff] [blame] | 630 | struct serio *port) |
| 631 | { |
| 632 | static bool extended; |
| 633 | |
| 634 | if (str & 0x20) |
| 635 | return false; |
| 636 | |
| 637 | if (unlikely(data == 0xe0)) { |
| 638 | extended = true; |
| 639 | return false; |
| 640 | } else if (unlikely(extended)) { |
| 641 | switch (data) { |
| 642 | case 0x8: |
| 643 | schedule_delayed_work(&dell_rfkill_work, |
| 644 | round_jiffies_relative(HZ)); |
| 645 | break; |
| 646 | } |
| 647 | extended = false; |
| 648 | } |
| 649 | |
| 650 | return false; |
| 651 | } |
| 652 | |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 653 | static int __init dell_init(void) |
| 654 | { |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 655 | int max_intensity = 0; |
| 656 | int ret; |
| 657 | |
| 658 | if (!dmi_check_system(dell_device_table)) |
| 659 | return -ENODEV; |
| 660 | |
AceLan Kao | 2d8b90b | 2011-10-04 16:25:44 +0800 | [diff] [blame] | 661 | quirks = NULL; |
| 662 | /* find if this machine support other functions */ |
| 663 | dmi_check_system(dell_quirks); |
| 664 | |
Jean Delvare | e7a19c5 | 2009-03-30 21:46:44 +0200 | [diff] [blame] | 665 | dmi_walk(find_tokens, NULL); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 666 | |
| 667 | if (!da_tokens) { |
Joe Perches | eb88952 | 2011-03-29 15:21:37 -0700 | [diff] [blame] | 668 | pr_info("Unable to find dmi tokens\n"); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 669 | return -ENODEV; |
| 670 | } |
| 671 | |
Alan Jenkins | ada3248 | 2009-08-19 15:06:49 +0100 | [diff] [blame] | 672 | ret = platform_driver_register(&platform_driver); |
| 673 | if (ret) |
| 674 | goto fail_platform_driver; |
| 675 | platform_device = platform_device_alloc("dell-laptop", -1); |
| 676 | if (!platform_device) { |
| 677 | ret = -ENOMEM; |
| 678 | goto fail_platform_device1; |
| 679 | } |
| 680 | ret = platform_device_add(platform_device); |
| 681 | if (ret) |
| 682 | goto fail_platform_device2; |
| 683 | |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 684 | /* |
| 685 | * Allocate buffer below 4GB for SMI data--only 32-bit physical addr |
| 686 | * is passed to SMI handler. |
| 687 | */ |
| 688 | bufferpage = alloc_page(GFP_KERNEL | GFP_DMA32); |
| 689 | |
| 690 | if (!bufferpage) |
| 691 | goto fail_buffer; |
| 692 | buffer = page_address(bufferpage); |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 693 | |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 694 | ret = dell_setup_rfkill(); |
| 695 | |
| 696 | if (ret) { |
Joe Perches | eb88952 | 2011-03-29 15:21:37 -0700 | [diff] [blame] | 697 | pr_warn("Unable to setup rfkill\n"); |
Alan Jenkins | 71e9dc7 | 2009-08-19 15:06:47 +0100 | [diff] [blame] | 698 | goto fail_rfkill; |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 699 | } |
| 700 | |
Matthew Garrett | 814cb8a | 2009-12-09 18:23:36 +0000 | [diff] [blame] | 701 | ret = i8042_install_filter(dell_laptop_i8042_filter); |
| 702 | if (ret) { |
Joe Perches | eb88952 | 2011-03-29 15:21:37 -0700 | [diff] [blame] | 703 | pr_warn("Unable to install key filter\n"); |
Matthew Garrett | 814cb8a | 2009-12-09 18:23:36 +0000 | [diff] [blame] | 704 | goto fail_filter; |
| 705 | } |
| 706 | |
AceLan Kao | 2d8b90b | 2011-10-04 16:25:44 +0800 | [diff] [blame] | 707 | if (quirks && quirks->touchpad_led) |
| 708 | touchpad_led_init(&platform_device->dev); |
| 709 | |
Keng-Yu Lin | 037accf | 2010-09-28 11:43:31 +0800 | [diff] [blame] | 710 | dell_laptop_dir = debugfs_create_dir("dell_laptop", NULL); |
| 711 | if (dell_laptop_dir != NULL) |
| 712 | debugfs_create_file("rfkill", 0444, dell_laptop_dir, NULL, |
| 713 | &dell_debugfs_fops); |
| 714 | |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 715 | #ifdef CONFIG_ACPI |
| 716 | /* In the event of an ACPI backlight being available, don't |
| 717 | * register the platform controller. |
| 718 | */ |
| 719 | if (acpi_video_backlight_support()) |
| 720 | return 0; |
| 721 | #endif |
| 722 | |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 723 | get_buffer(); |
| 724 | buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN); |
| 725 | if (buffer->input[0] != -1) { |
| 726 | dell_send_request(buffer, 0, 2); |
| 727 | max_intensity = buffer->output[3]; |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 728 | } |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 729 | release_buffer(); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 730 | |
| 731 | if (max_intensity) { |
Matthew Garrett | a19a6ee | 2010-02-17 16:39:44 -0500 | [diff] [blame] | 732 | struct backlight_properties props; |
| 733 | memset(&props, 0, sizeof(struct backlight_properties)); |
Matthew Garrett | bb7ca74 | 2011-03-22 16:30:21 -0700 | [diff] [blame] | 734 | props.type = BACKLIGHT_PLATFORM; |
Matthew Garrett | a19a6ee | 2010-02-17 16:39:44 -0500 | [diff] [blame] | 735 | props.max_brightness = max_intensity; |
| 736 | dell_backlight_device = backlight_device_register("dell_backlight", |
| 737 | &platform_device->dev, |
| 738 | NULL, |
| 739 | &dell_ops, |
| 740 | &props); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 741 | |
| 742 | if (IS_ERR(dell_backlight_device)) { |
| 743 | ret = PTR_ERR(dell_backlight_device); |
| 744 | dell_backlight_device = NULL; |
Alan Jenkins | 71e9dc7 | 2009-08-19 15:06:47 +0100 | [diff] [blame] | 745 | goto fail_backlight; |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 746 | } |
| 747 | |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 748 | dell_backlight_device->props.brightness = |
| 749 | dell_get_intensity(dell_backlight_device); |
| 750 | backlight_update_status(dell_backlight_device); |
| 751 | } |
| 752 | |
| 753 | return 0; |
Alan Jenkins | 71e9dc7 | 2009-08-19 15:06:47 +0100 | [diff] [blame] | 754 | |
| 755 | fail_backlight: |
Matthew Garrett | 814cb8a | 2009-12-09 18:23:36 +0000 | [diff] [blame] | 756 | i8042_remove_filter(dell_laptop_i8042_filter); |
Matthew Garrett | 92e00e4 | 2010-03-01 09:46:43 -0500 | [diff] [blame] | 757 | cancel_delayed_work_sync(&dell_rfkill_work); |
Matthew Garrett | 814cb8a | 2009-12-09 18:23:36 +0000 | [diff] [blame] | 758 | fail_filter: |
Alan Jenkins | 4311bb2 | 2009-08-19 15:06:48 +0100 | [diff] [blame] | 759 | dell_cleanup_rfkill(); |
Alan Jenkins | 71e9dc7 | 2009-08-19 15:06:47 +0100 | [diff] [blame] | 760 | fail_rfkill: |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 761 | free_page((unsigned long)bufferpage); |
| 762 | fail_buffer: |
Alan Jenkins | ada3248 | 2009-08-19 15:06:49 +0100 | [diff] [blame] | 763 | platform_device_del(platform_device); |
| 764 | fail_platform_device2: |
| 765 | platform_device_put(platform_device); |
| 766 | fail_platform_device1: |
| 767 | platform_driver_unregister(&platform_driver); |
| 768 | fail_platform_driver: |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 769 | kfree(da_tokens); |
| 770 | return ret; |
| 771 | } |
| 772 | |
| 773 | static void __exit dell_exit(void) |
| 774 | { |
Keng-Yu Lin | 037accf | 2010-09-28 11:43:31 +0800 | [diff] [blame] | 775 | debugfs_remove_recursive(dell_laptop_dir); |
AceLan Kao | 2d8b90b | 2011-10-04 16:25:44 +0800 | [diff] [blame] | 776 | if (quirks && quirks->touchpad_led) |
| 777 | touchpad_led_exit(); |
Matthew Garrett | 814cb8a | 2009-12-09 18:23:36 +0000 | [diff] [blame] | 778 | i8042_remove_filter(dell_laptop_i8042_filter); |
Matthew Garrett | 92e00e4 | 2010-03-01 09:46:43 -0500 | [diff] [blame] | 779 | cancel_delayed_work_sync(&dell_rfkill_work); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 780 | backlight_device_unregister(dell_backlight_device); |
Alan Jenkins | 4311bb2 | 2009-08-19 15:06:48 +0100 | [diff] [blame] | 781 | dell_cleanup_rfkill(); |
Matthew Garrett | facd61d | 2010-02-09 14:03:04 -0500 | [diff] [blame] | 782 | if (platform_device) { |
Matthew Garrett | 92e00e4 | 2010-03-01 09:46:43 -0500 | [diff] [blame] | 783 | platform_device_unregister(platform_device); |
Matthew Garrett | facd61d | 2010-02-09 14:03:04 -0500 | [diff] [blame] | 784 | platform_driver_unregister(&platform_driver); |
| 785 | } |
Matthew Garrett | e551260 | 2010-02-09 14:05:01 -0500 | [diff] [blame] | 786 | kfree(da_tokens); |
Stuart Hayes | 116ee77 | 2010-02-10 14:12:13 -0500 | [diff] [blame] | 787 | free_page((unsigned long)buffer); |
Matthew Garrett | ad8f07c | 2009-01-07 18:08:56 -0800 | [diff] [blame] | 788 | } |
| 789 | |
| 790 | module_init(dell_init); |
| 791 | module_exit(dell_exit); |
| 792 | |
| 793 | MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>"); |
| 794 | MODULE_DESCRIPTION("Dell laptop driver"); |
| 795 | MODULE_LICENSE("GPL"); |