motionpro.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * (C) Copyright 2003-2007
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * modified for Promess PRO - by Andy Joseph, andy@promessdev.com
  6. * modified for Promess PRO-Motion - by Robert McCullough, rob@promessdev.com
  7. * modified by Chris M. Tumas 6/20/06 Change CAS latency to 2 from 3
  8. * Also changed the refresh for 100Mhz operation
  9. *
  10. * See file CREDITS for list of people who contributed to this
  11. * project.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License as
  15. * published by the Free Software Foundation; either version 2 of
  16. * the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  26. * MA 02111-1307 USA
  27. */
  28. #include <common.h>
  29. #include <mpc5xxx.h>
  30. /* Kollmorgen DPR initialization data */
  31. struct init_elem {
  32. unsigned long addr;
  33. unsigned len;
  34. char *data;
  35. } init_seq[] = {
  36. {0x500003F2, 2, "\x86\x00"}, /* HW parameter */
  37. {0x500003F0, 2, "\x00\x00"},
  38. {0x500003EC, 4, "\x00\x80\xc1\x52"}, /* Magic word */
  39. };
  40. /*
  41. * Initialize Kollmorgen DPR
  42. */
  43. static void kollmorgen_init(void)
  44. {
  45. unsigned i, j;
  46. vu_char *p;
  47. for (i = 0; i < sizeof(init_seq) / sizeof(struct init_elem); ++i) {
  48. p = (vu_char *)init_seq[i].addr;
  49. for (j = 0; j < init_seq[i].len; ++j)
  50. *(p + j) = *(init_seq[i].data + j);
  51. }
  52. printf("DPR: Kollmorgen DPR initialized\n");
  53. }
  54. /*
  55. * Early board initalization.
  56. */
  57. int board_early_init_r(void)
  58. {
  59. /* Now, when we are in RAM, disable Boot Chipselect and enable CS0 */
  60. *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 25);
  61. *(vu_long *)MPC5XXX_ADDECR |= (1 << 16);
  62. /* Initialize Kollmorgen DPR */
  63. kollmorgen_init();
  64. return 0;
  65. }
  66. #ifndef CFG_RAMBOOT
  67. /*
  68. * Helper function to initialize SDRAM controller.
  69. */
  70. static void sdram_start (int hi_addr)
  71. {
  72. long hi_addr_bit = hi_addr ? 0x01000000 : 0;
  73. /* unlock mode register */
  74. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 |
  75. hi_addr_bit;
  76. /* precharge all banks */
  77. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 |
  78. hi_addr_bit;
  79. /* auto refresh */
  80. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 |
  81. hi_addr_bit;
  82. /* auto refresh, second time */
  83. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 |
  84. hi_addr_bit;
  85. /* set mode register */
  86. *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE;
  87. /* normal operation */
  88. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
  89. }
  90. #endif /* !CFG_RAMBOOT */
  91. /*
  92. * Initalize SDRAM - configure SDRAM controller, detect memory size.
  93. */
  94. long int initdram (int board_type)
  95. {
  96. ulong dramsize = 0;
  97. #ifndef CFG_RAMBOOT
  98. ulong test1, test2;
  99. /* configure SDRAM start/end for detection */
  100. *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001e; /* 2G at 0x0 */
  101. *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x80000000; /* disabled */
  102. /* setup config registers */
  103. *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
  104. *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
  105. sdram_start(0);
  106. test1 = get_ram_size((long *)CFG_SDRAM_BASE, 0x80000000);
  107. sdram_start(1);
  108. test2 = get_ram_size((long *)CFG_SDRAM_BASE, 0x80000000);
  109. if (test1 > test2) {
  110. sdram_start(0);
  111. dramsize = test1;
  112. } else {
  113. dramsize = test2;
  114. }
  115. /* memory smaller than 1MB is impossible */
  116. if (dramsize < (1 << 20))
  117. dramsize = 0;
  118. /* set SDRAM CS0 size according to the amount of RAM found */
  119. if (dramsize > 0) {
  120. *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 +
  121. __builtin_ffs(dramsize >> 20) - 1;
  122. } else {
  123. *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */
  124. }
  125. /* let SDRAM CS1 start right after CS0 and disable it */
  126. *(vu_long *) MPC5XXX_SDRAM_CS1CFG = dramsize;
  127. #else /* !CFG_RAMBOOT */
  128. /* retrieve size of memory connected to SDRAM CS0 */
  129. dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF;
  130. if (dramsize >= 0x13)
  131. dramsize = (1 << (dramsize - 0x13)) << 20;
  132. else
  133. dramsize = 0;
  134. #endif /* CFG_RAMBOOT */
  135. /* return total ram size */
  136. return dramsize;
  137. }
  138. int checkboard (void)
  139. {
  140. puts("Board: Promess Motion-PRO board\n");
  141. return 0;
  142. }