aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/dell-laptop.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/platform/x86/dell-laptop.c')
-rw-r--r--drivers/platform/x86/dell-laptop.c98
1 files changed, 88 insertions, 10 deletions
diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index 4413975912e0..e39ab1d3ed87 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -11,6 +11,8 @@
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
12 */ 12 */
13 13
14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15
14#include <linux/module.h> 16#include <linux/module.h>
15#include <linux/kernel.h> 17#include <linux/kernel.h>
16#include <linux/init.h> 18#include <linux/init.h>
@@ -25,6 +27,8 @@
25#include <linux/mm.h> 27#include <linux/mm.h>
26#include <linux/i8042.h> 28#include <linux/i8042.h>
27#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/debugfs.h>
31#include <linux/seq_file.h>
28#include "../../firmware/dcdbas.h" 32#include "../../firmware/dcdbas.h"
29 33
30#define BRIGHTNESS_TOKEN 0x7d 34#define BRIGHTNESS_TOKEN 0x7d
@@ -325,6 +329,75 @@ static const struct rfkill_ops dell_rfkill_ops = {
325 .query = dell_rfkill_query, 329 .query = dell_rfkill_query,
326}; 330};
327 331
332static struct dentry *dell_laptop_dir;
333
334static int dell_debugfs_show(struct seq_file *s, void *data)
335{
336 int status;
337
338 get_buffer();
339 dell_send_request(buffer, 17, 11);
340 status = buffer->output[1];
341 release_buffer();
342
343 seq_printf(s, "status:\t0x%X\n", status);
344 seq_printf(s, "Bit 0 : Hardware switch supported: %lu\n",
345 status & BIT(0));
346 seq_printf(s, "Bit 1 : Wifi locator supported: %lu\n",
347 (status & BIT(1)) >> 1);
348 seq_printf(s, "Bit 2 : Wifi is supported: %lu\n",
349 (status & BIT(2)) >> 2);
350 seq_printf(s, "Bit 3 : Bluetooth is supported: %lu\n",
351 (status & BIT(3)) >> 3);
352 seq_printf(s, "Bit 4 : WWAN is supported: %lu\n",
353 (status & BIT(4)) >> 4);
354 seq_printf(s, "Bit 5 : Wireless keyboard supported: %lu\n",
355 (status & BIT(5)) >> 5);
356 seq_printf(s, "Bit 8 : Wifi is installed: %lu\n",
357 (status & BIT(8)) >> 8);
358 seq_printf(s, "Bit 9 : Bluetooth is installed: %lu\n",
359 (status & BIT(9)) >> 9);
360 seq_printf(s, "Bit 10: WWAN is installed: %lu\n",
361 (status & BIT(10)) >> 10);
362 seq_printf(s, "Bit 16: Hardware switch is on: %lu\n",
363 (status & BIT(16)) >> 16);
364 seq_printf(s, "Bit 17: Wifi is blocked: %lu\n",
365 (status & BIT(17)) >> 17);
366 seq_printf(s, "Bit 18: Bluetooth is blocked: %lu\n",
367 (status & BIT(18)) >> 18);
368 seq_printf(s, "Bit 19: WWAN is blocked: %lu\n",
369 (status & BIT(19)) >> 19);
370
371 seq_printf(s, "\nhwswitch_state:\t0x%X\n", hwswitch_state);
372 seq_printf(s, "Bit 0 : Wifi controlled by switch: %lu\n",
373 hwswitch_state & BIT(0));
374 seq_printf(s, "Bit 1 : Bluetooth controlled by switch: %lu\n",
375 (hwswitch_state & BIT(1)) >> 1);
376 seq_printf(s, "Bit 2 : WWAN controlled by switch: %lu\n",
377 (hwswitch_state & BIT(2)) >> 2);
378 seq_printf(s, "Bit 7 : Wireless switch config locked: %lu\n",
379 (hwswitch_state & BIT(7)) >> 7);
380 seq_printf(s, "Bit 8 : Wifi locator enabled: %lu\n",
381 (hwswitch_state & BIT(8)) >> 8);
382 seq_printf(s, "Bit 15: Wifi locator setting locked: %lu\n",
383 (hwswitch_state & BIT(15)) >> 15);
384
385 return 0;
386}
387
388static int dell_debugfs_open(struct inode *inode, struct file *file)
389{
390 return single_open(file, dell_debugfs_show, inode->i_private);
391}
392
393static const struct file_operations dell_debugfs_fops = {
394 .owner = THIS_MODULE,
395 .open = dell_debugfs_open,
396 .read = seq_read,
397 .llseek = seq_lseek,
398 .release = single_release,
399};
400
328static void dell_update_rfkill(struct work_struct *ignored) 401static void dell_update_rfkill(struct work_struct *ignored)
329{ 402{
330 if (wifi_rfkill) 403 if (wifi_rfkill)
@@ -343,8 +416,7 @@ static int __init dell_setup_rfkill(void)
343 int ret; 416 int ret;
344 417
345 if (dmi_check_system(dell_blacklist)) { 418 if (dmi_check_system(dell_blacklist)) {
346 printk(KERN_INFO "dell-laptop: Blacklisted hardware detected - " 419 pr_info("Blacklisted hardware detected - not enabling rfkill\n");
347 "not enabling rfkill\n");
348 return 0; 420 return 0;
349 } 421 }
350 422
@@ -468,14 +540,14 @@ static int dell_get_intensity(struct backlight_device *bd)
468 else 540 else
469 dell_send_request(buffer, 0, 1); 541 dell_send_request(buffer, 0, 1);
470 542
543 ret = buffer->output[1];
544
471out: 545out:
472 release_buffer(); 546 release_buffer();
473 if (ret) 547 return ret;
474 return ret;
475 return buffer->output[1];
476} 548}
477 549
478static struct backlight_ops dell_ops = { 550static const struct backlight_ops dell_ops = {
479 .get_brightness = dell_get_intensity, 551 .get_brightness = dell_get_intensity,
480 .update_status = dell_send_intensity, 552 .update_status = dell_send_intensity,
481}; 553};
@@ -515,7 +587,7 @@ static int __init dell_init(void)
515 dmi_walk(find_tokens, NULL); 587 dmi_walk(find_tokens, NULL);
516 588
517 if (!da_tokens) { 589 if (!da_tokens) {
518 printk(KERN_INFO "dell-laptop: Unable to find dmi tokens\n"); 590 pr_info("Unable to find dmi tokens\n");
519 return -ENODEV; 591 return -ENODEV;
520 } 592 }
521 593
@@ -545,17 +617,21 @@ static int __init dell_init(void)
545 ret = dell_setup_rfkill(); 617 ret = dell_setup_rfkill();
546 618
547 if (ret) { 619 if (ret) {
548 printk(KERN_WARNING "dell-laptop: Unable to setup rfkill\n"); 620 pr_warn("Unable to setup rfkill\n");
549 goto fail_rfkill; 621 goto fail_rfkill;
550 } 622 }
551 623
552 ret = i8042_install_filter(dell_laptop_i8042_filter); 624 ret = i8042_install_filter(dell_laptop_i8042_filter);
553 if (ret) { 625 if (ret) {
554 printk(KERN_WARNING 626 pr_warn("Unable to install key filter\n");
555 "dell-laptop: Unable to install key filter\n");
556 goto fail_filter; 627 goto fail_filter;
557 } 628 }
558 629
630 dell_laptop_dir = debugfs_create_dir("dell_laptop", NULL);
631 if (dell_laptop_dir != NULL)
632 debugfs_create_file("rfkill", 0444, dell_laptop_dir, NULL,
633 &dell_debugfs_fops);
634
559#ifdef CONFIG_ACPI 635#ifdef CONFIG_ACPI
560 /* In the event of an ACPI backlight being available, don't 636 /* In the event of an ACPI backlight being available, don't
561 * register the platform controller. 637 * register the platform controller.
@@ -575,6 +651,7 @@ static int __init dell_init(void)
575 if (max_intensity) { 651 if (max_intensity) {
576 struct backlight_properties props; 652 struct backlight_properties props;
577 memset(&props, 0, sizeof(struct backlight_properties)); 653 memset(&props, 0, sizeof(struct backlight_properties));
654 props.type = BACKLIGHT_PLATFORM;
578 props.max_brightness = max_intensity; 655 props.max_brightness = max_intensity;
579 dell_backlight_device = backlight_device_register("dell_backlight", 656 dell_backlight_device = backlight_device_register("dell_backlight",
580 &platform_device->dev, 657 &platform_device->dev,
@@ -615,6 +692,7 @@ fail_platform_driver:
615 692
616static void __exit dell_exit(void) 693static void __exit dell_exit(void)
617{ 694{
695 debugfs_remove_recursive(dell_laptop_dir);
618 i8042_remove_filter(dell_laptop_i8042_filter); 696 i8042_remove_filter(dell_laptop_i8042_filter);
619 cancel_delayed_work_sync(&dell_rfkill_work); 697 cancel_delayed_work_sync(&dell_rfkill_work);
620 backlight_device_unregister(dell_backlight_device); 698 backlight_device_unregister(dell_backlight_device);