spr.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * (C) Copyright 2007
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. /*
  25. * SPR test
  26. *
  27. * The test checks the contents of Special Purpose Registers (SPR) listed
  28. * in the spr_test_list array below.
  29. * Each SPR value is read using mfspr instruction, some bits are masked
  30. * according to the table and the resulting value is compared to the
  31. * corresponding table value.
  32. */
  33. #ifdef CONFIG_POST
  34. #include <post.h>
  35. #if CONFIG_POST & CFG_POST_SPR
  36. static struct
  37. {
  38. int number;
  39. char * name;
  40. unsigned long mask;
  41. unsigned long value;
  42. } spr_test_list [] = {
  43. /* Standard Special-Purpose Registers */
  44. {0x001, "XER", 0x00000000, 0x00000000},
  45. {0x008, "LR", 0x00000000, 0x00000000},
  46. {0x009, "CTR", 0x00000000, 0x00000000},
  47. {0x016, "DEC", 0x00000000, 0x00000000},
  48. {0x01a, "SRR0", 0x00000000, 0x00000000},
  49. {0x01b, "SRR1", 0x00000000, 0x00000000},
  50. {0x110, "SPRG0", 0x00000000, 0x00000000},
  51. {0x111, "SPRG1", 0x00000000, 0x00000000},
  52. {0x112, "SPRG2", 0x00000000, 0x00000000},
  53. {0x113, "SPRG3", 0x00000000, 0x00000000},
  54. {0x11f, "PVR", 0x00000000, 0x00000000},
  55. /* Additional Special-Purpose Registers */
  56. {0x30, "PID", 0x00000000, 0x00000000},
  57. {0x3a, "CSRR0", 0x00000000, 0x00000000},
  58. {0x3b, "CSRR1", 0x00000000, 0x00000000},
  59. {0x3d, "DEAR", 0x00000000, 0x00000000},
  60. {0x3e, "ESR", 0x00000000, 0x00000000},
  61. {0x3f, "IVPR", 0xffff0000, 0x00000000},
  62. {0x100, "USPRG0", 0x00000000, 0x00000000},
  63. {0x104, "SPRG4", 0x00000000, 0x00000000},
  64. {0x105, "SPRG5", 0x00000000, 0x00000000},
  65. {0x106, "SPRG6", 0x00000000, 0x00000000},
  66. {0x107, "SPRG7", 0x00000000, 0x00000000},
  67. {0x10c, "TBL", 0x00000000, 0x00000000},
  68. {0x10d, "TBU", 0x00000000, 0x00000000},
  69. {0x11e, "PIR", 0x0000000f, 0x00000000},
  70. {0x130, "DBSR", 0x00000000, 0x00000000},
  71. {0x134, "DBCR0", 0x00000000, 0x00000000},
  72. {0x135, "DBCR1", 0x00000000, 0x00000000},
  73. {0x136, "DBCR2", 0x00000000, 0x00000000},
  74. {0x138, "IAC1", 0x00000000, 0x00000000},
  75. {0x139, "IAC2", 0x00000000, 0x00000000},
  76. {0x13a, "IAC3", 0x00000000, 0x00000000},
  77. {0x13b, "IAC4", 0x00000000, 0x00000000},
  78. {0x13c, "DAC1", 0x00000000, 0x00000000},
  79. {0x13d, "DAC2", 0x00000000, 0x00000000},
  80. {0x13e, "DVC1", 0x00000000, 0x00000000},
  81. {0x13f, "DVC2", 0x00000000, 0x00000000},
  82. {0x150, "TSR", 0x00000000, 0x00000000},
  83. {0x154, "TCR", 0x00000000, 0x00000000},
  84. {0x190, "IVOR0", 0x00000000, 0x00000000},
  85. {0x191, "IVOR1", 0x00000000, 0x00000000},
  86. {0x192, "IVOR2", 0x00000000, 0x00000000},
  87. {0x193, "IVOR3", 0x00000000, 0x00000000},
  88. {0x194, "IVOR4", 0x00000000, 0x00000000},
  89. {0x195, "IVOR5", 0x00000000, 0x00000000},
  90. {0x196, "IVOR6", 0x00000000, 0x00000000},
  91. {0x197, "IVOR7", 0x00000000, 0x00000000},
  92. {0x198, "IVOR8", 0x00000000, 0x00000000},
  93. {0x199, "IVOR9", 0x00000000, 0x00000000},
  94. {0x19a, "IVOR10", 0x00000000, 0x00000000},
  95. {0x19b, "IVOR11", 0x00000000, 0x00000000},
  96. {0x19c, "IVOR12", 0x00000000, 0x00000000},
  97. {0x19d, "IVOR13", 0x00000000, 0x00000000},
  98. {0x19e, "IVOR14", 0x00000000, 0x00000000},
  99. {0x19f, "IVOR15", 0x00000000, 0x00000000},
  100. {0x23a, "MCSRR0", 0x00000000, 0x00000000},
  101. {0x23b, "MCSRR1", 0x00000000, 0x00000000},
  102. {0x23c, "MCSR", 0x00000000, 0x00000000},
  103. {0x370, "INV0", 0x00000000, 0x00000000},
  104. {0x371, "INV1", 0x00000000, 0x00000000},
  105. {0x372, "INV2", 0x00000000, 0x00000000},
  106. {0x373, "INV3", 0x00000000, 0x00000000},
  107. {0x374, "ITV0", 0x00000000, 0x00000000},
  108. {0x375, "ITV1", 0x00000000, 0x00000000},
  109. {0x376, "ITV2", 0x00000000, 0x00000000},
  110. {0x377, "ITV3", 0x00000000, 0x00000000},
  111. {0x378, "CCR1", 0x00000000, 0x00000000},
  112. {0x390, "DNV0", 0x00000000, 0x00000000},
  113. {0x391, "DNV1", 0x00000000, 0x00000000},
  114. {0x392, "DNV2", 0x00000000, 0x00000000},
  115. {0x393, "DNV3", 0x00000000, 0x00000000},
  116. {0x394, "DTV0", 0x00000000, 0x00000000},
  117. {0x395, "DTV1", 0x00000000, 0x00000000},
  118. {0x396, "DTV2", 0x00000000, 0x00000000},
  119. {0x397, "DTV3", 0x00000000, 0x00000000},
  120. {0x398, "DVLIM", 0x00000000, 0x00000000},
  121. {0x399, "IVLIM", 0x00000000, 0x00000000},
  122. {0x39b, "RSTCFG", 0x00000000, 0x00000000},
  123. {0x39c, "DCDBTRL", 0x00000000, 0x00000000},
  124. {0x39d, "DCDBTRH", 0x00000000, 0x00000000},
  125. {0x39e, "ICDBTRL", 0x00000000, 0x00000000},
  126. {0x39f, "ICDBTRH", 0x00000000, 0x00000000},
  127. {0x3b2, "MMUCR", 0x00000000, 0x00000000},
  128. {0x3b3, "CCR0", 0x00000000, 0x00000000},
  129. {0x3d3, "ICDBDR", 0x00000000, 0x00000000},
  130. {0x3f3, "DBDR", 0x00000000, 0x00000000},
  131. };
  132. static int spr_test_list_size =
  133. sizeof (spr_test_list) / sizeof (spr_test_list[0]);
  134. int spr_post_test (int flags)
  135. {
  136. int ret = 0;
  137. int i;
  138. unsigned long code[] = {
  139. 0x7c6002a6, /* mfspr r3,SPR */
  140. 0x4e800020 /* blr */
  141. };
  142. unsigned long (*get_spr) (void) = (void *) code;
  143. for (i = 0; i < spr_test_list_size; i++) {
  144. int num = spr_test_list[i].number;
  145. /* mfspr r3,num */
  146. code[0] = 0x7c6002a6 | ((num & 0x1F) << 16) | ((num & 0x3E0) << 6);
  147. asm volatile ("isync");
  148. if ((get_spr () & spr_test_list[i].mask) !=
  149. (spr_test_list[i].value & spr_test_list[i].mask)) {
  150. post_log ("The value of %s special register "
  151. "is incorrect: 0x%08X\n",
  152. spr_test_list[i].name, get_spr ());
  153. ret = -1;
  154. }
  155. }
  156. return ret;
  157. }
  158. #endif /* CONFIG_POST & CFG_POST_SPR */
  159. #endif /* CONFIG_POST */