cplb.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Copyright 2004-2009 Analog Devices Inc.
  3. *
  4. * Licensed under the GPL-2 or later.
  5. */
  6. #ifndef _CPLB_H
  7. #define _CPLB_H
  8. #include <mach/anomaly.h>
  9. #define SDRAM_IGENERIC (CPLB_L1_CHBL | CPLB_USER_RD | CPLB_VALID | CPLB_PORTPRIO)
  10. #define SDRAM_IKERNEL (SDRAM_IGENERIC | CPLB_LOCK)
  11. #define L1_IMEMORY ( CPLB_USER_RD | CPLB_VALID | CPLB_LOCK)
  12. #define SDRAM_INON_CHBL ( CPLB_USER_RD | CPLB_VALID)
  13. #if ANOMALY_05000158
  14. #define ANOMALY_05000158_WORKAROUND 0x200
  15. #else
  16. #define ANOMALY_05000158_WORKAROUND 0x0
  17. #endif
  18. #define CPLB_COMMON (CPLB_DIRTY | CPLB_SUPV_WR | CPLB_USER_WR | CPLB_USER_RD | CPLB_VALID | ANOMALY_05000158_WORKAROUND)
  19. #ifdef CONFIG_BFIN_EXTMEM_WRITEBACK
  20. #define SDRAM_DGENERIC (CPLB_L1_CHBL | CPLB_COMMON)
  21. #elif defined(CONFIG_BFIN_EXTMEM_WRITETHROUGH)
  22. #define SDRAM_DGENERIC (CPLB_L1_CHBL | CPLB_WT | CPLB_L1_AOW | CPLB_COMMON)
  23. #else
  24. #define SDRAM_DGENERIC (CPLB_COMMON)
  25. #endif
  26. #define SDRAM_DNON_CHBL (CPLB_COMMON)
  27. #define SDRAM_EBIU (CPLB_COMMON)
  28. #define SDRAM_OOPS (CPLB_VALID | ANOMALY_05000158_WORKAROUND | CPLB_LOCK | CPLB_DIRTY)
  29. #define L1_DMEMORY (CPLB_LOCK | CPLB_COMMON)
  30. #ifdef CONFIG_SMP
  31. #define L2_ATTR (INITIAL_T | I_CPLB | D_CPLB)
  32. #define L2_IMEMORY (CPLB_COMMON | PAGE_SIZE_1MB)
  33. #define L2_DMEMORY (CPLB_LOCK | CPLB_COMMON | PAGE_SIZE_1MB)
  34. #else
  35. #define L2_ATTR (INITIAL_T | SWITCH_T | I_CPLB | D_CPLB)
  36. # if defined(CONFIG_BFIN_L2_ICACHEABLE)
  37. # define L2_IMEMORY (CPLB_L1_CHBL | CPLB_USER_RD | CPLB_VALID | PAGE_SIZE_1MB)
  38. # else
  39. # define L2_IMEMORY ( CPLB_USER_RD | CPLB_VALID | PAGE_SIZE_1MB)
  40. # endif
  41. # if defined(CONFIG_BFIN_L2_WRITEBACK)
  42. # define L2_DMEMORY (CPLB_L1_CHBL | CPLB_COMMON | PAGE_SIZE_1MB)
  43. # elif defined(CONFIG_BFIN_L2_WRITETHROUGH)
  44. # define L2_DMEMORY (CPLB_L1_CHBL | CPLB_WT | CPLB_L1_AOW | CPLB_COMMON | PAGE_SIZE_1MB)
  45. # else
  46. # define L2_DMEMORY (CPLB_COMMON | PAGE_SIZE_1MB)
  47. # endif
  48. #endif /* CONFIG_SMP */
  49. #define SIZE_1K 0x00000400 /* 1K */
  50. #define SIZE_4K 0x00001000 /* 4K */
  51. #define SIZE_1M 0x00100000 /* 1M */
  52. #define SIZE_4M 0x00400000 /* 4M */
  53. #define SIZE_16K 0x00004000 /* 16K */
  54. #define SIZE_64K 0x00010000 /* 64K */
  55. #define SIZE_16M 0x01000000 /* 16M */
  56. #define SIZE_64M 0x04000000 /* 64M */
  57. #define MAX_CPLBS 16
  58. #define CPLB_ENABLE_ICACHE_P 0
  59. #define CPLB_ENABLE_DCACHE_P 1
  60. #define CPLB_ENABLE_DCACHE2_P 2
  61. #define CPLB_ENABLE_CPLBS_P 3 /* Deprecated! */
  62. #define CPLB_ENABLE_ICPLBS_P 4
  63. #define CPLB_ENABLE_DCPLBS_P 5
  64. #define CPLB_ENABLE_ICACHE (1<<CPLB_ENABLE_ICACHE_P)
  65. #define CPLB_ENABLE_DCACHE (1<<CPLB_ENABLE_DCACHE_P)
  66. #define CPLB_ENABLE_DCACHE2 (1<<CPLB_ENABLE_DCACHE2_P)
  67. #define CPLB_ENABLE_CPLBS (1<<CPLB_ENABLE_CPLBS_P)
  68. #define CPLB_ENABLE_ICPLBS (1<<CPLB_ENABLE_ICPLBS_P)
  69. #define CPLB_ENABLE_DCPLBS (1<<CPLB_ENABLE_DCPLBS_P)
  70. #define CPLB_ENABLE_ANY_CPLBS CPLB_ENABLE_CPLBS | \
  71. CPLB_ENABLE_ICPLBS | \
  72. CPLB_ENABLE_DCPLBS
  73. #define CPLB_RELOADED 0x0000
  74. #define CPLB_NO_UNLOCKED 0x0001
  75. #define CPLB_NO_ADDR_MATCH 0x0002
  76. #define CPLB_PROT_VIOL 0x0003
  77. #define CPLB_UNKNOWN_ERR 0x0004
  78. #define CPLB_DEF_CACHE CPLB_L1_CHBL | CPLB_WT
  79. #define CPLB_CACHE_ENABLED CPLB_L1_CHBL | CPLB_DIRTY
  80. #define CPLB_I_PAGE_MGMT CPLB_LOCK | CPLB_VALID
  81. #define CPLB_D_PAGE_MGMT CPLB_LOCK | CPLB_ALL_ACCESS | CPLB_VALID
  82. #define CPLB_DNOCACHE CPLB_ALL_ACCESS | CPLB_VALID
  83. #define CPLB_DDOCACHE CPLB_DNOCACHE | CPLB_DEF_CACHE
  84. #define CPLB_INOCACHE CPLB_USER_RD | CPLB_VALID
  85. #define CPLB_IDOCACHE CPLB_INOCACHE | CPLB_L1_CHBL
  86. #define FAULT_RW (1 << 16)
  87. #define FAULT_USERSUPV (1 << 17)
  88. #define FAULT_CPLBBITS 0x0000ffff
  89. #ifndef __ASSEMBLY__
  90. static inline void _disable_cplb(u32 mmr, u32 mask)
  91. {
  92. u32 ctrl = bfin_read32(mmr) & ~mask;
  93. /* CSYNC to ensure load store ordering */
  94. __builtin_bfin_csync();
  95. bfin_write32(mmr, ctrl);
  96. __builtin_bfin_ssync();
  97. }
  98. static inline void disable_cplb(u32 mmr, u32 mask)
  99. {
  100. u32 ctrl = bfin_read32(mmr) & ~mask;
  101. CSYNC();
  102. bfin_write32(mmr, ctrl);
  103. SSYNC();
  104. }
  105. #define _disable_dcplb() _disable_cplb(DMEM_CONTROL, ENDCPLB)
  106. #define disable_dcplb() disable_cplb(DMEM_CONTROL, ENDCPLB)
  107. #define _disable_icplb() _disable_cplb(IMEM_CONTROL, ENICPLB)
  108. #define disable_icplb() disable_cplb(IMEM_CONTROL, ENICPLB)
  109. static inline void _enable_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 enable_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 _enable_dcplb() _enable_cplb(DMEM_CONTROL, ENDCPLB)
  125. #define enable_dcplb() enable_cplb(DMEM_CONTROL, ENDCPLB)
  126. #define _enable_icplb() _enable_cplb(IMEM_CONTROL, ENICPLB)
  127. #define enable_icplb() enable_cplb(IMEM_CONTROL, ENICPLB)
  128. #endif /* __ASSEMBLY__ */
  129. #endif /* _CPLB_H */