Wu Zhangjin | a9e8641 | 2009-11-11 14:57:41 +0800 | [diff] [blame^] | 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 | } |