cplbinit.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * Blackfin CPLB initialization
  3. *
  4. * Copyright 2007-2009 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #include <linux/module.h>
  9. #include <asm/blackfin.h>
  10. #include <asm/cacheflush.h>
  11. #include <asm/cplb.h>
  12. #include <asm/cplbinit.h>
  13. #include <asm/mem_map.h>
  14. struct cplb_entry icplb_tbl[NR_CPUS][MAX_CPLBS] PDT_ATTR;
  15. struct cplb_entry dcplb_tbl[NR_CPUS][MAX_CPLBS] PDT_ATTR;
  16. int first_switched_icplb PDT_ATTR;
  17. int first_switched_dcplb PDT_ATTR;
  18. struct cplb_boundary dcplb_bounds[9] PDT_ATTR;
  19. struct cplb_boundary icplb_bounds[9] PDT_ATTR;
  20. int icplb_nr_bounds PDT_ATTR;
  21. int dcplb_nr_bounds PDT_ATTR;
  22. void __init generate_cplb_tables_cpu(unsigned int cpu)
  23. {
  24. int i_d, i_i;
  25. unsigned long addr;
  26. struct cplb_entry *d_tbl = dcplb_tbl[cpu];
  27. struct cplb_entry *i_tbl = icplb_tbl[cpu];
  28. printk(KERN_INFO "NOMPU: setting up cplb tables\n");
  29. i_d = i_i = 0;
  30. #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
  31. /* Set up the zero page. */
  32. d_tbl[i_d].addr = 0;
  33. d_tbl[i_d++].data = SDRAM_OOPS | PAGE_SIZE_1KB;
  34. i_tbl[i_i].addr = 0;
  35. i_tbl[i_i++].data = SDRAM_OOPS | PAGE_SIZE_1KB;
  36. #endif
  37. /* Cover kernel memory with 4M pages. */
  38. addr = 0;
  39. for (; addr < memory_start; addr += 4 * 1024 * 1024) {
  40. d_tbl[i_d].addr = addr;
  41. d_tbl[i_d++].data = SDRAM_DGENERIC | PAGE_SIZE_4MB;
  42. i_tbl[i_i].addr = addr;
  43. i_tbl[i_i++].data = SDRAM_IGENERIC | PAGE_SIZE_4MB;
  44. }
  45. /* Cover L1 memory. One 4M area for code and data each is enough. */
  46. if (cpu == 0) {
  47. if (L1_DATA_A_LENGTH || L1_DATA_B_LENGTH) {
  48. d_tbl[i_d].addr = L1_DATA_A_START;
  49. d_tbl[i_d++].data = L1_DMEMORY | PAGE_SIZE_4MB;
  50. }
  51. i_tbl[i_i].addr = L1_CODE_START;
  52. i_tbl[i_i++].data = L1_IMEMORY | PAGE_SIZE_4MB;
  53. }
  54. #ifdef CONFIG_SMP
  55. else {
  56. if (L1_DATA_A_LENGTH || L1_DATA_B_LENGTH) {
  57. d_tbl[i_d].addr = COREB_L1_DATA_A_START;
  58. d_tbl[i_d++].data = L1_DMEMORY | PAGE_SIZE_4MB;
  59. }
  60. i_tbl[i_i].addr = COREB_L1_CODE_START;
  61. i_tbl[i_i++].data = L1_IMEMORY | PAGE_SIZE_4MB;
  62. }
  63. #endif
  64. first_switched_dcplb = i_d;
  65. first_switched_icplb = i_i;
  66. BUG_ON(first_switched_dcplb > MAX_CPLBS);
  67. BUG_ON(first_switched_icplb > MAX_CPLBS);
  68. while (i_d < MAX_CPLBS)
  69. d_tbl[i_d++].data = 0;
  70. while (i_i < MAX_CPLBS)
  71. i_tbl[i_i++].data = 0;
  72. }
  73. void __init generate_cplb_tables_all(void)
  74. {
  75. unsigned long uncached_end;
  76. int i_d, i_i;
  77. i_d = 0;
  78. /* Normal RAM, including MTD FS. */
  79. #ifdef CONFIG_MTD_UCLINUX
  80. uncached_end = memory_mtd_start + mtd_size;
  81. #else
  82. uncached_end = memory_end;
  83. #endif
  84. /*
  85. * if DMA uncached is less than 1MB, mark the 1MB chunk as uncached
  86. * so that we don't have to use 4kB pages and cause CPLB thrashing
  87. */
  88. if ((DMA_UNCACHED_REGION >= 1 * 1024 * 1024) || !DMA_UNCACHED_REGION ||
  89. ((_ramend - uncached_end) >= 1 * 1024 * 1024))
  90. dcplb_bounds[i_d].eaddr = uncached_end;
  91. else
  92. dcplb_bounds[i_d].eaddr = uncached_end & ~(1 * 1024 * 1024);
  93. dcplb_bounds[i_d++].data = SDRAM_DGENERIC;
  94. /* DMA uncached region. */
  95. if (DMA_UNCACHED_REGION) {
  96. dcplb_bounds[i_d].eaddr = _ramend;
  97. dcplb_bounds[i_d++].data = SDRAM_DNON_CHBL;
  98. }
  99. if (_ramend != physical_mem_end) {
  100. /* Reserved memory. */
  101. dcplb_bounds[i_d].eaddr = physical_mem_end;
  102. dcplb_bounds[i_d++].data = (reserved_mem_dcache_on ?
  103. SDRAM_DGENERIC : SDRAM_DNON_CHBL);
  104. }
  105. /* Addressing hole up to the async bank. */
  106. dcplb_bounds[i_d].eaddr = ASYNC_BANK0_BASE;
  107. dcplb_bounds[i_d++].data = 0;
  108. /* ASYNC banks. */
  109. dcplb_bounds[i_d].eaddr = ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE;
  110. dcplb_bounds[i_d++].data = SDRAM_EBIU;
  111. /* Addressing hole up to BootROM. */
  112. dcplb_bounds[i_d].eaddr = BOOT_ROM_START;
  113. dcplb_bounds[i_d++].data = 0;
  114. /* BootROM -- largest one should be less than 1 meg. */
  115. dcplb_bounds[i_d].eaddr = BOOT_ROM_START + (1 * 1024 * 1024);
  116. dcplb_bounds[i_d++].data = SDRAM_DGENERIC;
  117. if (L2_LENGTH) {
  118. /* Addressing hole up to L2 SRAM. */
  119. dcplb_bounds[i_d].eaddr = L2_START;
  120. dcplb_bounds[i_d++].data = 0;
  121. /* L2 SRAM. */
  122. dcplb_bounds[i_d].eaddr = L2_START + L2_LENGTH;
  123. dcplb_bounds[i_d++].data = L2_DMEMORY;
  124. }
  125. dcplb_nr_bounds = i_d;
  126. BUG_ON(dcplb_nr_bounds > ARRAY_SIZE(dcplb_bounds));
  127. i_i = 0;
  128. /* Normal RAM, including MTD FS. */
  129. icplb_bounds[i_i].eaddr = uncached_end;
  130. icplb_bounds[i_i++].data = SDRAM_IGENERIC;
  131. if (_ramend != physical_mem_end) {
  132. /* DMA uncached region. */
  133. if (DMA_UNCACHED_REGION) {
  134. /* Normally this hole is caught by the async below. */
  135. icplb_bounds[i_i].eaddr = _ramend;
  136. icplb_bounds[i_i++].data = 0;
  137. }
  138. /* Reserved memory. */
  139. icplb_bounds[i_i].eaddr = physical_mem_end;
  140. icplb_bounds[i_i++].data = (reserved_mem_icache_on ?
  141. SDRAM_IGENERIC : SDRAM_INON_CHBL);
  142. }
  143. /* Addressing hole up to the async bank. */
  144. icplb_bounds[i_i].eaddr = ASYNC_BANK0_BASE;
  145. icplb_bounds[i_i++].data = 0;
  146. /* ASYNC banks. */
  147. icplb_bounds[i_i].eaddr = ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE;
  148. icplb_bounds[i_i++].data = SDRAM_EBIU;
  149. /* Addressing hole up to BootROM. */
  150. icplb_bounds[i_i].eaddr = BOOT_ROM_START;
  151. icplb_bounds[i_i++].data = 0;
  152. /* BootROM -- largest one should be less than 1 meg. */
  153. icplb_bounds[i_i].eaddr = BOOT_ROM_START + (1 * 1024 * 1024);
  154. icplb_bounds[i_i++].data = SDRAM_IGENERIC;
  155. if (L2_LENGTH) {
  156. /* Addressing hole up to L2 SRAM. */
  157. icplb_bounds[i_i].eaddr = L2_START;
  158. icplb_bounds[i_i++].data = 0;
  159. /* L2 SRAM. */
  160. icplb_bounds[i_i].eaddr = L2_START + L2_LENGTH;
  161. icplb_bounds[i_i++].data = L2_IMEMORY;
  162. }
  163. icplb_nr_bounds = i_i;
  164. BUG_ON(icplb_nr_bounds > ARRAY_SIZE(icplb_bounds));
  165. }