gen860t.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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
  117. checkboard(void)
  118. {
  119. DECLARE_GLOBAL_DATA_PTR;
  120. unsigned char *s;
  121. unsigned char buf[64];
  122. int i;
  123. i = getenv_r("board_id", buf, sizeof(buf));
  124. s = (i>0) ? buf : NULL;
  125. if (s) {
  126. printf("%s ", s);
  127. } else {
  128. printf("<unknown> ");
  129. }
  130. i = getenv_r("serial#", buf, sizeof(buf));
  131. s = (i>0) ? buf : NULL;
  132. if (s) {
  133. printf("S/N %s\n", s);
  134. } else {
  135. printf("S/N <unknown>\n");
  136. }
  137. printf("CPU at %s MHz, ",strmhz(buf, gd->cpu_clk));
  138. printf("local bus at %s MHz\n", strmhz(buf, gd->bus_clk));
  139. return (0);
  140. }
  141. /*
  142. * Initialize SDRAM
  143. */
  144. long int
  145. initdram(int board_type)
  146. {
  147. volatile immap_t *immr = (immap_t *)CFG_IMMR;
  148. volatile memctl8xx_t *memctl = &immr->im_memctl;
  149. upmconfig(UPMA,
  150. (uint *)sdram_upm_table,
  151. sizeof(sdram_upm_table) / sizeof(uint)
  152. );
  153. /*
  154. * Setup MAMR register
  155. */
  156. memctl->memc_mptpr = CFG_MPTPR_1BK_8K;
  157. memctl->memc_mamr = CFG_MAMR_8COL & (~(MAMR_PTAE)); /* no refresh yet */
  158. /*
  159. * Map CS1* to SDRAM bank
  160. */
  161. memctl->memc_or1 = CFG_OR1;
  162. memctl->memc_br1 = CFG_BR1;
  163. /*
  164. * Perform SDRAM initialization sequence:
  165. * 1. Apply at least one NOP command
  166. * 2. 100 uS delay (JEDEC standard says 200 uS)
  167. * 3. Issue 4 precharge commands
  168. * 4. Perform two refresh cycles
  169. * 5. Program mode register
  170. *
  171. * Program SDRAM for standard operation, sequential burst, burst length
  172. * of 4, CAS latency of 2.
  173. */
  174. memctl->memc_mar = 0x00000000;
  175. memctl->memc_mcr = MCR_UPM_A | MCR_OP_RUN | MCR_MB_CS1 |
  176. MCR_MLCF(0) | UPMA_NOP_ADDR;
  177. udelay(200);
  178. memctl->memc_mar = 0x00000000;
  179. memctl->memc_mcr = MCR_UPM_A | MCR_OP_RUN | MCR_MB_CS1 |
  180. MCR_MLCF(4) | UPMA_PRECHARGE_ADDR;
  181. memctl->memc_mar = 0x00000000;
  182. memctl->memc_mcr = MCR_UPM_A | MCR_OP_RUN | MCR_MB_CS1 |
  183. MCR_MLCF(2) | UPM_REFRESH_ADDR;
  184. memctl->memc_mar = 0x00000088;
  185. memctl->memc_mcr = MCR_UPM_A | MCR_OP_RUN | MCR_MB_CS1 |
  186. MCR_MLCF(1) | UPMA_MRS_ADDR;
  187. memctl->memc_mar = 0x00000000;
  188. memctl->memc_mcr = MCR_UPM_A | MCR_OP_RUN | MCR_MB_CS1 |
  189. MCR_MLCF(0) | UPMA_NOP_ADDR;
  190. /*
  191. * Enable refresh
  192. */
  193. memctl->memc_mamr |= MAMR_PTAE;
  194. return (SDRAM_SIZE);
  195. }
  196. /*
  197. * Disk On Chip (DOC) Millenium initialization.
  198. * The DOC lives in the CS2* space
  199. */
  200. #if (CONFIG_COMMANDS & CFG_CMD_DOC)
  201. extern void
  202. doc_probe(ulong physadr);
  203. void
  204. doc_init(void)
  205. {
  206. printf("Probing at 0x%.8x: ", DOC_BASE);
  207. doc_probe(DOC_BASE);
  208. }
  209. #endif
  210. /*
  211. * Miscellaneous intialization
  212. */
  213. int
  214. misc_init_r (void)
  215. {
  216. volatile immap_t *immr = (immap_t *)CFG_IMMR;
  217. volatile memctl8xx_t *memctl = &immr->im_memctl;
  218. /*
  219. * Set up UPMB to handle the Virtex FPGA SelectMap interface
  220. */
  221. upmconfig(UPMB, (uint *)selectmap_upm_table,
  222. sizeof(selectmap_upm_table) / sizeof(uint));
  223. memctl->memc_mbmr = 0x0;
  224. config_mpc8xx_ioports(immr);
  225. #if (CONFIG_COMMANDS & CFG_CMD_MII)
  226. mii_init();
  227. #endif
  228. #if (CONFIG_FPGA)
  229. gen860t_init_fpga();
  230. #endif
  231. return 0;
  232. }
  233. /*
  234. * Final init hook before entering command loop.
  235. */
  236. int
  237. last_stage_init(void)
  238. {
  239. #if !defined(CONFIG_SC)
  240. unsigned char buf[256];
  241. int i;
  242. /*
  243. * Turn the beeper volume all the way down in case this is a warm boot.
  244. */
  245. set_beeper_volume(-64);
  246. init_beeper();
  247. /*
  248. * Read the environment to see what to do with the beeper
  249. */
  250. i = getenv_r("beeper", buf, sizeof(buf));
  251. if (i > 0) {
  252. do_beeper(buf);
  253. }
  254. #endif
  255. return 0;
  256. }
  257. /*
  258. * Stub to make POST code happy. Can't self-poweroff, so just hang.
  259. */
  260. void
  261. board_poweroff(void)
  262. {
  263. puts("### Please power off the board ###\n");
  264. while (1);
  265. }
  266. #ifdef CONFIG_POST
  267. /*
  268. * Returns 1 if keys pressed to start the power-on long-running tests
  269. * Called from board_init_f().
  270. */
  271. int post_hotkeys_pressed(void)
  272. {
  273. return 0; /* No hotkeys supported */
  274. }
  275. #endif
  276. /* vim: set ts=4 sw=4 tw=78 : */