icecube.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * (C) Copyright 2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  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 <mpc5xxx.h>
  25. long int initdram (int board_type)
  26. {
  27. #ifndef CFG_RAMBOOT
  28. /* configure SDRAM start/end */
  29. #if defined(CONFIG_MPC5200)
  30. *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x00000018;/* 32M at 0x0 */
  31. *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x02000000;/* disabled */
  32. /* setup config registers */
  33. *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = 0xc2233a00;
  34. *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = 0x88b70004;
  35. /* unlock mode register */
  36. *(vu_long *)MPC5XXX_SDRAM_CTRL = 0xd04f0000;
  37. /* precharge all banks */
  38. *(vu_long *)MPC5XXX_SDRAM_CTRL = 0xd04f0002;
  39. /* set mode register */
  40. *(vu_long *)MPC5XXX_SDRAM_MODE = 0x408d0000;
  41. /* precharge all banks */
  42. *(vu_long *)MPC5XXX_SDRAM_CTRL = 0xd04f0002;
  43. /* auto refresh */
  44. *(vu_long *)MPC5XXX_SDRAM_CTRL = 0xd04f0004;
  45. /* set mode register */
  46. *(vu_long *)MPC5XXX_SDRAM_MODE = 0x008d0000;
  47. /* normal operation */
  48. *(vu_long *)MPC5XXX_SDRAM_CTRL = 0x504f0000;
  49. #elif defined(CONFIG_MGT5100)
  50. *(vu_long *)MPC5XXX_SDRAM_START = 0x00000000;
  51. *(vu_long *)MPC5XXX_SDRAM_STOP = 0x000007ff;/* 64M */
  52. *(vu_long *)MPC5XXX_ADDECR |= (1 << 22); /* Enable SDRAM */
  53. /* setup config registers */
  54. *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = 0xc2222600;
  55. *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = 0x88b70004;
  56. /* address select register */
  57. *(vu_long *)MPC5XXX_SDRAM_XLBSEL = 0x03000000;
  58. /* unlock mode register */
  59. *(vu_long *)MPC5XXX_SDRAM_CTRL = 0xd14f0000;
  60. /* precharge all banks */
  61. *(vu_long *)MPC5XXX_SDRAM_CTRL = 0xd14f0002;
  62. /* set mode register */
  63. *(vu_long *)MPC5XXX_SDRAM_MODE = 0x008d0000;
  64. /* precharge all banks */
  65. *(vu_long *)MPC5XXX_SDRAM_CTRL = 0xd14f0002;
  66. /* auto refresh */
  67. *(vu_long *)MPC5XXX_SDRAM_CTRL = 0xd14f0004;
  68. /* set mode register */
  69. *(vu_long *)MPC5XXX_SDRAM_MODE = 0x008d0000;
  70. /* normal operation */
  71. *(vu_long *)MPC5XXX_SDRAM_CTRL = 0x514f0000;
  72. #endif
  73. #else
  74. #ifdef CONFIG_MGT5100
  75. *(vu_long *)MPC5XXX_ADDECR |= (1 << 22); /* Enable SDRAM */
  76. #endif
  77. #endif
  78. /* return total ram size */
  79. #if defined(CONFIG_MGT5100)
  80. return (64 * 1024 * 1024);
  81. #elif defined(CONFIG_MPC5200)
  82. return (32 * 1024 * 1024);
  83. #endif
  84. }
  85. int checkboard (void)
  86. {
  87. #if defined(CONFIG_MPC5200)
  88. puts ("Board: Motorola MPC5200 (IceCube)\n");
  89. #elif defined(CONFIG_MGT5100)
  90. puts ("Board: Motorola MGT5100 (IceCube)\n");
  91. #endif
  92. return 0;
  93. }
  94. void flash_preinit(void)
  95. {
  96. /*
  97. * Now, when we are in RAM, enable flash write
  98. * access for detection process.
  99. * Note that CS_BOOT cannot be cleared when
  100. * executing in flash.
  101. */
  102. #if defined(CONFIG_MGT5100)
  103. *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 25); /* disable CS_BOOT */
  104. *(vu_long *)MPC5XXX_ADDECR |= (1 << 16); /* enable CS0 */
  105. #endif
  106. *(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1; /* clear RO */
  107. }