fads.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  1. /*
  2. * (C) Copyright 2000
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <config.h>
  25. #include <mpc8xx.h>
  26. #include "fads.h"
  27. /* ------------------------------------------------------------------------- */
  28. #define _NOT_USED_ 0xFFFFFFFF
  29. #if defined(CONFIG_DRAM_50MHZ)
  30. /* 50MHz tables */
  31. const uint dram_60ns[] =
  32. { 0x8fffec24, 0x0fffec04, 0x0cffec04, 0x00ffec04,
  33. 0x00ffec00, 0x37ffec47, 0xffffffff, 0xffffffff,
  34. 0x8fffec24, 0x0fffec04, 0x08ffec04, 0x00ffec0c,
  35. 0x03ffec00, 0x00ffec44, 0x00ffcc08, 0x0cffcc44,
  36. 0x00ffec0c, 0x03ffec00, 0x00ffec44, 0x00ffcc00,
  37. 0x3fffc847, 0xffffffff, 0xffffffff, 0xffffffff,
  38. 0x8fafcc24, 0x0fafcc04, 0x0cafcc00, 0x11bfcc47,
  39. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  40. 0x8fafcc24, 0x0fafcc04, 0x0cafcc00, 0x03afcc4c,
  41. 0x0cafcc00, 0x03afcc4c, 0x0cafcc00, 0x03afcc4c,
  42. 0x0cafcc00, 0x33bfcc4f, 0xffffffff, 0xffffffff,
  43. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  44. 0xc0ffcc84, 0x00ffcc04, 0x07ffcc04, 0x3fffcc06,
  45. 0xffffcc85, 0xffffcc05, 0xffffffff, 0xffffffff,
  46. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  47. 0x33ffcc07, 0xffffffff, 0xffffffff, 0xffffffff };
  48. const uint dram_70ns[] =
  49. { 0x8fffcc24, 0x0fffcc04, 0x0cffcc04, 0x00ffcc04,
  50. 0x00ffcc00, 0x37ffcc47, 0xffffffff, 0xffffffff,
  51. 0x8fffcc24, 0x0fffcc04, 0x0cffcc04, 0x00ffcc04,
  52. 0x00ffcc08, 0x0cffcc44, 0x00ffec0c, 0x03ffec00,
  53. 0x00ffec44, 0x00ffcc08, 0x0cffcc44, 0x00ffec04,
  54. 0x00ffec00, 0x3fffec47, 0xffffffff, 0xffffffff,
  55. 0x8fafcc24, 0x0fafcc04, 0x0cafcc00, 0x11bfcc47,
  56. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  57. 0x8fafcc24, 0x0fafcc04, 0x0cafcc00, 0x03afcc4c,
  58. 0x0cafcc00, 0x03afcc4c, 0x0cafcc00, 0x03afcc4c,
  59. 0x0cafcc00, 0x33bfcc4f, 0xffffffff, 0xffffffff,
  60. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  61. 0xe0ffcc84, 0x00ffcc04, 0x00ffcc04, 0x0fffcc04,
  62. 0x7fffcc06, 0xffffcc85, 0xffffcc05, 0xffffffff,
  63. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  64. 0x33ffcc07, 0xffffffff, 0xffffffff, 0xffffffff };
  65. const uint edo_60ns[] =
  66. { 0x8ffbec24, 0x0ff3ec04, 0x0cf3ec04, 0x00f3ec04,
  67. 0x00f3ec00, 0x37f7ec47, 0xffffffff, 0xffffffff,
  68. 0x8fffec24, 0x0ffbec04, 0x0cf3ec04, 0x00f3ec0c,
  69. 0x0cf3ec00, 0x00f3ec4c, 0x0cf3ec00, 0x00f3ec4c,
  70. 0x0cf3ec00, 0x00f3ec44, 0x03f3ec00, 0x3ff7ec47,
  71. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  72. 0x8fffcc24, 0x0fefcc04, 0x0cafcc00, 0x11bfcc47,
  73. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  74. 0x8fffcc24, 0x0fefcc04, 0x0cafcc00, 0x03afcc4c,
  75. 0x0cafcc00, 0x03afcc4c, 0x0cafcc00, 0x03afcc4c,
  76. 0x0cafcc00, 0x33bfcc4f, 0xffffffff, 0xffffffff,
  77. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  78. 0xc0ffcc84, 0x00ffcc04, 0x07ffcc04, 0x3fffcc06,
  79. 0xffffcc85, 0xffffcc05, 0xffffffff, 0xffffffff,
  80. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  81. 0x33ffcc07, 0xffffffff, 0xffffffff, 0xffffffff };
  82. const uint edo_70ns[] =
  83. { 0x8ffbcc24, 0x0ff3cc04, 0x0cf3cc04, 0x00f3cc04,
  84. 0x00f3cc00, 0x37f7cc47, 0xffffffff, 0xffffffff,
  85. 0x8fffcc24, 0x0ffbcc04, 0x0cf3cc04, 0x00f3cc0c,
  86. 0x03f3cc00, 0x00f3cc44, 0x00f3ec0c, 0x0cf3ec00,
  87. 0x00f3ec4c, 0x03f3ec00, 0x00f3ec44, 0x00f3cc00,
  88. 0x33f7cc47, 0xffffffff, 0xffffffff, 0xffffffff,
  89. 0x8fffcc24, 0x0fefcc04, 0x0cafcc00, 0x11bfcc47,
  90. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  91. 0x8fffcc24, 0x0fefcc04, 0x0cafcc00, 0x03afcc4c,
  92. 0x0cafcc00, 0x03afcc4c, 0x0cafcc00, 0x03afcc4c,
  93. 0x0cafcc00, 0x33bfcc47, 0xffffffff, 0xffffffff,
  94. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  95. 0xe0ffcc84, 0x00ffcc04, 0x00ffcc04, 0x0fffcc04,
  96. 0x7fffcc04, 0xffffcc86, 0xffffcc05, 0xffffffff,
  97. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  98. 0x33ffcc07, 0xffffffff, 0xffffffff, 0xffffffff };
  99. #elif defined(CONFIG_DRAM_25MHZ)
  100. /* 25MHz tables */
  101. const uint dram_60ns[] =
  102. { 0x0fffcc04, 0x08ffcc00, 0x33ffcc47, 0xffffffff,
  103. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  104. 0x0fffcc24, 0x0fffcc04, 0x08ffcc00, 0x03ffcc4c,
  105. 0x08ffcc00, 0x03ffcc4c, 0x08ffcc00, 0x03ffcc4c,
  106. 0x08ffcc00, 0x33ffcc47, 0xffffffff, 0xffffffff,
  107. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  108. 0x0fafcc04, 0x08afcc00, 0x3fbfcc47, 0xffffffff,
  109. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  110. 0x0fafcc04, 0x0cafcc00, 0x01afcc4c, 0x0cafcc00,
  111. 0x01afcc4c, 0x0cafcc00, 0x01afcc4c, 0x0cafcc00,
  112. 0x31bfcc43, 0xffffffff, 0xffffffff, 0xffffffff,
  113. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  114. 0x80ffcc84, 0x13ffcc04, 0xffffcc87, 0xffffcc05,
  115. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  116. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  117. 0x33ffcc07, 0xffffffff, 0xffffffff, 0xffffffff };
  118. const uint dram_70ns[] =
  119. { 0x0fffec04, 0x08ffec04, 0x00ffec00, 0x3fffcc47,
  120. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  121. 0x0fffcc24, 0x0fffcc04, 0x08ffcc00, 0x03ffcc4c,
  122. 0x08ffcc00, 0x03ffcc4c, 0x08ffcc00, 0x03ffcc4c,
  123. 0x08ffcc00, 0x33ffcc47, 0xffffffff, 0xffffffff,
  124. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  125. 0x0fafcc04, 0x08afcc00, 0x3fbfcc47, 0xffffffff,
  126. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  127. 0x0fafcc04, 0x0cafcc00, 0x01afcc4c, 0x0cafcc00,
  128. 0x01afcc4c, 0x0cafcc00, 0x01afcc4c, 0x0cafcc00,
  129. 0x31bfcc43, 0xffffffff, 0xffffffff, 0xffffffff,
  130. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  131. 0xc0ffcc84, 0x01ffcc04, 0x7fffcc86, 0xffffcc05,
  132. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  133. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  134. 0x33ffcc07, 0xffffffff, 0xffffffff, 0xffffffff };
  135. const uint edo_60ns[] =
  136. { 0x0ffbcc04, 0x0cf3cc04, 0x00f3cc00, 0x33f7cc47,
  137. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  138. 0x0ffbcc04, 0x09f3cc0c, 0x09f3cc0c, 0x09f3cc0c,
  139. 0x08f3cc00, 0x3ff7cc47, 0xffffffff, 0xffffffff,
  140. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  141. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  142. 0x0fefcc04, 0x08afcc04, 0x00afcc00, 0x3fbfcc47,
  143. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  144. 0x0fefcc04, 0x08afcc00, 0x07afcc48, 0x08afcc48,
  145. 0x08afcc48, 0x39bfcc47, 0xffffffff, 0xffffffff,
  146. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  147. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  148. 0x80ffcc84, 0x13ffcc04, 0xffffcc87, 0xffffcc05,
  149. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  150. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  151. 0x33ffcc07, 0xffffffff, 0xffffffff, 0xffffffff };
  152. const uint edo_70ns[] =
  153. { 0x0ffbcc04, 0x0cf3cc04, 0x00f3cc00, 0x33f7cc47,
  154. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  155. 0x0ffbec04, 0x08f3ec04, 0x03f3ec48, 0x08f3cc00,
  156. 0x0ff3cc4c, 0x08f3cc00, 0x0ff3cc4c, 0x08f3cc00,
  157. 0x3ff7cc47, 0xffffffff, 0xffffffff, 0xffffffff,
  158. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  159. 0x0fefcc04, 0x08afcc04, 0x00afcc00, 0x3fbfcc47,
  160. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  161. 0x0fefcc04, 0x08afcc00, 0x07afcc4c, 0x08afcc00,
  162. 0x07afcc4c, 0x08afcc00, 0x07afcc4c, 0x08afcc00,
  163. 0x37bfcc47, 0xffffffff, 0xffffffff, 0xffffffff,
  164. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  165. 0xc0ffcc84, 0x01ffcc04, 0x7fffcc86, 0xffffcc05,
  166. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  167. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  168. 0x33ffcc07, 0xffffffff, 0xffffffff, 0xffffffff };
  169. #else
  170. #error dram not correct defined - use CONFIG_DRAM_25MHZ or CONFIG_DRAM_50MHZ
  171. #endif
  172. /* ------------------------------------------------------------------------- */
  173. /*
  174. * Check Board Identity:
  175. */
  176. int checkboard (void)
  177. {
  178. uint k;
  179. puts ("Board: ");
  180. #ifdef CONFIG_FADS
  181. k = (*((uint *)BCSR3) >> 24) & 0x3f;
  182. switch(k) {
  183. case 0x03 :
  184. case 0x20 :
  185. case 0x21 :
  186. case 0x22 :
  187. case 0x23 :
  188. case 0x24 :
  189. case 0x2a :
  190. case 0x3f :
  191. puts ("FADS");
  192. break;
  193. default :
  194. printf("unknown board (0x%02x)\n", k);
  195. return -1;
  196. }
  197. printf(" with db ");
  198. switch(k) {
  199. case 0x03 :
  200. puts ("MPC823");
  201. break;
  202. case 0x20 :
  203. puts ("MPC801");
  204. break;
  205. case 0x21 :
  206. puts ("MPC850");
  207. break;
  208. case 0x22 :
  209. puts ("MPC821, MPC860 / MPC860SAR / MPC860T");
  210. break;
  211. case 0x23 :
  212. puts ("MPC860SAR");
  213. break;
  214. case 0x24 :
  215. puts ("MPC860T");
  216. break;
  217. case 0x3f :
  218. puts ("MPC850SAR");
  219. break;
  220. }
  221. printf(" rev ");
  222. k = (((*((uint *)BCSR3) >> 23) & 1) << 3)
  223. | (((*((uint *)BCSR3) >> 19) & 1) << 2)
  224. | (((*((uint *)BCSR3) >> 16) & 3));
  225. switch(k) {
  226. case 0x01 :
  227. puts ("ENG or PILOT\n");
  228. break;
  229. default:
  230. printf("unknown (0x%x)\n", k);
  231. return -1;
  232. }
  233. return 0;
  234. #endif /* CONFIG_FADS */
  235. #ifdef CONFIG_ADS
  236. printf("ADS rev ");
  237. k = (((*((uint *)BCSR3) >> 23) & 1) << 3)
  238. | (((*((uint *)BCSR3) >> 19) & 1) << 2)
  239. | (((*((uint *)BCSR3) >> 16) & 3));
  240. switch(k) {
  241. case 0x00 : puts ("ENG - this board sucks, check the errata, not supported\n");
  242. return -1;
  243. case 0x01 : puts ("PILOT - warning, read errata \n"); break;
  244. case 0x02 : puts ("A - warning, read errata \n"); break;
  245. case 0x03 : puts ("B \n"); break;
  246. default : printf ("unknown revision (0x%x)\n", k); return -1;
  247. }
  248. return 0;
  249. #endif /* CONFIG_ADS */
  250. }
  251. /* ------------------------------------------------------------------------- */
  252. int _draminit(uint base, uint noMbytes, uint edo, uint delay)
  253. {
  254. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  255. volatile memctl8xx_t *memctl = &immap->im_memctl;
  256. /* init upm */
  257. switch(delay)
  258. {
  259. case 70:
  260. {
  261. if(edo)
  262. {
  263. upmconfig(UPMA, (uint *) edo_70ns, sizeof(edo_70ns)/sizeof(uint));
  264. }
  265. else
  266. {
  267. upmconfig(UPMA, (uint *) dram_70ns, sizeof(dram_70ns)/sizeof(uint));
  268. }
  269. break;
  270. }
  271. case 60:
  272. {
  273. if(edo)
  274. {
  275. upmconfig(UPMA, (uint *) edo_60ns, sizeof(edo_60ns)/sizeof(uint));
  276. }
  277. else
  278. {
  279. upmconfig(UPMA, (uint *) dram_60ns, sizeof(dram_60ns)/sizeof(uint));
  280. }
  281. break;
  282. }
  283. default :
  284. return -1;
  285. }
  286. memctl->memc_mptpr = 0x0400; /* divide by 16 */
  287. switch(noMbytes)
  288. {
  289. case 8: /* 8 Mbyte uses both CS3 and CS2 */
  290. {
  291. memctl->memc_mamr = 0x13a01114;
  292. memctl->memc_or3 = 0xffc00800;
  293. memctl->memc_br3 = 0x00400081 + base;
  294. memctl->memc_or2 = 0xffc00800;
  295. break;
  296. }
  297. case 4: /* 4 Mbyte uses only CS2 */
  298. {
  299. memctl->memc_mamr = 0x13a01114;
  300. memctl->memc_or2 = 0xffc00800;
  301. break;
  302. }
  303. case 32: /* 32 Mbyte uses both CS3 and CS2 */
  304. {
  305. memctl->memc_mamr = 0x13b01114;
  306. memctl->memc_or3 = 0xff000800;
  307. memctl->memc_br3 = 0x01000081 + base;
  308. memctl->memc_or2 = 0xff000800;
  309. break;
  310. }
  311. case 16: /* 16 Mbyte uses only CS2 */
  312. {
  313. #ifdef CONFIG_ADS
  314. memctl->memc_mamr = 0x60b21114;
  315. #else
  316. memctl->memc_mamr = 0x13b01114;
  317. #endif
  318. memctl->memc_or2 = 0xff000800;
  319. break;
  320. }
  321. default:
  322. return -1;
  323. }
  324. memctl->memc_br2 = 0x81 + base; /* use upma */
  325. return 0;
  326. }
  327. /* ------------------------------------------------------------------------- */
  328. void _dramdisable(void)
  329. {
  330. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  331. volatile memctl8xx_t *memctl = &immap->im_memctl;
  332. memctl->memc_br2 = 0x00000000;
  333. memctl->memc_br3 = 0x00000000;
  334. /* maybe we should turn off upma here or something */
  335. }
  336. #if defined(CONFIG_SDRAM_100MHZ)
  337. /* ------------------------------------------------------------------------- */
  338. /* sdram table by Dan Malek */
  339. /* This has the stretched early timing so the 50 MHz
  340. * processor can make the 100 MHz timing. This will
  341. * work at all processor speeds.
  342. */
  343. #define SDRAM_MPTPRVALUE 0x0400
  344. #define SDRAM_MBMRVALUE0 0xc3802114 /* (16-14) 50 MHz */
  345. #define SDRAM_MBMRVALUE1 SDRAM_MBMRVALUE0
  346. #define SDRAM_OR4VALUE 0xffc00a00
  347. #define SDRAM_BR4VALUE 0x000000c1 /* base address will be or:ed on */
  348. #define SDRAM_MARVALUE 0x88
  349. #define SDRAM_MCRVALUE0 0x80808111 /* run pattern 0x11 */
  350. #define SDRAM_MCRVALUE1 SDRAM_MCRVALUE0
  351. const uint sdram_table[] =
  352. {
  353. /* single read. (offset 0 in upm RAM) */
  354. 0xefebfc24, 0x1f07fc24, 0xeeaefc04, 0x11adfc04,
  355. 0xefbbbc00, 0x1ff77c45, 0xffffffff, 0xffffffff,
  356. /* burst read. (offset 8 in upm RAM) */
  357. 0xefebfc24, 0x1f07fc24, 0xeeaefc04, 0x10adfc04,
  358. 0xf0affc00, 0xf0affc00, 0xf1affc00, 0xefbbbc00,
  359. 0x1ff77c45, 0xeffbbc04, 0x1ff77c34, 0xefeabc34,
  360. 0x1fb57c35, 0xffffffff, 0xffffffff, 0xffffffff,
  361. /* single write. (offset 18 in upm RAM) */
  362. 0xefebfc24, 0x1f07fc24, 0xeeaebc00, 0x01b93c04,
  363. 0x1ff77c45, 0xffffffff, 0xffffffff, 0xffffffff,
  364. /* burst write. (offset 20 in upm RAM) */
  365. 0xefebfc24, 0x1f07fc24, 0xeeaebc00, 0x10ad7c00,
  366. 0xf0affc00, 0xf0affc00, 0xe1bbbc04, 0x1ff77c45,
  367. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  368. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  369. /* refresh. (offset 30 in upm RAM) */
  370. 0xeffafc84, 0x1ff5fc04, 0xfffffc04, 0xfffffc04,
  371. 0xfffffc84, 0xfffffc07, 0xffffffff, 0xffffffff,
  372. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  373. /* exception. (offset 3c in upm RAM) */
  374. 0xeffffc06, 0x1ffffc07, 0xffffffff, 0xffffffff };
  375. #elif defined(CONFIG_SDRAM_50MHZ)
  376. /* ------------------------------------------------------------------------- */
  377. /* sdram table stolen from the fads manual */
  378. /* for chip MB811171622A-100 */
  379. /* this table is for 32-50MHz operation */
  380. #define _not_used_ 0xffffffff
  381. #define SDRAM_MPTPRVALUE 0x0400
  382. #define SDRAM_MBMRVALUE0 0x80802114 /* refresh at 32MHz */
  383. #define SDRAM_MBMRVALUE1 0x80802118
  384. #define SDRAM_OR4VALUE 0xffc00a00
  385. #define SDRAM_BR4VALUE 0x000000c1 /* base address will be or:ed on */
  386. #define SDRAM_MARVALUE 0x88
  387. #define SDRAM_MCRVALUE0 0x80808105
  388. #define SDRAM_MCRVALUE1 0x80808130
  389. const uint sdram_table[] =
  390. {
  391. /* single read. (offset 0 in upm RAM) */
  392. 0x1f07fc04, 0xeeaefc04, 0x11adfc04, 0xefbbbc00,
  393. 0x1ff77c47,
  394. /* MRS initialization (offset 5) */
  395. 0x1ff77c34, 0xefeabc34, 0x1fb57c35,
  396. /* burst read. (offset 8 in upm RAM) */
  397. 0x1f07fc04, 0xeeaefc04, 0x10adfc04, 0xf0affc00,
  398. 0xf0affc00, 0xf1affc00, 0xefbbbc00, 0x1ff77c47,
  399. _not_used_, _not_used_, _not_used_, _not_used_,
  400. _not_used_, _not_used_, _not_used_, _not_used_,
  401. /* single write. (offset 18 in upm RAM) */
  402. 0x1f27fc04, 0xeeaebc00, 0x01b93c04, 0x1ff77c47,
  403. _not_used_, _not_used_, _not_used_, _not_used_,
  404. /* burst write. (offset 20 in upm RAM) */
  405. 0x1f07fc04, 0xeeaebc00, 0x10ad7c00, 0xf0affc00,
  406. 0xf0affc00, 0xe1bbbc04, 0x1ff77c47, _not_used_,
  407. _not_used_, _not_used_, _not_used_, _not_used_,
  408. _not_used_, _not_used_, _not_used_, _not_used_,
  409. /* refresh. (offset 30 in upm RAM) */
  410. 0x1ff5fc84, 0xfffffc04, 0xfffffc04, 0xfffffc04,
  411. 0xfffffc84, 0xfffffc07, _not_used_, _not_used_,
  412. _not_used_, _not_used_, _not_used_, _not_used_,
  413. /* exception. (offset 3c in upm RAM) */
  414. 0x7ffffc07, _not_used_, _not_used_, _not_used_ };
  415. /* ------------------------------------------------------------------------- */
  416. #else
  417. #error SDRAM not correctly configured
  418. #endif
  419. int _initsdram(uint base, uint noMbytes)
  420. {
  421. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  422. volatile memctl8xx_t *memctl = &immap->im_memctl;
  423. if(noMbytes != 4)
  424. {
  425. return -1;
  426. }
  427. upmconfig(UPMB, (uint *)sdram_table,sizeof(sdram_table)/sizeof(uint));
  428. memctl->memc_mptpr = SDRAM_MPTPRVALUE;
  429. /* Configure the refresh (mostly). This needs to be
  430. * based upon processor clock speed and optimized to provide
  431. * the highest level of performance. For multiple banks,
  432. * this time has to be divided by the number of banks.
  433. * Although it is not clear anywhere, it appears the
  434. * refresh steps through the chip selects for this UPM
  435. * on each refresh cycle.
  436. * We have to be careful changing
  437. * UPM registers after we ask it to run these commands.
  438. */
  439. memctl->memc_mbmr = SDRAM_MBMRVALUE0;
  440. memctl->memc_mar = SDRAM_MARVALUE; /* MRS code */
  441. udelay(200);
  442. /* Now run the precharge/nop/mrs commands.
  443. */
  444. memctl->memc_mcr = 0x80808111; /* run pattern 0x11 */
  445. udelay(200);
  446. /* Run 8 refresh cycles */
  447. memctl->memc_mcr = SDRAM_MCRVALUE0;
  448. udelay(200);
  449. memctl->memc_mbmr = SDRAM_MBMRVALUE1;
  450. memctl->memc_mcr = SDRAM_MCRVALUE1;
  451. udelay(200);
  452. memctl->memc_mbmr = SDRAM_MBMRVALUE0;
  453. memctl->memc_or4 = SDRAM_OR4VALUE;
  454. memctl->memc_br4 = SDRAM_BR4VALUE | base;
  455. return 0;
  456. }
  457. /* ------------------------------------------------------------------------- */
  458. void _sdramdisable(void)
  459. {
  460. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  461. volatile memctl8xx_t *memctl = &immap->im_memctl;
  462. memctl->memc_br4 = 0x00000000;
  463. /* maybe we should turn off upmb here or something */
  464. }
  465. /* ------------------------------------------------------------------------- */
  466. int initsdram(uint base, uint *noMbytes)
  467. {
  468. uint m = 4;
  469. *((uint *)BCSR1) |= BCSR1_SDRAM_EN; /* enable sdram */
  470. /* _fads_sdraminit needs access to sdram */
  471. *noMbytes = m;
  472. if(!_initsdram(base, m))
  473. {
  474. return 0;
  475. }
  476. else
  477. {
  478. *((uint *)BCSR1) &= ~BCSR1_SDRAM_EN; /* disable sdram */
  479. _sdramdisable();
  480. return -1;
  481. }
  482. }
  483. long int initdram (int board_type)
  484. {
  485. #ifdef CONFIG_ADS
  486. /* ADS: has no SDRAM, so start DRAM at 0 */
  487. uint base = (unsigned long)0x0;
  488. #else
  489. /* FADS: has 4MB SDRAM, put DRAM above it */
  490. uint base = (unsigned long)0x00400000;
  491. #endif
  492. uint k, m, s;
  493. k = (*((uint *)BCSR2) >> 23) & 0x0f;
  494. m = 0;
  495. switch(k & 0x3)
  496. {
  497. /* "MCM36100 / MT8D132X" */
  498. case 0x00 :
  499. m = 4;
  500. break;
  501. /* "MCM36800 / MT16D832X" */
  502. case 0x01 :
  503. m = 32;
  504. break;
  505. /* "MCM36400 / MT8D432X" */
  506. case 0x02 :
  507. m = 16;
  508. break;
  509. /* "MCM36200 / MT16D832X ?" */
  510. case 0x03 :
  511. m = 8;
  512. break;
  513. }
  514. switch(k >> 2)
  515. {
  516. case 0x02 :
  517. k = 70;
  518. break;
  519. case 0x03 :
  520. k = 60;
  521. break;
  522. default :
  523. printf("unknown dramdelay (0x%x) - defaulting to 70 ns", k);
  524. k = 70;
  525. }
  526. #ifdef CONFIG_FADS
  527. /* the FADS is missing this bit, all rams treated as non-edo */
  528. s = 0;
  529. #else
  530. s = (*((uint *)BCSR2) >> 27) & 0x01;
  531. #endif
  532. if(!_draminit(base, m, s, k))
  533. {
  534. #ifdef CONFIG_FADS
  535. uint sdramsz;
  536. #endif
  537. *((uint *)BCSR1) &= ~BCSR1_DRAM_EN; /* enable dram */
  538. #ifdef CONFIG_FADS
  539. if (!initsdram(0x00000000, &sdramsz)) {
  540. m += sdramsz;
  541. printf("(%u MB SDRAM) ", sdramsz);
  542. } else {
  543. _dramdisable();
  544. /********************************
  545. *DRAM ERROR, HALT PROCESSOR
  546. *********************************/
  547. while(1);
  548. return -1;
  549. }
  550. #endif
  551. return (m << 20);
  552. }
  553. else
  554. {
  555. _dramdisable();
  556. /********************************
  557. *DRAM ERROR, HALT PROCESSOR
  558. *********************************/
  559. while(1);
  560. return -1;
  561. }
  562. }
  563. /* ------------------------------------------------------------------------- */
  564. int testdram (void)
  565. {
  566. /* TODO: XXX XXX XXX */
  567. printf ("test: 16 MB - ok\n");
  568. return (0);
  569. }
  570. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  571. #ifdef CFG_PCMCIA_MEM_ADDR
  572. volatile unsigned char *pcmcia_mem = (unsigned char*)CFG_PCMCIA_MEM_ADDR;
  573. #endif
  574. int pcmcia_init(void)
  575. {
  576. volatile pcmconf8xx_t *pcmp;
  577. uint v, slota, slotb;
  578. /*
  579. ** Enable the PCMCIA for a Flash card.
  580. */
  581. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  582. #if 0
  583. pcmp->pcmc_pbr0 = CFG_PCMCIA_MEM_ADDR;
  584. pcmp->pcmc_por0 = 0xc00ff05d;
  585. #endif
  586. /* Set all slots to zero by default. */
  587. pcmp->pcmc_pgcra = 0;
  588. pcmp->pcmc_pgcrb = 0;
  589. #ifdef PCMCIA_SLOT_A
  590. pcmp->pcmc_pgcra = 0x40;
  591. #endif
  592. #ifdef PCMCIA_SLOT_B
  593. pcmp->pcmc_pgcrb = 0x40;
  594. #endif
  595. /* enable PCMCIA buffers */
  596. *((uint *)BCSR1) &= ~BCSR1_PCCEN;
  597. /* Check if any PCMCIA card is plugged in. */
  598. slota = (pcmp->pcmc_pipr & 0x18000000) == 0 ;
  599. slotb = (pcmp->pcmc_pipr & 0x00001800) == 0 ;
  600. if (!(slota || slotb))
  601. {
  602. printf("No card present\n");
  603. #ifdef PCMCIA_SLOT_A
  604. pcmp->pcmc_pgcra = 0;
  605. #endif
  606. #ifdef PCMCIA_SLOT_B
  607. pcmp->pcmc_pgcrb = 0;
  608. #endif
  609. return -1;
  610. }
  611. else
  612. printf("Card present (");
  613. v = 0;
  614. /* both the ADS and the FADS have a 5V keyed pcmcia connector (?)
  615. **
  616. ** Paolo - Yes, but i have to insert some 3.3V card in that slot on
  617. ** my FADS... :-)
  618. */
  619. #if defined(CONFIG_MPC860)
  620. switch( (pcmp->pcmc_pipr >> 30) & 3 )
  621. #elif defined(CONFIG_MPC823) || defined(CONFIG_MPC850)
  622. switch( (pcmp->pcmc_pipr >> 14) & 3 )
  623. #endif
  624. {
  625. case 0x00 :
  626. printf("5V");
  627. v = 5;
  628. break;
  629. case 0x01 :
  630. printf("5V and 3V");
  631. #ifdef CONFIG_FADS
  632. v = 3; /* User lower voltage if supported! */
  633. #else
  634. v = 5;
  635. #endif
  636. break;
  637. case 0x03 :
  638. printf("5V, 3V and x.xV");
  639. #ifdef CONFIG_FADS
  640. v = 3; /* User lower voltage if supported! */
  641. #else
  642. v = 5;
  643. #endif
  644. break;
  645. }
  646. switch(v){
  647. #ifdef CONFIG_FADS
  648. case 3:
  649. printf("; using 3V");
  650. /*
  651. ** Enable 3 volt Vcc.
  652. */
  653. *((uint *)BCSR1) &= ~BCSR1_PCCVCC1;
  654. *((uint *)BCSR1) |= BCSR1_PCCVCC0;
  655. break;
  656. #endif
  657. case 5:
  658. printf("; using 5V");
  659. #ifdef CONFIG_ADS
  660. /*
  661. ** Enable 5 volt Vcc.
  662. */
  663. *((uint *)BCSR1) &= ~BCSR1_PCCVCCON;
  664. #endif
  665. #ifdef CONFIG_FADS
  666. /*
  667. ** Enable 5 volt Vcc.
  668. */
  669. *((uint *)BCSR1) &= ~BCSR1_PCCVCC0;
  670. *((uint *)BCSR1) |= BCSR1_PCCVCC1;
  671. #endif
  672. break;
  673. default:
  674. *((uint *)BCSR1) |= BCSR1_PCCEN; /* disable pcmcia */
  675. printf("; unknown voltage");
  676. return -1;
  677. }
  678. printf(")\n");
  679. /* disable pcmcia reset after a while */
  680. udelay(20);
  681. #ifdef MPC860
  682. pcmp->pcmc_pgcra = 0;
  683. #elif MPC823
  684. pcmp->pcmc_pgcrb = 0;
  685. #endif
  686. /* If you using a real hd you should give a short
  687. * spin-up time. */
  688. #ifdef CONFIG_DISK_SPINUP_TIME
  689. udelay(CONFIG_DISK_SPINUP_TIME);
  690. #endif
  691. return 0;
  692. }
  693. #endif /* CFG_CMD_PCMCIA */
  694. /* ------------------------------------------------------------------------- */
  695. #ifdef CFG_PC_IDE_RESET
  696. void ide_set_reset(int on)
  697. {
  698. volatile immap_t *immr = (immap_t *)CFG_IMMR;
  699. /*
  700. * Configure PC for IDE Reset Pin
  701. */
  702. if (on) { /* assert RESET */
  703. immr->im_ioport.iop_pcdat &= ~(CFG_PC_IDE_RESET);
  704. } else { /* release RESET */
  705. immr->im_ioport.iop_pcdat |= CFG_PC_IDE_RESET;
  706. }
  707. /* program port pin as GPIO output */
  708. immr->im_ioport.iop_pcpar &= ~(CFG_PC_IDE_RESET);
  709. immr->im_ioport.iop_pcso &= ~(CFG_PC_IDE_RESET);
  710. immr->im_ioport.iop_pcdir |= CFG_PC_IDE_RESET;
  711. }
  712. #endif /* CFG_PC_IDE_RESET */
  713. /* ------------------------------------------------------------------------- */