idle.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (C) 2006-2007 PA Semi, Inc
  3. *
  4. * Maintained by: Olof Johansson <olof@lixom.net>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. *
  19. */
  20. #undef DEBUG
  21. #include <linux/kernel.h>
  22. #include <linux/string.h>
  23. #include <asm/machdep.h>
  24. #include <asm/reg.h>
  25. #include "pasemi.h"
  26. struct sleep_mode {
  27. char *name;
  28. void (*entry)(void);
  29. };
  30. static struct sleep_mode modes[] = {
  31. { .name = "spin", .entry = &idle_spin },
  32. { .name = "doze", .entry = &idle_doze },
  33. };
  34. static int current_mode = 0;
  35. static int pasemi_system_reset_exception(struct pt_regs *regs)
  36. {
  37. /* If we were woken up from power savings, we need to return
  38. * to the calling function, since nip is not saved across
  39. * all modes.
  40. */
  41. if (regs->msr & SRR1_WAKEMASK)
  42. regs->nip = regs->link;
  43. switch (regs->msr & SRR1_WAKEMASK) {
  44. case SRR1_WAKEEE:
  45. do_IRQ(regs);
  46. break;
  47. case SRR1_WAKEDEC:
  48. timer_interrupt(regs);
  49. break;
  50. default:
  51. /* do system reset */
  52. return 0;
  53. }
  54. /* everything handled */
  55. regs->msr |= MSR_RI;
  56. return 1;
  57. }
  58. void __init pasemi_idle_init(void)
  59. {
  60. ppc_md.system_reset_exception = pasemi_system_reset_exception;
  61. ppc_md.power_save = modes[current_mode].entry;
  62. printk(KERN_INFO "Using PA6T idle loop (%s)\n", modes[current_mode].name);
  63. }
  64. static int __init idle_param(char *p)
  65. {
  66. int i;
  67. for (i = 0; i < sizeof(modes)/sizeof(struct sleep_mode); i++) {
  68. if (!strcmp(modes[i].name, p)) {
  69. current_mode = i;
  70. break;
  71. }
  72. }
  73. return 0;
  74. }
  75. early_param("idle", idle_param);