spr.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * (C) Copyright 2002
  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. {1, "XER", 0x00000000, 0x00000000},
  45. {8, "LR", 0x00000000, 0x00000000},
  46. {9, "CTR", 0x00000000, 0x00000000},
  47. {18, "DSISR", 0x00000000, 0x00000000},
  48. {19, "DAR", 0x00000000, 0x00000000},
  49. {22, "DEC", 0x00000000, 0x00000000},
  50. {26, "SRR0", 0x00000000, 0x00000000},
  51. {27, "SRR1", 0x00000000, 0x00000000},
  52. {272, "SPRG0", 0x00000000, 0x00000000},
  53. {273, "SPRG1", 0x00000000, 0x00000000},
  54. {274, "SPRG2", 0x00000000, 0x00000000},
  55. {275, "SPRG3", 0x00000000, 0x00000000},
  56. {287, "PVR", 0xFFFF0000, 0x00500000},
  57. /* Additional Special-Purpose Registers */
  58. {144, "CMPA", 0x00000000, 0x00000000},
  59. {145, "CMPB", 0x00000000, 0x00000000},
  60. {146, "CMPC", 0x00000000, 0x00000000},
  61. {147, "CMPD", 0x00000000, 0x00000000},
  62. {148, "ICR", 0xFFFFFFFF, 0x00000000},
  63. {149, "DER", 0x00000000, 0x00000000},
  64. {150, "COUNTA", 0xFFFFFFFF, 0x00000000},
  65. {151, "COUNTB", 0xFFFFFFFF, 0x00000000},
  66. {152, "CMPE", 0x00000000, 0x00000000},
  67. {153, "CMPF", 0x00000000, 0x00000000},
  68. {154, "CMPG", 0x00000000, 0x00000000},
  69. {155, "CMPH", 0x00000000, 0x00000000},
  70. {156, "LCTRL1", 0xFFFFFFFF, 0x00000000},
  71. {157, "LCTRL2", 0xFFFFFFFF, 0x00000000},
  72. {158, "ICTRL", 0xFFFFFFFF, 0x00000007},
  73. {159, "BAR", 0x00000000, 0x00000000},
  74. {630, "DPDR", 0x00000000, 0x00000000},
  75. {631, "DPIR", 0x00000000, 0x00000000},
  76. {638, "IMMR", 0xFFFF0000, CFG_IMMR },
  77. {560, "IC_CST", 0x8E380000, 0x00000000},
  78. {561, "IC_ADR", 0x00000000, 0x00000000},
  79. {562, "IC_DAT", 0x00000000, 0x00000000},
  80. {568, "DC_CST", 0xEF380000, 0x00000000},
  81. {569, "DC_ADR", 0x00000000, 0x00000000},
  82. {570, "DC_DAT", 0x00000000, 0x00000000},
  83. {784, "MI_CTR", 0xFFFFFFFF, 0x00000000},
  84. {786, "MI_AP", 0x00000000, 0x00000000},
  85. {787, "MI_EPN", 0x00000000, 0x00000000},
  86. {789, "MI_TWC", 0xFFFFFE02, 0x00000000},
  87. {790, "MI_RPN", 0x00000000, 0x00000000},
  88. {816, "MI_DBCAM", 0x00000000, 0x00000000},
  89. {817, "MI_DBRAM0", 0x00000000, 0x00000000},
  90. {818, "MI_DBRAM1", 0x00000000, 0x00000000},
  91. {792, "MD_CTR", 0xFFFFFFFF, 0x04000000},
  92. {793, "M_CASID", 0xFFFFFFF0, 0x00000000},
  93. {794, "MD_AP", 0x00000000, 0x00000000},
  94. {795, "MD_EPN", 0x00000000, 0x00000000},
  95. {796, "M_TWB", 0x00000003, 0x00000000},
  96. {797, "MD_TWC", 0x00000003, 0x00000000},
  97. {798, "MD_RPN", 0x00000000, 0x00000000},
  98. {799, "M_TW", 0x00000000, 0x00000000},
  99. {824, "MD_DBCAM", 0x00000000, 0x00000000},
  100. {825, "MD_DBRAM0", 0x00000000, 0x00000000},
  101. {826, "MD_DBRAM1", 0x00000000, 0x00000000},
  102. };
  103. static int spr_test_list_size =
  104. sizeof (spr_test_list) / sizeof (spr_test_list[0]);
  105. int spr_post_test (int flags)
  106. {
  107. int ret = 0;
  108. int ic = icache_status ();
  109. int i;
  110. unsigned long code[] = {
  111. 0x7c6002a6, /* mfspr r3,SPR */
  112. 0x4e800020 /* blr */
  113. };
  114. unsigned long (*get_spr) (void) = (void *) code;
  115. if (ic)
  116. icache_disable ();
  117. for (i = 0; i < spr_test_list_size; i++) {
  118. int num = spr_test_list[i].number;
  119. /* mfspr r3,num */
  120. code[0] = 0x7c6002a6 | ((num & 0x1F) << 16) | ((num & 0x3E0) << 6);
  121. if ((get_spr () & spr_test_list[i].mask) !=
  122. (spr_test_list[i].value & spr_test_list[i].mask)) {
  123. post_log ("The value of %s special register "
  124. "is incorrect: 0x%08X\n",
  125. spr_test_list[i].name, get_spr ());
  126. ret = -1;
  127. }
  128. }
  129. if (ic)
  130. icache_enable ();
  131. return ret;
  132. }
  133. #endif /* CONFIG_POST & CFG_POST_SPR */
  134. #endif /* CONFIG_POST */