motionpro.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. #if defined(CONFIG_OF_FLAT_TREE)
  31. #include <ft_build.h>
  32. #endif
  33. /* Kollmorgen DPR initialization data */
  34. struct init_elem {
  35. unsigned long addr;
  36. unsigned len;
  37. char *data;
  38. } init_seq[] = {
  39. {0x500003F2, 2, "\x86\x00"}, /* HW parameter */
  40. {0x500003F0, 2, "\x00\x00"},
  41. {0x500003EC, 4, "\x00\x80\xc1\x52"}, /* Magic word */
  42. };
  43. /*
  44. * Initialize Kollmorgen DPR
  45. */
  46. static void kollmorgen_init(void)
  47. {
  48. unsigned i, j;
  49. vu_char *p;
  50. for (i = 0; i < sizeof(init_seq) / sizeof(struct init_elem); ++i) {
  51. p = (vu_char *)init_seq[i].addr;
  52. for (j = 0; j < init_seq[i].len; ++j)
  53. *(p + j) = *(init_seq[i].data + j);
  54. }
  55. printf("DPR: Kollmorgen DPR initialized\n");
  56. }
  57. /*
  58. * Early board initalization.
  59. */
  60. int board_early_init_r(void)
  61. {
  62. /* Now, when we are in RAM, disable Boot Chipselect and enable CS0 */
  63. *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 25);
  64. *(vu_long *)MPC5XXX_ADDECR |= (1 << 16);
  65. /* Initialize Kollmorgen DPR */
  66. kollmorgen_init();
  67. return 0;
  68. }
  69. #ifndef CFG_RAMBOOT
  70. /*
  71. * Helper function to initialize SDRAM controller.
  72. */
  73. static void sdram_start (int hi_addr)
  74. {
  75. long hi_addr_bit = hi_addr ? 0x01000000 : 0;
  76. /* unlock mode register */
  77. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 |
  78. hi_addr_bit;
  79. /* precharge all banks */
  80. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 |
  81. hi_addr_bit;
  82. /* auto refresh */
  83. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 |
  84. hi_addr_bit;
  85. /* auto refresh, second time */
  86. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 |
  87. hi_addr_bit;
  88. /* set mode register */
  89. *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE;
  90. /* normal operation */
  91. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
  92. }
  93. #endif /* !CFG_RAMBOOT */
  94. /*
  95. * Initalize SDRAM - configure SDRAM controller, detect memory size.
  96. */
  97. long int initdram (int board_type)
  98. {
  99. ulong dramsize = 0;
  100. #ifndef CFG_RAMBOOT
  101. ulong test1, test2;
  102. /* configure SDRAM start/end for detection */
  103. *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001e; /* 2G at 0x0 */
  104. *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x80000000; /* disabled */
  105. /* setup config registers */
  106. *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
  107. *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
  108. sdram_start(0);
  109. test1 = get_ram_size((long *)CFG_SDRAM_BASE, 0x80000000);
  110. sdram_start(1);
  111. test2 = get_ram_size((long *)CFG_SDRAM_BASE, 0x80000000);
  112. if (test1 > test2) {
  113. sdram_start(0);
  114. dramsize = test1;
  115. } else {
  116. dramsize = test2;
  117. }
  118. /* memory smaller than 1MB is impossible */
  119. if (dramsize < (1 << 20))
  120. dramsize = 0;
  121. /* set SDRAM CS0 size according to the amount of RAM found */
  122. if (dramsize > 0) {
  123. *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 +
  124. __builtin_ffs(dramsize >> 20) - 1;
  125. } else {
  126. *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */
  127. }
  128. /* let SDRAM CS1 start right after CS0 and disable it */
  129. *(vu_long *) MPC5XXX_SDRAM_CS1CFG = dramsize;
  130. #else /* !CFG_RAMBOOT */
  131. /* retrieve size of memory connected to SDRAM CS0 */
  132. dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF;
  133. if (dramsize >= 0x13)
  134. dramsize = (1 << (dramsize - 0x13)) << 20;
  135. else
  136. dramsize = 0;
  137. #endif /* CFG_RAMBOOT */
  138. /* return total ram size */
  139. return dramsize;
  140. }
  141. int checkboard (void)
  142. {
  143. puts("Board: Promess Motion-PRO board\n");
  144. return 0;
  145. }
  146. #if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
  147. void ft_board_setup(void *blob, bd_t *bd)
  148. {
  149. ft_cpu_setup(blob, bd);
  150. }
  151. #endif /* defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) */