diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2012-09-13 10:41:01 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-09-13 10:41:01 -0400 |
commit | 78890b5989d96ddce989cde929c45ceeded0fcaf (patch) | |
tree | 4e2da81fc7c97f11aee174b1eedac110c9a68b3a /drivers/platform/x86/ideapad-laptop.c | |
parent | 1959ec5f82acbdf91425b41600f119ebecb5f6a8 (diff) | |
parent | 55d512e245bc7699a8800e23df1a24195dd08217 (diff) |
Merge commit 'v3.6-rc5' into next
* commit 'v3.6-rc5': (1098 commits)
Linux 3.6-rc5
HID: tpkbd: work even if the new Lenovo Keyboard driver is not configured
Remove user-triggerable BUG from mpol_to_str
xen/pciback: Fix proper FLR steps.
uml: fix compile error in deliver_alarm()
dj: memory scribble in logi_dj
Fix order of arguments to compat_put_time[spec|val]
xen: Use correct masking in xen_swiotlb_alloc_coherent.
xen: fix logical error in tlb flushing
xen/p2m: Fix one-off error in checking the P2M tree directory.
powerpc: Don't use __put_user() in patch_instruction
powerpc: Make sure IPI handlers see data written by IPI senders
powerpc: Restore correct DSCR in context switch
powerpc: Fix DSCR inheritance in copy_thread()
powerpc: Keep thread.dscr and thread.dscr_inherit in sync
powerpc: Update DSCR on all CPUs when writing sysfs dscr_default
powerpc/powernv: Always go into nap mode when CPU is offline
powerpc: Give hypervisor decrementer interrupts their own handler
powerpc/vphn: Fix arch_update_cpu_topology() return value
ARM: gemini: fix the gemini build
...
Conflicts:
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
drivers/rapidio/devices/tsi721.c
Diffstat (limited to 'drivers/platform/x86/ideapad-laptop.c')
-rw-r--r-- | drivers/platform/x86/ideapad-laptop.c | 110 |
1 files changed, 107 insertions, 3 deletions
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 17f6dfd8dbfb..dae7abe1d711 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/fb.h> | 36 | #include <linux/fb.h> |
37 | #include <linux/debugfs.h> | 37 | #include <linux/debugfs.h> |
38 | #include <linux/seq_file.h> | 38 | #include <linux/seq_file.h> |
39 | #include <linux/i8042.h> | ||
39 | 40 | ||
40 | #define IDEAPAD_RFKILL_DEV_NUM (3) | 41 | #define IDEAPAD_RFKILL_DEV_NUM (3) |
41 | 42 | ||
@@ -63,8 +64,11 @@ enum { | |||
63 | VPCCMD_R_3G, | 64 | VPCCMD_R_3G, |
64 | VPCCMD_W_3G, | 65 | VPCCMD_W_3G, |
65 | VPCCMD_R_ODD, /* 0x21 */ | 66 | VPCCMD_R_ODD, /* 0x21 */ |
66 | VPCCMD_R_RF = 0x23, | 67 | VPCCMD_W_FAN, |
68 | VPCCMD_R_RF, | ||
67 | VPCCMD_W_RF, | 69 | VPCCMD_W_RF, |
70 | VPCCMD_R_FAN = 0x2B, | ||
71 | VPCCMD_R_SPECIAL_BUTTONS = 0x31, | ||
68 | VPCCMD_W_BL_POWER = 0x33, | 72 | VPCCMD_W_BL_POWER = 0x33, |
69 | }; | 73 | }; |
70 | 74 | ||
@@ -356,14 +360,46 @@ static ssize_t store_ideapad_cam(struct device *dev, | |||
356 | return -EINVAL; | 360 | return -EINVAL; |
357 | ret = write_ec_cmd(ideapad_handle, VPCCMD_W_CAMERA, state); | 361 | ret = write_ec_cmd(ideapad_handle, VPCCMD_W_CAMERA, state); |
358 | if (ret < 0) | 362 | if (ret < 0) |
359 | return ret; | 363 | return -EIO; |
360 | return count; | 364 | return count; |
361 | } | 365 | } |
362 | 366 | ||
363 | static DEVICE_ATTR(camera_power, 0644, show_ideapad_cam, store_ideapad_cam); | 367 | static DEVICE_ATTR(camera_power, 0644, show_ideapad_cam, store_ideapad_cam); |
364 | 368 | ||
369 | static ssize_t show_ideapad_fan(struct device *dev, | ||
370 | struct device_attribute *attr, | ||
371 | char *buf) | ||
372 | { | ||
373 | unsigned long result; | ||
374 | |||
375 | if (read_ec_data(ideapad_handle, VPCCMD_R_FAN, &result)) | ||
376 | return sprintf(buf, "-1\n"); | ||
377 | return sprintf(buf, "%lu\n", result); | ||
378 | } | ||
379 | |||
380 | static ssize_t store_ideapad_fan(struct device *dev, | ||
381 | struct device_attribute *attr, | ||
382 | const char *buf, size_t count) | ||
383 | { | ||
384 | int ret, state; | ||
385 | |||
386 | if (!count) | ||
387 | return 0; | ||
388 | if (sscanf(buf, "%i", &state) != 1) | ||
389 | return -EINVAL; | ||
390 | if (state < 0 || state > 4 || state == 3) | ||
391 | return -EINVAL; | ||
392 | ret = write_ec_cmd(ideapad_handle, VPCCMD_W_FAN, state); | ||
393 | if (ret < 0) | ||
394 | return -EIO; | ||
395 | return count; | ||
396 | } | ||
397 | |||
398 | static DEVICE_ATTR(fan_mode, 0644, show_ideapad_fan, store_ideapad_fan); | ||
399 | |||
365 | static struct attribute *ideapad_attributes[] = { | 400 | static struct attribute *ideapad_attributes[] = { |
366 | &dev_attr_camera_power.attr, | 401 | &dev_attr_camera_power.attr, |
402 | &dev_attr_fan_mode.attr, | ||
367 | NULL | 403 | NULL |
368 | }; | 404 | }; |
369 | 405 | ||
@@ -377,7 +413,10 @@ static umode_t ideapad_is_visible(struct kobject *kobj, | |||
377 | 413 | ||
378 | if (attr == &dev_attr_camera_power.attr) | 414 | if (attr == &dev_attr_camera_power.attr) |
379 | supported = test_bit(CFG_CAMERA_BIT, &(priv->cfg)); | 415 | supported = test_bit(CFG_CAMERA_BIT, &(priv->cfg)); |
380 | else | 416 | else if (attr == &dev_attr_fan_mode.attr) { |
417 | unsigned long value; | ||
418 | supported = !read_ec_data(ideapad_handle, VPCCMD_R_FAN, &value); | ||
419 | } else | ||
381 | supported = true; | 420 | supported = true; |
382 | 421 | ||
383 | return supported ? attr->mode : 0; | 422 | return supported ? attr->mode : 0; |
@@ -518,9 +557,15 @@ static void ideapad_platform_exit(struct ideapad_private *priv) | |||
518 | */ | 557 | */ |
519 | static const struct key_entry ideapad_keymap[] = { | 558 | static const struct key_entry ideapad_keymap[] = { |
520 | { KE_KEY, 6, { KEY_SWITCHVIDEOMODE } }, | 559 | { KE_KEY, 6, { KEY_SWITCHVIDEOMODE } }, |
560 | { KE_KEY, 7, { KEY_CAMERA } }, | ||
561 | { KE_KEY, 11, { KEY_F16 } }, | ||
521 | { KE_KEY, 13, { KEY_WLAN } }, | 562 | { KE_KEY, 13, { KEY_WLAN } }, |
522 | { KE_KEY, 16, { KEY_PROG1 } }, | 563 | { KE_KEY, 16, { KEY_PROG1 } }, |
523 | { KE_KEY, 17, { KEY_PROG2 } }, | 564 | { KE_KEY, 17, { KEY_PROG2 } }, |
565 | { KE_KEY, 64, { KEY_PROG3 } }, | ||
566 | { KE_KEY, 65, { KEY_PROG4 } }, | ||
567 | { KE_KEY, 66, { KEY_TOUCHPAD_OFF } }, | ||
568 | { KE_KEY, 67, { KEY_TOUCHPAD_ON } }, | ||
524 | { KE_END, 0 }, | 569 | { KE_END, 0 }, |
525 | }; | 570 | }; |
526 | 571 | ||
@@ -587,6 +632,28 @@ static void ideapad_input_novokey(struct ideapad_private *priv) | |||
587 | ideapad_input_report(priv, 16); | 632 | ideapad_input_report(priv, 16); |
588 | } | 633 | } |
589 | 634 | ||
635 | static void ideapad_check_special_buttons(struct ideapad_private *priv) | ||
636 | { | ||
637 | unsigned long bit, value; | ||
638 | |||
639 | read_ec_data(ideapad_handle, VPCCMD_R_SPECIAL_BUTTONS, &value); | ||
640 | |||
641 | for (bit = 0; bit < 16; bit++) { | ||
642 | if (test_bit(bit, &value)) { | ||
643 | switch (bit) { | ||
644 | case 6: | ||
645 | /* Thermal Management button */ | ||
646 | ideapad_input_report(priv, 65); | ||
647 | break; | ||
648 | case 1: | ||
649 | /* OneKey Theater button */ | ||
650 | ideapad_input_report(priv, 64); | ||
651 | break; | ||
652 | } | ||
653 | } | ||
654 | } | ||
655 | } | ||
656 | |||
590 | /* | 657 | /* |
591 | * backlight | 658 | * backlight |
592 | */ | 659 | */ |
@@ -691,6 +758,24 @@ static const struct acpi_device_id ideapad_device_ids[] = { | |||
691 | }; | 758 | }; |
692 | MODULE_DEVICE_TABLE(acpi, ideapad_device_ids); | 759 | MODULE_DEVICE_TABLE(acpi, ideapad_device_ids); |
693 | 760 | ||
761 | static void ideapad_sync_touchpad_state(struct acpi_device *adevice) | ||
762 | { | ||
763 | struct ideapad_private *priv = dev_get_drvdata(&adevice->dev); | ||
764 | unsigned long value; | ||
765 | |||
766 | /* Without reading from EC touchpad LED doesn't switch state */ | ||
767 | if (!read_ec_data(adevice->handle, VPCCMD_R_TOUCHPAD, &value)) { | ||
768 | /* Some IdeaPads don't really turn off touchpad - they only | ||
769 | * switch the LED state. We (de)activate KBC AUX port to turn | ||
770 | * touchpad off and on. We send KEY_TOUCHPAD_OFF and | ||
771 | * KEY_TOUCHPAD_ON to not to get out of sync with LED */ | ||
772 | unsigned char param; | ||
773 | i8042_command(¶m, value ? I8042_CMD_AUX_ENABLE : | ||
774 | I8042_CMD_AUX_DISABLE); | ||
775 | ideapad_input_report(priv, value ? 67 : 66); | ||
776 | } | ||
777 | } | ||
778 | |||
694 | static int __devinit ideapad_acpi_add(struct acpi_device *adevice) | 779 | static int __devinit ideapad_acpi_add(struct acpi_device *adevice) |
695 | { | 780 | { |
696 | int ret, i; | 781 | int ret, i; |
@@ -727,6 +812,7 @@ static int __devinit ideapad_acpi_add(struct acpi_device *adevice) | |||
727 | priv->rfk[i] = NULL; | 812 | priv->rfk[i] = NULL; |
728 | } | 813 | } |
729 | ideapad_sync_rfk_state(priv); | 814 | ideapad_sync_rfk_state(priv); |
815 | ideapad_sync_touchpad_state(adevice); | ||
730 | 816 | ||
731 | if (!acpi_video_backlight_support()) { | 817 | if (!acpi_video_backlight_support()) { |
732 | ret = ideapad_backlight_init(priv); | 818 | ret = ideapad_backlight_init(priv); |
@@ -785,9 +871,14 @@ static void ideapad_acpi_notify(struct acpi_device *adevice, u32 event) | |||
785 | ideapad_sync_rfk_state(priv); | 871 | ideapad_sync_rfk_state(priv); |
786 | break; | 872 | break; |
787 | case 13: | 873 | case 13: |
874 | case 11: | ||
875 | case 7: | ||
788 | case 6: | 876 | case 6: |
789 | ideapad_input_report(priv, vpc_bit); | 877 | ideapad_input_report(priv, vpc_bit); |
790 | break; | 878 | break; |
879 | case 5: | ||
880 | ideapad_sync_touchpad_state(adevice); | ||
881 | break; | ||
791 | case 4: | 882 | case 4: |
792 | ideapad_backlight_notify_brightness(priv); | 883 | ideapad_backlight_notify_brightness(priv); |
793 | break; | 884 | break; |
@@ -797,6 +888,9 @@ static void ideapad_acpi_notify(struct acpi_device *adevice, u32 event) | |||
797 | case 2: | 888 | case 2: |
798 | ideapad_backlight_notify_power(priv); | 889 | ideapad_backlight_notify_power(priv); |
799 | break; | 890 | break; |
891 | case 0: | ||
892 | ideapad_check_special_buttons(priv); | ||
893 | break; | ||
800 | default: | 894 | default: |
801 | pr_info("Unknown event: %lu\n", vpc_bit); | 895 | pr_info("Unknown event: %lu\n", vpc_bit); |
802 | } | 896 | } |
@@ -804,6 +898,15 @@ static void ideapad_acpi_notify(struct acpi_device *adevice, u32 event) | |||
804 | } | 898 | } |
805 | } | 899 | } |
806 | 900 | ||
901 | static int ideapad_acpi_resume(struct device *device) | ||
902 | { | ||
903 | ideapad_sync_rfk_state(ideapad_priv); | ||
904 | ideapad_sync_touchpad_state(to_acpi_device(device)); | ||
905 | return 0; | ||
906 | } | ||
907 | |||
908 | static SIMPLE_DEV_PM_OPS(ideapad_pm, NULL, ideapad_acpi_resume); | ||
909 | |||
807 | static struct acpi_driver ideapad_acpi_driver = { | 910 | static struct acpi_driver ideapad_acpi_driver = { |
808 | .name = "ideapad_acpi", | 911 | .name = "ideapad_acpi", |
809 | .class = "IdeaPad", | 912 | .class = "IdeaPad", |
@@ -811,6 +914,7 @@ static struct acpi_driver ideapad_acpi_driver = { | |||
811 | .ops.add = ideapad_acpi_add, | 914 | .ops.add = ideapad_acpi_add, |
812 | .ops.remove = ideapad_acpi_remove, | 915 | .ops.remove = ideapad_acpi_remove, |
813 | .ops.notify = ideapad_acpi_notify, | 916 | .ops.notify = ideapad_acpi_notify, |
917 | .drv.pm = &ideapad_pm, | ||
814 | .owner = THIS_MODULE, | 918 | .owner = THIS_MODULE, |
815 | }; | 919 | }; |
816 | 920 | ||