aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/loongson
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/loongson')
-rw-r--r--arch/mips/loongson/lemote-2f/Makefile6
-rw-r--r--arch/mips/loongson/lemote-2f/pm.c73
2 files changed, 79 insertions, 0 deletions
diff --git a/arch/mips/loongson/lemote-2f/Makefile b/arch/mips/loongson/lemote-2f/Makefile
index da543b1b51e..5add7b2ead1 100644
--- a/arch/mips/loongson/lemote-2f/Makefile
+++ b/arch/mips/loongson/lemote-2f/Makefile
@@ -3,3 +3,9 @@
3# 3#
4 4
5obj-y += irq.o reset.o 5obj-y += irq.o reset.o
6
7#
8# Suspend Support
9#
10
11obj-$(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 00000000000..8090d051422
--- /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
28static unsigned char i8042_ctr;
29
30static 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 */
55void 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}