diff options
author | Dmitry Torokhov <dtor@insightbb.com> | 2007-02-18 01:40:30 -0500 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2007-02-18 01:40:30 -0500 |
commit | 82dd9eff4bf3b17f5f511ae931a1f350c36ca9eb (patch) | |
tree | ccdd9581910720c07e7b1e0019278ea800671f24 /drivers/input | |
parent | a1cec06177386ecc320af643de11cfa77e8945bd (diff) |
Input: i8042 - let serio bus suspend ports
Let serio subsystem take care of suspending the ports; concentrate
on suspending/resuming the controller itself.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/serio/i8042.c | 56 | ||||
-rw-r--r-- | drivers/input/serio/serio.c | 36 |
2 files changed, 64 insertions, 28 deletions
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index c3fdfc1f342a..b90a2cddc8a1 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c | |||
@@ -724,7 +724,7 @@ static int i8042_controller_init(void) | |||
724 | if (~i8042_read_status() & I8042_STR_KEYLOCK) { | 724 | if (~i8042_read_status() & I8042_STR_KEYLOCK) { |
725 | if (i8042_unlock) | 725 | if (i8042_unlock) |
726 | i8042_ctr |= I8042_CTR_IGNKEYLOCK; | 726 | i8042_ctr |= I8042_CTR_IGNKEYLOCK; |
727 | else | 727 | else |
728 | printk(KERN_WARNING "i8042.c: Warning: Keylock active.\n"); | 728 | printk(KERN_WARNING "i8042.c: Warning: Keylock active.\n"); |
729 | } | 729 | } |
730 | spin_unlock_irqrestore(&i8042_lock, flags); | 730 | spin_unlock_irqrestore(&i8042_lock, flags); |
@@ -791,27 +791,6 @@ static void i8042_controller_reset(void) | |||
791 | 791 | ||
792 | 792 | ||
793 | /* | 793 | /* |
794 | * Here we try to reset everything back to a state in which the BIOS will be | ||
795 | * able to talk to the hardware when rebooting. | ||
796 | */ | ||
797 | |||
798 | static void i8042_controller_cleanup(void) | ||
799 | { | ||
800 | int i; | ||
801 | |||
802 | /* | ||
803 | * Reset anything that is connected to the ports. | ||
804 | */ | ||
805 | |||
806 | for (i = 0; i < I8042_NUM_PORTS; i++) | ||
807 | if (i8042_ports[i].serio) | ||
808 | serio_cleanup(i8042_ports[i].serio); | ||
809 | |||
810 | i8042_controller_reset(); | ||
811 | } | ||
812 | |||
813 | |||
814 | /* | ||
815 | * i8042_panic_blink() will flash the keyboard LEDs and is called when | 794 | * i8042_panic_blink() will flash the keyboard LEDs and is called when |
816 | * kernel panics. Flashing LEDs is useful for users running X who may | 795 | * kernel panics. Flashing LEDs is useful for users running X who may |
817 | * not see the console and will help distingushing panics from "real" | 796 | * not see the console and will help distingushing panics from "real" |
@@ -857,13 +836,22 @@ static long i8042_panic_blink(long count) | |||
857 | 836 | ||
858 | #undef DELAY | 837 | #undef DELAY |
859 | 838 | ||
839 | #ifdef CONFIG_PM | ||
860 | /* | 840 | /* |
861 | * Here we try to restore the original BIOS settings | 841 | * Here we try to restore the original BIOS settings. We only want to |
842 | * do that once, when we really suspend, not when we taking memory | ||
843 | * snapshot for swsusp (in this case we'll perform required cleanup | ||
844 | * as part of shutdown process). | ||
862 | */ | 845 | */ |
863 | 846 | ||
864 | static int i8042_suspend(struct platform_device *dev, pm_message_t state) | 847 | static int i8042_suspend(struct platform_device *dev, pm_message_t state) |
865 | { | 848 | { |
866 | i8042_controller_cleanup(); | 849 | if (dev->dev.power.power_state.event != state.event) { |
850 | if (state.event == PM_EVENT_SUSPEND) | ||
851 | i8042_controller_reset(); | ||
852 | |||
853 | dev->dev.power.power_state = state; | ||
854 | } | ||
867 | 855 | ||
868 | return 0; | 856 | return 0; |
869 | } | 857 | } |
@@ -877,6 +865,12 @@ static int i8042_resume(struct platform_device *dev) | |||
877 | { | 865 | { |
878 | int error; | 866 | int error; |
879 | 867 | ||
868 | /* | ||
869 | * Do not bother with restoring state if we haven't suspened yet | ||
870 | */ | ||
871 | if (dev->dev.power.power_state.event == PM_EVENT_ON) | ||
872 | return 0; | ||
873 | |||
880 | error = i8042_controller_check(); | 874 | error = i8042_controller_check(); |
881 | if (error) | 875 | if (error) |
882 | return error; | 876 | return error; |
@@ -886,9 +880,12 @@ static int i8042_resume(struct platform_device *dev) | |||
886 | return error; | 880 | return error; |
887 | 881 | ||
888 | /* | 882 | /* |
889 | * Restore pre-resume CTR value and disable all ports | 883 | * Restore original CTR value and disable all ports |
890 | */ | 884 | */ |
891 | 885 | ||
886 | i8042_ctr = i8042_initial_ctr; | ||
887 | if (i8042_direct) | ||
888 | i8042_ctr &= ~I8042_CTR_XLATE; | ||
892 | i8042_ctr |= I8042_CTR_AUXDIS | I8042_CTR_KBDDIS; | 889 | i8042_ctr |= I8042_CTR_AUXDIS | I8042_CTR_KBDDIS; |
893 | i8042_ctr &= ~(I8042_CTR_AUXINT | I8042_CTR_KBDINT); | 890 | i8042_ctr &= ~(I8042_CTR_AUXINT | I8042_CTR_KBDINT); |
894 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) { | 891 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) { |
@@ -909,8 +906,11 @@ static int i8042_resume(struct platform_device *dev) | |||
909 | 906 | ||
910 | i8042_interrupt(0, NULL); | 907 | i8042_interrupt(0, NULL); |
911 | 908 | ||
909 | dev->dev.power.power_state = PMSG_ON; | ||
910 | |||
912 | return 0; | 911 | return 0; |
913 | } | 912 | } |
913 | #endif /* CONFIG_PM */ | ||
914 | 914 | ||
915 | /* | 915 | /* |
916 | * We need to reset the 8042 back to original mode on system shutdown, | 916 | * We need to reset the 8042 back to original mode on system shutdown, |
@@ -919,7 +919,7 @@ static int i8042_resume(struct platform_device *dev) | |||
919 | 919 | ||
920 | static void i8042_shutdown(struct platform_device *dev) | 920 | static void i8042_shutdown(struct platform_device *dev) |
921 | { | 921 | { |
922 | i8042_controller_cleanup(); | 922 | i8042_controller_reset(); |
923 | } | 923 | } |
924 | 924 | ||
925 | static int __devinit i8042_create_kbd_port(void) | 925 | static int __devinit i8042_create_kbd_port(void) |
@@ -1154,9 +1154,11 @@ static struct platform_driver i8042_driver = { | |||
1154 | }, | 1154 | }, |
1155 | .probe = i8042_probe, | 1155 | .probe = i8042_probe, |
1156 | .remove = __devexit_p(i8042_remove), | 1156 | .remove = __devexit_p(i8042_remove), |
1157 | .shutdown = i8042_shutdown, | ||
1158 | #ifdef CONFIG_PM | ||
1157 | .suspend = i8042_suspend, | 1159 | .suspend = i8042_suspend, |
1158 | .resume = i8042_resume, | 1160 | .resume = i8042_resume, |
1159 | .shutdown = i8042_shutdown, | 1161 | #endif |
1160 | }; | 1162 | }; |
1161 | 1163 | ||
1162 | static int __init i8042_init(void) | 1164 | static int __init i8042_init(void) |
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index 17c8c63cbe1a..a15e531ec755 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c | |||
@@ -778,6 +778,19 @@ static int serio_driver_remove(struct device *dev) | |||
778 | return 0; | 778 | return 0; |
779 | } | 779 | } |
780 | 780 | ||
781 | static void serio_cleanup(struct serio *serio) | ||
782 | { | ||
783 | if (serio->drv && serio->drv->cleanup) | ||
784 | serio->drv->cleanup(serio); | ||
785 | } | ||
786 | |||
787 | static void serio_shutdown(struct device *dev) | ||
788 | { | ||
789 | struct serio *serio = to_serio_port(dev); | ||
790 | |||
791 | serio_cleanup(serio); | ||
792 | } | ||
793 | |||
781 | static void serio_attach_driver(struct serio_driver *drv) | 794 | static void serio_attach_driver(struct serio_driver *drv) |
782 | { | 795 | { |
783 | int error; | 796 | int error; |
@@ -910,11 +923,25 @@ static int serio_uevent(struct device *dev, char **envp, int num_envp, char *buf | |||
910 | 923 | ||
911 | #endif /* CONFIG_HOTPLUG */ | 924 | #endif /* CONFIG_HOTPLUG */ |
912 | 925 | ||
926 | #ifdef CONFIG_PM | ||
927 | static int serio_suspend(struct device *dev, pm_message_t state) | ||
928 | { | ||
929 | if (dev->power.power_state.event != state.event) { | ||
930 | if (state.event == PM_EVENT_SUSPEND) | ||
931 | serio_cleanup(to_serio_port(dev)); | ||
932 | |||
933 | dev->power.power_state = state; | ||
934 | } | ||
935 | |||
936 | return 0; | ||
937 | } | ||
938 | |||
913 | static int serio_resume(struct device *dev) | 939 | static int serio_resume(struct device *dev) |
914 | { | 940 | { |
915 | struct serio *serio = to_serio_port(dev); | 941 | struct serio *serio = to_serio_port(dev); |
916 | 942 | ||
917 | if (serio_reconnect_driver(serio)) { | 943 | if (dev->power.power_state.event != PM_EVENT_ON && |
944 | serio_reconnect_driver(serio)) { | ||
918 | /* | 945 | /* |
919 | * Driver re-probing can take a while, so better let kseriod | 946 | * Driver re-probing can take a while, so better let kseriod |
920 | * deal with it. | 947 | * deal with it. |
@@ -922,8 +949,11 @@ static int serio_resume(struct device *dev) | |||
922 | serio_rescan(serio); | 949 | serio_rescan(serio); |
923 | } | 950 | } |
924 | 951 | ||
952 | dev->power.power_state = PMSG_ON; | ||
953 | |||
925 | return 0; | 954 | return 0; |
926 | } | 955 | } |
956 | #endif /* CONFIG_PM */ | ||
927 | 957 | ||
928 | /* called from serio_driver->connect/disconnect methods under serio_mutex */ | 958 | /* called from serio_driver->connect/disconnect methods under serio_mutex */ |
929 | int serio_open(struct serio *serio, struct serio_driver *drv) | 959 | int serio_open(struct serio *serio, struct serio_driver *drv) |
@@ -974,7 +1004,11 @@ static struct bus_type serio_bus = { | |||
974 | .uevent = serio_uevent, | 1004 | .uevent = serio_uevent, |
975 | .probe = serio_driver_probe, | 1005 | .probe = serio_driver_probe, |
976 | .remove = serio_driver_remove, | 1006 | .remove = serio_driver_remove, |
1007 | .shutdown = serio_shutdown, | ||
1008 | #ifdef CONFIG_PM | ||
1009 | .suspend = serio_suspend, | ||
977 | .resume = serio_resume, | 1010 | .resume = serio_resume, |
1011 | #endif | ||
978 | }; | 1012 | }; |
979 | 1013 | ||
980 | static int __init serio_init(void) | 1014 | static int __init serio_init(void) |