cplbinit.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * Blackfin CPLB initialization
  3. *
  4. * Copyright 2004-2007 Analog Devices Inc.
  5. *
  6. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, see the file COPYING, or write
  20. * to the Free Software Foundation, Inc.,
  21. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  22. */
  23. #include <linux/module.h>
  24. #include <asm/blackfin.h>
  25. #include <asm/cacheflush.h>
  26. #include <asm/cplb.h>
  27. #include <asm/cplbinit.h>
  28. #include <asm/mem_map.h>
  29. struct cplb_entry icplb_tbl[NR_CPUS][MAX_CPLBS] PDT_ATTR;
  30. struct cplb_entry dcplb_tbl[NR_CPUS][MAX_CPLBS] PDT_ATTR;
  31. int first_switched_icplb PDT_ATTR;
  32. int first_switched_dcplb PDT_ATTR;
  33. struct cplb_boundary dcplb_bounds[9] PDT_ATTR;
  34. struct cplb_boundary icplb_bounds[7] PDT_ATTR;
  35. int icplb_nr_bounds PDT_ATTR;
  36. int dcplb_nr_bounds PDT_ATTR;
  37. void __init generate_cplb_tables_cpu(unsigned int cpu)
  38. {
  39. int i_d, i_i;
  40. unsigned long addr;
  41. struct cplb_entry *d_tbl = dcplb_tbl[cpu];
  42. struct cplb_entry *i_tbl = icplb_tbl[cpu];
  43. printk(KERN_INFO "NOMPU: setting up cplb tables\n");
  44. i_d = i_i = 0;
  45. #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
  46. /* Set up the zero page. */
  47. d_tbl[i_d].addr = 0;
  48. d_tbl[i_d++].data = SDRAM_OOPS | PAGE_SIZE_1KB;
  49. i_tbl[i_i].addr = 0;
  50. i_tbl[i_i++].data = SDRAM_OOPS | PAGE_SIZE_1KB;
  51. #endif
  52. /* Cover kernel memory with 4M pages. */
  53. addr = 0;
  54. for (; addr < memory_start; addr += 4 * 1024 * 1024) {
  55. d_tbl[i_d].addr = addr;
  56. d_tbl[i_d++].data = SDRAM_DGENERIC | PAGE_SIZE_4MB;
  57. i_tbl[i_i].addr = addr;
  58. i_tbl[i_i++].data = SDRAM_IGENERIC | PAGE_SIZE_4MB;
  59. }
  60. /* Cover L1 memory. One 4M area for code and data each is enough. */
  61. if (cpu == 0) {
  62. if (L1_DATA_A_LENGTH || L1_DATA_B_LENGTH) {
  63. d_tbl[i_d].addr = L1_DATA_A_START;
  64. d_tbl[i_d++].data = L1_DMEMORY | PAGE_SIZE_4MB;
  65. }
  66. i_tbl[i_i].addr = L1_CODE_START;
  67. i_tbl[i_i++].data = L1_IMEMORY | PAGE_SIZE_4MB;
  68. }
  69. #ifdef CONFIG_SMP
  70. else {
  71. if (L1_DATA_A_LENGTH || L1_DATA_B_LENGTH) {
  72. d_tbl[i_d].addr = COREB_L1_DATA_A_START;
  73. d_tbl[i_d++].data = L1_DMEMORY | PAGE_SIZE_4MB;
  74. }
  75. i_tbl[i_i].addr = COREB_L1_CODE_START;
  76. i_tbl[i_i++].data = L1_IMEMORY | PAGE_SIZE_4MB;
  77. }
  78. #endif
  79. first_switched_dcplb = i_d;
  80. first_switched_icplb = i_i;
  81. BUG_ON(first_switched_dcplb > MAX_CPLBS);
  82. BUG_ON(first_switched_icplb > MAX_CPLBS);
  83. while (i_d < MAX_CPLBS)
  84. d_tbl[i_d++].data = 0;
  85. while (i_i < MAX_CPLBS)
  86. i_tbl[i_i++].data = 0;
  87. }
  88. void __init generate_cplb_tables_all(void)
  89. {
  90. int i_d, i_i;
  91. i_d = 0;
  92. /* Normal RAM, including MTD FS. */
  93. #ifdef CONFIG_MTD_UCLINUX
  94. dcplb_bounds[i_d].eaddr = memory_mtd_start + mtd_size;
  95. #else
  96. dcplb_bounds[i_d].eaddr = memory_end;
  97. #endif
  98. dcplb_bounds[i_d++].data = SDRAM_DGENERIC;
  99. /* DMA uncached region. */
  100. if (DMA_UNCACHED_REGION) {
  101. dcplb_bounds[i_d].eaddr = _ramend;
  102. dcplb_bounds[i_d++].data = SDRAM_DNON_CHBL;
  103. }
  104. if (_ramend != physical_mem_end) {
  105. /* Reserved memory. */
  106. dcplb_bounds[i_d].eaddr = physical_mem_end;
  107. dcplb_bounds[i_d++].data = (reserved_mem_dcache_on ?
  108. SDRAM_DGENERIC : SDRAM_DNON_CHBL);
  109. }
  110. /* Addressing hole up to the async bank. */
  111. dcplb_bounds[i_d].eaddr = ASYNC_BANK0_BASE;
  112. dcplb_bounds[i_d++].data = 0;
  113. /* ASYNC banks. */
  114. dcplb_bounds[i_d].eaddr = ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE;
  115. dcplb_bounds[i_d++].data = SDRAM_EBIU;
  116. /* Addressing hole up to BootROM. */
  117. dcplb_bounds[i_d].eaddr = BOOT_ROM_START;
  118. dcplb_bounds[i_d++].data = 0;
  119. /* BootROM -- largest one should be less than 1 meg. */
  120. dcplb_bounds[i_d].eaddr = BOOT_ROM_START + (1 * 1024 * 1024);
  121. dcplb_bounds[i_d++].data = SDRAM_DGENERIC;
  122. if (L2_LENGTH) {
  123. /* Addressing hole up to L2 SRAM. */
  124. dcplb_bounds[i_d].eaddr = L2_START;
  125. dcplb_bounds[i_d++].data = 0;
  126. /* L2 SRAM. */
  127. dcplb_bounds[i_d].eaddr = L2_START + L2_LENGTH;
  128. dcplb_bounds[i_d++].data = L2_DMEMORY;
  129. }
  130. dcplb_nr_bounds = i_d;
  131. BUG_ON(dcplb_nr_bounds > ARRAY_SIZE(dcplb_bounds));
  132. i_i = 0;
  133. /* Normal RAM, including MTD FS. */
  134. #ifdef CONFIG_MTD_UCLINUX
  135. icplb_bounds[i_i].eaddr = memory_mtd_start + mtd_size;
  136. #else
  137. icplb_bounds[i_i].eaddr = memory_end;
  138. #endif
  139. icplb_bounds[i_i++].data = SDRAM_IGENERIC;
  140. /* DMA uncached region. */
  141. if (DMA_UNCACHED_REGION) {
  142. icplb_bounds[i_i].eaddr = _ramend;
  143. icplb_bounds[i_i++].data = 0;
  144. }
  145. if (_ramend != physical_mem_end) {
  146. /* Reserved memory. */
  147. icplb_bounds[i_i].eaddr = physical_mem_end;
  148. icplb_bounds[i_i++].data = (reserved_mem_icache_on ?
  149. SDRAM_IGENERIC : SDRAM_INON_CHBL);
  150. }
  151. /* Addressing hole up to BootROM. */
  152. icplb_bounds[i_i].eaddr = BOOT_ROM_START;
  153. icplb_bounds[i_i++].data = 0;
  154. /* BootROM -- largest one should be less than 1 meg. */
  155. icplb_bounds[i_i].eaddr = BOOT_ROM_START + (1 * 1024 * 1024);
  156. icplb_bounds[i_i++].data = SDRAM_IGENERIC;
  157. if (L2_LENGTH) {
  158. /* Addressing hole up to L2 SRAM, including the async bank. */
  159. icplb_bounds[i_i].eaddr = L2_START;
  160. icplb_bounds[i_i++].data = 0;
  161. /* L2 SRAM. */
  162. icplb_bounds[i_i].eaddr = L2_START + L2_LENGTH;
  163. icplb_bounds[i_i++].data = L2_IMEMORY;
  164. }
  165. icplb_nr_bounds = i_i;
  166. BUG_ON(icplb_nr_bounds > ARRAY_SIZE(icplb_bounds));
  167. }