pm.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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/config.h>
  10. #include <linux/init.h>
  11. #include <linux/suspend.h>
  12. #include <linux/errno.h>
  13. #include <linux/time.h>
  14. #include <asm/io.h>
  15. #include <asm/hd64461.h>
  16. #include <asm/hp6xx/hp6xx.h>
  17. #include <asm/cpu/dac.h>
  18. #include <asm/pm.h>
  19. #define STBCR 0xffffff82
  20. #define STBCR2 0xffffff88
  21. static int hp6x0_pm_enter(suspend_state_t state)
  22. {
  23. u8 stbcr, stbcr2;
  24. #ifdef CONFIG_HD64461_ENABLER
  25. u8 scr;
  26. u16 hd64461_stbcr;
  27. #endif
  28. if (state != PM_SUSPEND_MEM)
  29. return -EINVAL;
  30. #ifdef CONFIG_HD64461_ENABLER
  31. outb(0, HD64461_PCC1CSCIER);
  32. scr = inb(HD64461_PCC1SCR);
  33. scr |= HD64461_PCCSCR_VCC1;
  34. outb(scr, HD64461_PCC1SCR);
  35. hd64461_stbcr = inw(HD64461_STBCR);
  36. hd64461_stbcr |= HD64461_STBCR_SPC1ST;
  37. outw(hd64461_stbcr, HD64461_STBCR);
  38. #endif
  39. ctrl_outb(0x1f, DACR);
  40. stbcr = ctrl_inb(STBCR);
  41. ctrl_outb(0x01, STBCR);
  42. stbcr2 = ctrl_inb(STBCR2);
  43. ctrl_outb(0x7f , STBCR2);
  44. outw(0xf07f, HD64461_SCPUCR);
  45. pm_enter();
  46. outw(0, HD64461_SCPUCR);
  47. ctrl_outb(stbcr, STBCR);
  48. ctrl_outb(stbcr2, STBCR2);
  49. #ifdef CONFIG_HD64461_ENABLER
  50. hd64461_stbcr = inw(HD64461_STBCR);
  51. hd64461_stbcr &= ~HD64461_STBCR_SPC1ST;
  52. outw(hd64461_stbcr, HD64461_STBCR);
  53. outb(0x4c, HD64461_PCC1CSCIER);
  54. outb(0x00, HD64461_PCC1CSCR);
  55. #endif
  56. return 0;
  57. }
  58. /*
  59. * Set to PM_DISK_FIRMWARE so we can quickly veto suspend-to-disk.
  60. */
  61. static struct pm_ops hp6x0_pm_ops = {
  62. .pm_disk_mode = PM_DISK_FIRMWARE,
  63. .enter = hp6x0_pm_enter,
  64. };
  65. static int __init hp6x0_pm_init(void)
  66. {
  67. pm_set_ops(&hp6x0_pm_ops);
  68. return 0;
  69. }
  70. late_initcall(hp6x0_pm_init);