probe.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. /*
  2. * arch/sh/kernel/cpu/sh4/probe.c
  3. *
  4. * CPU Subtype Probing for SH-4.
  5. *
  6. * Copyright (C) 2001 - 2007 Paul Mundt
  7. * Copyright (C) 2003 Richard Curnow
  8. *
  9. * This file is subject to the terms and conditions of the GNU General Public
  10. * License. See the file "COPYING" in the main directory of this archive
  11. * for more details.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/io.h>
  15. #include <asm/processor.h>
  16. #include <asm/cache.h>
  17. void cpu_probe(void)
  18. {
  19. unsigned long pvr, prr, cvr;
  20. unsigned long size;
  21. static unsigned long sizes[16] = {
  22. [1] = (1 << 12),
  23. [2] = (1 << 13),
  24. [4] = (1 << 14),
  25. [8] = (1 << 15),
  26. [9] = (1 << 16)
  27. };
  28. pvr = (__raw_readl(CCN_PVR) >> 8) & 0xffffff;
  29. prr = (__raw_readl(CCN_PRR) >> 4) & 0xff;
  30. cvr = (__raw_readl(CCN_CVR));
  31. /*
  32. * Setup some sane SH-4 defaults for the icache
  33. */
  34. boot_cpu_data.icache.way_incr = (1 << 13);
  35. boot_cpu_data.icache.entry_shift = 5;
  36. boot_cpu_data.icache.sets = 256;
  37. boot_cpu_data.icache.ways = 1;
  38. boot_cpu_data.icache.linesz = L1_CACHE_BYTES;
  39. /*
  40. * And again for the dcache ..
  41. */
  42. boot_cpu_data.dcache.way_incr = (1 << 14);
  43. boot_cpu_data.dcache.entry_shift = 5;
  44. boot_cpu_data.dcache.sets = 512;
  45. boot_cpu_data.dcache.ways = 1;
  46. boot_cpu_data.dcache.linesz = L1_CACHE_BYTES;
  47. /* We don't know the chip cut */
  48. boot_cpu_data.cut_major = boot_cpu_data.cut_minor = -1;
  49. /*
  50. * Setup some generic flags we can probe on SH-4A parts
  51. */
  52. if (((pvr >> 16) & 0xff) == 0x10) {
  53. boot_cpu_data.family = CPU_FAMILY_SH4A;
  54. if ((cvr & 0x10000000) == 0) {
  55. boot_cpu_data.flags |= CPU_HAS_DSP;
  56. boot_cpu_data.family = CPU_FAMILY_SH4AL_DSP;
  57. }
  58. boot_cpu_data.flags |= CPU_HAS_LLSC | CPU_HAS_PERF_COUNTER;
  59. boot_cpu_data.cut_major = pvr & 0x7f;
  60. boot_cpu_data.icache.ways = 4;
  61. boot_cpu_data.dcache.ways = 4;
  62. } else {
  63. /* And some SH-4 defaults.. */
  64. boot_cpu_data.flags |= CPU_HAS_PTEA | CPU_HAS_FPU;
  65. boot_cpu_data.family = CPU_FAMILY_SH4;
  66. }
  67. /* FPU detection works for almost everyone */
  68. if ((cvr & 0x20000000))
  69. boot_cpu_data.flags |= CPU_HAS_FPU;
  70. /* Mask off the upper chip ID */
  71. pvr &= 0xffff;
  72. /*
  73. * Probe the underlying processor version/revision and
  74. * adjust cpu_data setup accordingly.
  75. */
  76. switch (pvr) {
  77. case 0x205:
  78. boot_cpu_data.type = CPU_SH7750;
  79. boot_cpu_data.flags |= CPU_HAS_P2_FLUSH_BUG |
  80. CPU_HAS_PERF_COUNTER;
  81. break;
  82. case 0x206:
  83. boot_cpu_data.type = CPU_SH7750S;
  84. boot_cpu_data.flags |= CPU_HAS_P2_FLUSH_BUG |
  85. CPU_HAS_PERF_COUNTER;
  86. break;
  87. case 0x1100:
  88. boot_cpu_data.type = CPU_SH7751;
  89. break;
  90. case 0x2001:
  91. case 0x2004:
  92. boot_cpu_data.type = CPU_SH7770;
  93. break;
  94. case 0x2006:
  95. case 0x200A:
  96. if (prr == 0x61)
  97. boot_cpu_data.type = CPU_SH7781;
  98. else if (prr == 0xa1)
  99. boot_cpu_data.type = CPU_SH7763;
  100. else
  101. boot_cpu_data.type = CPU_SH7780;
  102. break;
  103. case 0x3000:
  104. case 0x3003:
  105. case 0x3009:
  106. boot_cpu_data.type = CPU_SH7343;
  107. break;
  108. case 0x3004:
  109. case 0x3007:
  110. boot_cpu_data.type = CPU_SH7785;
  111. break;
  112. case 0x4004:
  113. case 0x4005:
  114. boot_cpu_data.type = CPU_SH7786;
  115. boot_cpu_data.flags |= CPU_HAS_PTEAEX | CPU_HAS_L2_CACHE;
  116. break;
  117. case 0x3008:
  118. switch (prr) {
  119. case 0x50:
  120. case 0x51:
  121. boot_cpu_data.type = CPU_SH7723;
  122. boot_cpu_data.flags |= CPU_HAS_L2_CACHE;
  123. break;
  124. case 0x70:
  125. boot_cpu_data.type = CPU_SH7366;
  126. break;
  127. case 0xa0:
  128. case 0xa1:
  129. boot_cpu_data.type = CPU_SH7722;
  130. break;
  131. }
  132. break;
  133. case 0x300b:
  134. switch (prr) {
  135. case 0x20:
  136. boot_cpu_data.type = CPU_SH7724;
  137. boot_cpu_data.flags |= CPU_HAS_L2_CACHE;
  138. break;
  139. case 0x10:
  140. case 0x11:
  141. boot_cpu_data.type = CPU_SH7757;
  142. break;
  143. case 0xd0:
  144. case 0x40: /* yon-ten-go */
  145. boot_cpu_data.type = CPU_SH7372;
  146. break;
  147. case 0xE0: /* 0x4E0 */
  148. boot_cpu_data.type = CPU_SH7734; /* SH7733/SH7734 */
  149. break;
  150. }
  151. break;
  152. case 0x4000: /* 1st cut */
  153. case 0x4001: /* 2nd cut */
  154. boot_cpu_data.type = CPU_SHX3;
  155. break;
  156. case 0x700:
  157. boot_cpu_data.type = CPU_SH4_501;
  158. boot_cpu_data.flags &= ~CPU_HAS_FPU;
  159. boot_cpu_data.icache.ways = 2;
  160. boot_cpu_data.dcache.ways = 2;
  161. break;
  162. case 0x600:
  163. boot_cpu_data.type = CPU_SH4_202;
  164. boot_cpu_data.icache.ways = 2;
  165. boot_cpu_data.dcache.ways = 2;
  166. break;
  167. case 0x500 ... 0x501:
  168. switch (prr) {
  169. case 0x10:
  170. boot_cpu_data.type = CPU_SH7750R;
  171. break;
  172. case 0x11:
  173. boot_cpu_data.type = CPU_SH7751R;
  174. break;
  175. case 0x50 ... 0x5f:
  176. boot_cpu_data.type = CPU_SH7760;
  177. break;
  178. }
  179. boot_cpu_data.icache.ways = 2;
  180. boot_cpu_data.dcache.ways = 2;
  181. break;
  182. }
  183. /*
  184. * On anything that's not a direct-mapped cache, look to the CVR
  185. * for I/D-cache specifics.
  186. */
  187. if (boot_cpu_data.icache.ways > 1) {
  188. size = sizes[(cvr >> 20) & 0xf];
  189. boot_cpu_data.icache.way_incr = (size >> 1);
  190. boot_cpu_data.icache.sets = (size >> 6);
  191. }
  192. /* And the rest of the D-cache */
  193. if (boot_cpu_data.dcache.ways > 1) {
  194. size = sizes[(cvr >> 16) & 0xf];
  195. boot_cpu_data.dcache.way_incr = (size >> 1);
  196. boot_cpu_data.dcache.sets = (size >> 6);
  197. }
  198. /*
  199. * SH-4A's have an optional PIPT L2.
  200. */
  201. if (boot_cpu_data.flags & CPU_HAS_L2_CACHE) {
  202. /*
  203. * Verify that it really has something hooked up, this
  204. * is the safety net for CPUs that have optional L2
  205. * support yet do not implement it.
  206. */
  207. if ((cvr & 0xf) == 0)
  208. boot_cpu_data.flags &= ~CPU_HAS_L2_CACHE;
  209. else {
  210. /*
  211. * Silicon and specifications have clearly never
  212. * met..
  213. */
  214. cvr ^= 0xf;
  215. /*
  216. * Size calculation is much more sensible
  217. * than it is for the L1.
  218. *
  219. * Sizes are 128KB, 256KB, 512KB, and 1MB.
  220. */
  221. size = (cvr & 0xf) << 17;
  222. boot_cpu_data.scache.way_incr = (1 << 16);
  223. boot_cpu_data.scache.entry_shift = 5;
  224. boot_cpu_data.scache.ways = 4;
  225. boot_cpu_data.scache.linesz = L1_CACHE_BYTES;
  226. boot_cpu_data.scache.entry_mask =
  227. (boot_cpu_data.scache.way_incr -
  228. boot_cpu_data.scache.linesz);
  229. boot_cpu_data.scache.sets = size /
  230. (boot_cpu_data.scache.linesz *
  231. boot_cpu_data.scache.ways);
  232. boot_cpu_data.scache.way_size =
  233. (boot_cpu_data.scache.sets *
  234. boot_cpu_data.scache.linesz);
  235. }
  236. }
  237. }