pm.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * hp6x0 Power Management Routines
  3. *
  4. * Copyright (c) 2006 Andriy Skulysh <askulsyh@gmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License.
  8. */
  9. #include <linux/init.h>
  10. #include <linux/suspend.h>
  11. #include <linux/errno.h>
  12. #include <linux/time.h>
  13. #include <asm/io.h>
  14. #include <asm/hd64461.h>
  15. #include <asm/hp6xx.h>
  16. #include <asm/cpu/dac.h>
  17. #include <asm/pm.h>
  18. #define STBCR 0xffffff82
  19. #define STBCR2 0xffffff88
  20. static int hp6x0_pm_enter(suspend_state_t state)
  21. {
  22. u8 stbcr, stbcr2;
  23. #ifdef CONFIG_HD64461_ENABLER
  24. u8 scr;
  25. u16 hd64461_stbcr;
  26. #endif
  27. if (state != PM_SUSPEND_MEM)
  28. return -EINVAL;
  29. #ifdef CONFIG_HD64461_ENABLER
  30. outb(0, HD64461_PCC1CSCIER);
  31. scr = inb(HD64461_PCC1SCR);
  32. scr |= HD64461_PCCSCR_VCC1;
  33. outb(scr, HD64461_PCC1SCR);
  34. hd64461_stbcr = inw(HD64461_STBCR);
  35. hd64461_stbcr |= HD64461_STBCR_SPC1ST;
  36. outw(hd64461_stbcr, HD64461_STBCR);
  37. #endif
  38. ctrl_outb(0x1f, DACR);
  39. stbcr = ctrl_inb(STBCR);
  40. ctrl_outb(0x01, STBCR);
  41. stbcr2 = ctrl_inb(STBCR2);
  42. ctrl_outb(0x7f , STBCR2);
  43. outw(0xf07f, HD64461_SCPUCR);
  44. pm_enter();
  45. outw(0, HD64461_SCPUCR);
  46. ctrl_outb(stbcr, STBCR);
  47. ctrl_outb(stbcr2, STBCR2);
  48. #ifdef CONFIG_HD64461_ENABLER
  49. hd64461_stbcr = inw(HD64461_STBCR);
  50. hd64461_stbcr &= ~HD64461_STBCR_SPC1ST;
  51. outw(hd64461_stbcr, HD64461_STBCR);
  52. outb(0x4c, HD64461_PCC1CSCIER);
  53. outb(0x00, HD64461_PCC1CSCR);
  54. #endif
  55. return 0;
  56. }
  57. /*
  58. * Set to PM_DISK_FIRMWARE so we can quickly veto suspend-to-disk.
  59. */
  60. static struct pm_ops hp6x0_pm_ops = {
  61. .pm_disk_mode = PM_DISK_FIRMWARE,
  62. .enter = hp6x0_pm_enter,
  63. };
  64. static int __init hp6x0_pm_init(void)
  65. {
  66. pm_set_ops(&hp6x0_pm_ops);
  67. return 0;
  68. }
  69. late_initcall(hp6x0_pm_init);