blob: bfdda33feb26547dea8a5187543bb4b58de38f01 [file] [log] [blame]
David Woodhouse58ac7aa2010-08-10 23:44:05 +01001/*
Ike Panhca4b5a272010-12-13 18:00:48 +08002 * ideapad-laptop.c - Lenovo IdeaPad ACPI Extras
David Woodhouse58ac7aa2010-08-10 23:44:05 +01003 *
4 * Copyright © 2010 Intel Corporation
5 * Copyright © 2010 David Woodhouse <dwmw2@infradead.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 */
22
Joe Perches9ab23982011-03-29 15:21:43 -070023#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24
David Woodhouse58ac7aa2010-08-10 23:44:05 +010025#include <linux/kernel.h>
26#include <linux/module.h>
27#include <linux/init.h>
28#include <linux/types.h>
29#include <acpi/acpi_bus.h>
30#include <acpi/acpi_drivers.h>
31#include <linux/rfkill.h>
Ike Panhc98ee6912010-12-13 18:00:15 +080032#include <linux/platform_device.h>
Ike Panhcf63409a2010-12-13 18:00:38 +080033#include <linux/input.h>
34#include <linux/input/sparse-keymap.h>
David Woodhouse58ac7aa2010-08-10 23:44:05 +010035
Ike Panhcc1f73652010-12-13 18:01:12 +080036#define IDEAPAD_RFKILL_DEV_NUM (3)
David Woodhouse58ac7aa2010-08-10 23:44:05 +010037
David Woodhousece326322010-08-11 17:59:35 +010038struct ideapad_private {
Ike Panhcc1f73652010-12-13 18:01:12 +080039 struct rfkill *rfk[IDEAPAD_RFKILL_DEV_NUM];
Ike Panhc98ee6912010-12-13 18:00:15 +080040 struct platform_device *platform_device;
Ike Panhcf63409a2010-12-13 18:00:38 +080041 struct input_dev *inputdev;
David Woodhouse58ac7aa2010-08-10 23:44:05 +010042};
43
Ike Panhcc1f73652010-12-13 18:01:12 +080044static acpi_handle ideapad_handle;
Ike Panhcbfa97b72010-10-01 15:40:22 +080045static bool no_bt_rfkill;
46module_param(no_bt_rfkill, bool, 0444);
47MODULE_PARM_DESC(no_bt_rfkill, "No rfkill for bluetooth.");
48
Ike Panhc6a09f212010-10-01 15:38:46 +080049/*
50 * ACPI Helpers
51 */
52#define IDEAPAD_EC_TIMEOUT (100) /* in ms */
53
54static int read_method_int(acpi_handle handle, const char *method, int *val)
55{
56 acpi_status status;
57 unsigned long long result;
58
59 status = acpi_evaluate_integer(handle, (char *)method, NULL, &result);
60 if (ACPI_FAILURE(status)) {
61 *val = -1;
62 return -1;
63 } else {
64 *val = result;
65 return 0;
66 }
67}
68
69static int method_vpcr(acpi_handle handle, int cmd, int *ret)
70{
71 acpi_status status;
72 unsigned long long result;
73 struct acpi_object_list params;
74 union acpi_object in_obj;
75
76 params.count = 1;
77 params.pointer = &in_obj;
78 in_obj.type = ACPI_TYPE_INTEGER;
79 in_obj.integer.value = cmd;
80
81 status = acpi_evaluate_integer(handle, "VPCR", &params, &result);
82
83 if (ACPI_FAILURE(status)) {
84 *ret = -1;
85 return -1;
86 } else {
87 *ret = result;
88 return 0;
89 }
90}
91
92static int method_vpcw(acpi_handle handle, int cmd, int data)
93{
94 struct acpi_object_list params;
95 union acpi_object in_obj[2];
96 acpi_status status;
97
98 params.count = 2;
99 params.pointer = in_obj;
100 in_obj[0].type = ACPI_TYPE_INTEGER;
101 in_obj[0].integer.value = cmd;
102 in_obj[1].type = ACPI_TYPE_INTEGER;
103 in_obj[1].integer.value = data;
104
105 status = acpi_evaluate_object(handle, "VPCW", &params, NULL);
106 if (status != AE_OK)
107 return -1;
108 return 0;
109}
110
111static int read_ec_data(acpi_handle handle, int cmd, unsigned long *data)
112{
113 int val;
114 unsigned long int end_jiffies;
115
116 if (method_vpcw(handle, 1, cmd))
117 return -1;
118
119 for (end_jiffies = jiffies+(HZ)*IDEAPAD_EC_TIMEOUT/1000+1;
120 time_before(jiffies, end_jiffies);) {
121 schedule();
122 if (method_vpcr(handle, 1, &val))
123 return -1;
124 if (val == 0) {
125 if (method_vpcr(handle, 0, &val))
126 return -1;
127 *data = val;
128 return 0;
129 }
130 }
131 pr_err("timeout in read_ec_cmd\n");
132 return -1;
133}
134
135static int write_ec_cmd(acpi_handle handle, int cmd, unsigned long data)
136{
137 int val;
138 unsigned long int end_jiffies;
139
140 if (method_vpcw(handle, 0, data))
141 return -1;
142 if (method_vpcw(handle, 1, cmd))
143 return -1;
144
145 for (end_jiffies = jiffies+(HZ)*IDEAPAD_EC_TIMEOUT/1000+1;
146 time_before(jiffies, end_jiffies);) {
147 schedule();
148 if (method_vpcr(handle, 1, &val))
149 return -1;
150 if (val == 0)
151 return 0;
152 }
153 pr_err("timeout in write_ec_cmd\n");
154 return -1;
155}
Ike Panhc6a09f212010-10-01 15:38:46 +0800156
Ike Panhca4b5a272010-12-13 18:00:48 +0800157/*
158 * camera power
159 */
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100160static ssize_t show_ideapad_cam(struct device *dev,
161 struct device_attribute *attr,
162 char *buf)
163{
Ike Panhc26c81d52010-10-01 15:39:40 +0800164 unsigned long result;
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100165
Ike Panhcc1f73652010-12-13 18:01:12 +0800166 if (read_ec_data(ideapad_handle, 0x1D, &result))
Ike Panhc26c81d52010-10-01 15:39:40 +0800167 return sprintf(buf, "-1\n");
168 return sprintf(buf, "%lu\n", result);
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100169}
170
171static ssize_t store_ideapad_cam(struct device *dev,
172 struct device_attribute *attr,
173 const char *buf, size_t count)
174{
175 int ret, state;
176
177 if (!count)
178 return 0;
179 if (sscanf(buf, "%i", &state) != 1)
180 return -EINVAL;
Ike Panhcc1f73652010-12-13 18:01:12 +0800181 ret = write_ec_cmd(ideapad_handle, 0x1E, state);
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100182 if (ret < 0)
183 return ret;
184 return count;
185}
186
187static DEVICE_ATTR(camera_power, 0644, show_ideapad_cam, store_ideapad_cam);
188
Ike Panhca4b5a272010-12-13 18:00:48 +0800189/*
190 * Rfkill
191 */
Ike Panhcc1f73652010-12-13 18:01:12 +0800192struct ideapad_rfk_data {
193 char *name;
194 int cfgbit;
195 int opcode;
196 int type;
197};
198
199const struct ideapad_rfk_data ideapad_rfk_data[] = {
200 { "ideapad_wlan", 18, 0x15, RFKILL_TYPE_WLAN },
201 { "ideapad_bluetooth", 16, 0x17, RFKILL_TYPE_BLUETOOTH },
202 { "ideapad_3g", 17, 0x20, RFKILL_TYPE_WWAN },
203};
204
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100205static int ideapad_rfk_set(void *data, bool blocked)
206{
Ike Panhcc1f73652010-12-13 18:01:12 +0800207 unsigned long opcode = (unsigned long)data;
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100208
Ike Panhcc1f73652010-12-13 18:01:12 +0800209 return write_ec_cmd(ideapad_handle, opcode, !blocked);
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100210}
211
212static struct rfkill_ops ideapad_rfk_ops = {
213 .set_block = ideapad_rfk_set,
214};
215
David Woodhousece326322010-08-11 17:59:35 +0100216static void ideapad_sync_rfk_state(struct acpi_device *adevice)
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100217{
David Woodhousece326322010-08-11 17:59:35 +0100218 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev);
Ike Panhc2b7266b2010-10-01 15:39:49 +0800219 unsigned long hw_blocked;
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100220 int i;
221
Ike Panhcc1f73652010-12-13 18:01:12 +0800222 if (read_ec_data(ideapad_handle, 0x23, &hw_blocked))
Ike Panhc2b7266b2010-10-01 15:39:49 +0800223 return;
224 hw_blocked = !hw_blocked;
225
Ike Panhcc1f73652010-12-13 18:01:12 +0800226 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++)
David Woodhousece326322010-08-11 17:59:35 +0100227 if (priv->rfk[i])
228 rfkill_set_hw_state(priv->rfk[i], hw_blocked);
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100229}
230
Ike Panhca4b5a272010-12-13 18:00:48 +0800231static int __devinit ideapad_register_rfkill(struct acpi_device *adevice,
232 int dev)
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100233{
David Woodhousece326322010-08-11 17:59:35 +0100234 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev);
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100235 int ret;
Ike Panhc2b7266b2010-10-01 15:39:49 +0800236 unsigned long sw_blocked;
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100237
Ike Panhcbfa97b72010-10-01 15:40:22 +0800238 if (no_bt_rfkill &&
239 (ideapad_rfk_data[dev].type == RFKILL_TYPE_BLUETOOTH)) {
240 /* Force to enable bluetooth when no_bt_rfkill=1 */
Ike Panhcc1f73652010-12-13 18:01:12 +0800241 write_ec_cmd(ideapad_handle,
Ike Panhcbfa97b72010-10-01 15:40:22 +0800242 ideapad_rfk_data[dev].opcode, 1);
243 return 0;
244 }
245
Ike Panhc2b7266b2010-10-01 15:39:49 +0800246 priv->rfk[dev] = rfkill_alloc(ideapad_rfk_data[dev].name, &adevice->dev,
247 ideapad_rfk_data[dev].type, &ideapad_rfk_ops,
David Woodhousece326322010-08-11 17:59:35 +0100248 (void *)(long)dev);
249 if (!priv->rfk[dev])
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100250 return -ENOMEM;
251
Ike Panhcc1f73652010-12-13 18:01:12 +0800252 if (read_ec_data(ideapad_handle, ideapad_rfk_data[dev].opcode-1,
Ike Panhc2b7266b2010-10-01 15:39:49 +0800253 &sw_blocked)) {
254 rfkill_init_sw_state(priv->rfk[dev], 0);
255 } else {
256 sw_blocked = !sw_blocked;
257 rfkill_init_sw_state(priv->rfk[dev], sw_blocked);
258 }
259
David Woodhousece326322010-08-11 17:59:35 +0100260 ret = rfkill_register(priv->rfk[dev]);
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100261 if (ret) {
David Woodhousece326322010-08-11 17:59:35 +0100262 rfkill_destroy(priv->rfk[dev]);
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100263 return ret;
264 }
265 return 0;
266}
267
Ike Panhca4b5a272010-12-13 18:00:48 +0800268static void __devexit ideapad_unregister_rfkill(struct acpi_device *adevice,
269 int dev)
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100270{
David Woodhousece326322010-08-11 17:59:35 +0100271 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev);
272
273 if (!priv->rfk[dev])
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100274 return;
275
David Woodhousece326322010-08-11 17:59:35 +0100276 rfkill_unregister(priv->rfk[dev]);
277 rfkill_destroy(priv->rfk[dev]);
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100278}
279
Ike Panhc98ee6912010-12-13 18:00:15 +0800280/*
281 * Platform device
282 */
Ike Panhcc9f718d2010-12-13 18:00:27 +0800283static struct attribute *ideapad_attributes[] = {
284 &dev_attr_camera_power.attr,
285 NULL
286};
287
288static struct attribute_group ideapad_attribute_group = {
289 .attrs = ideapad_attributes
290};
291
Ike Panhc8693ae82010-12-13 18:01:01 +0800292static int __devinit ideapad_platform_init(struct ideapad_private *priv)
Ike Panhc98ee6912010-12-13 18:00:15 +0800293{
294 int result;
295
Ike Panhc8693ae82010-12-13 18:01:01 +0800296 priv->platform_device = platform_device_alloc("ideapad", -1);
297 if (!priv->platform_device)
Ike Panhc98ee6912010-12-13 18:00:15 +0800298 return -ENOMEM;
Ike Panhc8693ae82010-12-13 18:01:01 +0800299 platform_set_drvdata(priv->platform_device, priv);
Ike Panhc98ee6912010-12-13 18:00:15 +0800300
Ike Panhc8693ae82010-12-13 18:01:01 +0800301 result = platform_device_add(priv->platform_device);
Ike Panhc98ee6912010-12-13 18:00:15 +0800302 if (result)
303 goto fail_platform_device;
304
Ike Panhc8693ae82010-12-13 18:01:01 +0800305 result = sysfs_create_group(&priv->platform_device->dev.kobj,
Ike Panhcc9f718d2010-12-13 18:00:27 +0800306 &ideapad_attribute_group);
307 if (result)
308 goto fail_sysfs;
Ike Panhc98ee6912010-12-13 18:00:15 +0800309 return 0;
310
Ike Panhcc9f718d2010-12-13 18:00:27 +0800311fail_sysfs:
Ike Panhc8693ae82010-12-13 18:01:01 +0800312 platform_device_del(priv->platform_device);
Ike Panhc98ee6912010-12-13 18:00:15 +0800313fail_platform_device:
Ike Panhc8693ae82010-12-13 18:01:01 +0800314 platform_device_put(priv->platform_device);
Ike Panhc98ee6912010-12-13 18:00:15 +0800315 return result;
316}
317
Ike Panhc8693ae82010-12-13 18:01:01 +0800318static void ideapad_platform_exit(struct ideapad_private *priv)
Ike Panhc98ee6912010-12-13 18:00:15 +0800319{
Ike Panhc8693ae82010-12-13 18:01:01 +0800320 sysfs_remove_group(&priv->platform_device->dev.kobj,
Ike Panhcc9f718d2010-12-13 18:00:27 +0800321 &ideapad_attribute_group);
Ike Panhc8693ae82010-12-13 18:01:01 +0800322 platform_device_unregister(priv->platform_device);
Ike Panhc98ee6912010-12-13 18:00:15 +0800323}
Ike Panhc98ee6912010-12-13 18:00:15 +0800324
Ike Panhcf63409a2010-12-13 18:00:38 +0800325/*
326 * input device
327 */
328static const struct key_entry ideapad_keymap[] = {
329 { KE_KEY, 0x06, { KEY_SWITCHVIDEOMODE } },
330 { KE_KEY, 0x0D, { KEY_WLAN } },
331 { KE_END, 0 },
332};
333
Ike Panhc8693ae82010-12-13 18:01:01 +0800334static int __devinit ideapad_input_init(struct ideapad_private *priv)
Ike Panhcf63409a2010-12-13 18:00:38 +0800335{
336 struct input_dev *inputdev;
337 int error;
338
339 inputdev = input_allocate_device();
340 if (!inputdev) {
341 pr_info("Unable to allocate input device\n");
342 return -ENOMEM;
343 }
344
345 inputdev->name = "Ideapad extra buttons";
346 inputdev->phys = "ideapad/input0";
347 inputdev->id.bustype = BUS_HOST;
Ike Panhc8693ae82010-12-13 18:01:01 +0800348 inputdev->dev.parent = &priv->platform_device->dev;
Ike Panhcf63409a2010-12-13 18:00:38 +0800349
350 error = sparse_keymap_setup(inputdev, ideapad_keymap, NULL);
351 if (error) {
352 pr_err("Unable to setup input device keymap\n");
353 goto err_free_dev;
354 }
355
356 error = input_register_device(inputdev);
357 if (error) {
358 pr_err("Unable to register input device\n");
359 goto err_free_keymap;
360 }
361
Ike Panhc8693ae82010-12-13 18:01:01 +0800362 priv->inputdev = inputdev;
Ike Panhcf63409a2010-12-13 18:00:38 +0800363 return 0;
364
365err_free_keymap:
366 sparse_keymap_free(inputdev);
367err_free_dev:
368 input_free_device(inputdev);
369 return error;
370}
371
Ike Panhc8693ae82010-12-13 18:01:01 +0800372static void __devexit ideapad_input_exit(struct ideapad_private *priv)
Ike Panhcf63409a2010-12-13 18:00:38 +0800373{
Ike Panhc8693ae82010-12-13 18:01:01 +0800374 sparse_keymap_free(priv->inputdev);
375 input_unregister_device(priv->inputdev);
376 priv->inputdev = NULL;
Ike Panhcf63409a2010-12-13 18:00:38 +0800377}
378
Ike Panhc8693ae82010-12-13 18:01:01 +0800379static void ideapad_input_report(struct ideapad_private *priv,
380 unsigned long scancode)
Ike Panhcf63409a2010-12-13 18:00:38 +0800381{
Ike Panhc8693ae82010-12-13 18:01:01 +0800382 sparse_keymap_report_event(priv->inputdev, scancode, 1, true);
Ike Panhcf63409a2010-12-13 18:00:38 +0800383}
Ike Panhcf63409a2010-12-13 18:00:38 +0800384
Ike Panhca4b5a272010-12-13 18:00:48 +0800385/*
386 * module init/exit
387 */
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100388static const struct acpi_device_id ideapad_device_ids[] = {
389 { "VPC2004", 0},
390 { "", 0},
391};
392MODULE_DEVICE_TABLE(acpi, ideapad_device_ids);
393
Ike Panhca4b5a272010-12-13 18:00:48 +0800394static int __devinit ideapad_acpi_add(struct acpi_device *adevice)
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100395{
Ike Panhc98ee6912010-12-13 18:00:15 +0800396 int ret, i, cfg;
David Woodhousece326322010-08-11 17:59:35 +0100397 struct ideapad_private *priv;
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100398
Ike Panhc6f8371c2010-10-01 15:39:14 +0800399 if (read_method_int(adevice->handle, "_CFG", &cfg))
400 return -ENODEV;
401
David Woodhousece326322010-08-11 17:59:35 +0100402 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
403 if (!priv)
404 return -ENOMEM;
Ike Panhcc9f718d2010-12-13 18:00:27 +0800405 dev_set_drvdata(&adevice->dev, priv);
Ike Panhcc1f73652010-12-13 18:01:12 +0800406 ideapad_handle = adevice->handle;
Ike Panhc98ee6912010-12-13 18:00:15 +0800407
Ike Panhc8693ae82010-12-13 18:01:01 +0800408 ret = ideapad_platform_init(priv);
Ike Panhc98ee6912010-12-13 18:00:15 +0800409 if (ret)
410 goto platform_failed;
David Woodhousece326322010-08-11 17:59:35 +0100411
Ike Panhc8693ae82010-12-13 18:01:01 +0800412 ret = ideapad_input_init(priv);
Ike Panhcf63409a2010-12-13 18:00:38 +0800413 if (ret)
414 goto input_failed;
415
Ike Panhcc1f73652010-12-13 18:01:12 +0800416 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) {
Ike Panhcc9f718d2010-12-13 18:00:27 +0800417 if (test_bit(ideapad_rfk_data[i].cfgbit, (unsigned long *)&cfg))
418 ideapad_register_rfkill(adevice, i);
Ike Panhcc1f73652010-12-13 18:01:12 +0800419 else
420 priv->rfk[i] = NULL;
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100421 }
David Woodhousece326322010-08-11 17:59:35 +0100422 ideapad_sync_rfk_state(adevice);
Ike Panhcc9f718d2010-12-13 18:00:27 +0800423
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100424 return 0;
Ike Panhc98ee6912010-12-13 18:00:15 +0800425
Ike Panhcf63409a2010-12-13 18:00:38 +0800426input_failed:
Ike Panhc8693ae82010-12-13 18:01:01 +0800427 ideapad_platform_exit(priv);
Ike Panhc98ee6912010-12-13 18:00:15 +0800428platform_failed:
429 kfree(priv);
430 return ret;
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100431}
432
Ike Panhca4b5a272010-12-13 18:00:48 +0800433static int __devexit ideapad_acpi_remove(struct acpi_device *adevice, int type)
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100434{
David Woodhousece326322010-08-11 17:59:35 +0100435 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev);
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100436 int i;
David Woodhousece326322010-08-11 17:59:35 +0100437
Ike Panhcc1f73652010-12-13 18:01:12 +0800438 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++)
David Woodhousece326322010-08-11 17:59:35 +0100439 ideapad_unregister_rfkill(adevice, i);
Ike Panhc8693ae82010-12-13 18:01:01 +0800440 ideapad_input_exit(priv);
441 ideapad_platform_exit(priv);
David Woodhousece326322010-08-11 17:59:35 +0100442 dev_set_drvdata(&adevice->dev, NULL);
443 kfree(priv);
Ike Panhcc9f718d2010-12-13 18:00:27 +0800444
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100445 return 0;
446}
447
David Woodhousece326322010-08-11 17:59:35 +0100448static void ideapad_acpi_notify(struct acpi_device *adevice, u32 event)
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100449{
Ike Panhc8693ae82010-12-13 18:01:01 +0800450 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev);
Ike Panhc8e7d3542010-10-01 15:39:05 +0800451 acpi_handle handle = adevice->handle;
452 unsigned long vpc1, vpc2, vpc_bit;
453
454 if (read_ec_data(handle, 0x10, &vpc1))
455 return;
456 if (read_ec_data(handle, 0x1A, &vpc2))
457 return;
458
459 vpc1 = (vpc2 << 8) | vpc1;
460 for (vpc_bit = 0; vpc_bit < 16; vpc_bit++) {
461 if (test_bit(vpc_bit, &vpc1)) {
462 if (vpc_bit == 9)
463 ideapad_sync_rfk_state(adevice);
Ike Panhc883ae792011-02-23 21:39:59 +0800464 else if (vpc_bit == 4)
465 read_ec_data(handle, 0x12, &vpc2);
Ike Panhcf63409a2010-12-13 18:00:38 +0800466 else
Ike Panhc8693ae82010-12-13 18:01:01 +0800467 ideapad_input_report(priv, vpc_bit);
Ike Panhc8e7d3542010-10-01 15:39:05 +0800468 }
469 }
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100470}
471
472static struct acpi_driver ideapad_acpi_driver = {
473 .name = "ideapad_acpi",
474 .class = "IdeaPad",
475 .ids = ideapad_device_ids,
476 .ops.add = ideapad_acpi_add,
477 .ops.remove = ideapad_acpi_remove,
478 .ops.notify = ideapad_acpi_notify,
479 .owner = THIS_MODULE,
480};
481
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100482static int __init ideapad_acpi_module_init(void)
483{
Ike Panhca4b5a272010-12-13 18:00:48 +0800484 return acpi_bus_register_driver(&ideapad_acpi_driver);
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100485}
486
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100487static void __exit ideapad_acpi_module_exit(void)
488{
489 acpi_bus_unregister_driver(&ideapad_acpi_driver);
David Woodhouse58ac7aa2010-08-10 23:44:05 +0100490}
491
492MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
493MODULE_DESCRIPTION("IdeaPad ACPI Extras");
494MODULE_LICENSE("GPL");
495
496module_init(ideapad_acpi_module_init);
497module_exit(ideapad_acpi_module_exit);