cache.S 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * File: arch/blackfin/mach-common/cache.S
  3. * Based on:
  4. * Author: LG Soft India
  5. *
  6. * Created:
  7. * Description: cache control support
  8. *
  9. * Modified:
  10. * Copyright 2004-2006 Analog Devices Inc.
  11. *
  12. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, see the file COPYING, or write
  26. * to the Free Software Foundation, Inc.,
  27. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  28. */
  29. #include <linux/linkage.h>
  30. #include <asm/cplb.h>
  31. #include <asm/entry.h>
  32. #include <asm/blackfin.h>
  33. #include <asm/cache.h>
  34. .text
  35. /*
  36. * blackfin_cache_flush_range(start, end)
  37. * Invalidate all cache lines assocoiated with this
  38. * area of memory.
  39. *
  40. * start: Start address
  41. * end: End address
  42. */
  43. ENTRY(_blackfin_icache_flush_range)
  44. R2 = -L1_CACHE_BYTES;
  45. R2 = R0 & R2;
  46. P0 = R2;
  47. P1 = R1;
  48. CSYNC(R3);
  49. IFLUSH [P0];
  50. 1:
  51. IFLUSH [P0++];
  52. CC = P0 < P1 (iu);
  53. IF CC JUMP 1b (bp);
  54. IFLUSH [P0];
  55. SSYNC(R3);
  56. RTS;
  57. ENDPROC(_blackfin_icache_flush_range)
  58. /*
  59. * blackfin_icache_dcache_flush_range(start, end)
  60. * FLUSH all cache lines assocoiated with this
  61. * area of memory.
  62. *
  63. * start: Start address
  64. * end: End address
  65. */
  66. ENTRY(_blackfin_icache_dcache_flush_range)
  67. R2 = -L1_CACHE_BYTES;
  68. R2 = R0 & R2;
  69. P0 = R2;
  70. P1 = R1;
  71. CSYNC(R3);
  72. IFLUSH [P0];
  73. 1:
  74. FLUSH [P0];
  75. IFLUSH [P0++];
  76. CC = P0 < P1 (iu);
  77. IF CC JUMP 1b (bp);
  78. IFLUSH [P0];
  79. FLUSH [P0];
  80. SSYNC(R3);
  81. RTS;
  82. ENDPROC(_blackfin_icache_dcache_flush_range)
  83. /* Throw away all D-cached data in specified region without any obligation to
  84. * write them back. However, we must clean the D-cached entries around the
  85. * boundaries of the start and/or end address is not cache aligned.
  86. *
  87. * Start: start address,
  88. * end : end address.
  89. */
  90. ENTRY(_blackfin_dcache_invalidate_range)
  91. R2 = -L1_CACHE_BYTES;
  92. R2 = R0 & R2;
  93. P0 = R2;
  94. P1 = R1;
  95. CSYNC(R3);
  96. FLUSHINV[P0];
  97. 1:
  98. FLUSHINV[P0++];
  99. CC = P0 < P1 (iu);
  100. IF CC JUMP 1b (bp);
  101. /* If the data crosses a cache line, then we'll be pointing to
  102. * the last cache line, but won't have flushed/invalidated it yet,
  103. * so do one more.
  104. */
  105. FLUSHINV[P0];
  106. SSYNC(R3);
  107. RTS;
  108. ENDPROC(_blackfin_dcache_invalidate_range)
  109. ENTRY(_blackfin_dcache_flush_range)
  110. R2 = -L1_CACHE_BYTES;
  111. R2 = R0 & R2;
  112. P0 = R2;
  113. P1 = R1;
  114. CSYNC(R3);
  115. FLUSH[P0];
  116. 1:
  117. FLUSH[P0++];
  118. CC = P0 < P1 (iu);
  119. IF CC JUMP 1b (bp);
  120. /* If the data crosses a cache line, then we'll be pointing to
  121. * the last cache line, but won't have flushed it yet, so do
  122. * one more.
  123. */
  124. FLUSH[P0];
  125. SSYNC(R3);
  126. RTS;
  127. ENDPROC(_blackfin_dcache_flush_range)
  128. ENTRY(_blackfin_dflush_page)
  129. P1 = 1 << (PAGE_SHIFT - L1_CACHE_SHIFT);
  130. P0 = R0;
  131. CSYNC(R3);
  132. FLUSH[P0];
  133. LSETUP (.Lfl1, .Lfl1) LC0 = P1;
  134. .Lfl1: FLUSH [P0++];
  135. SSYNC(R3);
  136. RTS;
  137. ENDPROC(_blackfin_dflush_page)