cplb.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * File: include/asm-blackfin/cplb.h
  3. * Based on: include/asm-blackfin/mach-bf537/bf537.h
  4. * Author: Robin Getz <rgetz@blackfin.uclinux.org>
  5. *
  6. * Created: 2000
  7. * Description: Common CPLB definitions for CPLB init
  8. *
  9. * Modified:
  10. * Copyright 2004-2007 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. #ifndef _CPLB_H
  30. #define _CPLB_H
  31. #include <mach/anomaly.h>
  32. #define SDRAM_IGENERIC (CPLB_L1_CHBL | CPLB_USER_RD | CPLB_VALID | CPLB_PORTPRIO)
  33. #define SDRAM_IKERNEL (SDRAM_IGENERIC | CPLB_LOCK)
  34. #define L1_IMEMORY ( CPLB_USER_RD | CPLB_VALID | CPLB_LOCK)
  35. #define SDRAM_INON_CHBL ( CPLB_USER_RD | CPLB_VALID)
  36. #if ANOMALY_05000158
  37. #define ANOMALY_05000158_WORKAROUND 0x200
  38. #else
  39. #define ANOMALY_05000158_WORKAROUND 0x0
  40. #endif
  41. #define CPLB_COMMON (CPLB_DIRTY | CPLB_SUPV_WR | CPLB_USER_WR | CPLB_USER_RD | CPLB_VALID | ANOMALY_05000158_WORKAROUND)
  42. #ifdef CONFIG_BFIN_EXTMEM_WRITEBACK
  43. #define SDRAM_DGENERIC (CPLB_L1_CHBL | CPLB_COMMON)
  44. #elif defined(CONFIG_BFIN_EXTMEM_WRITETHROUGH)
  45. #define SDRAM_DGENERIC (CPLB_L1_CHBL | CPLB_WT | CPLB_L1_AOW | CPLB_COMMON)
  46. #else
  47. #define SDRAM_DGENERIC (CPLB_COMMON)
  48. #endif
  49. #define SDRAM_DNON_CHBL (CPLB_COMMON)
  50. #define SDRAM_EBIU (CPLB_COMMON)
  51. #define SDRAM_OOPS (CPLB_VALID | ANOMALY_05000158_WORKAROUND | CPLB_LOCK | CPLB_DIRTY)
  52. #define L1_DMEMORY (CPLB_LOCK | CPLB_COMMON)
  53. #ifdef CONFIG_SMP
  54. #define L2_ATTR (INITIAL_T | I_CPLB | D_CPLB)
  55. #define L2_IMEMORY (CPLB_COMMON | PAGE_SIZE_1MB)
  56. #define L2_DMEMORY (CPLB_LOCK | CPLB_COMMON | PAGE_SIZE_1MB)
  57. #else
  58. #define L2_ATTR (INITIAL_T | SWITCH_T | I_CPLB | D_CPLB)
  59. # if defined(CONFIG_BFIN_L2_ICACHEABLE)
  60. # define L2_IMEMORY (CPLB_L1_CHBL | CPLB_USER_RD | CPLB_VALID | PAGE_SIZE_1MB)
  61. # else
  62. # define L2_IMEMORY ( CPLB_USER_RD | CPLB_VALID | PAGE_SIZE_1MB)
  63. # endif
  64. # if defined(CONFIG_BFIN_L2_WRITEBACK)
  65. # define L2_DMEMORY (CPLB_L1_CHBL | CPLB_COMMON | PAGE_SIZE_1MB)
  66. # elif defined(CONFIG_BFIN_L2_WRITETHROUGH)
  67. # define L2_DMEMORY (CPLB_L1_CHBL | CPLB_WT | CPLB_L1_AOW | CPLB_COMMON | PAGE_SIZE_1MB)
  68. # else
  69. # define L2_DMEMORY (CPLB_COMMON | PAGE_SIZE_1MB)
  70. # endif
  71. #endif /* CONFIG_SMP */
  72. #define SIZE_1K 0x00000400 /* 1K */
  73. #define SIZE_4K 0x00001000 /* 4K */
  74. #define SIZE_1M 0x00100000 /* 1M */
  75. #define SIZE_4M 0x00400000 /* 4M */
  76. #define MAX_CPLBS 16
  77. #define CPLB_ENABLE_ICACHE_P 0
  78. #define CPLB_ENABLE_DCACHE_P 1
  79. #define CPLB_ENABLE_DCACHE2_P 2
  80. #define CPLB_ENABLE_CPLBS_P 3 /* Deprecated! */
  81. #define CPLB_ENABLE_ICPLBS_P 4
  82. #define CPLB_ENABLE_DCPLBS_P 5
  83. #define CPLB_ENABLE_ICACHE (1<<CPLB_ENABLE_ICACHE_P)
  84. #define CPLB_ENABLE_DCACHE (1<<CPLB_ENABLE_DCACHE_P)
  85. #define CPLB_ENABLE_DCACHE2 (1<<CPLB_ENABLE_DCACHE2_P)
  86. #define CPLB_ENABLE_CPLBS (1<<CPLB_ENABLE_CPLBS_P)
  87. #define CPLB_ENABLE_ICPLBS (1<<CPLB_ENABLE_ICPLBS_P)
  88. #define CPLB_ENABLE_DCPLBS (1<<CPLB_ENABLE_DCPLBS_P)
  89. #define CPLB_ENABLE_ANY_CPLBS CPLB_ENABLE_CPLBS | \
  90. CPLB_ENABLE_ICPLBS | \
  91. CPLB_ENABLE_DCPLBS
  92. #define CPLB_RELOADED 0x0000
  93. #define CPLB_NO_UNLOCKED 0x0001
  94. #define CPLB_NO_ADDR_MATCH 0x0002
  95. #define CPLB_PROT_VIOL 0x0003
  96. #define CPLB_UNKNOWN_ERR 0x0004
  97. #define CPLB_DEF_CACHE CPLB_L1_CHBL | CPLB_WT
  98. #define CPLB_CACHE_ENABLED CPLB_L1_CHBL | CPLB_DIRTY
  99. #define CPLB_I_PAGE_MGMT CPLB_LOCK | CPLB_VALID
  100. #define CPLB_D_PAGE_MGMT CPLB_LOCK | CPLB_ALL_ACCESS | CPLB_VALID
  101. #define CPLB_DNOCACHE CPLB_ALL_ACCESS | CPLB_VALID
  102. #define CPLB_DDOCACHE CPLB_DNOCACHE | CPLB_DEF_CACHE
  103. #define CPLB_INOCACHE CPLB_USER_RD | CPLB_VALID
  104. #define CPLB_IDOCACHE CPLB_INOCACHE | CPLB_L1_CHBL
  105. #define FAULT_RW (1 << 16)
  106. #define FAULT_USERSUPV (1 << 17)
  107. #define FAULT_CPLBBITS 0x0000ffff
  108. #ifndef __ASSEMBLY__
  109. static inline void _disable_cplb(u32 mmr, u32 mask)
  110. {
  111. u32 ctrl = bfin_read32(mmr) & ~mask;
  112. /* CSYNC to ensure load store ordering */
  113. __builtin_bfin_csync();
  114. bfin_write32(mmr, ctrl);
  115. __builtin_bfin_ssync();
  116. }
  117. static inline void disable_cplb(u32 mmr, u32 mask)
  118. {
  119. u32 ctrl = bfin_read32(mmr) & ~mask;
  120. CSYNC();
  121. bfin_write32(mmr, ctrl);
  122. SSYNC();
  123. }
  124. #define _disable_dcplb() _disable_cplb(DMEM_CONTROL, ENDCPLB)
  125. #define disable_dcplb() disable_cplb(DMEM_CONTROL, ENDCPLB)
  126. #define _disable_icplb() _disable_cplb(IMEM_CONTROL, ENICPLB)
  127. #define disable_icplb() disable_cplb(IMEM_CONTROL, ENICPLB)
  128. static inline void _enable_cplb(u32 mmr, u32 mask)
  129. {
  130. u32 ctrl = bfin_read32(mmr) | mask;
  131. /* CSYNC to ensure load store ordering */
  132. __builtin_bfin_csync();
  133. bfin_write32(mmr, ctrl);
  134. __builtin_bfin_ssync();
  135. }
  136. static inline void enable_cplb(u32 mmr, u32 mask)
  137. {
  138. u32 ctrl = bfin_read32(mmr) | mask;
  139. CSYNC();
  140. bfin_write32(mmr, ctrl);
  141. SSYNC();
  142. }
  143. #define _enable_dcplb() _enable_cplb(DMEM_CONTROL, ENDCPLB)
  144. #define enable_dcplb() enable_cplb(DMEM_CONTROL, ENDCPLB)
  145. #define _enable_icplb() _enable_cplb(IMEM_CONTROL, ENICPLB)
  146. #define enable_icplb() enable_cplb(IMEM_CONTROL, ENICPLB)
  147. #endif /* __ASSEMBLY__ */
  148. #endif /* _CPLB_H */