amilo-rfkill: Use proper functions to write to the i8042 safely

svn path=/dists/sid/linux-2.6/; revision=18318
This commit is contained in:
Ben Hutchings 2011-11-26 03:21:20 +00:00
parent 1a7fd6fae1
commit 01f077e6d8
2 changed files with 16 additions and 22 deletions

1
debian/changelog vendored
View File

@ -14,6 +14,7 @@ linux-2.6 (3.1.2-1) UNRELEASED; urgency=low
* Include module taint flags in bug reports
* lirc_serial: Fix various bugs that may result in a crash, deadlock or
other failure (Closes: #645811)
* amilo-rfkill: Use proper functions to write to the i8042 safely
-- Ben Hutchings <ben@decadent.org.uk> Tue, 22 Nov 2011 05:26:25 +0000

View File

@ -9,15 +9,15 @@ Fujitsu-Siemens Amilo A1655 and M7440 models found at:
http://sourceforge.net/projects/fsaa1655g/
http://sourceforge.net/projects/fsam7440/
This adds DMI matching and replaces the procfs files with rfkill
devices.
This adds DMI matching, replaces the procfs files with rfkill devices,
and uses the proper function to write to the i8042 safely.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
drivers/platform/x86/Kconfig | 7 ++
drivers/platform/x86/Makefile | 1 +
drivers/platform/x86/amilo-rfkill.c | 180 +++++++++++++++++++++++++++++++++++
3 files changed, 188 insertions(+), 0 deletions(-)
drivers/platform/x86/amilo-rfkill.c | 173 +++++++++++++++++++++++++++++++++++
3 files changed, 181 insertions(+), 0 deletions(-)
create mode 100644 drivers/platform/x86/amilo-rfkill.c
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
@ -52,10 +52,10 @@ index 293a320..3acbaad 100644
obj-$(CONFIG_IDEAPAD_LAPTOP) += ideapad-laptop.o
diff --git a/drivers/platform/x86/amilo-rfkill.c b/drivers/platform/x86/amilo-rfkill.c
new file mode 100644
index 0000000..028d3ec
index 0000000..19170bb
--- /dev/null
+++ b/drivers/platform/x86/amilo-rfkill.c
@@ -0,0 +1,180 @@
@@ -0,0 +1,173 @@
+/*
+ * Support for rfkill on some Fujitsu-Siemens Amilo laptops.
+ * Copyright 2011 Ben Hutchings.
@ -73,6 +73,7 @@ index 0000000..028d3ec
+
+#include <linux/module.h>
+#include <linux/dmi.h>
+#include <linux/i8042.h>
+#include <linux/io.h>
+#include <linux/moduleparam.h>
+#include <linux/platform_device.h>
@ -82,27 +83,19 @@ index 0000000..028d3ec
+ * These values were obtained from disassembling and debugging the
+ * PM.exe program installed in the Fujitsu-Siemens AMILO A1655G
+ */
+#define A1655_STATE_PORT 0x64
+#define A1655_COMMAND_PORT 0x64
+#define A1655_DATA_PORT 0x60
+#define A1655_WIFI_COMMAND 0xC5
+#define A1655_WIFI_COMMAND 0x10C5
+#define A1655_WIFI_ON 0x25
+#define A1655_WIFI_OFF 0x45
+
+static int amilo_a1655_rfkill_set_block(void *data, bool blocked)
+{
+ u8 val;
+ u8 param = blocked ? A1655_WIFI_OFF : A1655_WIFI_ON;
+ int rc;
+
+ do
+ val = inb(A1655_STATE_PORT);
+ while ((val & 2) == 2);
+ outb(A1655_WIFI_COMMAND, A1655_COMMAND_PORT);
+ do
+ val = inb(A1655_STATE_PORT);
+ while ((val & 2) == 2);
+ outb(blocked ? A1655_WIFI_OFF : A1655_WIFI_ON, A1655_DATA_PORT);
+
+ return 0;
+ i8042_lock_chip();
+ rc = i8042_command(&param, A1655_WIFI_COMMAND);
+ i8042_unlock_chip();
+ return rc;
+}
+
+static const struct rfkill_ops amilo_a1655_rfkill_ops = {
@ -237,5 +230,5 @@ index 0000000..028d3ec
+module_init(amilo_rfkill_init);
+module_exit(amilo_rfkill_exit);
--
1.7.7.2
1.7.7.3