Commit a5b0cc80 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: wistron - add PM support

Register wistron-bios as a platform device, restore WIFI and
Bluetooth state upon resume.
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 22a397e2
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* Wistron laptop button driver * Wistron laptop button driver
* Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz> * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz>
* Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org> * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org>
* Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru>
* *
* You can redistribute and/or modify this program under the terms of the * You can redistribute and/or modify this program under the terms of the
* GNU General Public License version 2 as published by the Free Software * GNU General Public License version 2 as published by the Free Software
...@@ -28,6 +29,7 @@ ...@@ -28,6 +29,7 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/platform_device.h>
/* /*
* Number of attempts to read data from queue per poll; * Number of attempts to read data from queue per poll;
...@@ -58,6 +60,8 @@ static char *keymap_name; /* = NULL; */ ...@@ -58,6 +60,8 @@ static char *keymap_name; /* = NULL; */
module_param_named(keymap, keymap_name, charp, 0); module_param_named(keymap, keymap_name, charp, 0);
MODULE_PARM_DESC(keymap, "Keymap name, if it can't be autodetected"); MODULE_PARM_DESC(keymap, "Keymap name, if it can't be autodetected");
static struct platform_device *wistron_device;
/* BIOS interface implementation */ /* BIOS interface implementation */
static void __iomem *bios_entry_point; /* BIOS routine entry point */ static void __iomem *bios_entry_point; /* BIOS routine entry point */
...@@ -356,6 +360,7 @@ static int __init setup_input_dev(void) ...@@ -356,6 +360,7 @@ static int __init setup_input_dev(void)
input_dev->name = "Wistron laptop buttons"; input_dev->name = "Wistron laptop buttons";
input_dev->phys = "wistron/input0"; input_dev->phys = "wistron/input0";
input_dev->id.bustype = BUS_HOST; input_dev->id.bustype = BUS_HOST;
input_dev->cdev.dev = &wistron_device->dev;
for (key = keymap; key->type != KE_END; key++) { for (key = keymap; key->type != KE_END; key++) {
if (key->type == KE_KEY) { if (key->type == KE_KEY) {
...@@ -442,6 +447,34 @@ static void poll_bios(unsigned long discard) ...@@ -442,6 +447,34 @@ static void poll_bios(unsigned long discard)
mod_timer(&poll_timer, jiffies + HZ / POLL_FREQUENCY); mod_timer(&poll_timer, jiffies + HZ / POLL_FREQUENCY);
} }
static int wistron_suspend(struct platform_device *dev, pm_message_t state)
{
del_timer_sync(&poll_timer);
return 0;
}
static int wistron_resume(struct platform_device *dev)
{
if (have_wifi)
bios_set_state(WIFI, wifi_enabled);
if (have_bluetooth)
bios_set_state(BLUETOOTH, bluetooth_enabled);
poll_bios(1);
return 0;
}
static struct platform_driver wistron_driver = {
.suspend = wistron_suspend,
.resume = wistron_resume,
.driver = {
.name = "wistron-bios",
},
};
static int __init wb_module_init(void) static int __init wb_module_init(void)
{ {
int err; int err;
...@@ -457,6 +490,16 @@ static int __init wb_module_init(void) ...@@ -457,6 +490,16 @@ static int __init wb_module_init(void)
bios_attach(); bios_attach();
cmos_address = bios_get_cmos_address(); cmos_address = bios_get_cmos_address();
err = platform_driver_register(&wistron_driver);
if (err)
goto err_detach_bios;
wistron_device = platform_device_register_simple("wistron-bios", -1, NULL, 0);
if (IS_ERR(wistron_device)) {
err = PTR_ERR(wistron_device);
goto err_unregister_driver;
}
if (have_wifi) { if (have_wifi) {
u16 wifi = bios_get_default_setting(WIFI); u16 wifi = bios_get_default_setting(WIFI);
if (wifi & 1) if (wifi & 1)
...@@ -480,21 +523,30 @@ static int __init wb_module_init(void) ...@@ -480,21 +523,30 @@ static int __init wb_module_init(void)
} }
err = setup_input_dev(); err = setup_input_dev();
if (err) { if (err)
bios_detach(); goto err_unregister_device;
unmap_bios();
return err;
}
poll_bios(1); /* Flush stale event queue and arm timer */ poll_bios(1); /* Flush stale event queue and arm timer */
return 0; return 0;
err_unregister_device:
platform_device_unregister(wistron_device);
err_unregister_driver:
platform_driver_unregister(&wistron_driver);
err_detach_bios:
bios_detach();
unmap_bios();
return err;
} }
static void __exit wb_module_exit(void) static void __exit wb_module_exit(void)
{ {
del_timer_sync(&poll_timer); del_timer_sync(&poll_timer);
input_unregister_device(input_dev); input_unregister_device(input_dev);
platform_device_unregister(wistron_device);
platform_driver_unregister(&wistron_driver);
bios_detach(); bios_detach();
unmap_bios(); unmap_bios();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment