pm-debug.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * OMAP Power Management debug routines
  3. *
  4. * Copyright (C) 2005 Texas Instruments, Inc.
  5. * Copyright (C) 2006-2008 Nokia Corporation
  6. *
  7. * Written by:
  8. * Richard Woodruff <r-woodruff2@ti.com>
  9. * Tony Lindgren
  10. * Juha Yrjola
  11. * Amit Kucheria <amit.kucheria@nokia.com>
  12. * Igor Stoppa <igor.stoppa@nokia.com>
  13. * Jouni Hogander
  14. *
  15. * Based on pm.c for omap2
  16. *
  17. * This program is free software; you can redistribute it and/or modify
  18. * it under the terms of the GNU General Public License version 2 as
  19. * published by the Free Software Foundation.
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/timer.h>
  23. #include <linux/clk.h>
  24. #include <linux/err.h>
  25. #include <linux/io.h>
  26. #include <mach/clock.h>
  27. #include <mach/board.h>
  28. #include "prm.h"
  29. #include "cm.h"
  30. #include "pm.h"
  31. int omap2_pm_debug;
  32. #define DUMP_PRM_MOD_REG(mod, reg) \
  33. regs[reg_count].name = #mod "." #reg; \
  34. regs[reg_count++].val = prm_read_mod_reg(mod, reg)
  35. #define DUMP_CM_MOD_REG(mod, reg) \
  36. regs[reg_count].name = #mod "." #reg; \
  37. regs[reg_count++].val = cm_read_mod_reg(mod, reg)
  38. #define DUMP_PRM_REG(reg) \
  39. regs[reg_count].name = #reg; \
  40. regs[reg_count++].val = __raw_readl(reg)
  41. #define DUMP_CM_REG(reg) \
  42. regs[reg_count].name = #reg; \
  43. regs[reg_count++].val = __raw_readl(reg)
  44. #define DUMP_INTC_REG(reg, off) \
  45. regs[reg_count].name = #reg; \
  46. regs[reg_count++].val = __raw_readl(IO_ADDRESS(0x480fe000 + (off)))
  47. void omap2_pm_dump(int mode, int resume, unsigned int us)
  48. {
  49. struct reg {
  50. const char *name;
  51. u32 val;
  52. } regs[32];
  53. int reg_count = 0, i;
  54. const char *s1 = NULL, *s2 = NULL;
  55. if (!resume) {
  56. #if 0
  57. /* MPU */
  58. DUMP_PRM_MOD_REG(OCP_MOD, OMAP2_PRM_IRQENABLE_MPU_OFFSET);
  59. DUMP_CM_MOD_REG(MPU_MOD, CM_CLKSTCTRL);
  60. DUMP_PRM_MOD_REG(MPU_MOD, PM_PWSTCTRL);
  61. DUMP_PRM_MOD_REG(MPU_MOD, PM_PWSTST);
  62. DUMP_PRM_MOD_REG(MPU_MOD, PM_WKDEP);
  63. #endif
  64. #if 0
  65. /* INTC */
  66. DUMP_INTC_REG(INTC_MIR0, 0x0084);
  67. DUMP_INTC_REG(INTC_MIR1, 0x00a4);
  68. DUMP_INTC_REG(INTC_MIR2, 0x00c4);
  69. #endif
  70. #if 0
  71. DUMP_CM_MOD_REG(CORE_MOD, CM_FCLKEN1);
  72. if (cpu_is_omap24xx()) {
  73. DUMP_CM_MOD_REG(CORE_MOD, OMAP24XX_CM_FCLKEN2);
  74. DUMP_PRM_MOD_REG(OMAP24XX_GR_MOD,
  75. OMAP2_PRCM_CLKEMUL_CTRL_OFFSET);
  76. DUMP_PRM_MOD_REG(OMAP24XX_GR_MOD,
  77. OMAP2_PRCM_CLKSRC_CTRL_OFFSET);
  78. }
  79. DUMP_CM_MOD_REG(WKUP_MOD, CM_FCLKEN);
  80. DUMP_CM_MOD_REG(CORE_MOD, CM_ICLKEN1);
  81. DUMP_CM_MOD_REG(CORE_MOD, CM_ICLKEN2);
  82. DUMP_CM_MOD_REG(WKUP_MOD, CM_ICLKEN);
  83. DUMP_CM_MOD_REG(PLL_MOD, CM_CLKEN);
  84. DUMP_CM_MOD_REG(PLL_MOD, CM_AUTOIDLE);
  85. DUMP_PRM_MOD_REG(CORE_MOD, PM_PWSTST);
  86. #endif
  87. #if 0
  88. /* DSP */
  89. if (cpu_is_omap24xx()) {
  90. DUMP_CM_MOD_REG(OMAP24XX_DSP_MOD, CM_FCLKEN);
  91. DUMP_CM_MOD_REG(OMAP24XX_DSP_MOD, CM_ICLKEN);
  92. DUMP_CM_MOD_REG(OMAP24XX_DSP_MOD, CM_IDLEST);
  93. DUMP_CM_MOD_REG(OMAP24XX_DSP_MOD, CM_AUTOIDLE);
  94. DUMP_CM_MOD_REG(OMAP24XX_DSP_MOD, CM_CLKSEL);
  95. DUMP_CM_MOD_REG(OMAP24XX_DSP_MOD, CM_CLKSTCTRL);
  96. DUMP_PRM_MOD_REG(OMAP24XX_DSP_MOD, RM_RSTCTRL);
  97. DUMP_PRM_MOD_REG(OMAP24XX_DSP_MOD, RM_RSTST);
  98. DUMP_PRM_MOD_REG(OMAP24XX_DSP_MOD, PM_PWSTCTRL);
  99. DUMP_PRM_MOD_REG(OMAP24XX_DSP_MOD, PM_PWSTST);
  100. }
  101. #endif
  102. } else {
  103. DUMP_PRM_MOD_REG(CORE_MOD, PM_WKST1);
  104. if (cpu_is_omap24xx())
  105. DUMP_PRM_MOD_REG(CORE_MOD, OMAP24XX_PM_WKST2);
  106. DUMP_PRM_MOD_REG(WKUP_MOD, PM_WKST);
  107. DUMP_PRM_MOD_REG(OCP_MOD, OMAP2_PRCM_IRQSTATUS_MPU_OFFSET);
  108. #if 1
  109. DUMP_INTC_REG(INTC_PENDING_IRQ0, 0x0098);
  110. DUMP_INTC_REG(INTC_PENDING_IRQ1, 0x00b8);
  111. DUMP_INTC_REG(INTC_PENDING_IRQ2, 0x00d8);
  112. #endif
  113. }
  114. switch (mode) {
  115. case 0:
  116. s1 = "full";
  117. s2 = "retention";
  118. break;
  119. case 1:
  120. s1 = "MPU";
  121. s2 = "retention";
  122. break;
  123. case 2:
  124. s1 = "MPU";
  125. s2 = "idle";
  126. break;
  127. }
  128. if (!resume)
  129. #ifdef CONFIG_NO_HZ
  130. printk(KERN_INFO
  131. "--- Going to %s %s (next timer after %u ms)\n", s1, s2,
  132. jiffies_to_msecs(get_next_timer_interrupt(jiffies) -
  133. jiffies));
  134. #else
  135. printk(KERN_INFO "--- Going to %s %s\n", s1, s2);
  136. #endif
  137. else
  138. printk(KERN_INFO "--- Woke up (slept for %u.%03u ms)\n",
  139. us / 1000, us % 1000);
  140. for (i = 0; i < reg_count; i++)
  141. printk(KERN_INFO "%-20s: 0x%08x\n", regs[i].name, regs[i].val);
  142. }