ispan.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. /*
  2. * Copyright (C) 2004 Arabella Software Ltd.
  3. * Yuli Barcohen <yuli@arabellasw.com>
  4. *
  5. * Support for Interphase iSPAN Communications Controllers
  6. * (453x and others). Tested on 4532.
  7. *
  8. * Derived from iSPAN 4539 port (iphase4539) by
  9. * Wolfgang Grandegger <wg@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 <ioports.h>
  31. #include <mpc8260.h>
  32. #include <asm/io.h>
  33. /*
  34. * I/O Ports configuration table
  35. *
  36. * If conf is 1, then that port pin will be configured at boot time
  37. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  38. */
  39. #define CFG_FCC1 (CONFIG_ETHER_INDEX == 1)
  40. #define CFG_FCC2 (CONFIG_ETHER_INDEX == 2)
  41. #define CFG_FCC3 (CONFIG_ETHER_INDEX == 3)
  42. const iop_conf_t iop_conf_tab[4][32] = {
  43. /* Port A */
  44. { /* conf ppar psor pdir podr pdat */
  45. /* PA31 */ { CFG_FCC1, 1, 1, 0, 0, 0 }, /* FCC1 MII COL */
  46. /* PA30 */ { CFG_FCC1, 1, 1, 0, 0, 0 }, /* FCC1 MII CRS */
  47. /* PA29 */ { CFG_FCC1, 1, 1, 1, 0, 0 }, /* FCC1 MII TX_ER */
  48. /* PA28 */ { CFG_FCC1, 1, 1, 1, 0, 0 }, /* FCC1 MII TX_EN */
  49. /* PA27 */ { CFG_FCC1, 1, 1, 0, 0, 0 }, /* FCC1 MII RX_DV */
  50. /* PA26 */ { CFG_FCC1, 1, 1, 0, 0, 0 }, /* FCC1 MII RX_ER */
  51. /* PA25 */ { 0, 0, 0, 0, 0, 0 }, /* PA25 */
  52. /* PA24 */ { 0, 0, 0, 0, 0, 0 }, /* PA24 */
  53. /* PA23 */ { 0, 0, 0, 0, 0, 0 }, /* PA23 */
  54. /* PA22 */ { 0, 0, 0, 0, 0, 0 }, /* PA22 */
  55. /* PA21 */ { CFG_FCC1, 1, 0, 1, 0, 0 }, /* FCC1 MII TxD[3] */
  56. /* PA20 */ { CFG_FCC1, 1, 0, 1, 0, 0 }, /* FCC1 MII TxD[2] */
  57. /* PA19 */ { CFG_FCC1, 1, 0, 1, 0, 0 }, /* FCC1 MII TxD[1] */
  58. /* PA18 */ { CFG_FCC1, 1, 0, 1, 0, 0 }, /* FCC1 MII TxD[0] */
  59. /* PA17 */ { CFG_FCC1, 1, 0, 0, 0, 0 }, /* FCC1 MII RxD[0] */
  60. /* PA16 */ { CFG_FCC1, 1, 0, 0, 0, 0 }, /* FCC1 MII RxD[1] */
  61. /* PA15 */ { CFG_FCC1, 1, 0, 0, 0, 0 }, /* FCC1 MII RxD[2] */
  62. /* PA14 */ { CFG_FCC1, 1, 0, 0, 0, 0 }, /* FCC1 MII RxD[3] */
  63. /* PA13 */ { 0, 0, 0, 0, 0, 0 }, /* PA13 */
  64. /* PA12 */ { 0, 0, 0, 0, 0, 0 }, /* PA12 */
  65. /* PA11 */ { 0, 0, 0, 0, 0, 0 }, /* PA11 */
  66. /* PA10 */ { 0, 0, 0, 0, 0, 0 }, /* PA10 */
  67. /* PA9 */ { 0, 1, 0, 1, 0, 0 }, /* SMC2 SMTXD */
  68. /* PA8 */ { 0, 1, 0, 0, 0, 0 }, /* SMC2 SMRXD */
  69. /* PA7 */ { 0, 0, 0, 0, 0, 0 }, /* PA7 */
  70. /* PA6 */ { 0, 0, 0, 0, 0, 0 }, /* PA6 */
  71. /* PA5 */ { 0, 0, 0, 0, 0, 0 }, /* PA5 */
  72. /* PA4 */ { 0, 0, 0, 0, 0, 0 }, /* PA4 */
  73. /* PA3 */ { 0, 0, 0, 0, 0, 0 }, /* PA3 */
  74. /* PA2 */ { 0, 0, 0, 0, 0, 0 }, /* PA2 */
  75. /* PA1 */ { 0, 0, 0, 0, 0, 0 }, /* PA1 */
  76. /* PA0 */ { 0, 0, 0, 0, 0, 0 } /* PA0 */
  77. },
  78. /* Port B */
  79. { /* conf ppar psor pdir podr pdat */
  80. /* PB31 */ { CFG_FCC2, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
  81. /* PB30 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
  82. /* PB29 */ { CFG_FCC2, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
  83. /* PB28 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
  84. /* PB27 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
  85. /* PB26 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
  86. /* PB25 */ { CFG_FCC2, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
  87. /* PB24 */ { CFG_FCC2, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
  88. /* PB23 */ { CFG_FCC2, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
  89. /* PB22 */ { CFG_FCC2, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
  90. /* PB21 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
  91. /* PB20 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
  92. /* PB19 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
  93. /* PB18 */ { CFG_FCC2, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
  94. /* PB17 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3 MII RX_DV */
  95. /* PB16 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3 MII RX_ER */
  96. /* PB15 */ { CFG_FCC3, 1, 0, 1, 0, 0 }, /* FCC3 MII TX_ER */
  97. /* PB14 */ { CFG_FCC3, 1, 0, 1, 0, 0 }, /* FCC3 MII TX_EN */
  98. /* PB13 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3 MII COL */
  99. /* PB12 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3 MII CRS */
  100. /* PB11 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3 MII RxD[3] */
  101. /* PB10 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3 MII RxD[2] */
  102. /* PB9 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3 MII RxD[1] */
  103. /* PB8 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3 MII RxD[0] */
  104. /* PB7 */ { CFG_FCC3, 1, 0, 1, 0, 0 }, /* FCC3 MII TxD[0] */
  105. /* PB6 */ { CFG_FCC3, 1, 0, 1, 0, 0 }, /* FCC3 MII TxD[1] */
  106. /* PB5 */ { CFG_FCC3, 1, 0, 1, 0, 0 }, /* FCC3 MII TxD[2] */
  107. /* PB4 */ { CFG_FCC3, 1, 0, 1, 0, 0 }, /* FCC3 MII TxD[3] */
  108. /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  109. /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  110. /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  111. /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  112. },
  113. /* Port C */
  114. { /* conf ppar psor pdir podr pdat */
  115. /* PC31 */ { 0, 0, 0, 0, 0, 0 }, /* PC31 */
  116. /* PC30 */ { 0, 0, 0, 0, 0, 0 }, /* PC30 */
  117. /* PC29 */ { 0, 0, 0, 0, 0, 0 }, /* PC29 */
  118. /* PC28 */ { 0, 0, 0, 0, 0, 0 }, /* PC28 */
  119. /* PC27 */ { 0, 0, 0, 0, 0, 0 }, /* PC27 */
  120. /* PC26 */ { 0, 0, 0, 0, 0, 0 }, /* PC26 */
  121. /* PC25 */ { 0, 0, 0, 0, 0, 0 }, /* PC25 */
  122. /* PC24 */ { 0, 0, 0, 0, 0, 0 }, /* PC24 */
  123. /* PC23 */ { 0, 0, 0, 0, 0, 0 }, /* PC23 */
  124. /* PC22 */ { 0, 0, 0, 0, 0, 0 }, /* PC22 */
  125. /* PC21 */ { 0, 0, 0, 0, 0, 0 }, /* PC21 */
  126. /* PC20 */ { 0, 0, 0, 0, 0, 0 }, /* PC20 */
  127. /* PC19 */ { 0, 0, 0, 0, 0, 0 }, /* PC19 */
  128. /* PC18 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3 MII Rx Clock (CLK14) */
  129. /* PC17 */ { 0, 0, 0, 0, 0, 0 }, /* PC17 */
  130. /* PC16 */ { CFG_FCC3, 1, 0, 0, 0, 0 }, /* FCC3 MII Tx Clock (CLK16) */
  131. /* PC15 */ { 0, 0, 0, 0, 0, 0 }, /* PC15 */
  132. /* PC14 */ { 0, 0, 0, 0, 0, 0 }, /* PC14 */
  133. /* PC13 */ { 0, 0, 0, 0, 0, 0 }, /* PC13 */
  134. /* PC12 */ { 0, 0, 0, 0, 0, 0 }, /* PC12 */
  135. /* PC11 */ { 0, 0, 0, 0, 0, 0 }, /* PC11 */
  136. /* PC10 */ { 0, 0, 0, 0, 0, 0 }, /* PC10 */
  137. /* PC9 */ { 0, 0, 0, 0, 0, 0 }, /* PC9 */
  138. /* PC8 */ { 0, 0, 0, 0, 0, 0 }, /* PC8 */
  139. /* PC7 */ { 0, 0, 0, 0, 0, 0 }, /* PC7 */
  140. /* PC6 */ { 0, 0, 0, 0, 0, 0 }, /* PC6 */
  141. /* PC5 */ { 0, 0, 0, 0, 0, 0 }, /* PC5 */
  142. /* PC4 */ { 0, 0, 0, 0, 0, 0 }, /* PC4 */
  143. /* PC3 */ { 0, 0, 0, 0, 0, 0 }, /* PC3 */
  144. /* PC2 */ { 0, 0, 0, 0, 0, 0 }, /* PC2 */
  145. /* PC1 */ { 0, 0, 0, 0, 0, 0 }, /* PC1 */
  146. /* PC0 */ { 0, 0, 0, 0, 0, 0 } /* PC0 */
  147. },
  148. /* Port D */
  149. { /* conf ppar psor pdir podr pdat */
  150. /* PD31 */ { 0, 0, 0, 0, 0, 0 }, /* PD31 */
  151. /* PD30 */ { 0, 0, 0, 0, 0, 0 }, /* PD30 */
  152. /* PD29 */ { 0, 0, 0, 0, 0, 0 }, /* PD29 */
  153. /* PD28 */ { 0, 0, 0, 0, 0, 0 }, /* PD28 */
  154. /* PD27 */ { 0, 0, 0, 0, 0, 0 }, /* PD27 */
  155. /* PD26 */ { 0, 0, 0, 0, 0, 0 }, /* PD26 */
  156. /* PD25 */ { 0, 0, 0, 0, 0, 0 }, /* PD25 */
  157. /* PD24 */ { 0, 0, 0, 0, 0, 0 }, /* PD24 */
  158. /* PD23 */ { 0, 0, 0, 0, 0, 0 }, /* PD23 */
  159. /* PD22 */ { 0, 0, 0, 0, 0, 0 }, /* PD22 */
  160. /* PD21 */ { 0, 0, 0, 0, 0, 0 }, /* PD21 */
  161. /* PD20 */ { 0, 0, 0, 0, 0, 0 }, /* PD20 */
  162. /* PD19 */ { 0, 0, 0, 0, 0, 0 }, /* PD19 */
  163. /* PD18 */ { 0, 1, 1, 0, 0, 0 }, /* SPICLK */
  164. /* PD17 */ { 0, 1, 1, 0, 0, 0 }, /* SPIMOSI */
  165. /* PD16 */ { 0, 1, 1, 0, 0, 0 }, /* SPIMISO */
  166. /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */
  167. /* PD14 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SCL */
  168. /* PD13 */ { 1, 0, 0, 0, 0, 0 }, /* MII MDIO */
  169. /* PD12 */ { 1, 0, 0, 1, 0, 0 }, /* MII MDC */
  170. /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
  171. /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
  172. /* PD9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC1 SMTXD */
  173. /* PD8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1 SMRXD */
  174. /* PD7 */ { 0, 0, 0, 0, 0, 0 }, /* PD7 */
  175. /* PD6 */ { CFG_FCC3, 0, 0, 1, 0, 1 }, /* MII PHY Reset */
  176. /* PD5 */ { CFG_FCC3, 0, 0, 1, 0, 0 }, /* MII PHY Enable */
  177. /* PD4 */ { 0, 0, 0, 0, 0, 0 }, /* PD4 */
  178. /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  179. /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  180. /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
  181. /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
  182. }
  183. };
  184. #define PSPAN_ADDR 0xF0020000
  185. #define EEPROM_REG 0x408
  186. #define EEPROM_READ_CMD 0xA000
  187. #define PSPAN_WRITE(a,v) \
  188. *((volatile unsigned long *)(PSPAN_ADDR+(a))) = v; eieio()
  189. #define PSPAN_READ(a) \
  190. *((volatile unsigned long *)(PSPAN_ADDR+(a)))
  191. static int seeprom_read (int addr, uchar * data, int size)
  192. {
  193. ulong val, cmd;
  194. int i;
  195. for (i = 0; i < size; i++) {
  196. cmd = EEPROM_READ_CMD;
  197. cmd |= ((addr + i) << 24) & 0xff000000;
  198. /* Wait for ACT to authorize write */
  199. while ((val = PSPAN_READ (EEPROM_REG)) & 0x80)
  200. eieio ();
  201. /* Write command */
  202. PSPAN_WRITE (EEPROM_REG, cmd);
  203. /* Wait for data to be valid */
  204. while ((val = PSPAN_READ (EEPROM_REG)) & 0x80)
  205. eieio ();
  206. /* Do it twice, first read might be erratic */
  207. while ((val = PSPAN_READ (EEPROM_REG)) & 0x80)
  208. eieio ();
  209. /* Read error */
  210. if (val & 0x00000040) {
  211. return -1;
  212. } else {
  213. data[i] = (val >> 16) & 0xff;
  214. }
  215. }
  216. return 0;
  217. }
  218. /***************************************************************
  219. * We take some basic Hardware Configuration Parameter from the
  220. * Serial EEPROM conected to the PSpan bridge. We keep it as
  221. * simple as possible.
  222. */
  223. #ifdef DEBUG
  224. static int hwc_flash_size (void)
  225. {
  226. uchar byte;
  227. if (!seeprom_read (0x40, &byte, sizeof (byte))) {
  228. switch ((byte >> 2) & 0x3) {
  229. case 0x1:
  230. return 0x0400000;
  231. break;
  232. case 0x2:
  233. return 0x0800000;
  234. break;
  235. case 0x3:
  236. return 0x1000000;
  237. default:
  238. return 0x0100000;
  239. }
  240. }
  241. return -1;
  242. }
  243. static int hwc_local_sdram_size (void)
  244. {
  245. uchar byte;
  246. if (!seeprom_read (0x40, &byte, sizeof (byte))) {
  247. switch ((byte & 0x03)) {
  248. case 0x1:
  249. return 0x0800000;
  250. case 0x2:
  251. return 0x1000000;
  252. default:
  253. return 0; /* not present */
  254. }
  255. }
  256. return -1;
  257. }
  258. #endif /* DEBUG */
  259. static int hwc_main_sdram_size (void)
  260. {
  261. uchar byte;
  262. if (!seeprom_read (0x41, &byte, sizeof (byte))) {
  263. return 0x1000000 << ((byte >> 5) & 0x7);
  264. }
  265. return -1;
  266. }
  267. static int hwc_serial_number (void)
  268. {
  269. int sn = -1;
  270. if (!seeprom_read (0xa0, (char *) &sn, sizeof (sn))) {
  271. sn = cpu_to_le32 (sn);
  272. }
  273. return sn;
  274. }
  275. static int hwc_mac_address (char *str)
  276. {
  277. char mac[6];
  278. if (!seeprom_read (0xb0, mac, sizeof (mac))) {
  279. sprintf (str, "%02X:%02X:%02X:%02X:%02X:%02X",
  280. mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  281. } else {
  282. strcpy (str, "ERROR");
  283. return -1;
  284. }
  285. return 0;
  286. }
  287. static int hwc_manufact_date (char *str)
  288. {
  289. uchar byte;
  290. int value;
  291. if (seeprom_read (0x92, &byte, sizeof (byte)))
  292. goto out;
  293. value = byte;
  294. if (seeprom_read (0x93, &byte, sizeof (byte)))
  295. goto out;
  296. value += byte << 8;
  297. sprintf (str, "%02d/%02d/%04d",
  298. value & 0x1F, (value >> 5) & 0xF,
  299. 1980 + ((value >> 9) & 0x1FF));
  300. return 0;
  301. out:
  302. strcpy (str, "ERROR");
  303. return -1;
  304. }
  305. static int hwc_board_type (char **str)
  306. {
  307. ushort id = 0;
  308. if (seeprom_read (7, (uchar *) & id, sizeof (id)) == 0) {
  309. switch (id) {
  310. case 0x9080:
  311. *str = "4532-002";
  312. break;
  313. case 0x9081:
  314. *str = "4532-001";
  315. break;
  316. case 0x9082:
  317. *str = "4532-000";
  318. break;
  319. default:
  320. *str = "Unknown";
  321. }
  322. } else {
  323. *str = "Unknown";
  324. }
  325. return id;
  326. }
  327. long int initdram (int board_type)
  328. {
  329. long maxsize = hwc_main_sdram_size();
  330. #if !defined(CFG_RAMBOOT) && !defined(CFG_USE_FIRMWARE)
  331. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  332. volatile memctl8260_t *memctl = &immap->im_memctl;
  333. volatile uchar *base;
  334. int i;
  335. immap->im_siu_conf.sc_ppc_acr = 0x00000026;
  336. immap->im_siu_conf.sc_ppc_alrh = 0x01276345;
  337. immap->im_siu_conf.sc_ppc_alrl = 0x89ABCDEF;
  338. immap->im_siu_conf.sc_lcl_acr = 0x00000000;
  339. immap->im_siu_conf.sc_lcl_alrh = 0x01234567;
  340. immap->im_siu_conf.sc_lcl_alrl = 0x89ABCDEF;
  341. immap->im_siu_conf.sc_tescr1 = 0x00004000;
  342. immap->im_siu_conf.sc_ltescr1 = 0x00004000;
  343. memctl->memc_mptpr = CFG_MPTPR;
  344. /* Initialise 60x bus SDRAM */
  345. base = (uchar *)(CFG_SDRAM_BASE | 0x110);
  346. memctl->memc_psrt = CFG_PSRT;
  347. memctl->memc_or1 = CFG_60x_OR;
  348. memctl->memc_br1 = CFG_SDRAM_BASE | CFG_60x_BR;
  349. memctl->memc_psdmr = CFG_PSDMR | 0x28000000;
  350. *base = 0xFF;
  351. memctl->memc_psdmr = CFG_PSDMR | 0x08000000;
  352. for (i = 0; i < 8; i++)
  353. *base = 0xFF;
  354. memctl->memc_psdmr = CFG_PSDMR | 0x18000000;
  355. *base = 0xFF;
  356. memctl->memc_psdmr = CFG_PSDMR | 0x40000000;
  357. /* Initialise local bus SDRAM */
  358. base = (uchar *)CFG_LSDRAM_BASE;
  359. memctl->memc_lsrt = CFG_LSRT;
  360. memctl->memc_or2 = CFG_LOC_OR;
  361. memctl->memc_br2 = CFG_LSDRAM_BASE | CFG_LOC_BR;
  362. memctl->memc_lsdmr = CFG_LSDMR | 0x28000000;
  363. *base = 0xFF;
  364. memctl->memc_lsdmr = CFG_LSDMR | 0x08000000;
  365. for (i = 0; i < 8; i++)
  366. *base = 0xFF;
  367. memctl->memc_lsdmr = CFG_LSDMR | 0x18000000;
  368. *base = 0xFF;
  369. memctl->memc_lsdmr = CFG_LSDMR | 0x40000000;
  370. /* We must be able to test a location outsize the maximum legal size
  371. * to find out THAT we are outside; but this address still has to be
  372. * mapped by the controller. That means, that the initial mapping has
  373. * to be (at least) twice as large as the maximum expected size.
  374. */
  375. maxsize = (~(memctl->memc_or1 & BRx_BA_MSK) + 1) / 2;
  376. maxsize = get_ram_size((long *)(memctl->memc_br1 & BRx_BA_MSK), maxsize);
  377. memctl->memc_or1 |= ~(maxsize - 1);
  378. if (maxsize != hwc_main_sdram_size())
  379. puts("Oops: memory test has not found all memory!\n");
  380. #endif /* !CFG_RAMBOOT && !CFG_USE_FIRMWARE */
  381. /* Return total RAM size (size of 60x SDRAM) */
  382. return maxsize;
  383. }
  384. int checkboard(void)
  385. {
  386. char string[32], *id;
  387. hwc_manufact_date(string);
  388. hwc_board_type(&id);
  389. printf("Board: Interphase iSPAN %s (#%d %s)\n",
  390. id, hwc_serial_number(), string);
  391. #ifdef DEBUG
  392. printf("Manufacturing date: %s\n", string);
  393. printf("Serial number : %d\n", hwc_serial_number());
  394. printf("FLASH size : %d MB\n", hwc_flash_size() >> 20);
  395. printf("Main SDRAM size : %d MB\n", hwc_main_sdram_size() >> 20);
  396. printf("Local SDRAM size : %d MB\n", hwc_local_sdram_size() >> 20);
  397. hwc_mac_address(string);
  398. printf("MAC address : %s\n", string);
  399. #endif
  400. return 0;
  401. }
  402. int misc_init_r(void)
  403. {
  404. char *s, str[32];
  405. int num;
  406. if ((s = getenv("serial#")) == NULL &&
  407. (num = hwc_serial_number()) != -1) {
  408. sprintf(str, "%06d", num);
  409. setenv("serial#", str);
  410. }
  411. if ((s = getenv("ethaddr")) == NULL && hwc_mac_address(str) == 0) {
  412. setenv("ethaddr", str);
  413. }
  414. return 0;
  415. }