gw8260.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. /*
  2. * (C) Copyright 2000
  3. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  4. * Marius Groeger <mgroeger@sysgo.de>
  5. *
  6. * (C) Copyright 2001
  7. * Advent Networks, Inc. <http://www.adventnetworks.com>
  8. * Jay Monkman <jtm@smoothsmoothie.com>
  9. *
  10. * (C) Copyright 2001
  11. * Advent Networks, Inc. <http://www.adventnetworks.com>
  12. * Oliver Brown <oliverb@alumni.utexas.net>
  13. *
  14. * See file CREDITS for list of people who contributed to this
  15. * project.
  16. *
  17. * This program is free software; you can redistribute it and/or
  18. * modify it under the terms of the GNU General Public License as
  19. * published by the Free Software Foundation; either version 2 of
  20. * the License, or (at your option) any later version.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program; if not, write to the Free Software
  29. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  30. * MA 02111-1307 USA
  31. */
  32. /*********************************************************************/
  33. /* DESCRIPTION:
  34. * This file contains the board routines for the GW8260 board.
  35. *
  36. * MODULE DEPENDENCY:
  37. * None
  38. *
  39. * RESTRICTIONS/LIMITATIONS:
  40. * None
  41. *
  42. * Copyright (c) 2001, Advent Networks, Inc.
  43. */
  44. /*********************************************************************/
  45. #include <common.h>
  46. #include <ioports.h>
  47. #include <mpc8260.h>
  48. /*
  49. * I/O Port configuration table
  50. *
  51. */
  52. const iop_conf_t iop_conf_tab[4][32] = {
  53. /* Port A configuration */
  54. { /* conf ppar psor pdir podr pdat */
  55. /* PA31 */ { 1, 0, 0, 1, 0, 0 }, /* TP14 */
  56. /* PA30 */ { 1, 1, 1, 1, 0, 0 }, /* US_RTS */
  57. /* PA29 */ { 1, 0, 0, 1, 0, 1 }, /* LSSI_DATA */
  58. /* PA28 */ { 1, 0, 0, 1, 0, 1 }, /* LSSI_CLK */
  59. /* PA27 */ { 1, 0, 0, 1, 0, 0 }, /* TP12 */
  60. /* PA26 */ { 1, 0, 0, 0, 0, 0 }, /* IO_STATUS */
  61. /* PA25 */ { 1, 0, 0, 0, 0, 0 }, /* IO_CLOCK */
  62. /* PA24 */ { 1, 0, 0, 0, 0, 0 }, /* IO_CONFIG */
  63. /* PA23 */ { 1, 0, 0, 0, 0, 0 }, /* IO_DONE */
  64. /* PA22 */ { 1, 0, 0, 0, 0, 0 }, /* IO_DATA */
  65. /* PA21 */ { 1, 1, 0, 1, 0, 0 }, /* US_TXD3 */
  66. /* PA20 */ { 1, 1, 0, 1, 0, 0 }, /* US_TXD2 */
  67. /* PA19 */ { 1, 1, 0, 1, 0, 0 }, /* US_TXD1 */
  68. /* PA18 */ { 1, 1, 0, 1, 0, 0 }, /* US_TXD0 */
  69. /* PA17 */ { 1, 1, 0, 0, 0, 0 }, /* DS_RXD0 */
  70. /* PA16 */ { 1, 1, 0, 0, 0, 0 }, /* DS_RXD1 */
  71. /* PA15 */ { 1, 1, 0, 0, 0, 0 }, /* DS_RXD2 */
  72. /* PA14 */ { 1, 1, 0, 0, 0, 0 }, /* DS_RXD3 */
  73. /* PA13 */ { 1, 0, 0, 1, 0, 0 }, /* SPARE7 */
  74. /* PA12 */ { 1, 0, 0, 1, 0, 0 }, /* SPARE6 */
  75. /* PA11 */ { 1, 0, 0, 1, 0, 0 }, /* SPARE5 */
  76. /* PA10 */ { 1, 0, 0, 1, 0, 0 }, /* SPARE4 */
  77. /* PA9 */ { 1, 0, 0, 1, 0, 0 }, /* SPARE3 */
  78. /* PA8 */ { 1, 0, 0, 1, 0, 0 }, /* SPARE2 */
  79. /* PA7 */ { 1, 0, 0, 0, 0, 0 }, /* LSSI_IN */
  80. /* PA6 */ { 1, 0, 0, 1, 0, 0 }, /* SPARE0 */
  81. /* PA5 */ { 1, 0, 0, 1, 0, 0 }, /* DEMOD_RESET_ */
  82. /* PA4 */ { 1, 0, 0, 1, 0, 0 }, /* MOD_RESET_ */
  83. /* PA3 */ { 1, 0, 0, 1, 0, 0 }, /* IO_RESET */
  84. /* PA2 */ { 1, 0, 0, 1, 0, 0 }, /* TX_ENABLE */
  85. /* PA1 */ { 1, 0, 0, 0, 0, 0 }, /* RX_LOCK */
  86. /* PA0 */ { 1, 0, 0, 1, 0, 1 } /* MPC_RESET_ */
  87. },
  88. /* Port B configuration */
  89. { /* conf ppar psor pdir podr pdat */
  90. /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FETH0_TX_ER */
  91. /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FETH0_RX_DV */
  92. /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FETH0_TX_EN */
  93. /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FETH0_RX_ER */
  94. /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FETH0_COL */
  95. /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FETH0_CRS */
  96. /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FETH0_TXD3 */
  97. /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FETH0_TXD2 */
  98. /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FETH0_TXD1 */
  99. /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FETH0_TXD0 */
  100. /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FETH0_RXD0 */
  101. /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FETH0_RXD1 */
  102. /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FETH0_RXD2 */
  103. /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FETH0_RXD3 */
  104. /* PB17 */ { 1, 1, 0, 0, 0, 0 }, /* FETH1_RX_DV */
  105. /* PB16 */ { 1, 1, 0, 0, 0, 0 }, /* FETH1_RX_ER */
  106. /* PB15 */ { 1, 1, 0, 1, 0, 0 }, /* FETH1_TX_ER */
  107. /* PB14 */ { 1, 1, 0, 1, 0, 0 }, /* FETH1_TX_EN */
  108. /* PB13 */ { 1, 1, 0, 0, 0, 0 }, /* FETH1_COL */
  109. /* PB12 */ { 1, 1, 0, 0, 0, 0 }, /* FETH1_CRS */
  110. /* PB11 */ { 1, 1, 0, 0, 0, 0 }, /* FETH1_RXD3 */
  111. /* PB10 */ { 1, 1, 0, 0, 0, 0 }, /* FETH1_RXD2 */
  112. /* PB9 */ { 1, 1, 0, 0, 0, 0 }, /* FETH1_RXD1 */
  113. /* PB8 */ { 1, 1, 0, 0, 0, 0 }, /* FETH1_RXD0 */
  114. /* PB7 */ { 1, 1, 0, 1, 0, 0 }, /* FETH1_TXD0 */
  115. /* PB6 */ { 1, 1, 0, 1, 0, 0 }, /* FETH1_TXD1 */
  116. /* PB5 */ { 1, 1, 0, 1, 0, 0 }, /* FETH1_TXD2 */
  117. /* PB4 */ { 1, 1, 0, 1, 0, 0 }, /* FETH1_TXD3 */
  118. /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  119. /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  120. /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  121. /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  122. },
  123. /* Port C */
  124. { /* conf ppar psor pdir podr pdat */
  125. /* PC31 */ { 1, 0, 0, 1, 0, 1 }, /* FAST_RESET_ */
  126. /* PC30 */ { 1, 0, 0, 1, 0, 1 }, /* FAST_PAUSE_ */
  127. /* PC29 */ { 1, 0, 0, 1, 0, 0 }, /* FAST_SLEW1 */
  128. /* PC28 */ { 1, 0, 0, 1, 0, 0 }, /* FAST_SLEW0 */
  129. /* PC27 */ { 1, 0, 0, 1, 0, 0 }, /* TP13 */
  130. /* PC26 */ { 1, 0, 0, 0, 0, 0 }, /* RXDECDFLG */
  131. /* PC25 */ { 1, 0, 0, 0, 0, 0 }, /* RXACQFAIL */
  132. /* PC24 */ { 1, 0, 0, 0, 0, 0 }, /* RXACQFLG */
  133. /* PC23 */ { 1, 0, 0, 1, 0, 0 }, /* WD_TCL */
  134. /* PC22 */ { 1, 0, 0, 1, 0, 0 }, /* WD_EN */
  135. /* PC21 */ { 1, 0, 0, 1, 0, 0 }, /* US_TXCLK */
  136. /* PC20 */ { 1, 0, 0, 0, 0, 0 }, /* DS_RXCLK */
  137. /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FETH0_RX_CLK */
  138. /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FETH0_TX_CLK */
  139. /* PC17 */ { 1, 1, 0, 0, 0, 0 }, /* FETH1_RX_CLK */
  140. /* PC16 */ { 1, 1, 0, 0, 0, 0 }, /* FETH1_TX_CLK */
  141. /* PC15 */ { 1, 0, 0, 1, 0, 0 }, /* TX_SHUTDOWN_ */
  142. /* PC14 */ { 1, 0, 0, 0, 0, 0 }, /* RS_232_DTR_ */
  143. /* PC13 */ { 1, 0, 0, 0, 0, 0 }, /* TXERR */
  144. /* PC12 */ { 1, 0, 0, 1, 0, 1 }, /* FETH1_MDDIS */
  145. /* PC11 */ { 1, 0, 0, 1, 0, 1 }, /* FETH0_MDDIS */
  146. /* PC10 */ { 1, 0, 0, 1, 0, 0 }, /* MDC */
  147. /* PC9 */ { 1, 0, 0, 1, 1, 1 }, /* MDIO */
  148. /* PC8 */ { 1, 0, 0, 1, 1, 1 }, /* SER_NUM */
  149. /* PC7 */ { 1, 1, 0, 0, 0, 0 }, /* US_CTS */
  150. /* PC6 */ { 1, 1, 0, 0, 0, 0 }, /* DS_CD_ */
  151. /* PC5 */ { 1, 0, 0, 1, 0, 0 }, /* FETH1_PWRDWN */
  152. /* PC4 */ { 1, 0, 0, 1, 0, 0 }, /* FETH0_PWRDWN */
  153. /* PC3 */ { 1, 0, 0, 1, 0, 0 }, /* MPULED3 */
  154. /* PC2 */ { 1, 0, 0, 1, 0, 0 }, /* MPULED2 */
  155. /* PC1 */ { 1, 0, 0, 1, 0, 0 }, /* MPULED1 */
  156. /* PC0 */ { 1, 0, 0, 1, 0, 1 }, /* MPULED0 */
  157. },
  158. /* Port D */
  159. { /* conf ppar psor pdir podr pdat */
  160. /* PD31 */ { 1, 0, 0, 0, 0, 0 }, /* not used */
  161. /* PD30 */ { 1, 0, 0, 0, 0, 0 }, /* not used */
  162. /* PD29 */ { 1, 0, 0, 0, 0, 0 }, /* not used */
  163. /* PD28 */ { 1, 0, 0, 0, 0, 0 }, /* not used */
  164. /* PD27 */ { 1, 0, 0, 0, 0, 0 }, /* not used */
  165. /* PD26 */ { 1, 0, 0, 0, 0, 0 }, /* not used */
  166. /* PD25 */ { 1, 0, 0, 0, 0, 0 }, /* not used */
  167. /* PD24 */ { 1, 0, 0, 0, 0, 0 }, /* not used */
  168. /* PD23 */ { 1, 0, 0, 0, 0, 0 }, /* not used */
  169. /* PD22 */ { 1, 0, 0, 0, 0, 0 }, /* not used */
  170. /* PD21 */ { 1, 0, 0, 0, 0, 0 }, /* not used */
  171. /* PD20 */ { 1, 0, 0, 0, 0, 0 }, /* not used */
  172. /* PD19 */ { 1, 1, 1, 0, 0, 0 }, /* not used */
  173. /* PD18 */ { 1, 1, 1, 0, 0, 0 }, /* not used */
  174. /* PD17 */ { 1, 1, 1, 0, 0, 0 }, /* not used */
  175. /* PD16 */ { 1, 1, 1, 0, 0, 0 }, /* not used */
  176. /* PD15 */ { 1, 1, 1, 0, 1, 1 }, /* SDRAM_SDA */
  177. /* PD14 */ { 1, 1, 1, 0, 1, 1 }, /* SDRAM_SCL */
  178. /* PD13 */ { 1, 0, 0, 1, 0, 0 }, /* MPULED7 */
  179. /* PD12 */ { 1, 0, 0, 1, 0, 0 }, /* MPULED6 */
  180. /* PD11 */ { 1, 0, 0, 1, 0, 0 }, /* MPULED5 */
  181. /* PD10 */ { 1, 0, 0, 1, 0, 0 }, /* MPULED4 */
  182. /* PD9 */ { 1, 1, 0, 1, 0, 0 }, /* RS232_TXD */
  183. /* PD8 */ { 1, 1, 0, 0, 0, 0 }, /* RD232_RXD */
  184. /* PD7 */ { 1, 0, 0, 0, 0, 0 }, /* not used */
  185. /* PD6 */ { 1, 0, 0, 0, 0, 0 }, /* not used */
  186. /* PD5 */ { 1, 0, 0, 0, 0, 0 }, /* not used */
  187. /* PD4 */ { 1, 0, 0, 0, 0, 0 }, /* not used */
  188. /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  189. /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  190. /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  191. /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  192. }
  193. };
  194. /*********************************************************************/
  195. /* NAME: checkboard() - Displays the board type and serial number */
  196. /* */
  197. /* OUTPUTS: */
  198. /* Displays the board type and serial number */
  199. /* */
  200. /* RETURNS: */
  201. /* Always returns 1 */
  202. /* */
  203. /* RESTRICTIONS/LIMITATIONS: */
  204. /* */
  205. /* */
  206. /*********************************************************************/
  207. int checkboard (void)
  208. {
  209. char *str;
  210. puts ("Board: Advent Networks gw8260\n");
  211. str = getenv ("serial#");
  212. if (str != NULL) {
  213. printf ("SN: %s\n", str);
  214. }
  215. return 0;
  216. }
  217. #if defined (CFG_DRAM_TEST)
  218. /*********************************************************************/
  219. /* NAME: move64() - moves a double word (64-bit) */
  220. /* */
  221. /* DESCRIPTION: */
  222. /* this function performs a double word move from the data at */
  223. /* the source pointer to the location at the destination pointer. */
  224. /* */
  225. /* INPUTS: */
  226. /* unsigned long long *src - pointer to data to move */
  227. /* */
  228. /* OUTPUTS: */
  229. /* unsigned long long *dest - pointer to locate to move data */
  230. /* */
  231. /* RETURNS: */
  232. /* None */
  233. /* */
  234. /* RESTRICTIONS/LIMITATIONS: */
  235. /* May cloober fr0. */
  236. /* */
  237. /*********************************************************************/
  238. static void move64 (unsigned long long *src, unsigned long long *dest)
  239. {
  240. asm ("lfd 0, 0(3)\n\t" /* fpr0 = *scr */
  241. "stfd 0, 0(4)" /* *dest = fpr0 */
  242. : : : "fr0"); /* Clobbers fr0 */
  243. return;
  244. }
  245. #if defined (CFG_DRAM_TEST_DATA)
  246. unsigned long long pattern[] = {
  247. 0xaaaaaaaaaaaaaaaaULL,
  248. 0xccccccccccccccccULL,
  249. 0xf0f0f0f0f0f0f0f0ULL,
  250. 0xff00ff00ff00ff00ULL,
  251. 0xffff0000ffff0000ULL,
  252. 0xffffffff00000000ULL,
  253. 0x00000000ffffffffULL,
  254. 0x0000ffff0000ffffULL,
  255. 0x00ff00ff00ff00ffULL,
  256. 0x0f0f0f0f0f0f0f0fULL,
  257. 0x3333333333333333ULL,
  258. 0x5555555555555555ULL,
  259. };
  260. /*********************************************************************/
  261. /* NAME: mem_test_data() - test data lines for shorts and opens */
  262. /* */
  263. /* DESCRIPTION: */
  264. /* Tests data lines for shorts and opens by forcing adjacent data */
  265. /* to opposite states. Because the data lines could be routed in */
  266. /* an arbitrary manner the must ensure test patterns ensure that */
  267. /* every case is tested. By using the following series of binary */
  268. /* patterns every combination of adjacent bits is test regardless */
  269. /* of routing. */
  270. /* */
  271. /* ...101010101010101010101010 */
  272. /* ...110011001100110011001100 */
  273. /* ...111100001111000011110000 */
  274. /* ...111111110000000011111111 */
  275. /* */
  276. /* Carrying this out, gives us six hex patterns as follows: */
  277. /* */
  278. /* 0xaaaaaaaaaaaaaaaa */
  279. /* 0xcccccccccccccccc */
  280. /* 0xf0f0f0f0f0f0f0f0 */
  281. /* 0xff00ff00ff00ff00 */
  282. /* 0xffff0000ffff0000 */
  283. /* 0xffffffff00000000 */
  284. /* */
  285. /* The number test patterns will always be given by: */
  286. /* */
  287. /* log(base 2)(number data bits) = log2 (64) = 6 */
  288. /* */
  289. /* To test for short and opens to other signals on our boards. we */
  290. /* simply */
  291. /* test with the 1's complemnt of the paterns as well. */
  292. /* */
  293. /* OUTPUTS: */
  294. /* Displays failing test pattern */
  295. /* */
  296. /* RETURNS: */
  297. /* 0 - Passed test */
  298. /* 1 - Failed test */
  299. /* */
  300. /* RESTRICTIONS/LIMITATIONS: */
  301. /* Assumes only one one SDRAM bank */
  302. /* */
  303. /*********************************************************************/
  304. int mem_test_data (void)
  305. {
  306. unsigned long long *pmem = (unsigned long long *) CFG_SDRAM_BASE;
  307. unsigned long long temp64 = 0;
  308. int num_patterns = sizeof (pattern) / sizeof (pattern[0]);
  309. int i;
  310. unsigned int hi, lo;
  311. for (i = 0; i < num_patterns; i++) {
  312. move64 (&(pattern[i]), pmem);
  313. move64 (pmem, &temp64);
  314. /* hi = (temp64>>32) & 0xffffffff; */
  315. /* lo = temp64 & 0xffffffff; */
  316. /* printf("\ntemp64 = 0x%08x%08x", hi, lo); */
  317. hi = (pattern[i] >> 32) & 0xffffffff;
  318. lo = pattern[i] & 0xffffffff;
  319. /* printf("\npattern[%d] = 0x%08x%08x", i, hi, lo); */
  320. if (temp64 != pattern[i]) {
  321. printf ("\n Data Test Failed, pattern 0x%08x%08x",
  322. hi, lo);
  323. return 1;
  324. }
  325. }
  326. return 0;
  327. }
  328. #endif /* CFG_DRAM_TEST_DATA */
  329. #if defined (CFG_DRAM_TEST_ADDRESS)
  330. /*********************************************************************/
  331. /* NAME: mem_test_address() - test address lines */
  332. /* */
  333. /* DESCRIPTION: */
  334. /* This function performs a test to verify that each word im */
  335. /* memory is uniquly addressable. The test sequence is as follows: */
  336. /* */
  337. /* 1) write the address of each word to each word. */
  338. /* 2) verify that each location equals its address */
  339. /* */
  340. /* OUTPUTS: */
  341. /* Displays failing test pattern and address */
  342. /* */
  343. /* RETURNS: */
  344. /* 0 - Passed test */
  345. /* 1 - Failed test */
  346. /* */
  347. /* RESTRICTIONS/LIMITATIONS: */
  348. /* */
  349. /* */
  350. /*********************************************************************/
  351. int mem_test_address (void)
  352. {
  353. volatile unsigned int *pmem =
  354. (volatile unsigned int *) CFG_SDRAM_BASE;
  355. const unsigned int size = (CFG_SDRAM_SIZE * 1024 * 1024) / 4;
  356. unsigned int i;
  357. /* write address to each location */
  358. for (i = 0; i < size; i++) {
  359. pmem[i] = i;
  360. }
  361. /* verify each loaction */
  362. for (i = 0; i < size; i++) {
  363. if (pmem[i] != i) {
  364. printf ("\n Address Test Failed at 0x%x", i);
  365. return 1;
  366. }
  367. }
  368. return 0;
  369. }
  370. #endif /* CFG_DRAM_TEST_ADDRESS */
  371. #if defined (CFG_DRAM_TEST_WALK)
  372. /*********************************************************************/
  373. /* NAME: mem_march() - memory march */
  374. /* */
  375. /* DESCRIPTION: */
  376. /* Marches up through memory. At each location verifies rmask if */
  377. /* read = 1. At each location write wmask if write = 1. Displays */
  378. /* failing address and pattern. */
  379. /* */
  380. /* INPUTS: */
  381. /* volatile unsigned long long * base - start address of test */
  382. /* unsigned int size - number of dwords(64-bit) to test */
  383. /* unsigned long long rmask - read verify mask */
  384. /* unsigned long long wmask - wrtie verify mask */
  385. /* short read - verifies rmask if read = 1 */
  386. /* short write - writes wmask if write = 1 */
  387. /* */
  388. /* OUTPUTS: */
  389. /* Displays failing test pattern and address */
  390. /* */
  391. /* RETURNS: */
  392. /* 0 - Passed test */
  393. /* 1 - Failed test */
  394. /* */
  395. /* RESTRICTIONS/LIMITATIONS: */
  396. /* */
  397. /* */
  398. /*********************************************************************/
  399. int mem_march (volatile unsigned long long *base,
  400. unsigned int size,
  401. unsigned long long rmask,
  402. unsigned long long wmask, short read, short write)
  403. {
  404. unsigned int i;
  405. unsigned long long temp = 0;
  406. unsigned int hitemp, lotemp, himask, lomask;
  407. for (i = 0; i < size; i++) {
  408. if (read != 0) {
  409. /* temp = base[i]; */
  410. move64 ((unsigned long long *) &(base[i]), &temp);
  411. if (rmask != temp) {
  412. hitemp = (temp >> 32) & 0xffffffff;
  413. lotemp = temp & 0xffffffff;
  414. himask = (rmask >> 32) & 0xffffffff;
  415. lomask = rmask & 0xffffffff;
  416. printf ("\n Walking one's test failed: address = 0x%08x," "\n\texpected 0x%08x%08x, found 0x%08x%08x", i << 3, himask, lomask, hitemp, lotemp);
  417. return 1;
  418. }
  419. }
  420. if (write != 0) {
  421. /* base[i] = wmask; */
  422. move64 (&wmask, (unsigned long long *) &(base[i]));
  423. }
  424. }
  425. return 0;
  426. }
  427. #endif /* CFG_DRAM_TEST_WALK */
  428. /*********************************************************************/
  429. /* NAME: mem_test_walk() - a simple walking ones test */
  430. /* */
  431. /* DESCRIPTION: */
  432. /* Performs a walking ones through entire physical memory. The */
  433. /* test uses as series of memory marches, mem_march(), to verify */
  434. /* and write the test patterns to memory. The test sequence is as */
  435. /* follows: */
  436. /* 1) march writing 0000...0001 */
  437. /* 2) march verifying 0000...0001 , writing 0000...0010 */
  438. /* 3) repeat step 2 shifting masks left 1 bit each time unitl */
  439. /* the write mask equals 1000...0000 */
  440. /* 4) march verifying 1000...0000 */
  441. /* The test fails if any of the memory marches return a failure. */
  442. /* */
  443. /* OUTPUTS: */
  444. /* Displays which pass on the memory test is executing */
  445. /* */
  446. /* RETURNS: */
  447. /* 0 - Passed test */
  448. /* 1 - Failed test */
  449. /* */
  450. /* RESTRICTIONS/LIMITATIONS: */
  451. /* */
  452. /* */
  453. /*********************************************************************/
  454. int mem_test_walk (void)
  455. {
  456. unsigned long long mask;
  457. volatile unsigned long long *pmem =
  458. (volatile unsigned long long *) CFG_SDRAM_BASE;
  459. const unsigned long size = (CFG_SDRAM_SIZE * 1024 * 1024) / 8;
  460. unsigned int i;
  461. mask = 0x01;
  462. printf ("Initial Pass");
  463. mem_march (pmem, size, 0x0, 0x1, 0, 1);
  464. printf ("\b\b\b\b\b\b\b\b\b\b\b\b");
  465. printf (" ");
  466. printf ("\b\b\b\b\b\b\b\b\b\b\b\b");
  467. for (i = 0; i < 63; i++) {
  468. printf ("Pass %2d", i + 2);
  469. if (mem_march (pmem, size, mask, mask << 1, 1, 1) != 0) {
  470. /*printf("mask: 0x%x, pass: %d, ", mask, i); */
  471. return 1;
  472. }
  473. mask = mask << 1;
  474. printf ("\b\b\b\b\b\b\b");
  475. }
  476. printf ("Last Pass");
  477. if (mem_march (pmem, size, 0, mask, 0, 1) != 0) {
  478. /* printf("mask: 0x%x", mask); */
  479. return 1;
  480. }
  481. printf ("\b\b\b\b\b\b\b\b\b");
  482. printf (" ");
  483. printf ("\b\b\b\b\b\b\b\b\b");
  484. return 0;
  485. }
  486. /*********************************************************************/
  487. /* NAME: testdram() - calls any enabled memory tests */
  488. /* */
  489. /* DESCRIPTION: */
  490. /* Runs memory tests if the environment test variables are set to */
  491. /* 'y'. */
  492. /* */
  493. /* INPUTS: */
  494. /* testdramdata - If set to 'y', data test is run. */
  495. /* testdramaddress - If set to 'y', address test is run. */
  496. /* testdramwalk - If set to 'y', walking ones test is run */
  497. /* */
  498. /* OUTPUTS: */
  499. /* None */
  500. /* */
  501. /* RETURNS: */
  502. /* 0 - Passed test */
  503. /* 1 - Failed test */
  504. /* */
  505. /* RESTRICTIONS/LIMITATIONS: */
  506. /* */
  507. /* */
  508. /*********************************************************************/
  509. int testdram (void)
  510. {
  511. char *s;
  512. int rundata, runaddress, runwalk;
  513. s = getenv ("testdramdata");
  514. rundata = (s && (*s == 'y')) ? 1 : 0;
  515. s = getenv ("testdramaddress");
  516. runaddress = (s && (*s == 'y')) ? 1 : 0;
  517. s = getenv ("testdramwalk");
  518. runwalk = (s && (*s == 'y')) ? 1 : 0;
  519. if ((rundata == 1) || (runaddress == 1) || (runwalk == 1)) {
  520. printf ("Testing RAM ... ");
  521. }
  522. #ifdef CFG_DRAM_TEST_DATA
  523. if (rundata == 1) {
  524. if (mem_test_data () == 1) {
  525. return 1;
  526. }
  527. }
  528. #endif
  529. #ifdef CFG_DRAM_TEST_ADDRESS
  530. if (runaddress == 1) {
  531. if (mem_test_address () == 1) {
  532. return 1;
  533. }
  534. }
  535. #endif
  536. #ifdef CFG_DRAM_TEST_WALK
  537. if (runwalk == 1) {
  538. if (mem_test_walk () == 1) {
  539. return 1;
  540. }
  541. }
  542. #endif
  543. if ((rundata == 1) || (runaddress == 1) || (runwalk == 1)) {
  544. printf ("passed");
  545. }
  546. return 0;
  547. }
  548. #endif /* CFG_DRAM_TEST */
  549. /*********************************************************************/
  550. /* NAME: initdram() - initializes SDRAM controller */
  551. /* */
  552. /* DESCRIPTION: */
  553. /* Initializes the MPC8260's SDRAM controller. */
  554. /* */
  555. /* INPUTS: */
  556. /* CFG_IMMR - MPC8260 Internal memory map */
  557. /* CFG_SDRAM_BASE - Physical start address of SDRAM */
  558. /* CFG_PSDMR - SDRAM mode register */
  559. /* CFG_MPTPR - Memory refresh timer prescaler register */
  560. /* CFG_SDRAM0_SIZE - SDRAM size */
  561. /* */
  562. /* RETURNS: */
  563. /* SDRAM size in bytes */
  564. /* */
  565. /* RESTRICTIONS/LIMITATIONS: */
  566. /* */
  567. /* */
  568. /*********************************************************************/
  569. long int initdram (int board_type)
  570. {
  571. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  572. volatile memctl8260_t *memctl = &immap->im_memctl;
  573. volatile uchar c = 0, *ramaddr = (uchar *) (CFG_SDRAM_BASE + 0x8);
  574. ulong psdmr = CFG_PSDMR;
  575. int i;
  576. /*
  577. * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
  578. *
  579. * "At system reset, initialization software must set up the
  580. * programmable parameters in the memory controller banks registers
  581. * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
  582. * system software should execute the following initialization sequence
  583. * for each SDRAM device.
  584. *
  585. * 1. Issue a PRECHARGE-ALL-BANKS command
  586. * 2. Issue eight CBR REFRESH commands
  587. * 3. Issue a MODE-SET command to initialize the mode register
  588. *
  589. * The initial commands are executed by setting P/LSDMR[OP] and
  590. * accessing the SDRAM with a single-byte transaction."
  591. *
  592. * The appropriate BRx/ORx registers have already been set when we
  593. * get here. The SDRAM can be accessed at the address CFG_SDRAM_BASE.
  594. */
  595. memctl->memc_psrt = CFG_PSRT;
  596. memctl->memc_mptpr = CFG_MPTPR;
  597. memctl->memc_psdmr = psdmr | PSDMR_OP_PREA;
  598. *ramaddr = c;
  599. memctl->memc_psdmr = psdmr | PSDMR_OP_CBRR;
  600. for (i = 0; i < 8; i++) {
  601. *ramaddr = c;
  602. }
  603. memctl->memc_psdmr = psdmr | PSDMR_OP_MRW;
  604. *ramaddr = c;
  605. memctl->memc_psdmr = psdmr | PSDMR_OP_NORM | PSDMR_RFEN;
  606. *ramaddr = c;
  607. /* return total ram size */
  608. return (CFG_SDRAM0_SIZE * 1024 * 1024);
  609. }
  610. /*********************************************************************/
  611. /* End of gw8260.c */
  612. /*********************************************************************/