pm.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #include <linux/suspend.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/pm.h>
  15. #include <linux/i8042.h>
  16. #include <asm/i8259.h>
  17. #include <asm/mipsregs.h>
  18. #include <asm/bootinfo.h>
  19. #include <loongson.h>
  20. #define I8042_KBD_IRQ 1
  21. #define I8042_CTR_KBDINT 0x01
  22. #define I8042_CTR_KBDDIS 0x10
  23. static unsigned char i8042_ctr;
  24. static int i8042_enable_kbd_port(void)
  25. {
  26. if (i8042_command(&i8042_ctr, I8042_CMD_CTL_RCTR)) {
  27. pr_err("i8042.c: Can't read CTR while enabling i8042 kbd port."
  28. "\n");
  29. return -EIO;
  30. }
  31. i8042_ctr &= ~I8042_CTR_KBDDIS;
  32. i8042_ctr |= I8042_CTR_KBDINT;
  33. if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) {
  34. i8042_ctr &= ~I8042_CTR_KBDINT;
  35. i8042_ctr |= I8042_CTR_KBDDIS;
  36. pr_err("i8042.c: Failed to enable KBD port.\n");
  37. return -EIO;
  38. }
  39. return 0;
  40. }
  41. /*
  42. * The i8042 is connnected to i8259A
  43. */
  44. void setup_wakeup_events(void)
  45. {
  46. int irq_mask;
  47. switch (mips_machtype) {
  48. case MACH_LEMOTE_ML2F7:
  49. case MACH_LEMOTE_YL2F89:
  50. /* open the keyboard irq in i8259A */
  51. outb((0xff & ~(1 << I8042_KBD_IRQ)), PIC_MASTER_IMR);
  52. irq_mask = inb(PIC_MASTER_IMR);
  53. /* enable keyboard port */
  54. i8042_enable_kbd_port();
  55. break;
  56. default:
  57. break;
  58. }
  59. }