2 * Lemote loongson2f family machines' specific suspend support
4 * Copyright (C) 2009 Lemote Inc.
5 * Author: Wu Zhangjin <wuzj@lemote.com>
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.
13 #include <linux/suspend.h>
14 #include <linux/interrupt.h>
16 #include <linux/i8042.h>
18 #include <asm/i8259.h>
19 #include <asm/mipsregs.h>
20 #include <asm/bootinfo.h>
24 #define I8042_KBD_IRQ 1
25 #define I8042_CTR_KBDINT 0x01
26 #define I8042_CTR_KBDDIS 0x10
28 static unsigned char i8042_ctr;
30 static int i8042_enable_kbd_port(void)
32 if (i8042_command(&i8042_ctr, I8042_CMD_CTL_RCTR)) {
33 pr_err("i8042.c: Can't read CTR while enabling i8042 kbd port."
38 i8042_ctr &= ~I8042_CTR_KBDDIS;
39 i8042_ctr |= I8042_CTR_KBDINT;
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");
53 * The i8042 is connnected to i8259A
55 void setup_wakeup_events(void)
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);
66 /* enable keyboard port */
67 i8042_enable_kbd_port();