qs860t.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /*
  2. * (C) Copyright 2003
  3. * MuLogic B.V.
  4. *
  5. * (C) Copyright 2002
  6. * Simple Network Magic Corporation, dnevil@snmc.com
  7. *
  8. * (C) Copyright 2000
  9. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  10. *
  11. * See file CREDITS for list of people who contributed to this
  12. * project.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  27. * MA 02111-1307 USA
  28. */
  29. #include <common.h>
  30. #include <asm/u-boot.h>
  31. #include <commproc.h>
  32. #include "mpc8xx.h"
  33. /* ------------------------------------------------------------------------- */
  34. static long int dram_size (long int, long int *, long int);
  35. /* ------------------------------------------------------------------------- */
  36. const uint sdram_table[] =
  37. {
  38. /*
  39. * Single Read. (Offset 0 in UPMA RAM)
  40. */
  41. 0x1F07FC04, 0xEEAEFC04, 0x11ADFC04, 0xEFBBBC00,
  42. 0x1FF77C47, 0x1FF77C35, 0xEFEABC34, 0x1FB57C35,
  43. /*
  44. * Burst Read. (Offset 8 in UPMA RAM)
  45. */
  46. 0x1F07FC04, 0xEEAEFC04, 0x10ADFC04, 0xF0AFFC00,
  47. 0xF0AFFC00, 0xF1AFFC00, 0xEFBBBC00, 0x1FF77C47,
  48. 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04,
  49. 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04,
  50. /*
  51. * Single Write. (Offset 18 in UPMA RAM)
  52. */
  53. 0x1F27FC04, 0xEEAEBC00, 0x01B93C04, 0x1FF77C47,
  54. 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04,
  55. /*
  56. * Burst Write. (Offset 20 in UPMA RAM)
  57. */
  58. 0x1F07FC04, 0xEEAEBC00, 0x10AD7C00, 0xF0AFFC00,
  59. 0xF0AFFC00, 0xE1BBBC04, 0x1FF77C47, 0xFFFFEC04,
  60. 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04,
  61. 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04,
  62. /*
  63. * Refresh (Offset 30 in UPMA RAM)
  64. */
  65. 0x1FF5FC84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04,
  66. 0xFFFFFC84, 0xFFFFFC07, 0xFFFFEC04, 0xFFFFEC04,
  67. 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04,
  68. /*
  69. * Exception. (Offset 3c in UPMA RAM)
  70. */
  71. 0x7FFFFC07, 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04
  72. };
  73. /* ------------------------------------------------------------------------- */
  74. /*
  75. * Check Board Identity:
  76. *
  77. * Test ID string (QS860T...)
  78. *
  79. * Always return 1
  80. */
  81. int checkboard (void)
  82. {
  83. unsigned char *s, *e;
  84. unsigned char buf[64];
  85. int i;
  86. i = getenv_r("serial#", buf, sizeof(buf));
  87. s = (i>0) ? buf : NULL;
  88. if (!s || strncmp(s, "QS860T", 6)) {
  89. puts ("### No HW ID - assuming QS860T");
  90. } else {
  91. for (e=s; *e; ++e) {
  92. if (*e == ' ')
  93. break;
  94. }
  95. for ( ; s<e; ++s) {
  96. putc (*s);
  97. }
  98. }
  99. putc ('\n');
  100. return (0);
  101. }
  102. /* ------------------------------------------------------------------------- */
  103. long int initdram (int board_type)
  104. {
  105. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  106. volatile memctl8xx_t *memctl = &immap->im_memctl;
  107. long int size;
  108. upmconfig(UPMB, (uint *)sdram_table, sizeof(sdram_table)/sizeof(uint));
  109. /*
  110. * Prescaler for refresh
  111. */
  112. memctl->memc_mptpr = 0x0400;
  113. /*
  114. * Map controller bank 2 to the SDRAM address
  115. */
  116. memctl->memc_or2 = CFG_OR2;
  117. memctl->memc_br2 = CFG_BR2;
  118. udelay(200);
  119. /* perform SDRAM initialization sequence */
  120. memctl->memc_mbmr = CFG_16M_MBMR;
  121. udelay(100);
  122. memctl->memc_mar = 0x00000088;
  123. memctl->memc_mcr = 0x80804105; /* run precharge pattern */
  124. udelay(1);
  125. /* Run two refresh cycles on SDRAM */
  126. memctl->memc_mbmr = 0x18802118;
  127. memctl->memc_mcr = 0x80804130;
  128. memctl->memc_mbmr = 0x18802114;
  129. memctl->memc_mcr = 0x80804106;
  130. udelay (1000);
  131. #if 0
  132. /*
  133. * Check for 64M SDRAM Memory Size
  134. */
  135. size = dram_size (CFG_64M_MBMR, (ulong *)SDRAM_BASE, SDRAM_64M_MAX_SIZE);
  136. udelay (1000);
  137. /*
  138. * Check for 16M SDRAM Memory Size
  139. */
  140. if (size != SDRAM_64M_MAX_SIZE) {
  141. #endif
  142. size = dram_size (CFG_16M_MBMR, (ulong *)SDRAM_BASE, SDRAM_16M_MAX_SIZE);
  143. udelay (1000);
  144. #if 0
  145. }
  146. memctl->memc_or2 = ((-size) & 0xFFFF0000) | SDRAM_TIMING;
  147. #endif
  148. udelay(10000);
  149. #if 0
  150. /*
  151. * Also, map other memory to correct position
  152. */
  153. /*
  154. * Map the 8M Intel Flash device to chip select 1
  155. */
  156. memctl->memc_or1 = CFG_OR1;
  157. memctl->memc_br1 = CFG_BR1;
  158. /*
  159. * Map 64K NVRAM, Sipex Device, NAND Ctl Reg, and LED Ctl Reg
  160. * to chip select 3
  161. */
  162. memctl->memc_or3 = CFG_OR3;
  163. memctl->memc_br3 = CFG_BR3;
  164. /*
  165. * Map chip selects 4, 5, 6, & 7 for external expansion connector
  166. */
  167. memctl->memc_or4 = CFG_OR4;
  168. memctl->memc_br4 = CFG_BR4;
  169. memctl->memc_or5 = CFG_OR5;
  170. memctl->memc_br5 = CFG_BR5;
  171. memctl->memc_or6 = CFG_OR6;
  172. memctl->memc_br6 = CFG_BR6;
  173. memctl->memc_or7 = CFG_OR7;
  174. memctl->memc_br7 = CFG_BR7;
  175. #endif
  176. return (size);
  177. }
  178. /* ------------------------------------------------------------------------- */
  179. /*
  180. * Check memory range for valid RAM. A simple memory test determines
  181. * the actually available RAM size between addresses `base' and
  182. * `base + maxsize'. Some (not all) hardware errors are detected:
  183. * - short between address lines
  184. * - short between data lines
  185. */
  186. static long int dram_size (long int mbmr_value, long int *base, long int maxsize)
  187. {
  188. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  189. volatile memctl8xx_t *memctl = &immap->im_memctl;
  190. memctl->memc_mbmr = mbmr_value;
  191. return (get_ram_size(base, maxsize));
  192. }