diff options
author | Wu Zhangjin <wuzhangjin@gmail.com> | 2009-11-11 01:57:41 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2009-12-16 20:57:16 -0500 |
commit | a9e8641f4c252f93875cf30cb28c0f333539f0bf (patch) | |
tree | e6d2e167cea80b7ea89eaf25fee85b9cc249ab25 /arch/mips/loongson | |
parent | f181bf60e3f31cdab48bd8b9d913201ed2f9e522 (diff) |
MIPS: Yeeloong 2F: Add board specific suspend support
Lemote Loongson 2F family machines need an external interrupt to wake the
system from the suspend mode.
For YeeLoong 2F and Mengloong 2F setup the keyboard interrupt as the wakeup
interrupt.
The new Fuloong 2F and LingLoong 2F have a button to directly send an
interrupt to the CPU so there is no need to setup an interrupt.
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: linux-mips@linux-mips.org
Cc: yanh@lemote.com
Cc: huhb@lemote.com
Cc: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: linux-pm@lists.linux-foundation.org
Patchwork: http://patchwork.linux-mips.org/patch/630/
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/loongson')
-rw-r--r-- | arch/mips/loongson/lemote-2f/Makefile | 6 | ||||
-rw-r--r-- | arch/mips/loongson/lemote-2f/pm.c | 73 |
2 files changed, 79 insertions, 0 deletions
diff --git a/arch/mips/loongson/lemote-2f/Makefile b/arch/mips/loongson/lemote-2f/Makefile index da543b1b51e1..5add7b2ead1c 100644 --- a/arch/mips/loongson/lemote-2f/Makefile +++ b/arch/mips/loongson/lemote-2f/Makefile | |||
@@ -3,3 +3,9 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y += irq.o reset.o | 5 | obj-y += irq.o reset.o |
6 | |||
7 | # | ||
8 | # Suspend Support | ||
9 | # | ||
10 | |||
11 | obj-$(CONFIG_LOONGSON_SUSPEND) += pm.o | ||
diff --git a/arch/mips/loongson/lemote-2f/pm.c b/arch/mips/loongson/lemote-2f/pm.c new file mode 100644 index 000000000000..8090d0514221 --- /dev/null +++ b/arch/mips/loongson/lemote-2f/pm.c | |||
@@ -0,0 +1,73 @@ | |||
1 | /* | ||
2 | * Lemote loongson2f family machines' specific suspend support | ||
3 | * | ||
4 | * Copyright (C) 2009 Lemote Inc. | ||
5 | * Author: Wu Zhangjin <wuzj@lemote.com> | ||
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 | |||
13 | #include <linux/suspend.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/pm.h> | ||
16 | #include <linux/i8042.h> | ||
17 | |||
18 | #include <asm/i8259.h> | ||
19 | #include <asm/mipsregs.h> | ||
20 | #include <asm/bootinfo.h> | ||
21 | |||
22 | #include <loongson.h> | ||
23 | |||
24 | #define I8042_KBD_IRQ 1 | ||
25 | #define I8042_CTR_KBDINT 0x01 | ||
26 | #define I8042_CTR_KBDDIS 0x10 | ||
27 | |||
28 | static unsigned char i8042_ctr; | ||
29 | |||
30 | static int i8042_enable_kbd_port(void) | ||
31 | { | ||
32 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_RCTR)) { | ||
33 | pr_err("i8042.c: Can't read CTR while enabling i8042 kbd port." | ||
34 | "\n"); | ||
35 | return -EIO; | ||
36 | } | ||
37 | |||
38 | i8042_ctr &= ~I8042_CTR_KBDDIS; | ||
39 | i8042_ctr |= I8042_CTR_KBDINT; | ||
40 | |||
41 | if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) { | ||
42 | i8042_ctr &= ~I8042_CTR_KBDINT; | ||
43 | i8042_ctr |= I8042_CTR_KBDDIS; | ||
44 | pr_err("i8042.c: Failed to enable KBD port.\n"); | ||
45 | |||
46 | return -EIO; | ||
47 | } | ||
48 | |||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | /* | ||
53 | * The i8042 is connnected to i8259A | ||
54 | */ | ||
55 | void setup_wakeup_events(void) | ||
56 | { | ||
57 | int irq_mask; | ||
58 | |||
59 | switch (mips_machtype) { | ||
60 | case MACH_LEMOTE_ML2F7: | ||
61 | case MACH_LEMOTE_YL2F89: | ||
62 | /* open the keyboard irq in i8259A */ | ||
63 | outb((0xff & ~(1 << I8042_KBD_IRQ)), PIC_MASTER_IMR); | ||
64 | irq_mask = inb(PIC_MASTER_IMR); | ||
65 | |||
66 | /* enable keyboard port */ | ||
67 | i8042_enable_kbd_port(); | ||
68 | break; | ||
69 | |||
70 | default: | ||
71 | break; | ||
72 | } | ||
73 | } | ||