2 * ideapad-laptop.c - Lenovo IdeaPad ACPI Extras
4 * Copyright © 2010 Intel Corporation
5 * Copyright © 2010 David Woodhouse <dwmw2@infradead.org>
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.
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.
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
23 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/init.h>
28 #include <linux/types.h>
29 #include <linux/acpi.h>
30 #include <linux/rfkill.h>
31 #include <linux/platform_device.h>
32 #include <linux/input.h>
33 #include <linux/input/sparse-keymap.h>
34 #include <linux/backlight.h>
36 #include <linux/debugfs.h>
37 #include <linux/seq_file.h>
38 #include <linux/i8042.h>
40 #define IDEAPAD_RFKILL_DEV_NUM (3)
42 #define CFG_BT_BIT (16)
43 #define CFG_3G_BIT (17)
44 #define CFG_WIFI_BIT (18)
45 #define CFG_CAMERA_BIT (19)
65 VPCCMD_R_ODD
, /* 0x21 */
70 VPCCMD_R_SPECIAL_BUTTONS
= 0x31,
71 VPCCMD_W_BL_POWER
= 0x33,
74 struct ideapad_rfk_priv
{
76 struct ideapad_private
*priv
;
79 struct ideapad_private
{
80 struct acpi_device
*adev
;
81 struct rfkill
*rfk
[IDEAPAD_RFKILL_DEV_NUM
];
82 struct ideapad_rfk_priv rfk_priv
[IDEAPAD_RFKILL_DEV_NUM
];
83 struct platform_device
*platform_device
;
84 struct input_dev
*inputdev
;
85 struct backlight_device
*blightdev
;
90 static bool no_bt_rfkill
;
91 module_param(no_bt_rfkill
, bool, 0444);
92 MODULE_PARM_DESC(no_bt_rfkill
, "No rfkill for bluetooth.");
97 #define IDEAPAD_EC_TIMEOUT (100) /* in ms */
99 static int read_method_int(acpi_handle handle
, const char *method
, int *val
)
102 unsigned long long result
;
104 status
= acpi_evaluate_integer(handle
, (char *)method
, NULL
, &result
);
105 if (ACPI_FAILURE(status
)) {
114 static int method_vpcr(acpi_handle handle
, int cmd
, int *ret
)
117 unsigned long long result
;
118 struct acpi_object_list params
;
119 union acpi_object in_obj
;
122 params
.pointer
= &in_obj
;
123 in_obj
.type
= ACPI_TYPE_INTEGER
;
124 in_obj
.integer
.value
= cmd
;
126 status
= acpi_evaluate_integer(handle
, "VPCR", ¶ms
, &result
);
128 if (ACPI_FAILURE(status
)) {
137 static int method_vpcw(acpi_handle handle
, int cmd
, int data
)
139 struct acpi_object_list params
;
140 union acpi_object in_obj
[2];
144 params
.pointer
= in_obj
;
145 in_obj
[0].type
= ACPI_TYPE_INTEGER
;
146 in_obj
[0].integer
.value
= cmd
;
147 in_obj
[1].type
= ACPI_TYPE_INTEGER
;
148 in_obj
[1].integer
.value
= data
;
150 status
= acpi_evaluate_object(handle
, "VPCW", ¶ms
, NULL
);
156 static int read_ec_data(acpi_handle handle
, int cmd
, unsigned long *data
)
159 unsigned long int end_jiffies
;
161 if (method_vpcw(handle
, 1, cmd
))
164 for (end_jiffies
= jiffies
+(HZ
)*IDEAPAD_EC_TIMEOUT
/1000+1;
165 time_before(jiffies
, end_jiffies
);) {
167 if (method_vpcr(handle
, 1, &val
))
170 if (method_vpcr(handle
, 0, &val
))
176 pr_err("timeout in read_ec_cmd\n");
180 static int write_ec_cmd(acpi_handle handle
, int cmd
, unsigned long data
)
183 unsigned long int end_jiffies
;
185 if (method_vpcw(handle
, 0, data
))
187 if (method_vpcw(handle
, 1, cmd
))
190 for (end_jiffies
= jiffies
+(HZ
)*IDEAPAD_EC_TIMEOUT
/1000+1;
191 time_before(jiffies
, end_jiffies
);) {
193 if (method_vpcr(handle
, 1, &val
))
198 pr_err("timeout in write_ec_cmd\n");
205 static int debugfs_status_show(struct seq_file
*s
, void *data
)
207 struct ideapad_private
*priv
= s
->private;
213 if (!read_ec_data(priv
->adev
->handle
, VPCCMD_R_BL_MAX
, &value
))
214 seq_printf(s
, "Backlight max:\t%lu\n", value
);
215 if (!read_ec_data(priv
->adev
->handle
, VPCCMD_R_BL
, &value
))
216 seq_printf(s
, "Backlight now:\t%lu\n", value
);
217 if (!read_ec_data(priv
->adev
->handle
, VPCCMD_R_BL_POWER
, &value
))
218 seq_printf(s
, "BL power value:\t%s\n", value
? "On" : "Off");
219 seq_printf(s
, "=====================\n");
221 if (!read_ec_data(priv
->adev
->handle
, VPCCMD_R_RF
, &value
))
222 seq_printf(s
, "Radio status:\t%s(%lu)\n",
223 value
? "On" : "Off", value
);
224 if (!read_ec_data(priv
->adev
->handle
, VPCCMD_R_WIFI
, &value
))
225 seq_printf(s
, "Wifi status:\t%s(%lu)\n",
226 value
? "On" : "Off", value
);
227 if (!read_ec_data(priv
->adev
->handle
, VPCCMD_R_BT
, &value
))
228 seq_printf(s
, "BT status:\t%s(%lu)\n",
229 value
? "On" : "Off", value
);
230 if (!read_ec_data(priv
->adev
->handle
, VPCCMD_R_3G
, &value
))
231 seq_printf(s
, "3G status:\t%s(%lu)\n",
232 value
? "On" : "Off", value
);
233 seq_printf(s
, "=====================\n");
235 if (!read_ec_data(priv
->adev
->handle
, VPCCMD_R_TOUCHPAD
, &value
))
236 seq_printf(s
, "Touchpad status:%s(%lu)\n",
237 value
? "On" : "Off", value
);
238 if (!read_ec_data(priv
->adev
->handle
, VPCCMD_R_CAMERA
, &value
))
239 seq_printf(s
, "Camera status:\t%s(%lu)\n",
240 value
? "On" : "Off", value
);
245 static int debugfs_status_open(struct inode
*inode
, struct file
*file
)
247 return single_open(file
, debugfs_status_show
, inode
->i_private
);
250 static const struct file_operations debugfs_status_fops
= {
251 .owner
= THIS_MODULE
,
252 .open
= debugfs_status_open
,
255 .release
= single_release
,
258 static int debugfs_cfg_show(struct seq_file
*s
, void *data
)
260 struct ideapad_private
*priv
= s
->private;
263 seq_printf(s
, "cfg: N/A\n");
265 seq_printf(s
, "cfg: 0x%.8lX\n\nCapability: ",
267 if (test_bit(CFG_BT_BIT
, &priv
->cfg
))
268 seq_printf(s
, "Bluetooth ");
269 if (test_bit(CFG_3G_BIT
, &priv
->cfg
))
270 seq_printf(s
, "3G ");
271 if (test_bit(CFG_WIFI_BIT
, &priv
->cfg
))
272 seq_printf(s
, "Wireless ");
273 if (test_bit(CFG_CAMERA_BIT
, &priv
->cfg
))
274 seq_printf(s
, "Camera ");
275 seq_printf(s
, "\nGraphic: ");
276 switch ((priv
->cfg
)&0x700) {
278 seq_printf(s
, "Intel");
281 seq_printf(s
, "ATI");
284 seq_printf(s
, "Nvidia");
287 seq_printf(s
, "Intel and ATI");
290 seq_printf(s
, "Intel and Nvidia");
298 static int debugfs_cfg_open(struct inode
*inode
, struct file
*file
)
300 return single_open(file
, debugfs_cfg_show
, inode
->i_private
);
303 static const struct file_operations debugfs_cfg_fops
= {
304 .owner
= THIS_MODULE
,
305 .open
= debugfs_cfg_open
,
308 .release
= single_release
,
311 static int ideapad_debugfs_init(struct ideapad_private
*priv
)
315 priv
->debug
= debugfs_create_dir("ideapad", NULL
);
316 if (priv
->debug
== NULL
) {
317 pr_err("failed to create debugfs directory");
321 node
= debugfs_create_file("cfg", S_IRUGO
, priv
->debug
, priv
,
324 pr_err("failed to create cfg in debugfs");
328 node
= debugfs_create_file("status", S_IRUGO
, priv
->debug
, priv
,
329 &debugfs_status_fops
);
331 pr_err("failed to create status in debugfs");
341 static void ideapad_debugfs_exit(struct ideapad_private
*priv
)
343 debugfs_remove_recursive(priv
->debug
);
350 static ssize_t
show_ideapad_cam(struct device
*dev
,
351 struct device_attribute
*attr
,
354 unsigned long result
;
355 struct ideapad_private
*priv
= dev_get_drvdata(dev
);
357 if (read_ec_data(priv
->adev
->handle
, VPCCMD_R_CAMERA
, &result
))
358 return sprintf(buf
, "-1\n");
359 return sprintf(buf
, "%lu\n", result
);
362 static ssize_t
store_ideapad_cam(struct device
*dev
,
363 struct device_attribute
*attr
,
364 const char *buf
, size_t count
)
367 struct ideapad_private
*priv
= dev_get_drvdata(dev
);
371 if (sscanf(buf
, "%i", &state
) != 1)
373 ret
= write_ec_cmd(priv
->adev
->handle
, VPCCMD_W_CAMERA
, state
);
379 static DEVICE_ATTR(camera_power
, 0644, show_ideapad_cam
, store_ideapad_cam
);
381 static ssize_t
show_ideapad_fan(struct device
*dev
,
382 struct device_attribute
*attr
,
385 unsigned long result
;
386 struct ideapad_private
*priv
= dev_get_drvdata(dev
);
388 if (read_ec_data(priv
->adev
->handle
, VPCCMD_R_FAN
, &result
))
389 return sprintf(buf
, "-1\n");
390 return sprintf(buf
, "%lu\n", result
);
393 static ssize_t
store_ideapad_fan(struct device
*dev
,
394 struct device_attribute
*attr
,
395 const char *buf
, size_t count
)
398 struct ideapad_private
*priv
= dev_get_drvdata(dev
);
402 if (sscanf(buf
, "%i", &state
) != 1)
404 if (state
< 0 || state
> 4 || state
== 3)
406 ret
= write_ec_cmd(priv
->adev
->handle
, VPCCMD_W_FAN
, state
);
412 static DEVICE_ATTR(fan_mode
, 0644, show_ideapad_fan
, store_ideapad_fan
);
414 static struct attribute
*ideapad_attributes
[] = {
415 &dev_attr_camera_power
.attr
,
416 &dev_attr_fan_mode
.attr
,
420 static umode_t
ideapad_is_visible(struct kobject
*kobj
,
421 struct attribute
*attr
,
424 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
425 struct ideapad_private
*priv
= dev_get_drvdata(dev
);
428 if (attr
== &dev_attr_camera_power
.attr
)
429 supported
= test_bit(CFG_CAMERA_BIT
, &(priv
->cfg
));
430 else if (attr
== &dev_attr_fan_mode
.attr
) {
432 supported
= !read_ec_data(priv
->adev
->handle
, VPCCMD_R_FAN
,
437 return supported
? attr
->mode
: 0;
440 static struct attribute_group ideapad_attribute_group
= {
441 .is_visible
= ideapad_is_visible
,
442 .attrs
= ideapad_attributes
448 struct ideapad_rfk_data
{
455 const struct ideapad_rfk_data ideapad_rfk_data
[] = {
456 { "ideapad_wlan", CFG_WIFI_BIT
, VPCCMD_W_WIFI
, RFKILL_TYPE_WLAN
},
457 { "ideapad_bluetooth", CFG_BT_BIT
, VPCCMD_W_BT
, RFKILL_TYPE_BLUETOOTH
},
458 { "ideapad_3g", CFG_3G_BIT
, VPCCMD_W_3G
, RFKILL_TYPE_WWAN
},
461 static int ideapad_rfk_set(void *data
, bool blocked
)
463 struct ideapad_rfk_priv
*priv
= data
;
465 return write_ec_cmd(priv
->priv
->adev
->handle
, priv
->dev
, !blocked
);
468 static struct rfkill_ops ideapad_rfk_ops
= {
469 .set_block
= ideapad_rfk_set
,
472 static void ideapad_sync_rfk_state(struct ideapad_private
*priv
)
474 unsigned long hw_blocked
;
477 if (read_ec_data(priv
->adev
->handle
, VPCCMD_R_RF
, &hw_blocked
))
479 hw_blocked
= !hw_blocked
;
481 for (i
= 0; i
< IDEAPAD_RFKILL_DEV_NUM
; i
++)
483 rfkill_set_hw_state(priv
->rfk
[i
], hw_blocked
);
486 static int ideapad_register_rfkill(struct ideapad_private
*priv
, int dev
)
489 unsigned long sw_blocked
;
492 (ideapad_rfk_data
[dev
].type
== RFKILL_TYPE_BLUETOOTH
)) {
493 /* Force to enable bluetooth when no_bt_rfkill=1 */
494 write_ec_cmd(priv
->adev
->handle
,
495 ideapad_rfk_data
[dev
].opcode
, 1);
498 priv
->rfk_priv
[dev
].dev
= dev
;
499 priv
->rfk_priv
[dev
].priv
= priv
;
501 priv
->rfk
[dev
] = rfkill_alloc(ideapad_rfk_data
[dev
].name
,
502 &priv
->platform_device
->dev
,
503 ideapad_rfk_data
[dev
].type
,
505 &priv
->rfk_priv
[dev
]);
509 if (read_ec_data(priv
->adev
->handle
, ideapad_rfk_data
[dev
].opcode
-1,
511 rfkill_init_sw_state(priv
->rfk
[dev
], 0);
513 sw_blocked
= !sw_blocked
;
514 rfkill_init_sw_state(priv
->rfk
[dev
], sw_blocked
);
517 ret
= rfkill_register(priv
->rfk
[dev
]);
519 rfkill_destroy(priv
->rfk
[dev
]);
525 static void ideapad_unregister_rfkill(struct ideapad_private
*priv
, int dev
)
530 rfkill_unregister(priv
->rfk
[dev
]);
531 rfkill_destroy(priv
->rfk
[dev
]);
537 static int ideapad_sysfs_init(struct ideapad_private
*priv
)
539 return sysfs_create_group(&priv
->platform_device
->dev
.kobj
,
540 &ideapad_attribute_group
);
543 static void ideapad_sysfs_exit(struct ideapad_private
*priv
)
545 sysfs_remove_group(&priv
->platform_device
->dev
.kobj
,
546 &ideapad_attribute_group
);
552 static const struct key_entry ideapad_keymap
[] = {
553 { KE_KEY
, 6, { KEY_SWITCHVIDEOMODE
} },
554 { KE_KEY
, 7, { KEY_CAMERA
} },
555 { KE_KEY
, 11, { KEY_F16
} },
556 { KE_KEY
, 13, { KEY_WLAN
} },
557 { KE_KEY
, 16, { KEY_PROG1
} },
558 { KE_KEY
, 17, { KEY_PROG2
} },
559 { KE_KEY
, 64, { KEY_PROG3
} },
560 { KE_KEY
, 65, { KEY_PROG4
} },
561 { KE_KEY
, 66, { KEY_TOUCHPAD_OFF
} },
562 { KE_KEY
, 67, { KEY_TOUCHPAD_ON
} },
566 static int ideapad_input_init(struct ideapad_private
*priv
)
568 struct input_dev
*inputdev
;
571 inputdev
= input_allocate_device();
575 inputdev
->name
= "Ideapad extra buttons";
576 inputdev
->phys
= "ideapad/input0";
577 inputdev
->id
.bustype
= BUS_HOST
;
578 inputdev
->dev
.parent
= &priv
->platform_device
->dev
;
580 error
= sparse_keymap_setup(inputdev
, ideapad_keymap
, NULL
);
582 pr_err("Unable to setup input device keymap\n");
586 error
= input_register_device(inputdev
);
588 pr_err("Unable to register input device\n");
589 goto err_free_keymap
;
592 priv
->inputdev
= inputdev
;
596 sparse_keymap_free(inputdev
);
598 input_free_device(inputdev
);
602 static void ideapad_input_exit(struct ideapad_private
*priv
)
604 sparse_keymap_free(priv
->inputdev
);
605 input_unregister_device(priv
->inputdev
);
606 priv
->inputdev
= NULL
;
609 static void ideapad_input_report(struct ideapad_private
*priv
,
610 unsigned long scancode
)
612 sparse_keymap_report_event(priv
->inputdev
, scancode
, 1, true);
615 static void ideapad_input_novokey(struct ideapad_private
*priv
)
617 unsigned long long_pressed
;
619 if (read_ec_data(priv
->adev
->handle
, VPCCMD_R_NOVO
, &long_pressed
))
622 ideapad_input_report(priv
, 17);
624 ideapad_input_report(priv
, 16);
627 static void ideapad_check_special_buttons(struct ideapad_private
*priv
)
629 unsigned long bit
, value
;
631 read_ec_data(priv
->adev
->handle
, VPCCMD_R_SPECIAL_BUTTONS
, &value
);
633 for (bit
= 0; bit
< 16; bit
++) {
634 if (test_bit(bit
, &value
)) {
638 /* Thermal Management button */
639 ideapad_input_report(priv
, 65);
642 /* OneKey Theater button */
643 ideapad_input_report(priv
, 64);
646 pr_info("Unknown special button: %lu\n", bit
);
656 static int ideapad_backlight_get_brightness(struct backlight_device
*blightdev
)
658 struct ideapad_private
*priv
= bl_get_data(blightdev
);
664 if (read_ec_data(priv
->adev
->handle
, VPCCMD_R_BL
, &now
))
669 static int ideapad_backlight_update_status(struct backlight_device
*blightdev
)
671 struct ideapad_private
*priv
= bl_get_data(blightdev
);
676 if (write_ec_cmd(priv
->adev
->handle
, VPCCMD_W_BL
,
677 blightdev
->props
.brightness
))
679 if (write_ec_cmd(priv
->adev
->handle
, VPCCMD_W_BL_POWER
,
680 blightdev
->props
.power
== FB_BLANK_POWERDOWN
? 0 : 1))
686 static const struct backlight_ops ideapad_backlight_ops
= {
687 .get_brightness
= ideapad_backlight_get_brightness
,
688 .update_status
= ideapad_backlight_update_status
,
691 static int ideapad_backlight_init(struct ideapad_private
*priv
)
693 struct backlight_device
*blightdev
;
694 struct backlight_properties props
;
695 unsigned long max
, now
, power
;
697 if (read_ec_data(priv
->adev
->handle
, VPCCMD_R_BL_MAX
, &max
))
699 if (read_ec_data(priv
->adev
->handle
, VPCCMD_R_BL
, &now
))
701 if (read_ec_data(priv
->adev
->handle
, VPCCMD_R_BL_POWER
, &power
))
704 memset(&props
, 0, sizeof(struct backlight_properties
));
705 props
.max_brightness
= max
;
706 props
.type
= BACKLIGHT_PLATFORM
;
707 blightdev
= backlight_device_register("ideapad",
708 &priv
->platform_device
->dev
,
710 &ideapad_backlight_ops
,
712 if (IS_ERR(blightdev
)) {
713 pr_err("Could not register backlight device\n");
714 return PTR_ERR(blightdev
);
717 priv
->blightdev
= blightdev
;
718 blightdev
->props
.brightness
= now
;
719 blightdev
->props
.power
= power
? FB_BLANK_UNBLANK
: FB_BLANK_POWERDOWN
;
720 backlight_update_status(blightdev
);
725 static void ideapad_backlight_exit(struct ideapad_private
*priv
)
728 backlight_device_unregister(priv
->blightdev
);
729 priv
->blightdev
= NULL
;
732 static void ideapad_backlight_notify_power(struct ideapad_private
*priv
)
735 struct backlight_device
*blightdev
= priv
->blightdev
;
739 if (read_ec_data(priv
->adev
->handle
, VPCCMD_R_BL_POWER
, &power
))
741 blightdev
->props
.power
= power
? FB_BLANK_UNBLANK
: FB_BLANK_POWERDOWN
;
744 static void ideapad_backlight_notify_brightness(struct ideapad_private
*priv
)
748 /* if we control brightness via acpi video driver */
749 if (priv
->blightdev
== NULL
) {
750 read_ec_data(priv
->adev
->handle
, VPCCMD_R_BL
, &now
);
754 backlight_force_update(priv
->blightdev
, BACKLIGHT_UPDATE_HOTKEY
);
760 static void ideapad_sync_touchpad_state(struct ideapad_private
*priv
)
764 /* Without reading from EC touchpad LED doesn't switch state */
765 if (!read_ec_data(priv
->adev
->handle
, VPCCMD_R_TOUCHPAD
, &value
)) {
766 /* Some IdeaPads don't really turn off touchpad - they only
767 * switch the LED state. We (de)activate KBC AUX port to turn
768 * touchpad off and on. We send KEY_TOUCHPAD_OFF and
769 * KEY_TOUCHPAD_ON to not to get out of sync with LED */
771 i8042_command(¶m
, value
? I8042_CMD_AUX_ENABLE
:
772 I8042_CMD_AUX_DISABLE
);
773 ideapad_input_report(priv
, value
? 67 : 66);
777 static void ideapad_acpi_notify(acpi_handle handle
, u32 event
, void *data
)
779 struct ideapad_private
*priv
= data
;
780 unsigned long vpc1
, vpc2
, vpc_bit
;
782 if (read_ec_data(handle
, VPCCMD_R_VPC1
, &vpc1
))
784 if (read_ec_data(handle
, VPCCMD_R_VPC2
, &vpc2
))
787 vpc1
= (vpc2
<< 8) | vpc1
;
788 for (vpc_bit
= 0; vpc_bit
< 16; vpc_bit
++) {
789 if (test_bit(vpc_bit
, &vpc1
)) {
792 ideapad_sync_rfk_state(priv
);
798 ideapad_input_report(priv
, vpc_bit
);
801 ideapad_sync_touchpad_state(priv
);
804 ideapad_backlight_notify_brightness(priv
);
807 ideapad_input_novokey(priv
);
810 ideapad_backlight_notify_power(priv
);
813 ideapad_check_special_buttons(priv
);
816 pr_info("Unknown event: %lu\n", vpc_bit
);
822 static int ideapad_acpi_add(struct platform_device
*pdev
)
826 struct ideapad_private
*priv
;
827 struct acpi_device
*adev
;
829 ret
= acpi_bus_get_device(ACPI_HANDLE(&pdev
->dev
), &adev
);
833 if (read_method_int(adev
->handle
, "_CFG", &cfg
))
836 priv
= kzalloc(sizeof(*priv
), GFP_KERNEL
);
840 dev_set_drvdata(&pdev
->dev
, priv
);
843 priv
->platform_device
= pdev
;
845 ret
= ideapad_sysfs_init(priv
);
849 ret
= ideapad_debugfs_init(priv
);
853 ret
= ideapad_input_init(priv
);
857 for (i
= 0; i
< IDEAPAD_RFKILL_DEV_NUM
; i
++) {
858 if (test_bit(ideapad_rfk_data
[i
].cfgbit
, &priv
->cfg
))
859 ideapad_register_rfkill(priv
, i
);
863 ideapad_sync_rfk_state(priv
);
864 ideapad_sync_touchpad_state(priv
);
866 if (!acpi_video_backlight_support()) {
867 ret
= ideapad_backlight_init(priv
);
868 if (ret
&& ret
!= -ENODEV
)
869 goto backlight_failed
;
871 ret
= acpi_install_notify_handler(adev
->handle
,
872 ACPI_DEVICE_NOTIFY
, ideapad_acpi_notify
, priv
);
874 goto notification_failed
;
878 ideapad_backlight_exit(priv
);
880 for (i
= 0; i
< IDEAPAD_RFKILL_DEV_NUM
; i
++)
881 ideapad_unregister_rfkill(priv
, i
);
882 ideapad_input_exit(priv
);
884 ideapad_debugfs_exit(priv
);
886 ideapad_sysfs_exit(priv
);
892 static int ideapad_acpi_remove(struct platform_device
*pdev
)
894 struct ideapad_private
*priv
= dev_get_drvdata(&pdev
->dev
);
897 acpi_remove_notify_handler(priv
->adev
->handle
,
898 ACPI_DEVICE_NOTIFY
, ideapad_acpi_notify
);
899 ideapad_backlight_exit(priv
);
900 for (i
= 0; i
< IDEAPAD_RFKILL_DEV_NUM
; i
++)
901 ideapad_unregister_rfkill(priv
, i
);
902 ideapad_input_exit(priv
);
903 ideapad_debugfs_exit(priv
);
904 ideapad_sysfs_exit(priv
);
905 dev_set_drvdata(&pdev
->dev
, NULL
);
911 #ifdef CONFIG_PM_SLEEP
912 static int ideapad_acpi_resume(struct device
*device
)
914 struct ideapad_private
*priv
;
918 priv
= dev_get_drvdata(device
);
920 ideapad_sync_rfk_state(priv
);
921 ideapad_sync_touchpad_state(priv
);
925 static SIMPLE_DEV_PM_OPS(ideapad_pm
, NULL
, ideapad_acpi_resume
);
927 static const struct acpi_device_id ideapad_device_ids
[] = {
931 MODULE_DEVICE_TABLE(acpi
, ideapad_device_ids
);
933 static struct platform_driver ideapad_acpi_driver
= {
934 .probe
= ideapad_acpi_add
,
935 .remove
= ideapad_acpi_remove
,
937 .name
= "ideapad_acpi",
938 .owner
= THIS_MODULE
,
940 .acpi_match_table
= ACPI_PTR(ideapad_device_ids
),
944 module_platform_driver(ideapad_acpi_driver
);
946 MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
947 MODULE_DESCRIPTION("IdeaPad ACPI Extras");
948 MODULE_LICENSE("GPL");