cache.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. /*
  2. * Cache control for MicroBlaze cache memories
  3. *
  4. * Copyright (C) 2007-2009 Michal Simek <[email protected]>
  5. * Copyright (C) 2007-2009 PetaLogix
  6. * Copyright (C) 2007-2009 John Williams <[email protected]>
  7. *
  8. * This file is subject to the terms and conditions of the GNU General
  9. * Public License. See the file COPYING in the main directory of this
  10. * archive for more details.
  11. */
  12. #include <asm/cacheflush.h>
  13. #include <linux/cache.h>
  14. #include <asm/cpuinfo.h>
  15. #include <asm/pvr.h>
  16. static inline void __enable_icache_msr(void)
  17. {
  18. __asm__ __volatile__ (" msrset r0, %0;" \
  19. "nop;" \
  20. : : "i" (MSR_ICE) : "memory");
  21. }
  22. static inline void __disable_icache_msr(void)
  23. {
  24. __asm__ __volatile__ (" msrclr r0, %0;" \
  25. "nop;" \
  26. : : "i" (MSR_ICE) : "memory");
  27. }
  28. static inline void __enable_dcache_msr(void)
  29. {
  30. __asm__ __volatile__ (" msrset r0, %0;" \
  31. "nop;" \
  32. : : "i" (MSR_DCE) : "memory");
  33. }
  34. static inline void __disable_dcache_msr(void)
  35. {
  36. __asm__ __volatile__ (" msrclr r0, %0;" \
  37. "nop; " \
  38. : : "i" (MSR_DCE) : "memory");
  39. }
  40. static inline void __enable_icache_nomsr(void)
  41. {
  42. __asm__ __volatile__ (" mfs r12, rmsr;" \
  43. "nop;" \
  44. "ori r12, r12, %0;" \
  45. "mts rmsr, r12;" \
  46. "nop;" \
  47. : : "i" (MSR_ICE) : "memory", "r12");
  48. }
  49. static inline void __disable_icache_nomsr(void)
  50. {
  51. __asm__ __volatile__ (" mfs r12, rmsr;" \
  52. "nop;" \
  53. "andi r12, r12, ~%0;" \
  54. "mts rmsr, r12;" \
  55. "nop;" \
  56. : : "i" (MSR_ICE) : "memory", "r12");
  57. }
  58. static inline void __enable_dcache_nomsr(void)
  59. {
  60. __asm__ __volatile__ (" mfs r12, rmsr;" \
  61. "nop;" \
  62. "ori r12, r12, %0;" \
  63. "mts rmsr, r12;" \
  64. "nop;" \
  65. : : "i" (MSR_DCE) : "memory", "r12");
  66. }
  67. static inline void __disable_dcache_nomsr(void)
  68. {
  69. __asm__ __volatile__ (" mfs r12, rmsr;" \
  70. "nop;" \
  71. "andi r12, r12, ~%0;" \
  72. "mts rmsr, r12;" \
  73. "nop;" \
  74. : : "i" (MSR_DCE) : "memory", "r12");
  75. }
  76. /* Helper macro for computing the limits of cache range loops
  77. *
  78. * End address can be unaligned which is OK for C implementation.
  79. * ASM implementation align it in ASM macros
  80. */
  81. #define CACHE_LOOP_LIMITS(start, end, cache_line_length, cache_size) \
  82. do { \
  83. int align = ~(cache_line_length - 1); \
  84. if (start < UINT_MAX - cache_size) \
  85. end = min(start + cache_size, end); \
  86. start &= align; \
  87. } while (0)
  88. /*
  89. * Helper macro to loop over the specified cache_size/line_length and
  90. * execute 'op' on that cacheline
  91. */
  92. #define CACHE_ALL_LOOP(cache_size, line_length, op) \
  93. do { \
  94. unsigned int len = cache_size - line_length; \
  95. int step = -line_length; \
  96. WARN_ON(step >= 0); \
  97. \
  98. __asm__ __volatile__ (" 1: " #op " %0, r0;" \
  99. "bgtid %0, 1b;" \
  100. "addk %0, %0, %1;" \
  101. : : "r" (len), "r" (step) \
  102. : "memory"); \
  103. } while (0)
  104. /* Used for wdc.flush/clear which can use rB for offset which is not possible
  105. * to use for simple wdc or wic.
  106. *
  107. * start address is cache aligned
  108. * end address is not aligned, if end is aligned then I have to subtract
  109. * cacheline length because I can't flush/invalidate the next cacheline.
  110. * If is not, I align it because I will flush/invalidate whole line.
  111. */
  112. #define CACHE_RANGE_LOOP_2(start, end, line_length, op) \
  113. do { \
  114. int step = -line_length; \
  115. int align = ~(line_length - 1); \
  116. int count; \
  117. end = ((end & align) == end) ? end - line_length : end & align; \
  118. count = end - start; \
  119. WARN_ON(count < 0); \
  120. \
  121. __asm__ __volatile__ (" 1: " #op " %0, %1;" \
  122. "bgtid %1, 1b;" \
  123. "addk %1, %1, %2;" \
  124. : : "r" (start), "r" (count), \
  125. "r" (step) : "memory"); \
  126. } while (0)
  127. /* It is used only first parameter for OP - for wic, wdc */
  128. #define CACHE_RANGE_LOOP_1(start, end, line_length, op) \
  129. do { \
  130. unsigned int volatile temp = 0; \
  131. unsigned int align = ~(line_length - 1); \
  132. end = ((end & align) == end) ? end - line_length : end & align; \
  133. WARN_ON(end < start); \
  134. \
  135. __asm__ __volatile__ (" 1: " #op " %1, r0;" \
  136. "cmpu %0, %1, %2;" \
  137. "bgtid %0, 1b;" \
  138. "addk %1, %1, %3;" \
  139. : : "r" (temp), "r" (start), "r" (end), \
  140. "r" (line_length) : "memory"); \
  141. } while (0)
  142. #define ASM_LOOP
  143. static void __flush_icache_range_msr_irq(unsigned long start, unsigned long end)
  144. {
  145. unsigned long flags;
  146. #ifndef ASM_LOOP
  147. int i;
  148. #endif
  149. pr_debug("%s: start 0x%x, end 0x%x\n", __func__,
  150. (unsigned int)start, (unsigned int) end);
  151. CACHE_LOOP_LIMITS(start, end,
  152. cpuinfo.icache_line_length, cpuinfo.icache_size);
  153. local_irq_save(flags);
  154. __disable_icache_msr();
  155. #ifdef ASM_LOOP
  156. CACHE_RANGE_LOOP_1(start, end, cpuinfo.icache_line_length, wic);
  157. #else
  158. for (i = start; i < end; i += cpuinfo.icache_line_length)
  159. __asm__ __volatile__ ("wic %0, r0;" \
  160. : : "r" (i));
  161. #endif
  162. __enable_icache_msr();
  163. local_irq_restore(flags);
  164. }
  165. static void __flush_icache_range_nomsr_irq(unsigned long start,
  166. unsigned long end)
  167. {
  168. unsigned long flags;
  169. #ifndef ASM_LOOP
  170. int i;
  171. #endif
  172. pr_debug("%s: start 0x%x, end 0x%x\n", __func__,
  173. (unsigned int)start, (unsigned int) end);
  174. CACHE_LOOP_LIMITS(start, end,
  175. cpuinfo.icache_line_length, cpuinfo.icache_size);
  176. local_irq_save(flags);
  177. __disable_icache_nomsr();
  178. #ifdef ASM_LOOP
  179. CACHE_RANGE_LOOP_1(start, end, cpuinfo.icache_line_length, wic);
  180. #else
  181. for (i = start; i < end; i += cpuinfo.icache_line_length)
  182. __asm__ __volatile__ ("wic %0, r0;" \
  183. : : "r" (i));
  184. #endif
  185. __enable_icache_nomsr();
  186. local_irq_restore(flags);
  187. }
  188. static void __flush_icache_range_noirq(unsigned long start,
  189. unsigned long end)
  190. {
  191. #ifndef ASM_LOOP
  192. int i;
  193. #endif
  194. pr_debug("%s: start 0x%x, end 0x%x\n", __func__,
  195. (unsigned int)start, (unsigned int) end);
  196. CACHE_LOOP_LIMITS(start, end,
  197. cpuinfo.icache_line_length, cpuinfo.icache_size);
  198. #ifdef ASM_LOOP
  199. CACHE_RANGE_LOOP_1(start, end, cpuinfo.icache_line_length, wic);
  200. #else
  201. for (i = start; i < end; i += cpuinfo.icache_line_length)
  202. __asm__ __volatile__ ("wic %0, r0;" \
  203. : : "r" (i));
  204. #endif
  205. }
  206. static void __flush_icache_all_msr_irq(void)
  207. {
  208. unsigned long flags;
  209. #ifndef ASM_LOOP
  210. int i;
  211. #endif
  212. pr_debug("%s\n", __func__);
  213. local_irq_save(flags);
  214. __disable_icache_msr();
  215. #ifdef ASM_LOOP
  216. CACHE_ALL_LOOP(cpuinfo.icache_size, cpuinfo.icache_line_length, wic);
  217. #else
  218. for (i = 0; i < cpuinfo.icache_size;
  219. i += cpuinfo.icache_line_length)
  220. __asm__ __volatile__ ("wic %0, r0;" \
  221. : : "r" (i));
  222. #endif
  223. __enable_icache_msr();
  224. local_irq_restore(flags);
  225. }
  226. static void __flush_icache_all_nomsr_irq(void)
  227. {
  228. unsigned long flags;
  229. #ifndef ASM_LOOP
  230. int i;
  231. #endif
  232. pr_debug("%s\n", __func__);
  233. local_irq_save(flags);
  234. __disable_icache_nomsr();
  235. #ifdef ASM_LOOP
  236. CACHE_ALL_LOOP(cpuinfo.icache_size, cpuinfo.icache_line_length, wic);
  237. #else
  238. for (i = 0; i < cpuinfo.icache_size;
  239. i += cpuinfo.icache_line_length)
  240. __asm__ __volatile__ ("wic %0, r0;" \
  241. : : "r" (i));
  242. #endif
  243. __enable_icache_nomsr();
  244. local_irq_restore(flags);
  245. }
  246. static void __flush_icache_all_noirq(void)
  247. {
  248. #ifndef ASM_LOOP
  249. int i;
  250. #endif
  251. pr_debug("%s\n", __func__);
  252. #ifdef ASM_LOOP
  253. CACHE_ALL_LOOP(cpuinfo.icache_size, cpuinfo.icache_line_length, wic);
  254. #else
  255. for (i = 0; i < cpuinfo.icache_size;
  256. i += cpuinfo.icache_line_length)
  257. __asm__ __volatile__ ("wic %0, r0;" \
  258. : : "r" (i));
  259. #endif
  260. }
  261. static void __invalidate_dcache_all_msr_irq(void)
  262. {
  263. unsigned long flags;
  264. #ifndef ASM_LOOP
  265. int i;
  266. #endif
  267. pr_debug("%s\n", __func__);
  268. local_irq_save(flags);
  269. __disable_dcache_msr();
  270. #ifdef ASM_LOOP
  271. CACHE_ALL_LOOP(cpuinfo.dcache_size, cpuinfo.dcache_line_length, wdc);
  272. #else
  273. for (i = 0; i < cpuinfo.dcache_size;
  274. i += cpuinfo.dcache_line_length)
  275. __asm__ __volatile__ ("wdc %0, r0;" \
  276. : : "r" (i));
  277. #endif
  278. __enable_dcache_msr();
  279. local_irq_restore(flags);
  280. }
  281. static void __invalidate_dcache_all_nomsr_irq(void)
  282. {
  283. unsigned long flags;
  284. #ifndef ASM_LOOP
  285. int i;
  286. #endif
  287. pr_debug("%s\n", __func__);
  288. local_irq_save(flags);
  289. __disable_dcache_nomsr();
  290. #ifdef ASM_LOOP
  291. CACHE_ALL_LOOP(cpuinfo.dcache_size, cpuinfo.dcache_line_length, wdc);
  292. #else
  293. for (i = 0; i < cpuinfo.dcache_size;
  294. i += cpuinfo.dcache_line_length)
  295. __asm__ __volatile__ ("wdc %0, r0;" \
  296. : : "r" (i));
  297. #endif
  298. __enable_dcache_nomsr();
  299. local_irq_restore(flags);
  300. }
  301. static void __invalidate_dcache_all_noirq_wt(void)
  302. {
  303. #ifndef ASM_LOOP
  304. int i;
  305. #endif
  306. pr_debug("%s\n", __func__);
  307. #ifdef ASM_LOOP
  308. CACHE_ALL_LOOP(cpuinfo.dcache_size, cpuinfo.dcache_line_length, wdc);
  309. #else
  310. for (i = 0; i < cpuinfo.dcache_size;
  311. i += cpuinfo.dcache_line_length)
  312. __asm__ __volatile__ ("wdc %0, r0;" \
  313. : : "r" (i));
  314. #endif
  315. }
  316. /*
  317. * FIXME It is blindly invalidation as is expected
  318. * but can't be called on noMMU in microblaze_cache_init below
  319. *
  320. * MS: noMMU kernel won't boot if simple wdc is used
  321. * The reason should be that there are discared data which kernel needs
  322. */
  323. static void __invalidate_dcache_all_wb(void)
  324. {
  325. #ifndef ASM_LOOP
  326. int i;
  327. #endif
  328. pr_debug("%s\n", __func__);
  329. #ifdef ASM_LOOP
  330. CACHE_ALL_LOOP(cpuinfo.dcache_size, cpuinfo.dcache_line_length,
  331. wdc);
  332. #else
  333. for (i = 0; i < cpuinfo.dcache_size;
  334. i += cpuinfo.dcache_line_length)
  335. __asm__ __volatile__ ("wdc %0, r0;" \
  336. : : "r" (i));
  337. #endif
  338. }
  339. static void __invalidate_dcache_range_wb(unsigned long start,
  340. unsigned long end)
  341. {
  342. #ifndef ASM_LOOP
  343. int i;
  344. #endif
  345. pr_debug("%s: start 0x%x, end 0x%x\n", __func__,
  346. (unsigned int)start, (unsigned int) end);
  347. CACHE_LOOP_LIMITS(start, end,
  348. cpuinfo.dcache_line_length, cpuinfo.dcache_size);
  349. #ifdef ASM_LOOP
  350. CACHE_RANGE_LOOP_2(start, end, cpuinfo.dcache_line_length, wdc.clear);
  351. #else
  352. for (i = start; i < end; i += cpuinfo.dcache_line_length)
  353. __asm__ __volatile__ ("wdc.clear %0, r0;" \
  354. : : "r" (i));
  355. #endif
  356. }
  357. static void __invalidate_dcache_range_nomsr_wt(unsigned long start,
  358. unsigned long end)
  359. {
  360. #ifndef ASM_LOOP
  361. int i;
  362. #endif
  363. pr_debug("%s: start 0x%x, end 0x%x\n", __func__,
  364. (unsigned int)start, (unsigned int) end);
  365. CACHE_LOOP_LIMITS(start, end,
  366. cpuinfo.dcache_line_length, cpuinfo.dcache_size);
  367. #ifdef ASM_LOOP
  368. CACHE_RANGE_LOOP_1(start, end, cpuinfo.dcache_line_length, wdc);
  369. #else
  370. for (i = start; i < end; i += cpuinfo.dcache_line_length)
  371. __asm__ __volatile__ ("wdc %0, r0;" \
  372. : : "r" (i));
  373. #endif
  374. }
  375. static void __invalidate_dcache_range_msr_irq_wt(unsigned long start,
  376. unsigned long end)
  377. {
  378. unsigned long flags;
  379. #ifndef ASM_LOOP
  380. int i;
  381. #endif
  382. pr_debug("%s: start 0x%x, end 0x%x\n", __func__,
  383. (unsigned int)start, (unsigned int) end);
  384. CACHE_LOOP_LIMITS(start, end,
  385. cpuinfo.dcache_line_length, cpuinfo.dcache_size);
  386. local_irq_save(flags);
  387. __disable_dcache_msr();
  388. #ifdef ASM_LOOP
  389. CACHE_RANGE_LOOP_1(start, end, cpuinfo.dcache_line_length, wdc);
  390. #else
  391. for (i = start; i < end; i += cpuinfo.dcache_line_length)
  392. __asm__ __volatile__ ("wdc %0, r0;" \
  393. : : "r" (i));
  394. #endif
  395. __enable_dcache_msr();
  396. local_irq_restore(flags);
  397. }
  398. static void __invalidate_dcache_range_nomsr_irq(unsigned long start,
  399. unsigned long end)
  400. {
  401. unsigned long flags;
  402. #ifndef ASM_LOOP
  403. int i;
  404. #endif
  405. pr_debug("%s: start 0x%x, end 0x%x\n", __func__,
  406. (unsigned int)start, (unsigned int) end);
  407. CACHE_LOOP_LIMITS(start, end,
  408. cpuinfo.dcache_line_length, cpuinfo.dcache_size);
  409. local_irq_save(flags);
  410. __disable_dcache_nomsr();
  411. #ifdef ASM_LOOP
  412. CACHE_RANGE_LOOP_1(start, end, cpuinfo.dcache_line_length, wdc);
  413. #else
  414. for (i = start; i < end; i += cpuinfo.dcache_line_length)
  415. __asm__ __volatile__ ("wdc %0, r0;" \
  416. : : "r" (i));
  417. #endif
  418. __enable_dcache_nomsr();
  419. local_irq_restore(flags);
  420. }
  421. static void __flush_dcache_all_wb(void)
  422. {
  423. #ifndef ASM_LOOP
  424. int i;
  425. #endif
  426. pr_debug("%s\n", __func__);
  427. #ifdef ASM_LOOP
  428. CACHE_ALL_LOOP(cpuinfo.dcache_size, cpuinfo.dcache_line_length,
  429. wdc.flush);
  430. #else
  431. for (i = 0; i < cpuinfo.dcache_size;
  432. i += cpuinfo.dcache_line_length)
  433. __asm__ __volatile__ ("wdc.flush %0, r0;" \
  434. : : "r" (i));
  435. #endif
  436. }
  437. static void __flush_dcache_range_wb(unsigned long start, unsigned long end)
  438. {
  439. #ifndef ASM_LOOP
  440. int i;
  441. #endif
  442. pr_debug("%s: start 0x%x, end 0x%x\n", __func__,
  443. (unsigned int)start, (unsigned int) end);
  444. CACHE_LOOP_LIMITS(start, end,
  445. cpuinfo.dcache_line_length, cpuinfo.dcache_size);
  446. #ifdef ASM_LOOP
  447. CACHE_RANGE_LOOP_2(start, end, cpuinfo.dcache_line_length, wdc.flush);
  448. #else
  449. for (i = start; i < end; i += cpuinfo.dcache_line_length)
  450. __asm__ __volatile__ ("wdc.flush %0, r0;" \
  451. : : "r" (i));
  452. #endif
  453. }
  454. /* struct for wb caches and for wt caches */
  455. struct scache *mbc;
  456. /* new wb cache model */
  457. static const struct scache wb_msr = {
  458. .ie = __enable_icache_msr,
  459. .id = __disable_icache_msr,
  460. .ifl = __flush_icache_all_noirq,
  461. .iflr = __flush_icache_range_noirq,
  462. .iin = __flush_icache_all_noirq,
  463. .iinr = __flush_icache_range_noirq,
  464. .de = __enable_dcache_msr,
  465. .dd = __disable_dcache_msr,
  466. .dfl = __flush_dcache_all_wb,
  467. .dflr = __flush_dcache_range_wb,
  468. .din = __invalidate_dcache_all_wb,
  469. .dinr = __invalidate_dcache_range_wb,
  470. };
  471. /* There is only difference in ie, id, de, dd functions */
  472. static const struct scache wb_nomsr = {
  473. .ie = __enable_icache_nomsr,
  474. .id = __disable_icache_nomsr,
  475. .ifl = __flush_icache_all_noirq,
  476. .iflr = __flush_icache_range_noirq,
  477. .iin = __flush_icache_all_noirq,
  478. .iinr = __flush_icache_range_noirq,
  479. .de = __enable_dcache_nomsr,
  480. .dd = __disable_dcache_nomsr,
  481. .dfl = __flush_dcache_all_wb,
  482. .dflr = __flush_dcache_range_wb,
  483. .din = __invalidate_dcache_all_wb,
  484. .dinr = __invalidate_dcache_range_wb,
  485. };
  486. /* Old wt cache model with disabling irq and turn off cache */
  487. static const struct scache wt_msr = {
  488. .ie = __enable_icache_msr,
  489. .id = __disable_icache_msr,
  490. .ifl = __flush_icache_all_msr_irq,
  491. .iflr = __flush_icache_range_msr_irq,
  492. .iin = __flush_icache_all_msr_irq,
  493. .iinr = __flush_icache_range_msr_irq,
  494. .de = __enable_dcache_msr,
  495. .dd = __disable_dcache_msr,
  496. .dfl = __invalidate_dcache_all_msr_irq,
  497. .dflr = __invalidate_dcache_range_msr_irq_wt,
  498. .din = __invalidate_dcache_all_msr_irq,
  499. .dinr = __invalidate_dcache_range_msr_irq_wt,
  500. };
  501. static const struct scache wt_nomsr = {
  502. .ie = __enable_icache_nomsr,
  503. .id = __disable_icache_nomsr,
  504. .ifl = __flush_icache_all_nomsr_irq,
  505. .iflr = __flush_icache_range_nomsr_irq,
  506. .iin = __flush_icache_all_nomsr_irq,
  507. .iinr = __flush_icache_range_nomsr_irq,
  508. .de = __enable_dcache_nomsr,
  509. .dd = __disable_dcache_nomsr,
  510. .dfl = __invalidate_dcache_all_nomsr_irq,
  511. .dflr = __invalidate_dcache_range_nomsr_irq,
  512. .din = __invalidate_dcache_all_nomsr_irq,
  513. .dinr = __invalidate_dcache_range_nomsr_irq,
  514. };
  515. /* New wt cache model for newer Microblaze versions */
  516. static const struct scache wt_msr_noirq = {
  517. .ie = __enable_icache_msr,
  518. .id = __disable_icache_msr,
  519. .ifl = __flush_icache_all_noirq,
  520. .iflr = __flush_icache_range_noirq,
  521. .iin = __flush_icache_all_noirq,
  522. .iinr = __flush_icache_range_noirq,
  523. .de = __enable_dcache_msr,
  524. .dd = __disable_dcache_msr,
  525. .dfl = __invalidate_dcache_all_noirq_wt,
  526. .dflr = __invalidate_dcache_range_nomsr_wt,
  527. .din = __invalidate_dcache_all_noirq_wt,
  528. .dinr = __invalidate_dcache_range_nomsr_wt,
  529. };
  530. static const struct scache wt_nomsr_noirq = {
  531. .ie = __enable_icache_nomsr,
  532. .id = __disable_icache_nomsr,
  533. .ifl = __flush_icache_all_noirq,
  534. .iflr = __flush_icache_range_noirq,
  535. .iin = __flush_icache_all_noirq,
  536. .iinr = __flush_icache_range_noirq,
  537. .de = __enable_dcache_nomsr,
  538. .dd = __disable_dcache_nomsr,
  539. .dfl = __invalidate_dcache_all_noirq_wt,
  540. .dflr = __invalidate_dcache_range_nomsr_wt,
  541. .din = __invalidate_dcache_all_noirq_wt,
  542. .dinr = __invalidate_dcache_range_nomsr_wt,
  543. };
  544. /* CPU version code for 7.20.c - see arch/microblaze/kernel/cpu/cpuinfo.c */
  545. #define CPUVER_7_20_A 0x0c
  546. #define CPUVER_7_20_D 0x0f
  547. void microblaze_cache_init(void)
  548. {
  549. if (cpuinfo.use_instr & PVR2_USE_MSR_INSTR) {
  550. if (cpuinfo.dcache_wb) {
  551. pr_info("wb_msr\n");
  552. mbc = (struct scache *)&wb_msr;
  553. if (cpuinfo.ver_code <= CPUVER_7_20_D) {
  554. /* MS: problem with signal handling - hw bug */
  555. pr_info("WB won't work properly\n");
  556. }
  557. } else {
  558. if (cpuinfo.ver_code >= CPUVER_7_20_A) {
  559. pr_info("wt_msr_noirq\n");
  560. mbc = (struct scache *)&wt_msr_noirq;
  561. } else {
  562. pr_info("wt_msr\n");
  563. mbc = (struct scache *)&wt_msr;
  564. }
  565. }
  566. } else {
  567. if (cpuinfo.dcache_wb) {
  568. pr_info("wb_nomsr\n");
  569. mbc = (struct scache *)&wb_nomsr;
  570. if (cpuinfo.ver_code <= CPUVER_7_20_D) {
  571. /* MS: problem with signal handling - hw bug */
  572. pr_info("WB won't work properly\n");
  573. }
  574. } else {
  575. if (cpuinfo.ver_code >= CPUVER_7_20_A) {
  576. pr_info("wt_nomsr_noirq\n");
  577. mbc = (struct scache *)&wt_nomsr_noirq;
  578. } else {
  579. pr_info("wt_nomsr\n");
  580. mbc = (struct scache *)&wt_nomsr;
  581. }
  582. }
  583. }
  584. /*
  585. * FIXME Invalidation is done in U-BOOT
  586. * WT cache: Data is already written to main memory
  587. * WB cache: Discard data on noMMU which caused that kernel doesn't boot
  588. */
  589. /* invalidate_dcache(); */
  590. enable_dcache();
  591. invalidate_icache();
  592. enable_icache();
  593. }