gen860t.c 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. /*
  2. * (C) Copyright 2000
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. * Keith Outwater, keith_outwater@mvis.com
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <virtex2.h>
  25. #include <common.h>
  26. #include <mpc8xx.h>
  27. #include <asm/8xx_immap.h>
  28. #include "beeper.h"
  29. #include "fpga.h"
  30. #include "ioport.h"
  31. #ifdef CONFIG_STATUS_LED
  32. #include <status_led.h>
  33. #endif
  34. #if defined(CFG_CMD_MII) && defined(CONFIG_MII)
  35. #include <net.h>
  36. #endif
  37. #if 0
  38. #define GEN860T_DEBUG
  39. #endif
  40. #ifdef GEN860T_DEBUG
  41. #define PRINTF(fmt,args...) printf (fmt ,##args)
  42. #else
  43. #define PRINTF(fmt,args...)
  44. #endif
  45. /*
  46. * The following UPM init tables were generated automatically by
  47. * Motorola's MCUINIT program. See the README file for UPM to
  48. * SDRAM pin assignments if you want to type this data into
  49. * MCUINIT in order to reverse engineer the waveforms.
  50. */
  51. /*
  52. * UPM initialization tables for MICRON MT48LC16M16A2TG SDRAM devices
  53. * (UPMA) and Virtex FPGA SelectMap interface (UPMB).
  54. * NOTE that unused areas of the table are used to hold NOP, precharge
  55. * and mode register set sequences.
  56. *
  57. */
  58. #define UPMA_NOP_ADDR 0x5
  59. #define UPMA_PRECHARGE_ADDR 0x6
  60. #define UPMA_MRS_ADDR 0x12
  61. #define UPM_SINGLE_READ_ADDR 0x00
  62. #define UPM_BURST_READ_ADDR 0x08
  63. #define UPM_SINGLE_WRITE_ADDR 0x18
  64. #define UPM_BURST_WRITE_ADDR 0x20
  65. #define UPM_REFRESH_ADDR 0x30
  66. const uint sdram_upm_table[] = {
  67. /* single read (offset 0x00 in upm ram) */
  68. 0x0e0fdc04, 0x01adfc04, 0x0fbffc00, 0x1fff5c05,
  69. 0xffffffff, 0x0fffffcd, 0x0fff0fce, 0xefcfffff,
  70. /* burst read (offset 0x08 in upm ram) */
  71. 0x0f0fdc04, 0x00fdfc04, 0xf0fffc00, 0xf0fffc00,
  72. 0xf1fffc00, 0xfffffc00, 0xfffffc05, 0xffffffff,
  73. 0xffffffff, 0xffffffff, 0x0ffffff4, 0x1f3d5ff4,
  74. 0xfffffff4, 0xfffffff5, 0xffffffff, 0xffffffff,
  75. /* single write (offset 0x18 in upm ram) */
  76. 0x0f0fdc04, 0x00ad3c00, 0x1fff5c05, 0xffffffff,
  77. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  78. /* burst write (offset 0x20 in upm ram) */
  79. 0x0f0fdc00, 0x10fd7c00, 0xf0fffc00, 0xf0fffc00,
  80. 0xf1fffc04, 0xfffffc05, 0xffffffff, 0xffffffff,
  81. 0xffffffff, 0xffffffff, 0xffffffff, 0xfffff7ff,
  82. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  83. /* refresh (offset 0x30 in upm ram) */
  84. 0x1ffddc84, 0xfffffc04, 0xfffffc04, 0xfffffc84,
  85. 0xfffffc05, 0xffffffff, 0xffffffff, 0xffffffff,
  86. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  87. /* exception (offset 0x3C in upm ram) */
  88. };
  89. const uint selectmap_upm_table[] = {
  90. /* single read (offset 0x00 in upm ram) */
  91. 0x88fffc06, 0x00fff404, 0x00fffc04, 0x33fffc00,
  92. 0xfffffc05, 0xffffffff, 0xffffffff, 0xffffffff,
  93. /* burst read (offset 0x08 in upm ram) */
  94. 0xfffffc04, 0xfffffc05, 0xffffffff, 0xffffffff,
  95. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  96. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  97. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  98. /* single write (offset 0x18 in upm ram) */
  99. 0x88fffc04, 0x00fff400, 0x77fffc05, 0xffffffff,
  100. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  101. /* burst write (offset 0x20 in upm ram) */
  102. 0xfffffc04, 0xfffffc05, 0xffffffff, 0xffffffff,
  103. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  104. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  105. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  106. /* refresh (offset 0x30 in upm ram) */
  107. 0xfffffc04, 0xfffffc05, 0xffffffff, 0xffffffff,
  108. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  109. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  110. /* exception (offset 0x3C in upm ram) */
  111. 0xfffffc05, 0xffffffff, 0xffffffff, 0xffffffff
  112. };
  113. /*
  114. * Check board identity. Always successful (gives information only)
  115. */
  116. int checkboard (void)
  117. {
  118. DECLARE_GLOBAL_DATA_PTR;
  119. unsigned char *s;
  120. unsigned char buf[64];
  121. int i;
  122. i = getenv_r ("board_id", buf, sizeof (buf));
  123. s = (i > 0) ? buf : NULL;
  124. if (s) {
  125. printf ("%s ", s);
  126. } else {
  127. printf ("<unknown> ");
  128. }
  129. i = getenv_r ("serial#", buf, sizeof (buf));
  130. s = (i > 0) ? buf : NULL;
  131. if (s) {
  132. printf ("S/N %s\n", s);
  133. } else {
  134. printf ("S/N <unknown>\n");
  135. }
  136. printf ("CPU at %s MHz, ", strmhz (buf, gd->cpu_clk));
  137. printf ("local bus at %s MHz\n", strmhz (buf, gd->bus_clk));
  138. return (0);
  139. }
  140. /*
  141. * Initialize SDRAM
  142. */
  143. long int initdram (int board_type)
  144. {
  145. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  146. volatile memctl8xx_t *memctl = &immr->im_memctl;
  147. upmconfig (UPMA,
  148. (uint *) sdram_upm_table,
  149. sizeof (sdram_upm_table) / sizeof (uint)
  150. );
  151. /*
  152. * Setup MAMR register
  153. */
  154. memctl->memc_mptpr = CFG_MPTPR_1BK_8K;
  155. memctl->memc_mamr = CFG_MAMR_8COL & (~(MAMR_PTAE)); /* no refresh yet */
  156. /*
  157. * Map CS1* to SDRAM bank
  158. */
  159. memctl->memc_or1 = CFG_OR1;
  160. memctl->memc_br1 = CFG_BR1;
  161. /*
  162. * Perform SDRAM initialization sequence:
  163. * 1. Apply at least one NOP command
  164. * 2. 100 uS delay (JEDEC standard says 200 uS)
  165. * 3. Issue 4 precharge commands
  166. * 4. Perform two refresh cycles
  167. * 5. Program mode register
  168. *
  169. * Program SDRAM for standard operation, sequential burst, burst length
  170. * of 4, CAS latency of 2.
  171. */
  172. memctl->memc_mar = 0x00000000;
  173. memctl->memc_mcr = MCR_UPM_A | MCR_OP_RUN | MCR_MB_CS1 |
  174. MCR_MLCF (0) | UPMA_NOP_ADDR;
  175. udelay (200);
  176. memctl->memc_mar = 0x00000000;
  177. memctl->memc_mcr = MCR_UPM_A | MCR_OP_RUN | MCR_MB_CS1 |
  178. MCR_MLCF (4) | UPMA_PRECHARGE_ADDR;
  179. memctl->memc_mar = 0x00000000;
  180. memctl->memc_mcr = MCR_UPM_A | MCR_OP_RUN | MCR_MB_CS1 |
  181. MCR_MLCF (2) | UPM_REFRESH_ADDR;
  182. memctl->memc_mar = 0x00000088;
  183. memctl->memc_mcr = MCR_UPM_A | MCR_OP_RUN | MCR_MB_CS1 |
  184. MCR_MLCF (1) | UPMA_MRS_ADDR;
  185. memctl->memc_mar = 0x00000000;
  186. memctl->memc_mcr = MCR_UPM_A | MCR_OP_RUN | MCR_MB_CS1 |
  187. MCR_MLCF (0) | UPMA_NOP_ADDR;
  188. /*
  189. * Enable refresh
  190. */
  191. memctl->memc_mamr |= MAMR_PTAE;
  192. return (SDRAM_SIZE);
  193. }
  194. /*
  195. * Disk On Chip (DOC) Millenium initialization.
  196. * The DOC lives in the CS2* space
  197. */
  198. #if (CONFIG_COMMANDS & CFG_CMD_DOC)
  199. extern void doc_probe (ulong physadr);
  200. void doc_init (void)
  201. {
  202. printf ("Probing at 0x%.8x: ", DOC_BASE);
  203. doc_probe (DOC_BASE);
  204. }
  205. #endif
  206. /*
  207. * Miscellaneous intialization
  208. */
  209. int misc_init_r (void)
  210. {
  211. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  212. volatile memctl8xx_t *memctl = &immr->im_memctl;
  213. /*
  214. * Set up UPMB to handle the Virtex FPGA SelectMap interface
  215. */
  216. upmconfig (UPMB, (uint *) selectmap_upm_table,
  217. sizeof (selectmap_upm_table) / sizeof (uint));
  218. memctl->memc_mbmr = 0x0;
  219. config_mpc8xx_ioports (immr);
  220. #if (CONFIG_COMMANDS & CFG_CMD_MII)
  221. mii_init ();
  222. #endif
  223. #if (CONFIG_FPGA)
  224. gen860t_init_fpga ();
  225. #endif
  226. return 0;
  227. }
  228. /*
  229. * Final init hook before entering command loop.
  230. */
  231. int last_stage_init (void)
  232. {
  233. #if !defined(CONFIG_SC)
  234. unsigned char buf[256];
  235. int i;
  236. /*
  237. * Turn the beeper volume all the way down in case this is a warm boot.
  238. */
  239. set_beeper_volume (-64);
  240. init_beeper ();
  241. /*
  242. * Read the environment to see what to do with the beeper
  243. */
  244. i = getenv_r ("beeper", buf, sizeof (buf));
  245. if (i > 0) {
  246. do_beeper (buf);
  247. }
  248. #endif
  249. return 0;
  250. }
  251. /*
  252. * Stub to make POST code happy. Can't self-poweroff, so just hang.
  253. */
  254. void board_poweroff (void)
  255. {
  256. puts ("### Please power off the board ###\n");
  257. while (1);
  258. }
  259. #ifdef CONFIG_POST
  260. /*
  261. * Returns 1 if keys pressed to start the power-on long-running tests
  262. * Called from board_init_f().
  263. */
  264. int post_hotkeys_pressed (void)
  265. {
  266. return 0; /* No hotkeys supported */
  267. }
  268. #endif
  269. /* vim: set ts=4 sw=4 tw=78 : */