aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/misc')
-rw-r--r--drivers/input/misc/Kconfig10
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/bfin_rotary.c283
-rw-r--r--drivers/input/misc/cobalt_btns.c2
-rw-r--r--drivers/input/misc/dm355evm_keys.c42
-rw-r--r--drivers/input/misc/wistron_btns.c66
6 files changed, 352 insertions, 52 deletions
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 1acfa3a05aad..cbe21bc96b52 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -269,4 +269,14 @@ config INPUT_DM355EVM
269 269
270 To compile this driver as a module, choose M here: the 270 To compile this driver as a module, choose M here: the
271 module will be called dm355evm_keys. 271 module will be called dm355evm_keys.
272
273config INPUT_BFIN_ROTARY
274 tristate "Blackfin Rotary support"
275 depends on BF54x || BF52x
276 help
277 Say Y here if you want to use the Blackfin Rotary.
278
279 To compile this driver as a module, choose M here: the
280 module will be called bfin-rotary.
281
272endif 282endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 0d979fd4cd57..79c1e9a5ea31 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_INPUT_APANEL) += apanel.o
8obj-$(CONFIG_INPUT_ATI_REMOTE) += ati_remote.o 8obj-$(CONFIG_INPUT_ATI_REMOTE) += ati_remote.o
9obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o 9obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o
10obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o 10obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o
11obj-$(CONFIG_INPUT_BFIN_ROTARY) += bfin_rotary.o
11obj-$(CONFIG_INPUT_CM109) += cm109.o 12obj-$(CONFIG_INPUT_CM109) += cm109.o
12obj-$(CONFIG_INPUT_COBALT_BTNS) += cobalt_btns.o 13obj-$(CONFIG_INPUT_COBALT_BTNS) += cobalt_btns.o
13obj-$(CONFIG_INPUT_DM355EVM) += dm355evm_keys.o 14obj-$(CONFIG_INPUT_DM355EVM) += dm355evm_keys.o
diff --git a/drivers/input/misc/bfin_rotary.c b/drivers/input/misc/bfin_rotary.c
new file mode 100644
index 000000000000..690f3fafa03b
--- /dev/null
+++ b/drivers/input/misc/bfin_rotary.c
@@ -0,0 +1,283 @@
1/*
2 * Rotary counter driver for Analog Devices Blackfin Processors
3 *
4 * Copyright 2008-2009 Analog Devices Inc.
5 * Licensed under the GPL-2 or later.
6 */
7
8#include <linux/module.h>
9#include <linux/version.h>
10#include <linux/init.h>
11#include <linux/interrupt.h>
12#include <linux/irq.h>
13#include <linux/pm.h>
14#include <linux/platform_device.h>
15#include <linux/input.h>
16
17#include <asm/portmux.h>
18#include <asm/bfin_rotary.h>
19
20static const u16 per_cnt[] = {
21 P_CNT_CUD,
22 P_CNT_CDG,
23 P_CNT_CZM,
24 0
25};
26
27struct bfin_rot {
28 struct input_dev *input;
29 int irq;
30 unsigned int up_key;
31 unsigned int down_key;
32 unsigned int button_key;
33 unsigned int rel_code;
34 unsigned short cnt_config;
35 unsigned short cnt_imask;
36 unsigned short cnt_debounce;
37};
38
39static void report_key_event(struct input_dev *input, int keycode)
40{
41 /* simulate a press-n-release */
42 input_report_key(input, keycode, 1);
43 input_sync(input);
44 input_report_key(input, keycode, 0);
45 input_sync(input);
46}
47
48static void report_rotary_event(struct bfin_rot *rotary, int delta)
49{
50 struct input_dev *input = rotary->input;
51
52 if (rotary->up_key) {
53 report_key_event(input,
54 delta > 0 ? rotary->up_key : rotary->down_key);
55 } else {
56 input_report_rel(input, rotary->rel_code, delta);
57 input_sync(input);
58 }
59}
60
61static irqreturn_t bfin_rotary_isr(int irq, void *dev_id)
62{
63 struct platform_device *pdev = dev_id;
64 struct bfin_rot *rotary = platform_get_drvdata(pdev);
65 int delta;
66
67 switch (bfin_read_CNT_STATUS()) {
68
69 case ICII:
70 break;
71
72 case UCII:
73 case DCII:
74 delta = bfin_read_CNT_COUNTER();
75 if (delta)
76 report_rotary_event(rotary, delta);
77 break;
78
79 case CZMII:
80 report_key_event(rotary->input, rotary->button_key);
81 break;
82
83 default:
84 break;
85 }
86
87 bfin_write_CNT_COMMAND(W1LCNT_ZERO); /* Clear COUNTER */
88 bfin_write_CNT_STATUS(-1); /* Clear STATUS */
89
90 return IRQ_HANDLED;
91}
92
93static int __devinit bfin_rotary_probe(struct platform_device *pdev)
94{
95 struct bfin_rotary_platform_data *pdata = pdev->dev.platform_data;
96 struct bfin_rot *rotary;
97 struct input_dev *input;
98 int error;
99
100 /* Basic validation */
101 if ((pdata->rotary_up_key && !pdata->rotary_down_key) ||
102 (!pdata->rotary_up_key && pdata->rotary_down_key)) {
103 return -EINVAL;
104 }
105
106 error = peripheral_request_list(per_cnt, dev_name(&pdev->dev));
107 if (error) {
108 dev_err(&pdev->dev, "requesting peripherals failed\n");
109 return error;
110 }
111
112 rotary = kzalloc(sizeof(struct bfin_rot), GFP_KERNEL);
113 input = input_allocate_device();
114 if (!rotary || !input) {
115 error = -ENOMEM;
116 goto out1;
117 }
118
119 rotary->input = input;
120
121 rotary->up_key = pdata->rotary_up_key;
122 rotary->down_key = pdata->rotary_down_key;
123 rotary->button_key = pdata->rotary_button_key;
124 rotary->rel_code = pdata->rotary_rel_code;
125
126 error = rotary->irq = platform_get_irq(pdev, 0);
127 if (error < 0)
128 goto out1;
129
130 input->name = pdev->name;
131 input->phys = "bfin-rotary/input0";
132 input->dev.parent = &pdev->dev;
133
134 input_set_drvdata(input, rotary);
135
136 input->id.bustype = BUS_HOST;
137 input->id.vendor = 0x0001;
138 input->id.product = 0x0001;
139 input->id.version = 0x0100;
140
141 if (rotary->up_key) {
142 __set_bit(EV_KEY, input->evbit);
143 __set_bit(rotary->up_key, input->keybit);
144 __set_bit(rotary->down_key, input->keybit);
145 } else {
146 __set_bit(EV_REL, input->evbit);
147 __set_bit(rotary->rel_code, input->relbit);
148 }
149
150 if (rotary->button_key) {
151 __set_bit(EV_KEY, input->evbit);
152 __set_bit(rotary->button_key, input->keybit);
153 }
154
155 error = request_irq(rotary->irq, bfin_rotary_isr,
156 0, dev_name(&pdev->dev), pdev);
157 if (error) {
158 dev_err(&pdev->dev,
159 "unable to claim irq %d; error %d\n",
160 rotary->irq, error);
161 goto out1;
162 }
163
164 error = input_register_device(input);
165 if (error) {
166 dev_err(&pdev->dev,
167 "unable to register input device (%d)\n", error);
168 goto out2;
169 }
170
171 if (pdata->rotary_button_key)
172 bfin_write_CNT_IMASK(CZMIE);
173
174 if (pdata->mode & ROT_DEBE)
175 bfin_write_CNT_DEBOUNCE(pdata->debounce & DPRESCALE);
176
177 if (pdata->mode)
178 bfin_write_CNT_CONFIG(bfin_read_CNT_CONFIG() |
179 (pdata->mode & ~CNTE));
180
181 bfin_write_CNT_IMASK(bfin_read_CNT_IMASK() | UCIE | DCIE);
182 bfin_write_CNT_CONFIG(bfin_read_CNT_CONFIG() | CNTE);
183
184 platform_set_drvdata(pdev, rotary);
185 device_init_wakeup(&pdev->dev, 1);
186
187 return 0;
188
189out2:
190 free_irq(rotary->irq, pdev);
191out1:
192 input_free_device(input);
193 kfree(rotary);
194 peripheral_free_list(per_cnt);
195
196 return error;
197}
198
199static int __devexit bfin_rotary_remove(struct platform_device *pdev)
200{
201 struct bfin_rot *rotary = platform_get_drvdata(pdev);
202
203 bfin_write_CNT_CONFIG(0);
204 bfin_write_CNT_IMASK(0);
205
206 free_irq(rotary->irq, pdev);
207 input_unregister_device(rotary->input);
208 peripheral_free_list(per_cnt);
209
210 kfree(rotary);
211 platform_set_drvdata(pdev, NULL);
212
213 return 0;
214}
215
216#ifdef CONFIG_PM
217static int bfin_rotary_suspend(struct device *dev)
218{
219 struct platform_device *pdev = to_platform_device(dev);
220 struct bfin_rot *rotary = platform_get_drvdata(pdev);
221
222 rotary->cnt_config = bfin_read_CNT_CONFIG();
223 rotary->cnt_imask = bfin_read_CNT_IMASK();
224 rotary->cnt_debounce = bfin_read_CNT_DEBOUNCE();
225
226 if (device_may_wakeup(&pdev->dev))
227 enable_irq_wake(rotary->irq);
228
229 return 0;
230}
231
232static int bfin_rotary_resume(struct device *dev)
233{
234 struct platform_device *pdev = to_platform_device(dev);
235 struct bfin_rot *rotary = platform_get_drvdata(pdev);
236
237 bfin_write_CNT_DEBOUNCE(rotary->cnt_debounce);
238 bfin_write_CNT_IMASK(rotary->cnt_imask);
239 bfin_write_CNT_CONFIG(rotary->cnt_config & ~CNTE);
240
241 if (device_may_wakeup(&pdev->dev))
242 disable_irq_wake(rotary->irq);
243
244 if (rotary->cnt_config & CNTE)
245 bfin_write_CNT_CONFIG(rotary->cnt_config);
246
247 return 0;
248}
249
250static struct dev_pm_ops bfin_rotary_pm_ops = {
251 .suspend = bfin_rotary_suspend,
252 .resume = bfin_rotary_resume,
253};
254#endif
255
256static struct platform_driver bfin_rotary_device_driver = {
257 .probe = bfin_rotary_probe,
258 .remove = __devexit_p(bfin_rotary_remove),
259 .driver = {
260 .name = "bfin-rotary",
261 .owner = THIS_MODULE,
262#ifdef CONFIG_PM
263 .pm = &bfin_rotary_pm_ops,
264#endif
265 },
266};
267
268static int __init bfin_rotary_init(void)
269{
270 return platform_driver_register(&bfin_rotary_device_driver);
271}
272module_init(bfin_rotary_init);
273
274static void __exit bfin_rotary_exit(void)
275{
276 platform_driver_unregister(&bfin_rotary_device_driver);
277}
278module_exit(bfin_rotary_exit);
279
280MODULE_LICENSE("GPL");
281MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
282MODULE_DESCRIPTION("Rotary Counter driver for Blackfin Processors");
283MODULE_ALIAS("platform:bfin-rotary");
diff --git a/drivers/input/misc/cobalt_btns.c b/drivers/input/misc/cobalt_btns.c
index d114d3a9e1e9..ee73d7219c92 100644
--- a/drivers/input/misc/cobalt_btns.c
+++ b/drivers/input/misc/cobalt_btns.c
@@ -116,7 +116,7 @@ static int __devinit cobalt_buttons_probe(struct platform_device *pdev)
116 } 116 }
117 117
118 bdev->poll_dev = poll_dev; 118 bdev->poll_dev = poll_dev;
119 bdev->reg = ioremap(res->start, res->end - res->start + 1); 119 bdev->reg = ioremap(res->start, resource_size(res));
120 dev_set_drvdata(&pdev->dev, bdev); 120 dev_set_drvdata(&pdev->dev, bdev);
121 121
122 error = input_register_polled_device(poll_dev); 122 error = input_register_polled_device(poll_dev);
diff --git a/drivers/input/misc/dm355evm_keys.c b/drivers/input/misc/dm355evm_keys.c
index a63315ce4a6c..0918acae584a 100644
--- a/drivers/input/misc/dm355evm_keys.c
+++ b/drivers/input/misc/dm355evm_keys.c
@@ -23,30 +23,16 @@
23 * pressed, or its autorepeat kicks in, an event is sent. This driver 23 * pressed, or its autorepeat kicks in, an event is sent. This driver
24 * read those events from the small (32 event) queue and reports them. 24 * read those events from the small (32 event) queue and reports them.
25 * 25 *
26 * Because we communicate with the MSP430 using I2C, and all I2C calls
27 * in Linux sleep, we need to cons up a kind of threaded IRQ handler
28 * using a work_struct. The IRQ is active low, but we use it through
29 * the GPIO controller so we can trigger on falling edges.
30 *
31 * Note that physically there can only be one of these devices. 26 * Note that physically there can only be one of these devices.
32 * 27 *
33 * This driver was tested with firmware revision A4. 28 * This driver was tested with firmware revision A4.
34 */ 29 */
35struct dm355evm_keys { 30struct dm355evm_keys {
36 struct work_struct work;
37 struct input_dev *input; 31 struct input_dev *input;
38 struct device *dev; 32 struct device *dev;
39 int irq; 33 int irq;
40}; 34};
41 35
42static irqreturn_t dm355evm_keys_irq(int irq, void *_keys)
43{
44 struct dm355evm_keys *keys = _keys;
45
46 schedule_work(&keys->work);
47 return IRQ_HANDLED;
48}
49
50/* These initial keycodes can be remapped by dm355evm_setkeycode(). */ 36/* These initial keycodes can be remapped by dm355evm_setkeycode(). */
51static struct { 37static struct {
52 u16 event; 38 u16 event;
@@ -110,13 +96,12 @@ static struct {
110 { 0x3169, KEY_PAUSE, }, 96 { 0x3169, KEY_PAUSE, },
111}; 97};
112 98
113static void dm355evm_keys_work(struct work_struct *work) 99/* runs in an IRQ thread -- can (and will!) sleep */
100static irqreturn_t dm355evm_keys_irq(int irq, void *_keys)
114{ 101{
115 struct dm355evm_keys *keys; 102 struct dm355evm_keys *keys = _keys;
116 int status; 103 int status;
117 104
118 keys = container_of(work, struct dm355evm_keys, work);
119
120 /* For simplicity we ignore INPUT_COUNT and just read 105 /* For simplicity we ignore INPUT_COUNT and just read
121 * events until we get the "queue empty" indicator. 106 * events until we get the "queue empty" indicator.
122 * Reading INPUT_LOW decrements the count. 107 * Reading INPUT_LOW decrements the count.
@@ -183,6 +168,19 @@ static void dm355evm_keys_work(struct work_struct *work)
183 input_report_key(keys->input, keycode, 0); 168 input_report_key(keys->input, keycode, 0);
184 input_sync(keys->input); 169 input_sync(keys->input);
185 } 170 }
171 return IRQ_HANDLED;
172}
173
174/*
175 * Because we communicate with the MSP430 using I2C, and all I2C calls
176 * in Linux sleep, we use a threaded IRQ handler. The IRQ itself is
177 * active low, but we go through the GPIO controller so we can trigger
178 * on falling edges and not worry about enabling/disabling the IRQ in
179 * the keypress handling path.
180 */
181static irqreturn_t dm355evm_keys_hardirq(int irq, void *_keys)
182{
183 return IRQ_WAKE_THREAD;
186} 184}
187 185
188static int dm355evm_setkeycode(struct input_dev *dev, int index, int keycode) 186static int dm355evm_setkeycode(struct input_dev *dev, int index, int keycode)
@@ -233,7 +231,6 @@ static int __devinit dm355evm_keys_probe(struct platform_device *pdev)
233 231
234 keys->dev = &pdev->dev; 232 keys->dev = &pdev->dev;
235 keys->input = input; 233 keys->input = input;
236 INIT_WORK(&keys->work, dm355evm_keys_work);
237 234
238 /* set up "threaded IRQ handler" */ 235 /* set up "threaded IRQ handler" */
239 status = platform_get_irq(pdev, 0); 236 status = platform_get_irq(pdev, 0);
@@ -260,9 +257,10 @@ static int __devinit dm355evm_keys_probe(struct platform_device *pdev)
260 257
261 /* REVISIT: flush the event queue? */ 258 /* REVISIT: flush the event queue? */
262 259
263 status = request_irq(keys->irq, dm355evm_keys_irq, 260 status = request_threaded_irq(keys->irq,
264 IRQF_TRIGGER_FALLING, 261 dm355evm_keys_hardirq, dm355evm_keys_irq,
265 dev_name(&pdev->dev), keys); 262 IRQF_TRIGGER_FALLING,
263 dev_name(&pdev->dev), keys);
266 if (status < 0) 264 if (status < 0)
267 goto fail1; 265 goto fail1;
268 266
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index 27ee976eb54c..ebb08cfe2731 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -243,9 +243,9 @@ enum { KE_END, KE_KEY, KE_SW, KE_WIFI, KE_BLUETOOTH };
243#define FE_UNTESTED 0x80 243#define FE_UNTESTED 0x80
244 244
245static struct key_entry *keymap; /* = NULL; Current key map */ 245static struct key_entry *keymap; /* = NULL; Current key map */
246static int have_wifi; 246static bool have_wifi;
247static int have_bluetooth; 247static bool have_bluetooth;
248static int have_leds; 248static int leds_present; /* bitmask of leds present */
249 249
250static int __init dmi_matched(const struct dmi_system_id *dmi) 250static int __init dmi_matched(const struct dmi_system_id *dmi)
251{ 251{
@@ -254,11 +254,11 @@ static int __init dmi_matched(const struct dmi_system_id *dmi)
254 keymap = dmi->driver_data; 254 keymap = dmi->driver_data;
255 for (key = keymap; key->type != KE_END; key++) { 255 for (key = keymap; key->type != KE_END; key++) {
256 if (key->type == KE_WIFI) 256 if (key->type == KE_WIFI)
257 have_wifi = 1; 257 have_wifi = true;
258 else if (key->type == KE_BLUETOOTH) 258 else if (key->type == KE_BLUETOOTH)
259 have_bluetooth = 1; 259 have_bluetooth = true;
260 } 260 }
261 have_leds = key->code & (FE_MAIL_LED | FE_WIFI_LED); 261 leds_present = key->code & (FE_MAIL_LED | FE_WIFI_LED);
262 262
263 return 1; 263 return 1;
264} 264}
@@ -1009,8 +1009,8 @@ static int __init select_keymap(void)
1009 1009
1010static struct input_polled_dev *wistron_idev; 1010static struct input_polled_dev *wistron_idev;
1011static unsigned long jiffies_last_press; 1011static unsigned long jiffies_last_press;
1012static int wifi_enabled; 1012static bool wifi_enabled;
1013static int bluetooth_enabled; 1013static bool bluetooth_enabled;
1014 1014
1015static void report_key(struct input_dev *dev, unsigned int keycode) 1015static void report_key(struct input_dev *dev, unsigned int keycode)
1016{ 1016{
@@ -1053,24 +1053,24 @@ static struct led_classdev wistron_wifi_led = {
1053 1053
1054static void __devinit wistron_led_init(struct device *parent) 1054static void __devinit wistron_led_init(struct device *parent)
1055{ 1055{
1056 if (have_leds & FE_WIFI_LED) { 1056 if (leds_present & FE_WIFI_LED) {
1057 u16 wifi = bios_get_default_setting(WIFI); 1057 u16 wifi = bios_get_default_setting(WIFI);
1058 if (wifi & 1) { 1058 if (wifi & 1) {
1059 wistron_wifi_led.brightness = (wifi & 2) ? LED_FULL : LED_OFF; 1059 wistron_wifi_led.brightness = (wifi & 2) ? LED_FULL : LED_OFF;
1060 if (led_classdev_register(parent, &wistron_wifi_led)) 1060 if (led_classdev_register(parent, &wistron_wifi_led))
1061 have_leds &= ~FE_WIFI_LED; 1061 leds_present &= ~FE_WIFI_LED;
1062 else 1062 else
1063 bios_set_state(WIFI, wistron_wifi_led.brightness); 1063 bios_set_state(WIFI, wistron_wifi_led.brightness);
1064 1064
1065 } else 1065 } else
1066 have_leds &= ~FE_WIFI_LED; 1066 leds_present &= ~FE_WIFI_LED;
1067 } 1067 }
1068 1068
1069 if (have_leds & FE_MAIL_LED) { 1069 if (leds_present & FE_MAIL_LED) {
1070 /* bios_get_default_setting(MAIL) always retuns 0, so just turn the led off */ 1070 /* bios_get_default_setting(MAIL) always retuns 0, so just turn the led off */
1071 wistron_mail_led.brightness = LED_OFF; 1071 wistron_mail_led.brightness = LED_OFF;
1072 if (led_classdev_register(parent, &wistron_mail_led)) 1072 if (led_classdev_register(parent, &wistron_mail_led))
1073 have_leds &= ~FE_MAIL_LED; 1073 leds_present &= ~FE_MAIL_LED;
1074 else 1074 else
1075 bios_set_state(MAIL_LED, wistron_mail_led.brightness); 1075 bios_set_state(MAIL_LED, wistron_mail_led.brightness);
1076 } 1076 }
@@ -1078,28 +1078,28 @@ static void __devinit wistron_led_init(struct device *parent)
1078 1078
1079static void __devexit wistron_led_remove(void) 1079static void __devexit wistron_led_remove(void)
1080{ 1080{
1081 if (have_leds & FE_MAIL_LED) 1081 if (leds_present & FE_MAIL_LED)
1082 led_classdev_unregister(&wistron_mail_led); 1082 led_classdev_unregister(&wistron_mail_led);
1083 1083
1084 if (have_leds & FE_WIFI_LED) 1084 if (leds_present & FE_WIFI_LED)
1085 led_classdev_unregister(&wistron_wifi_led); 1085 led_classdev_unregister(&wistron_wifi_led);
1086} 1086}
1087 1087
1088static inline void wistron_led_suspend(void) 1088static inline void wistron_led_suspend(void)
1089{ 1089{
1090 if (have_leds & FE_MAIL_LED) 1090 if (leds_present & FE_MAIL_LED)
1091 led_classdev_suspend(&wistron_mail_led); 1091 led_classdev_suspend(&wistron_mail_led);
1092 1092
1093 if (have_leds & FE_WIFI_LED) 1093 if (leds_present & FE_WIFI_LED)
1094 led_classdev_suspend(&wistron_wifi_led); 1094 led_classdev_suspend(&wistron_wifi_led);
1095} 1095}
1096 1096
1097static inline void wistron_led_resume(void) 1097static inline void wistron_led_resume(void)
1098{ 1098{
1099 if (have_leds & FE_MAIL_LED) 1099 if (leds_present & FE_MAIL_LED)
1100 led_classdev_resume(&wistron_mail_led); 1100 led_classdev_resume(&wistron_mail_led);
1101 1101
1102 if (have_leds & FE_WIFI_LED) 1102 if (leds_present & FE_WIFI_LED)
1103 led_classdev_resume(&wistron_wifi_led); 1103 led_classdev_resume(&wistron_wifi_led);
1104} 1104}
1105 1105
@@ -1312,7 +1312,7 @@ static int __devinit wistron_probe(struct platform_device *dev)
1312 if (have_wifi) { 1312 if (have_wifi) {
1313 u16 wifi = bios_get_default_setting(WIFI); 1313 u16 wifi = bios_get_default_setting(WIFI);
1314 if (wifi & 1) 1314 if (wifi & 1)
1315 wifi_enabled = (wifi & 2) ? 1 : 0; 1315 wifi_enabled = wifi & 2;
1316 else 1316 else
1317 have_wifi = 0; 1317 have_wifi = 0;
1318 1318
@@ -1323,15 +1323,16 @@ static int __devinit wistron_probe(struct platform_device *dev)
1323 if (have_bluetooth) { 1323 if (have_bluetooth) {
1324 u16 bt = bios_get_default_setting(BLUETOOTH); 1324 u16 bt = bios_get_default_setting(BLUETOOTH);
1325 if (bt & 1) 1325 if (bt & 1)
1326 bluetooth_enabled = (bt & 2) ? 1 : 0; 1326 bluetooth_enabled = bt & 2;
1327 else 1327 else
1328 have_bluetooth = 0; 1328 have_bluetooth = false;
1329 1329
1330 if (have_bluetooth) 1330 if (have_bluetooth)
1331 bios_set_state(BLUETOOTH, bluetooth_enabled); 1331 bios_set_state(BLUETOOTH, bluetooth_enabled);
1332 } 1332 }
1333 1333
1334 wistron_led_init(&dev->dev); 1334 wistron_led_init(&dev->dev);
1335
1335 err = setup_input_dev(); 1336 err = setup_input_dev();
1336 if (err) { 1337 if (err) {
1337 bios_detach(); 1338 bios_detach();
@@ -1352,7 +1353,7 @@ static int __devexit wistron_remove(struct platform_device *dev)
1352} 1353}
1353 1354
1354#ifdef CONFIG_PM 1355#ifdef CONFIG_PM
1355static int wistron_suspend(struct platform_device *dev, pm_message_t state) 1356static int wistron_suspend(struct device *dev)
1356{ 1357{
1357 if (have_wifi) 1358 if (have_wifi)
1358 bios_set_state(WIFI, 0); 1359 bios_set_state(WIFI, 0);
@@ -1361,10 +1362,11 @@ static int wistron_suspend(struct platform_device *dev, pm_message_t state)
1361 bios_set_state(BLUETOOTH, 0); 1362 bios_set_state(BLUETOOTH, 0);
1362 1363
1363 wistron_led_suspend(); 1364 wistron_led_suspend();
1365
1364 return 0; 1366 return 0;
1365} 1367}
1366 1368
1367static int wistron_resume(struct platform_device *dev) 1369static int wistron_resume(struct device *dev)
1368{ 1370{
1369 if (have_wifi) 1371 if (have_wifi)
1370 bios_set_state(WIFI, wifi_enabled); 1372 bios_set_state(WIFI, wifi_enabled);
@@ -1373,24 +1375,30 @@ static int wistron_resume(struct platform_device *dev)
1373 bios_set_state(BLUETOOTH, bluetooth_enabled); 1375 bios_set_state(BLUETOOTH, bluetooth_enabled);
1374 1376
1375 wistron_led_resume(); 1377 wistron_led_resume();
1378
1376 poll_bios(true); 1379 poll_bios(true);
1377 1380
1378 return 0; 1381 return 0;
1379} 1382}
1380#else 1383
1381#define wistron_suspend NULL 1384static const struct dev_pm_ops wistron_pm_ops = {
1382#define wistron_resume NULL 1385 .suspend = wistron_suspend,
1386 .resume = wistron_resume,
1387 .poweroff = wistron_suspend,
1388 .restore = wistron_resume,
1389};
1383#endif 1390#endif
1384 1391
1385static struct platform_driver wistron_driver = { 1392static struct platform_driver wistron_driver = {
1386 .driver = { 1393 .driver = {
1387 .name = "wistron-bios", 1394 .name = "wistron-bios",
1388 .owner = THIS_MODULE, 1395 .owner = THIS_MODULE,
1396#if CONFIG_PM
1397 .pm = &wistron_pm_ops,
1398#endif
1389 }, 1399 },
1390 .probe = wistron_probe, 1400 .probe = wistron_probe,
1391 .remove = __devexit_p(wistron_remove), 1401 .remove = __devexit_p(wistron_remove),
1392 .suspend = wistron_suspend,
1393 .resume = wistron_resume,
1394}; 1402};
1395 1403
1396static int __init wb_module_init(void) 1404static int __init wb_module_init(void)