cplbinit.c 5.0 KB

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