alaska.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * (C) Copyright 2004, Freescale Inc.
  3. * TsiChung Liew, Tsi-Chung.Liew@freescale.com
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (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, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <mpc8220.h>
  25. #include <asm/processor.h>
  26. #include <asm/mmu.h>
  27. void setupBat (ulong size)
  28. {
  29. ulong batu, batl;
  30. int blocksize = 0;
  31. /* Flash 0 */
  32. #if defined (CFG_AMD_BOOT)
  33. batu = CFG_FLASH0_BASE | (BL_512K << 2) | BPP_RW | BPP_RX;
  34. #else
  35. batu = CFG_FLASH0_BASE | (BL_16M << 2) | BPP_RW | BPP_RX;
  36. #endif
  37. batl = CFG_FLASH0_BASE | 0x22;
  38. write_bat (IBAT0, batu, batl);
  39. write_bat (DBAT0, batu, batl);
  40. /* Flash 1 */
  41. #if defined (CFG_AMD_BOOT)
  42. batu = CFG_FLASH1_BASE | (BL_16M << 2) | BPP_RW | BPP_RX;
  43. #else
  44. batu = CFG_FLASH1_BASE | (BL_512K << 2) | BPP_RW | BPP_RX;
  45. #endif
  46. batl = CFG_FLASH1_BASE | 0x22;
  47. write_bat (IBAT1, batu, batl);
  48. write_bat (DBAT1, batu, batl);
  49. /* CPLD */
  50. batu = CFG_CPLD_BASE | (BL_512K << 2) | BPP_RW | BPP_RX;
  51. batl = CFG_CPLD_BASE | 0x22;
  52. write_bat (IBAT2, 0, 0);
  53. write_bat (DBAT2, batu, batl);
  54. /* FPGA */
  55. batu = CFG_FPGA_BASE | (BL_512K << 2) | BPP_RW | BPP_RX;
  56. batl = CFG_FPGA_BASE | 0x22;
  57. write_bat (IBAT3, 0, 0);
  58. write_bat (DBAT3, batu, batl);
  59. /* MBAR - Data only */
  60. batu = CFG_MBAR | BPP_RW | BPP_RX;
  61. batl = CFG_MBAR | 0x22;
  62. mtspr (IBAT4L, 0);
  63. mtspr (IBAT4U, 0);
  64. mtspr (DBAT4L, batl);
  65. mtspr (DBAT4U, batu);
  66. /* MBAR - SRAM */
  67. batu = CFG_SRAM_BASE | BPP_RW | BPP_RX;
  68. batl = CFG_SRAM_BASE | 0x42;
  69. mtspr (IBAT5L, batl);
  70. mtspr (IBAT5U, batu);
  71. mtspr (DBAT5L, batl);
  72. mtspr (DBAT5U, batu);
  73. if (size <= 0x800000) /* 8MB */
  74. blocksize = BL_8M << 2;
  75. else if (size <= 0x1000000) /* 16MB */
  76. blocksize = BL_16M << 2;
  77. else if (size <= 0x2000000) /* 32MB */
  78. blocksize = BL_32M << 2;
  79. else if (size <= 0x4000000) /* 64MB */
  80. blocksize = BL_64M << 2;
  81. else if (size <= 0x8000000) /* 128MB */
  82. blocksize = BL_128M << 2;
  83. else if (size <= 0x10000000) /* 256MB */
  84. blocksize = BL_256M << 2;
  85. /* Memory */
  86. batu = CFG_SDRAM_BASE | blocksize | BPP_RW | BPP_RX;
  87. batl = CFG_SDRAM_BASE | 0x42;
  88. mtspr (IBAT6L, batl);
  89. mtspr (IBAT6U, batu);
  90. mtspr (DBAT6L, batl);
  91. mtspr (DBAT6U, batu);
  92. /* memory size is less than 256MB */
  93. if (size <= 0x10000000) {
  94. /* Nothing */
  95. batu = 0;
  96. batl = 0;
  97. } else {
  98. size -= 0x10000000;
  99. if (size <= 0x800000) /* 8MB */
  100. blocksize = BL_8M << 2;
  101. else if (size <= 0x1000000) /* 16MB */
  102. blocksize = BL_16M << 2;
  103. else if (size <= 0x2000000) /* 32MB */
  104. blocksize = BL_32M << 2;
  105. else if (size <= 0x4000000) /* 64MB */
  106. blocksize = BL_64M << 2;
  107. else if (size <= 0x8000000) /* 128MB */
  108. blocksize = BL_128M << 2;
  109. else if (size <= 0x10000000) /* 256MB */
  110. blocksize = BL_256M << 2;
  111. batu = (CFG_SDRAM_BASE +
  112. 0x10000000) | blocksize | BPP_RW | BPP_RX;
  113. batl = (CFG_SDRAM_BASE + 0x10000000) | 0x42;
  114. }
  115. mtspr (IBAT7L, batl);
  116. mtspr (IBAT7U, batu);
  117. mtspr (DBAT7L, batl);
  118. mtspr (DBAT7U, batu);
  119. }
  120. long int initdram (int board_type)
  121. {
  122. ulong size;
  123. size = dramSetup ();
  124. /* if iCache ad dCache is defined */
  125. #if defined(CONFIG_CMD_CACHE)
  126. /* setupBat(size);*/
  127. #endif
  128. return size;
  129. }
  130. int checkboard (void)
  131. {
  132. puts ("Board: Alaska MPC8220 Evaluation Board\n");
  133. return 0;
  134. }