cplb.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 MAX_CPLBS 16
  54. #define CPLB_ENABLE_ICACHE_P 0
  55. #define CPLB_ENABLE_DCACHE_P 1
  56. #define CPLB_ENABLE_DCACHE2_P 2
  57. #define CPLB_ENABLE_CPLBS_P 3 /* Deprecated! */
  58. #define CPLB_ENABLE_ICPLBS_P 4
  59. #define CPLB_ENABLE_DCPLBS_P 5
  60. #define CPLB_ENABLE_ICACHE (1<<CPLB_ENABLE_ICACHE_P)
  61. #define CPLB_ENABLE_DCACHE (1<<CPLB_ENABLE_DCACHE_P)
  62. #define CPLB_ENABLE_DCACHE2 (1<<CPLB_ENABLE_DCACHE2_P)
  63. #define CPLB_ENABLE_CPLBS (1<<CPLB_ENABLE_CPLBS_P)
  64. #define CPLB_ENABLE_ICPLBS (1<<CPLB_ENABLE_ICPLBS_P)
  65. #define CPLB_ENABLE_DCPLBS (1<<CPLB_ENABLE_DCPLBS_P)
  66. #define CPLB_ENABLE_ANY_CPLBS CPLB_ENABLE_CPLBS | \
  67. CPLB_ENABLE_ICPLBS | \
  68. CPLB_ENABLE_DCPLBS
  69. #define CPLB_RELOADED 0x0000
  70. #define CPLB_NO_UNLOCKED 0x0001
  71. #define CPLB_NO_ADDR_MATCH 0x0002
  72. #define CPLB_PROT_VIOL 0x0003
  73. #define CPLB_UNKNOWN_ERR 0x0004
  74. #define CPLB_DEF_CACHE CPLB_L1_CHBL | CPLB_WT
  75. #define CPLB_CACHE_ENABLED CPLB_L1_CHBL | CPLB_DIRTY
  76. #define CPLB_I_PAGE_MGMT CPLB_LOCK | CPLB_VALID
  77. #define CPLB_D_PAGE_MGMT CPLB_LOCK | CPLB_ALL_ACCESS | CPLB_VALID
  78. #define CPLB_DNOCACHE CPLB_ALL_ACCESS | CPLB_VALID
  79. #define CPLB_DDOCACHE CPLB_DNOCACHE | CPLB_DEF_CACHE
  80. #define CPLB_INOCACHE CPLB_USER_RD | CPLB_VALID
  81. #define CPLB_IDOCACHE CPLB_INOCACHE | CPLB_L1_CHBL
  82. #define FAULT_RW (1 << 16)
  83. #define FAULT_USERSUPV (1 << 17)
  84. #define FAULT_CPLBBITS 0x0000ffff
  85. #ifndef __ASSEMBLY__
  86. static inline void _disable_cplb(u32 mmr, u32 mask)
  87. {
  88. u32 ctrl = bfin_read32(mmr) & ~mask;
  89. /* CSYNC to ensure load store ordering */
  90. __builtin_bfin_csync();
  91. bfin_write32(mmr, ctrl);
  92. __builtin_bfin_ssync();
  93. }
  94. static inline void disable_cplb(u32 mmr, u32 mask)
  95. {
  96. u32 ctrl = bfin_read32(mmr) & ~mask;
  97. CSYNC();
  98. bfin_write32(mmr, ctrl);
  99. SSYNC();
  100. }
  101. #define _disable_dcplb() _disable_cplb(DMEM_CONTROL, ENDCPLB)
  102. #define disable_dcplb() disable_cplb(DMEM_CONTROL, ENDCPLB)
  103. #define _disable_icplb() _disable_cplb(IMEM_CONTROL, ENICPLB)
  104. #define disable_icplb() disable_cplb(IMEM_CONTROL, ENICPLB)
  105. static inline void _enable_cplb(u32 mmr, u32 mask)
  106. {
  107. u32 ctrl = bfin_read32(mmr) | mask;
  108. /* CSYNC to ensure load store ordering */
  109. __builtin_bfin_csync();
  110. bfin_write32(mmr, ctrl);
  111. __builtin_bfin_ssync();
  112. }
  113. static inline void enable_cplb(u32 mmr, u32 mask)
  114. {
  115. u32 ctrl = bfin_read32(mmr) | mask;
  116. CSYNC();
  117. bfin_write32(mmr, ctrl);
  118. SSYNC();
  119. }
  120. #define _enable_dcplb() _enable_cplb(DMEM_CONTROL, ENDCPLB)
  121. #define enable_dcplb() enable_cplb(DMEM_CONTROL, ENDCPLB)
  122. #define _enable_icplb() _enable_cplb(IMEM_CONTROL, ENICPLB)
  123. #define enable_icplb() enable_cplb(IMEM_CONTROL, ENICPLB)
  124. #endif /* __ASSEMBLY__ */
  125. #endif /* _CPLB_H */