cplbinit.c 5.1 KB

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