2009-01-08 02:08:56 +00:00
|
|
|
/*
|
|
|
|
* Driver for Dell laptop extras
|
|
|
|
*
|
|
|
|
* Copyright (c) Red Hat <mjg@redhat.com>
|
|
|
|
*
|
|
|
|
* Based on documentation in the libsmbios package, Copyright (C) 2005 Dell
|
|
|
|
* Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
2011-03-29 22:21:37 +00:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2009-01-08 02:08:56 +00:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/backlight.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/dmi.h>
|
|
|
|
#include <linux/io.h>
|
2013-11-17 13:00:16 +00:00
|
|
|
#include <linux/rfkill.h>
|
2009-01-08 02:08:56 +00:00
|
|
|
#include <linux/power_supply.h>
|
|
|
|
#include <linux/acpi.h>
|
2010-02-10 19:12:13 +00:00
|
|
|
#include <linux/mm.h>
|
2009-12-09 18:23:36 +00:00
|
|
|
#include <linux/i8042.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2010-09-28 03:43:31 +00:00
|
|
|
#include <linux/debugfs.h>
|
|
|
|
#include <linux/seq_file.h>
|
2009-01-09 22:23:38 +00:00
|
|
|
#include "../../firmware/dcdbas.h"
|
2009-01-08 02:08:56 +00:00
|
|
|
|
|
|
|
#define BRIGHTNESS_TOKEN 0x7d
|
|
|
|
|
|
|
|
/* This structure will be modified by the firmware when we enter
|
|
|
|
* system management mode, hence the volatiles */
|
|
|
|
|
|
|
|
struct calling_interface_buffer {
|
|
|
|
u16 class;
|
|
|
|
u16 select;
|
|
|
|
volatile u32 input[4];
|
|
|
|
volatile u32 output[4];
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct calling_interface_token {
|
|
|
|
u16 tokenID;
|
|
|
|
u16 location;
|
|
|
|
union {
|
|
|
|
u16 value;
|
|
|
|
u16 stringlength;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct calling_interface_structure {
|
|
|
|
struct dmi_header header;
|
|
|
|
u16 cmdIOAddress;
|
|
|
|
u8 cmdIOCode;
|
|
|
|
u32 supportedCmds;
|
|
|
|
struct calling_interface_token tokens[];
|
|
|
|
} __packed;
|
|
|
|
|
2011-10-04 08:25:44 +00:00
|
|
|
struct quirk_entry {
|
|
|
|
u8 touchpad_led;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct quirk_entry *quirks;
|
|
|
|
|
|
|
|
static struct quirk_entry quirk_dell_vostro_v130 = {
|
|
|
|
.touchpad_led = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int dmi_matched(const struct dmi_system_id *dmi)
|
|
|
|
{
|
|
|
|
quirks = dmi->driver_data;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-01-08 02:08:56 +00:00
|
|
|
static int da_command_address;
|
|
|
|
static int da_command_code;
|
|
|
|
static int da_num_tokens;
|
|
|
|
static struct calling_interface_token *da_tokens;
|
|
|
|
|
2009-08-19 14:06:49 +00:00
|
|
|
static struct platform_driver platform_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "dell-laptop",
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device *platform_device;
|
2009-01-08 02:08:56 +00:00
|
|
|
static struct backlight_device *dell_backlight_device;
|
2013-11-17 13:00:16 +00:00
|
|
|
static struct rfkill *wifi_rfkill;
|
|
|
|
static struct rfkill *bluetooth_rfkill;
|
|
|
|
static struct rfkill *wwan_rfkill;
|
2009-01-08 02:08:56 +00:00
|
|
|
|
2012-03-30 20:05:04 +00:00
|
|
|
static const struct dmi_system_id dell_device_table[] __initconst = {
|
2009-01-08 02:08:56 +00:00
|
|
|
{
|
|
|
|
.ident = "Dell laptop",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
|
|
|
DMI_MATCH(DMI_CHASSIS_TYPE, "8"),
|
|
|
|
},
|
|
|
|
},
|
2010-06-23 17:02:43 +00:00
|
|
|
{
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
|
|
|
DMI_MATCH(DMI_CHASSIS_TYPE, "9"), /*Laptop*/
|
|
|
|
},
|
|
|
|
},
|
2010-02-14 16:53:23 +00:00
|
|
|
{
|
|
|
|
.ident = "Dell Computer Corporation",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
|
|
|
|
DMI_MATCH(DMI_CHASSIS_TYPE, "8"),
|
|
|
|
},
|
|
|
|
},
|
2009-01-08 02:08:56 +00:00
|
|
|
{ }
|
|
|
|
};
|
2011-11-14 08:25:00 +00:00
|
|
|
MODULE_DEVICE_TABLE(dmi, dell_device_table);
|
2009-01-08 02:08:56 +00:00
|
|
|
|
2012-12-21 21:18:33 +00:00
|
|
|
static struct dmi_system_id dell_quirks[] = {
|
2011-10-04 08:25:44 +00:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Dell Vostro V130",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V130"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_dell_vostro_v130,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Dell Vostro V131",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V131"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_dell_vostro_v130,
|
|
|
|
},
|
2012-04-12 05:11:27 +00:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Dell Vostro 3350",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3350"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_dell_vostro_v130,
|
|
|
|
},
|
2011-11-17 07:30:42 +00:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Dell Vostro 3555",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3555"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_dell_vostro_v130,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Dell Inspiron N311z",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron N311z"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_dell_vostro_v130,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Dell Inspiron M5110",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron M5110"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_dell_vostro_v130,
|
|
|
|
},
|
2012-04-20 03:47:26 +00:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Dell Vostro 3360",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3360"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_dell_vostro_v130,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Dell Vostro 3460",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3460"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_dell_vostro_v130,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Dell Vostro 3560",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3560"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_dell_vostro_v130,
|
|
|
|
},
|
2012-05-22 04:38:51 +00:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Dell Vostro 3450",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Dell System Vostro 3450"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_dell_vostro_v130,
|
|
|
|
},
|
2012-07-13 08:39:57 +00:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Dell Inspiron 5420",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
2012-08-06 01:48:58 +00:00
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5420"),
|
2012-07-13 08:39:57 +00:00
|
|
|
},
|
|
|
|
.driver_data = &quirk_dell_vostro_v130,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Dell Inspiron 5520",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
2012-08-06 01:48:58 +00:00
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5520"),
|
2012-07-13 08:39:57 +00:00
|
|
|
},
|
|
|
|
.driver_data = &quirk_dell_vostro_v130,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Dell Inspiron 5720",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
2012-08-06 01:48:58 +00:00
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5720"),
|
2012-07-13 08:39:57 +00:00
|
|
|
},
|
|
|
|
.driver_data = &quirk_dell_vostro_v130,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Dell Inspiron 7420",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
2012-08-06 01:48:58 +00:00
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7420"),
|
2012-07-13 08:39:57 +00:00
|
|
|
},
|
|
|
|
.driver_data = &quirk_dell_vostro_v130,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Dell Inspiron 7520",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
2012-08-06 01:48:58 +00:00
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7520"),
|
2012-07-13 08:39:57 +00:00
|
|
|
},
|
|
|
|
.driver_data = &quirk_dell_vostro_v130,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Dell Inspiron 7720",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
|
2012-08-06 01:48:58 +00:00
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7720"),
|
2012-07-13 08:39:57 +00:00
|
|
|
},
|
|
|
|
.driver_data = &quirk_dell_vostro_v130,
|
|
|
|
},
|
2012-03-15 17:25:48 +00:00
|
|
|
{ }
|
2011-10-04 08:25:44 +00:00
|
|
|
};
|
|
|
|
|
2010-02-10 19:12:13 +00:00
|
|
|
static struct calling_interface_buffer *buffer;
|
2010-03-01 14:43:52 +00:00
|
|
|
static struct page *bufferpage;
|
|
|
|
static DEFINE_MUTEX(buffer_mutex);
|
2010-02-10 19:12:13 +00:00
|
|
|
|
2010-02-10 19:44:03 +00:00
|
|
|
static int hwswitch_state;
|
|
|
|
|
2010-02-10 19:12:13 +00:00
|
|
|
static void get_buffer(void)
|
|
|
|
{
|
|
|
|
mutex_lock(&buffer_mutex);
|
|
|
|
memset(buffer, 0, sizeof(struct calling_interface_buffer));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void release_buffer(void)
|
|
|
|
{
|
|
|
|
mutex_unlock(&buffer_mutex);
|
|
|
|
}
|
|
|
|
|
2009-08-19 14:06:50 +00:00
|
|
|
static void __init parse_da_table(const struct dmi_header *dm)
|
2009-01-08 02:08:56 +00:00
|
|
|
{
|
|
|
|
/* Final token is a terminator, so we don't want to copy it */
|
|
|
|
int tokens = (dm->length-11)/sizeof(struct calling_interface_token)-1;
|
2013-03-14 13:21:00 +00:00
|
|
|
struct calling_interface_token *new_da_tokens;
|
2009-01-08 02:08:56 +00:00
|
|
|
struct calling_interface_structure *table =
|
|
|
|
container_of(dm, struct calling_interface_structure, header);
|
|
|
|
|
|
|
|
/* 4 bytes of table header, plus 7 bytes of Dell header, plus at least
|
|
|
|
6 bytes of entry */
|
|
|
|
|
|
|
|
if (dm->length < 17)
|
|
|
|
return;
|
|
|
|
|
|
|
|
da_command_address = table->cmdIOAddress;
|
|
|
|
da_command_code = table->cmdIOCode;
|
|
|
|
|
2013-03-14 13:21:00 +00:00
|
|
|
new_da_tokens = krealloc(da_tokens, (da_num_tokens + tokens) *
|
|
|
|
sizeof(struct calling_interface_token),
|
|
|
|
GFP_KERNEL);
|
2009-01-08 02:08:56 +00:00
|
|
|
|
2013-03-14 13:21:00 +00:00
|
|
|
if (!new_da_tokens)
|
2009-01-08 02:08:56 +00:00
|
|
|
return;
|
2013-03-14 13:21:00 +00:00
|
|
|
da_tokens = new_da_tokens;
|
2009-01-08 02:08:56 +00:00
|
|
|
|
|
|
|
memcpy(da_tokens+da_num_tokens, table->tokens,
|
|
|
|
sizeof(struct calling_interface_token) * tokens);
|
|
|
|
|
|
|
|
da_num_tokens += tokens;
|
|
|
|
}
|
|
|
|
|
2009-08-19 14:06:50 +00:00
|
|
|
static void __init find_tokens(const struct dmi_header *dm, void *dummy)
|
2009-01-08 02:08:56 +00:00
|
|
|
{
|
|
|
|
switch (dm->type) {
|
|
|
|
case 0xd4: /* Indexed IO */
|
|
|
|
case 0xd5: /* Protected Area Type 1 */
|
|
|
|
case 0xd6: /* Protected Area Type 2 */
|
|
|
|
break;
|
|
|
|
case 0xda: /* Calling interface */
|
|
|
|
parse_da_table(dm);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int find_token_location(int tokenid)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < da_num_tokens; i++) {
|
|
|
|
if (da_tokens[i].tokenID == tokenid)
|
|
|
|
return da_tokens[i].location;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct calling_interface_buffer *
|
|
|
|
dell_send_request(struct calling_interface_buffer *buffer, int class,
|
|
|
|
int select)
|
|
|
|
{
|
|
|
|
struct smi_cmd command;
|
|
|
|
|
|
|
|
command.magic = SMI_CMD_MAGIC;
|
|
|
|
command.command_address = da_command_address;
|
|
|
|
command.command_code = da_command_code;
|
|
|
|
command.ebx = virt_to_phys(buffer);
|
|
|
|
command.ecx = 0x42534931;
|
|
|
|
|
|
|
|
buffer->class = class;
|
|
|
|
buffer->select = select;
|
|
|
|
|
|
|
|
dcdbas_smi_request(&command);
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2013-11-17 13:00:16 +00:00
|
|
|
/* Derived from information in DellWirelessCtl.cpp:
|
|
|
|
Class 17, select 11 is radio control. It returns an array of 32-bit values.
|
|
|
|
|
|
|
|
Input byte 0 = 0: Wireless information
|
|
|
|
|
|
|
|
result[0]: return code
|
|
|
|
result[1]:
|
|
|
|
Bit 0: Hardware switch supported
|
|
|
|
Bit 1: Wifi locator supported
|
|
|
|
Bit 2: Wifi is supported
|
|
|
|
Bit 3: Bluetooth is supported
|
|
|
|
Bit 4: WWAN is supported
|
|
|
|
Bit 5: Wireless keyboard supported
|
|
|
|
Bits 6-7: Reserved
|
|
|
|
Bit 8: Wifi is installed
|
|
|
|
Bit 9: Bluetooth is installed
|
|
|
|
Bit 10: WWAN is installed
|
|
|
|
Bits 11-15: Reserved
|
|
|
|
Bit 16: Hardware switch is on
|
|
|
|
Bit 17: Wifi is blocked
|
|
|
|
Bit 18: Bluetooth is blocked
|
|
|
|
Bit 19: WWAN is blocked
|
|
|
|
Bits 20-31: Reserved
|
|
|
|
result[2]: NVRAM size in bytes
|
|
|
|
result[3]: NVRAM format version number
|
|
|
|
|
|
|
|
Input byte 0 = 2: Wireless switch configuration
|
|
|
|
result[0]: return code
|
|
|
|
result[1]:
|
|
|
|
Bit 0: Wifi controlled by switch
|
|
|
|
Bit 1: Bluetooth controlled by switch
|
|
|
|
Bit 2: WWAN controlled by switch
|
|
|
|
Bits 3-6: Reserved
|
|
|
|
Bit 7: Wireless switch config locked
|
|
|
|
Bit 8: Wifi locator enabled
|
|
|
|
Bits 9-14: Reserved
|
|
|
|
Bit 15: Wifi locator setting locked
|
|
|
|
Bits 16-31: Reserved
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int dell_rfkill_set(void *data, bool blocked)
|
|
|
|
{
|
|
|
|
int disable = blocked ? 1 : 0;
|
|
|
|
unsigned long radio = (unsigned long)data;
|
|
|
|
int hwswitch_bit = (unsigned long)data - 1;
|
|
|
|
|
|
|
|
get_buffer();
|
|
|
|
dell_send_request(buffer, 17, 11);
|
|
|
|
|
|
|
|
/* If the hardware switch controls this radio, and the hardware
|
|
|
|
switch is disabled, don't allow changing the software state */
|
|
|
|
if ((hwswitch_state & BIT(hwswitch_bit)) &&
|
2013-11-17 13:00:22 +00:00
|
|
|
!(buffer->output[1] & BIT(16)))
|
2013-11-17 13:00:16 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
buffer->input[0] = (1 | (radio<<8) | (disable << 16));
|
|
|
|
dell_send_request(buffer, 17, 11);
|
|
|
|
|
|
|
|
out:
|
|
|
|
release_buffer();
|
2013-11-17 13:00:22 +00:00
|
|
|
return 0;
|
2013-11-17 13:00:16 +00:00
|
|
|
}
|
|
|
|
|
2013-11-17 13:00:20 +00:00
|
|
|
static void dell_rfkill_update_sw_state(struct rfkill *rfkill, int radio,
|
|
|
|
int status)
|
2013-11-17 13:00:19 +00:00
|
|
|
{
|
2013-11-17 13:00:21 +00:00
|
|
|
if (!(status & BIT(0))) {
|
|
|
|
/* No hw-switch, sync BIOS state to sw_state */
|
|
|
|
rfkill_set_sw_state(rfkill, !!(status & BIT(radio + 16)));
|
|
|
|
}
|
2013-11-17 13:00:20 +00:00
|
|
|
}
|
2013-11-17 13:00:19 +00:00
|
|
|
|
2013-11-17 13:00:20 +00:00
|
|
|
static void dell_rfkill_update_hw_state(struct rfkill *rfkill, int radio,
|
|
|
|
int status)
|
|
|
|
{
|
2013-11-17 13:00:19 +00:00
|
|
|
if (hwswitch_state & (BIT(radio - 1)))
|
|
|
|
rfkill_set_hw_state(rfkill, !(status & BIT(16)));
|
|
|
|
}
|
|
|
|
|
2013-11-17 13:00:16 +00:00
|
|
|
static void dell_rfkill_query(struct rfkill *rfkill, void *data)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
get_buffer();
|
|
|
|
dell_send_request(buffer, 17, 11);
|
|
|
|
status = buffer->output[1];
|
|
|
|
release_buffer();
|
|
|
|
|
2013-11-17 13:00:20 +00:00
|
|
|
dell_rfkill_update_hw_state(rfkill, (unsigned long)data, status);
|
2013-11-17 13:00:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct rfkill_ops dell_rfkill_ops = {
|
|
|
|
.set_block = dell_rfkill_set,
|
|
|
|
.query = dell_rfkill_query,
|
|
|
|
};
|
|
|
|
|
2010-09-28 03:43:31 +00:00
|
|
|
static struct dentry *dell_laptop_dir;
|
|
|
|
|
|
|
|
static int dell_debugfs_show(struct seq_file *s, void *data)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
get_buffer();
|
|
|
|
dell_send_request(buffer, 17, 11);
|
|
|
|
status = buffer->output[1];
|
|
|
|
release_buffer();
|
|
|
|
|
|
|
|
seq_printf(s, "status:\t0x%X\n", status);
|
|
|
|
seq_printf(s, "Bit 0 : Hardware switch supported: %lu\n",
|
|
|
|
status & BIT(0));
|
|
|
|
seq_printf(s, "Bit 1 : Wifi locator supported: %lu\n",
|
|
|
|
(status & BIT(1)) >> 1);
|
|
|
|
seq_printf(s, "Bit 2 : Wifi is supported: %lu\n",
|
|
|
|
(status & BIT(2)) >> 2);
|
|
|
|
seq_printf(s, "Bit 3 : Bluetooth is supported: %lu\n",
|
|
|
|
(status & BIT(3)) >> 3);
|
|
|
|
seq_printf(s, "Bit 4 : WWAN is supported: %lu\n",
|
|
|
|
(status & BIT(4)) >> 4);
|
|
|
|
seq_printf(s, "Bit 5 : Wireless keyboard supported: %lu\n",
|
|
|
|
(status & BIT(5)) >> 5);
|
|
|
|
seq_printf(s, "Bit 8 : Wifi is installed: %lu\n",
|
|
|
|
(status & BIT(8)) >> 8);
|
|
|
|
seq_printf(s, "Bit 9 : Bluetooth is installed: %lu\n",
|
|
|
|
(status & BIT(9)) >> 9);
|
|
|
|
seq_printf(s, "Bit 10: WWAN is installed: %lu\n",
|
|
|
|
(status & BIT(10)) >> 10);
|
|
|
|
seq_printf(s, "Bit 16: Hardware switch is on: %lu\n",
|
|
|
|
(status & BIT(16)) >> 16);
|
|
|
|
seq_printf(s, "Bit 17: Wifi is blocked: %lu\n",
|
|
|
|
(status & BIT(17)) >> 17);
|
|
|
|
seq_printf(s, "Bit 18: Bluetooth is blocked: %lu\n",
|
|
|
|
(status & BIT(18)) >> 18);
|
|
|
|
seq_printf(s, "Bit 19: WWAN is blocked: %lu\n",
|
|
|
|
(status & BIT(19)) >> 19);
|
|
|
|
|
|
|
|
seq_printf(s, "\nhwswitch_state:\t0x%X\n", hwswitch_state);
|
|
|
|
seq_printf(s, "Bit 0 : Wifi controlled by switch: %lu\n",
|
|
|
|
hwswitch_state & BIT(0));
|
|
|
|
seq_printf(s, "Bit 1 : Bluetooth controlled by switch: %lu\n",
|
|
|
|
(hwswitch_state & BIT(1)) >> 1);
|
|
|
|
seq_printf(s, "Bit 2 : WWAN controlled by switch: %lu\n",
|
|
|
|
(hwswitch_state & BIT(2)) >> 2);
|
|
|
|
seq_printf(s, "Bit 7 : Wireless switch config locked: %lu\n",
|
|
|
|
(hwswitch_state & BIT(7)) >> 7);
|
|
|
|
seq_printf(s, "Bit 8 : Wifi locator enabled: %lu\n",
|
|
|
|
(hwswitch_state & BIT(8)) >> 8);
|
|
|
|
seq_printf(s, "Bit 15: Wifi locator setting locked: %lu\n",
|
|
|
|
(hwswitch_state & BIT(15)) >> 15);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dell_debugfs_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
return single_open(file, dell_debugfs_show, inode->i_private);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct file_operations dell_debugfs_fops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = dell_debugfs_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
|
|
|
.release = single_release,
|
|
|
|
};
|
|
|
|
|
2013-11-17 13:00:16 +00:00
|
|
|
static void dell_update_rfkill(struct work_struct *ignored)
|
|
|
|
{
|
2013-11-17 13:00:19 +00:00
|
|
|
int status;
|
|
|
|
|
|
|
|
get_buffer();
|
|
|
|
dell_send_request(buffer, 17, 11);
|
|
|
|
status = buffer->output[1];
|
|
|
|
release_buffer();
|
|
|
|
|
2013-11-17 13:00:20 +00:00
|
|
|
if (wifi_rfkill) {
|
|
|
|
dell_rfkill_update_hw_state(wifi_rfkill, 1, status);
|
|
|
|
dell_rfkill_update_sw_state(wifi_rfkill, 1, status);
|
|
|
|
}
|
|
|
|
if (bluetooth_rfkill) {
|
|
|
|
dell_rfkill_update_hw_state(bluetooth_rfkill, 2, status);
|
|
|
|
dell_rfkill_update_sw_state(bluetooth_rfkill, 2, status);
|
|
|
|
}
|
|
|
|
if (wwan_rfkill) {
|
|
|
|
dell_rfkill_update_hw_state(wwan_rfkill, 3, status);
|
|
|
|
dell_rfkill_update_sw_state(wwan_rfkill, 3, status);
|
|
|
|
}
|
2013-11-17 13:00:16 +00:00
|
|
|
}
|
|
|
|
static DECLARE_DELAYED_WORK(dell_rfkill_work, dell_update_rfkill);
|
|
|
|
|
|
|
|
|
|
|
|
static int __init dell_setup_rfkill(void)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
int ret;
|
2013-11-17 13:00:17 +00:00
|
|
|
const char *product;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* rfkill causes trouble on various non Latitudes, according to Dell
|
|
|
|
* actually testing the rfkill functionality is only done on Latitudes.
|
|
|
|
*/
|
|
|
|
product = dmi_get_system_info(DMI_PRODUCT_NAME);
|
|
|
|
if (!product || strncmp(product, "Latitude", 8))
|
2013-11-17 13:00:16 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
get_buffer();
|
|
|
|
dell_send_request(buffer, 17, 11);
|
|
|
|
status = buffer->output[1];
|
|
|
|
buffer->input[0] = 0x2;
|
|
|
|
dell_send_request(buffer, 17, 11);
|
|
|
|
hwswitch_state = buffer->output[1];
|
2013-11-17 13:00:18 +00:00
|
|
|
/* If there is no hwswitch, then clear all hw-controlled bits */
|
|
|
|
if (!(status & BIT(0)))
|
|
|
|
hwswitch_state &= ~7;
|
2013-11-17 13:00:16 +00:00
|
|
|
release_buffer();
|
|
|
|
|
|
|
|
if ((status & (1<<2|1<<8)) == (1<<2|1<<8)) {
|
|
|
|
wifi_rfkill = rfkill_alloc("dell-wifi", &platform_device->dev,
|
|
|
|
RFKILL_TYPE_WLAN,
|
|
|
|
&dell_rfkill_ops, (void *) 1);
|
|
|
|
if (!wifi_rfkill) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err_wifi;
|
|
|
|
}
|
|
|
|
ret = rfkill_register(wifi_rfkill);
|
|
|
|
if (ret)
|
|
|
|
goto err_wifi;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((status & (1<<3|1<<9)) == (1<<3|1<<9)) {
|
|
|
|
bluetooth_rfkill = rfkill_alloc("dell-bluetooth",
|
|
|
|
&platform_device->dev,
|
|
|
|
RFKILL_TYPE_BLUETOOTH,
|
|
|
|
&dell_rfkill_ops, (void *) 2);
|
|
|
|
if (!bluetooth_rfkill) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err_bluetooth;
|
|
|
|
}
|
|
|
|
ret = rfkill_register(bluetooth_rfkill);
|
|
|
|
if (ret)
|
|
|
|
goto err_bluetooth;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((status & (1<<4|1<<10)) == (1<<4|1<<10)) {
|
|
|
|
wwan_rfkill = rfkill_alloc("dell-wwan",
|
|
|
|
&platform_device->dev,
|
|
|
|
RFKILL_TYPE_WWAN,
|
|
|
|
&dell_rfkill_ops, (void *) 3);
|
|
|
|
if (!wwan_rfkill) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err_wwan;
|
|
|
|
}
|
|
|
|
ret = rfkill_register(wwan_rfkill);
|
|
|
|
if (ret)
|
|
|
|
goto err_wwan;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
err_wwan:
|
|
|
|
rfkill_destroy(wwan_rfkill);
|
|
|
|
if (bluetooth_rfkill)
|
|
|
|
rfkill_unregister(bluetooth_rfkill);
|
|
|
|
err_bluetooth:
|
|
|
|
rfkill_destroy(bluetooth_rfkill);
|
|
|
|
if (wifi_rfkill)
|
|
|
|
rfkill_unregister(wifi_rfkill);
|
|
|
|
err_wifi:
|
|
|
|
rfkill_destroy(wifi_rfkill);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dell_cleanup_rfkill(void)
|
|
|
|
{
|
|
|
|
if (wifi_rfkill) {
|
|
|
|
rfkill_unregister(wifi_rfkill);
|
|
|
|
rfkill_destroy(wifi_rfkill);
|
|
|
|
}
|
|
|
|
if (bluetooth_rfkill) {
|
|
|
|
rfkill_unregister(bluetooth_rfkill);
|
|
|
|
rfkill_destroy(bluetooth_rfkill);
|
|
|
|
}
|
|
|
|
if (wwan_rfkill) {
|
|
|
|
rfkill_unregister(wwan_rfkill);
|
|
|
|
rfkill_destroy(wwan_rfkill);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-08 02:08:56 +00:00
|
|
|
static int dell_send_intensity(struct backlight_device *bd)
|
|
|
|
{
|
2010-02-10 19:12:13 +00:00
|
|
|
int ret = 0;
|
2009-01-08 02:08:56 +00:00
|
|
|
|
2010-02-10 19:12:13 +00:00
|
|
|
get_buffer();
|
|
|
|
buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN);
|
|
|
|
buffer->input[1] = bd->props.brightness;
|
2009-01-08 02:08:56 +00:00
|
|
|
|
2010-02-10 19:12:13 +00:00
|
|
|
if (buffer->input[0] == -1) {
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto out;
|
|
|
|
}
|
2009-01-08 02:08:56 +00:00
|
|
|
|
|
|
|
if (power_supply_is_system_supplied() > 0)
|
2010-02-10 19:12:13 +00:00
|
|
|
dell_send_request(buffer, 1, 2);
|
2009-01-08 02:08:56 +00:00
|
|
|
else
|
2010-02-10 19:12:13 +00:00
|
|
|
dell_send_request(buffer, 1, 1);
|
2009-01-08 02:08:56 +00:00
|
|
|
|
2010-02-10 19:12:13 +00:00
|
|
|
out:
|
|
|
|
release_buffer();
|
2009-01-08 02:08:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dell_get_intensity(struct backlight_device *bd)
|
|
|
|
{
|
2010-02-10 19:12:13 +00:00
|
|
|
int ret = 0;
|
2009-01-08 02:08:56 +00:00
|
|
|
|
2010-02-10 19:12:13 +00:00
|
|
|
get_buffer();
|
|
|
|
buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN);
|
2009-01-08 02:08:56 +00:00
|
|
|
|
2010-02-10 19:12:13 +00:00
|
|
|
if (buffer->input[0] == -1) {
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto out;
|
|
|
|
}
|
2009-01-08 02:08:56 +00:00
|
|
|
|
|
|
|
if (power_supply_is_system_supplied() > 0)
|
2010-02-10 19:12:13 +00:00
|
|
|
dell_send_request(buffer, 0, 2);
|
2009-01-08 02:08:56 +00:00
|
|
|
else
|
2010-02-10 19:12:13 +00:00
|
|
|
dell_send_request(buffer, 0, 1);
|
2009-01-08 02:08:56 +00:00
|
|
|
|
2011-07-10 18:46:51 +00:00
|
|
|
ret = buffer->output[1];
|
|
|
|
|
2010-02-10 19:12:13 +00:00
|
|
|
out:
|
|
|
|
release_buffer();
|
2011-07-10 18:46:51 +00:00
|
|
|
return ret;
|
2009-01-08 02:08:56 +00:00
|
|
|
}
|
|
|
|
|
2010-11-16 13:14:02 +00:00
|
|
|
static const struct backlight_ops dell_ops = {
|
2009-01-08 02:08:56 +00:00
|
|
|
.get_brightness = dell_get_intensity,
|
|
|
|
.update_status = dell_send_intensity,
|
|
|
|
};
|
|
|
|
|
2011-11-17 02:20:51 +00:00
|
|
|
static void touchpad_led_on(void)
|
2011-10-04 08:25:44 +00:00
|
|
|
{
|
|
|
|
int command = 0x97;
|
|
|
|
char data = 1;
|
|
|
|
i8042_command(&data, command | 1 << 12);
|
|
|
|
}
|
|
|
|
|
2011-11-17 02:20:51 +00:00
|
|
|
static void touchpad_led_off(void)
|
2011-10-04 08:25:44 +00:00
|
|
|
{
|
|
|
|
int command = 0x97;
|
|
|
|
char data = 2;
|
|
|
|
i8042_command(&data, command | 1 << 12);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void touchpad_led_set(struct led_classdev *led_cdev,
|
|
|
|
enum led_brightness value)
|
|
|
|
{
|
|
|
|
if (value > 0)
|
|
|
|
touchpad_led_on();
|
|
|
|
else
|
|
|
|
touchpad_led_off();
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct led_classdev touchpad_led = {
|
|
|
|
.name = "dell-laptop::touchpad",
|
|
|
|
.brightness_set = touchpad_led_set,
|
2012-01-17 08:18:06 +00:00
|
|
|
.flags = LED_CORE_SUSPENDRESUME,
|
2011-10-04 08:25:44 +00:00
|
|
|
};
|
|
|
|
|
2012-12-21 21:18:33 +00:00
|
|
|
static int touchpad_led_init(struct device *dev)
|
2011-10-04 08:25:44 +00:00
|
|
|
{
|
|
|
|
return led_classdev_register(dev, &touchpad_led);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void touchpad_led_exit(void)
|
|
|
|
{
|
|
|
|
led_classdev_unregister(&touchpad_led);
|
|
|
|
}
|
|
|
|
|
2013-11-17 13:00:16 +00:00
|
|
|
static bool dell_laptop_i8042_filter(unsigned char data, unsigned char str,
|
|
|
|
struct serio *port)
|
|
|
|
{
|
|
|
|
static bool extended;
|
|
|
|
|
|
|
|
if (str & 0x20)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (unlikely(data == 0xe0)) {
|
|
|
|
extended = true;
|
|
|
|
return false;
|
|
|
|
} else if (unlikely(extended)) {
|
|
|
|
switch (data) {
|
|
|
|
case 0x8:
|
|
|
|
schedule_delayed_work(&dell_rfkill_work,
|
|
|
|
round_jiffies_relative(HZ));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
extended = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-01-08 02:08:56 +00:00
|
|
|
static int __init dell_init(void)
|
|
|
|
{
|
|
|
|
int max_intensity = 0;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!dmi_check_system(dell_device_table))
|
|
|
|
return -ENODEV;
|
|
|
|
|
2011-10-04 08:25:44 +00:00
|
|
|
quirks = NULL;
|
|
|
|
/* find if this machine support other functions */
|
|
|
|
dmi_check_system(dell_quirks);
|
|
|
|
|
2009-03-30 19:46:44 +00:00
|
|
|
dmi_walk(find_tokens, NULL);
|
2009-01-08 02:08:56 +00:00
|
|
|
|
|
|
|
if (!da_tokens) {
|
2011-03-29 22:21:37 +00:00
|
|
|
pr_info("Unable to find dmi tokens\n");
|
2009-01-08 02:08:56 +00:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2009-08-19 14:06:49 +00:00
|
|
|
ret = platform_driver_register(&platform_driver);
|
|
|
|
if (ret)
|
|
|
|
goto fail_platform_driver;
|
|
|
|
platform_device = platform_device_alloc("dell-laptop", -1);
|
|
|
|
if (!platform_device) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto fail_platform_device1;
|
|
|
|
}
|
|
|
|
ret = platform_device_add(platform_device);
|
|
|
|
if (ret)
|
|
|
|
goto fail_platform_device2;
|
|
|
|
|
2010-02-10 19:12:13 +00:00
|
|
|
/*
|
|
|
|
* Allocate buffer below 4GB for SMI data--only 32-bit physical addr
|
|
|
|
* is passed to SMI handler.
|
|
|
|
*/
|
|
|
|
bufferpage = alloc_page(GFP_KERNEL | GFP_DMA32);
|
2013-05-09 02:03:02 +00:00
|
|
|
if (!bufferpage) {
|
|
|
|
ret = -ENOMEM;
|
2010-02-10 19:12:13 +00:00
|
|
|
goto fail_buffer;
|
2013-05-09 02:03:02 +00:00
|
|
|
}
|
2010-02-10 19:12:13 +00:00
|
|
|
buffer = page_address(bufferpage);
|
|
|
|
|
2013-11-17 13:00:16 +00:00
|
|
|
ret = dell_setup_rfkill();
|
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
pr_warn("Unable to setup rfkill\n");
|
|
|
|
goto fail_rfkill;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = i8042_install_filter(dell_laptop_i8042_filter);
|
|
|
|
if (ret) {
|
|
|
|
pr_warn("Unable to install key filter\n");
|
|
|
|
goto fail_filter;
|
|
|
|
}
|
|
|
|
|
2011-10-04 08:25:44 +00:00
|
|
|
if (quirks && quirks->touchpad_led)
|
|
|
|
touchpad_led_init(&platform_device->dev);
|
|
|
|
|
2010-09-28 03:43:31 +00:00
|
|
|
dell_laptop_dir = debugfs_create_dir("dell_laptop", NULL);
|
2013-11-17 13:00:16 +00:00
|
|
|
if (dell_laptop_dir != NULL)
|
|
|
|
debugfs_create_file("rfkill", 0444, dell_laptop_dir, NULL,
|
|
|
|
&dell_debugfs_fops);
|
2010-09-28 03:43:31 +00:00
|
|
|
|
2009-01-08 02:08:56 +00:00
|
|
|
#ifdef CONFIG_ACPI
|
|
|
|
/* In the event of an ACPI backlight being available, don't
|
|
|
|
* register the platform controller.
|
|
|
|
*/
|
|
|
|
if (acpi_video_backlight_support())
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
|
2010-02-10 19:12:13 +00:00
|
|
|
get_buffer();
|
|
|
|
buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN);
|
|
|
|
if (buffer->input[0] != -1) {
|
|
|
|
dell_send_request(buffer, 0, 2);
|
|
|
|
max_intensity = buffer->output[3];
|
2009-01-08 02:08:56 +00:00
|
|
|
}
|
2010-02-10 19:12:13 +00:00
|
|
|
release_buffer();
|
2009-01-08 02:08:56 +00:00
|
|
|
|
|
|
|
if (max_intensity) {
|
2010-02-17 21:39:44 +00:00
|
|
|
struct backlight_properties props;
|
|
|
|
memset(&props, 0, sizeof(struct backlight_properties));
|
2011-03-22 23:30:21 +00:00
|
|
|
props.type = BACKLIGHT_PLATFORM;
|
2010-02-17 21:39:44 +00:00
|
|
|
props.max_brightness = max_intensity;
|
|
|
|
dell_backlight_device = backlight_device_register("dell_backlight",
|
|
|
|
&platform_device->dev,
|
|
|
|
NULL,
|
|
|
|
&dell_ops,
|
|
|
|
&props);
|
2009-01-08 02:08:56 +00:00
|
|
|
|
|
|
|
if (IS_ERR(dell_backlight_device)) {
|
|
|
|
ret = PTR_ERR(dell_backlight_device);
|
|
|
|
dell_backlight_device = NULL;
|
2009-08-19 14:06:47 +00:00
|
|
|
goto fail_backlight;
|
2009-01-08 02:08:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dell_backlight_device->props.brightness =
|
|
|
|
dell_get_intensity(dell_backlight_device);
|
|
|
|
backlight_update_status(dell_backlight_device);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2009-08-19 14:06:47 +00:00
|
|
|
|
|
|
|
fail_backlight:
|
2013-11-17 13:00:16 +00:00
|
|
|
i8042_remove_filter(dell_laptop_i8042_filter);
|
|
|
|
cancel_delayed_work_sync(&dell_rfkill_work);
|
|
|
|
fail_filter:
|
|
|
|
dell_cleanup_rfkill();
|
|
|
|
fail_rfkill:
|
2010-02-10 19:12:13 +00:00
|
|
|
free_page((unsigned long)bufferpage);
|
|
|
|
fail_buffer:
|
2009-08-19 14:06:49 +00:00
|
|
|
platform_device_del(platform_device);
|
|
|
|
fail_platform_device2:
|
|
|
|
platform_device_put(platform_device);
|
|
|
|
fail_platform_device1:
|
|
|
|
platform_driver_unregister(&platform_driver);
|
|
|
|
fail_platform_driver:
|
2009-01-08 02:08:56 +00:00
|
|
|
kfree(da_tokens);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit dell_exit(void)
|
|
|
|
{
|
2010-09-28 03:43:31 +00:00
|
|
|
debugfs_remove_recursive(dell_laptop_dir);
|
2011-10-04 08:25:44 +00:00
|
|
|
if (quirks && quirks->touchpad_led)
|
|
|
|
touchpad_led_exit();
|
2013-11-17 13:00:16 +00:00
|
|
|
i8042_remove_filter(dell_laptop_i8042_filter);
|
|
|
|
cancel_delayed_work_sync(&dell_rfkill_work);
|
2009-01-08 02:08:56 +00:00
|
|
|
backlight_device_unregister(dell_backlight_device);
|
2013-11-17 13:00:16 +00:00
|
|
|
dell_cleanup_rfkill();
|
2010-02-09 19:03:04 +00:00
|
|
|
if (platform_device) {
|
2010-03-01 14:46:43 +00:00
|
|
|
platform_device_unregister(platform_device);
|
2010-02-09 19:03:04 +00:00
|
|
|
platform_driver_unregister(&platform_driver);
|
|
|
|
}
|
2010-02-09 19:05:01 +00:00
|
|
|
kfree(da_tokens);
|
2010-02-10 19:12:13 +00:00
|
|
|
free_page((unsigned long)buffer);
|
2009-01-08 02:08:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(dell_init);
|
|
|
|
module_exit(dell_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");
|
|
|
|
MODULE_DESCRIPTION("Dell laptop driver");
|
|
|
|
MODULE_LICENSE("GPL");
|