cplbinit.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 (L1_DATA_A_LENGTH || L1_DATA_B_LENGTH) {
  62. d_tbl[i_d].addr = L1_DATA_A_START;
  63. d_tbl[i_d++].data = L1_DMEMORY | PAGE_SIZE_4MB;
  64. }
  65. i_tbl[i_i].addr = L1_CODE_START;
  66. i_tbl[i_i++].data = L1_IMEMORY | PAGE_SIZE_4MB;
  67. first_switched_dcplb = i_d;
  68. first_switched_icplb = i_i;
  69. BUG_ON(first_switched_dcplb > MAX_CPLBS);
  70. BUG_ON(first_switched_icplb > MAX_CPLBS);
  71. while (i_d < MAX_CPLBS)
  72. d_tbl[i_d++].data = 0;
  73. while (i_i < MAX_CPLBS)
  74. i_tbl[i_i++].data = 0;
  75. }
  76. void __init generate_cplb_tables_all(void)
  77. {
  78. int i_d, i_i;
  79. i_d = 0;
  80. /* Normal RAM, including MTD FS. */
  81. #ifdef CONFIG_MTD_UCLINUX
  82. dcplb_bounds[i_d].eaddr = memory_mtd_start + mtd_size;
  83. #else
  84. dcplb_bounds[i_d].eaddr = memory_end;
  85. #endif
  86. dcplb_bounds[i_d++].data = SDRAM_DGENERIC;
  87. /* DMA uncached region. */
  88. if (DMA_UNCACHED_REGION) {
  89. dcplb_bounds[i_d].eaddr = _ramend;
  90. dcplb_bounds[i_d++].data = SDRAM_DNON_CHBL;
  91. }
  92. if (_ramend != physical_mem_end) {
  93. /* Reserved memory. */
  94. dcplb_bounds[i_d].eaddr = physical_mem_end;
  95. dcplb_bounds[i_d++].data = (reserved_mem_dcache_on ?
  96. SDRAM_DGENERIC : SDRAM_DNON_CHBL);
  97. }
  98. /* Addressing hole up to the async bank. */
  99. dcplb_bounds[i_d].eaddr = ASYNC_BANK0_BASE;
  100. dcplb_bounds[i_d++].data = 0;
  101. /* ASYNC banks. */
  102. dcplb_bounds[i_d].eaddr = ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE;
  103. dcplb_bounds[i_d++].data = SDRAM_EBIU;
  104. /* Addressing hole up to BootROM. */
  105. dcplb_bounds[i_d].eaddr = BOOT_ROM_START;
  106. dcplb_bounds[i_d++].data = 0;
  107. /* BootROM -- largest one should be less than 1 meg. */
  108. dcplb_bounds[i_d].eaddr = BOOT_ROM_START + (1 * 1024 * 1024);
  109. dcplb_bounds[i_d++].data = SDRAM_DGENERIC;
  110. if (L2_LENGTH) {
  111. /* Addressing hole up to L2 SRAM. */
  112. dcplb_bounds[i_d].eaddr = L2_START;
  113. dcplb_bounds[i_d++].data = 0;
  114. /* L2 SRAM. */
  115. dcplb_bounds[i_d].eaddr = L2_START + L2_LENGTH;
  116. dcplb_bounds[i_d++].data = L2_DMEMORY;
  117. }
  118. dcplb_nr_bounds = i_d;
  119. BUG_ON(dcplb_nr_bounds > ARRAY_SIZE(dcplb_bounds));
  120. i_i = 0;
  121. /* Normal RAM, including MTD FS. */
  122. #ifdef CONFIG_MTD_UCLINUX
  123. icplb_bounds[i_i].eaddr = memory_mtd_start + mtd_size;
  124. #else
  125. icplb_bounds[i_i].eaddr = memory_end;
  126. #endif
  127. icplb_bounds[i_i++].data = SDRAM_IGENERIC;
  128. /* DMA uncached region. */
  129. if (DMA_UNCACHED_REGION) {
  130. icplb_bounds[i_i].eaddr = _ramend;
  131. icplb_bounds[i_i++].data = 0;
  132. }
  133. if (_ramend != physical_mem_end) {
  134. /* Reserved memory. */
  135. icplb_bounds[i_i].eaddr = physical_mem_end;
  136. icplb_bounds[i_i++].data = (reserved_mem_icache_on ?
  137. SDRAM_IGENERIC : SDRAM_INON_CHBL);
  138. }
  139. /* Addressing hole up to BootROM. */
  140. icplb_bounds[i_i].eaddr = BOOT_ROM_START;
  141. icplb_bounds[i_i++].data = 0;
  142. /* BootROM -- largest one should be less than 1 meg. */
  143. icplb_bounds[i_i].eaddr = BOOT_ROM_START + (1 * 1024 * 1024);
  144. icplb_bounds[i_i++].data = SDRAM_IGENERIC;
  145. if (L2_LENGTH) {
  146. /* Addressing hole up to L2 SRAM, including the async bank. */
  147. icplb_bounds[i_i].eaddr = L2_START;
  148. icplb_bounds[i_i++].data = 0;
  149. /* L2 SRAM. */
  150. icplb_bounds[i_i].eaddr = L2_START + L2_LENGTH;
  151. icplb_bounds[i_i++].data = L2_IMEMORY;
  152. }
  153. icplb_nr_bounds = i_i;
  154. BUG_ON(icplb_nr_bounds > ARRAY_SIZE(icplb_bounds));
  155. }