ispan.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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. static int hwc_flash_size (void)
  224. {
  225. uchar byte;
  226. if (!seeprom_read (0x40, &byte, sizeof (byte))) {
  227. switch ((byte >> 2) & 0x3) {
  228. case 0x1:
  229. return 0x0400000;
  230. break;
  231. case 0x2:
  232. return 0x0800000;
  233. break;
  234. case 0x3:
  235. return 0x1000000;
  236. default:
  237. return 0x0100000;
  238. }
  239. }
  240. return -1;
  241. }
  242. static int hwc_local_sdram_size (void)
  243. {
  244. uchar byte;
  245. if (!seeprom_read (0x40, &byte, sizeof (byte))) {
  246. switch ((byte & 0x03)) {
  247. case 0x1:
  248. return 0x0800000;
  249. case 0x2:
  250. return 0x1000000;
  251. default:
  252. return 0; /* not present */
  253. }
  254. }
  255. return -1;
  256. }
  257. static int hwc_main_sdram_size (void)
  258. {
  259. uchar byte;
  260. if (!seeprom_read (0x41, &byte, sizeof (byte))) {
  261. return 0x1000000 << ((byte >> 5) & 0x7);
  262. }
  263. return -1;
  264. }
  265. static int hwc_serial_number (void)
  266. {
  267. int sn = -1;
  268. if (!seeprom_read (0xa0, (char *) &sn, sizeof (sn))) {
  269. sn = cpu_to_le32 (sn);
  270. }
  271. return sn;
  272. }
  273. static int hwc_mac_address (char *str)
  274. {
  275. char mac[6];
  276. if (!seeprom_read (0xb0, mac, sizeof (mac))) {
  277. sprintf (str, "%02X:%02X:%02X:%02X:%02X:%02X",
  278. mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  279. } else {
  280. strcpy (str, "ERROR");
  281. return -1;
  282. }
  283. return 0;
  284. }
  285. static int hwc_manufact_date (char *str)
  286. {
  287. uchar byte;
  288. int value;
  289. if (seeprom_read (0x92, &byte, sizeof (byte)))
  290. goto out;
  291. value = byte;
  292. if (seeprom_read (0x93, &byte, sizeof (byte)))
  293. goto out;
  294. value += byte << 8;
  295. sprintf (str, "%02d/%02d/%04d",
  296. value & 0x1F, (value >> 5) & 0xF,
  297. 1980 + ((value >> 9) & 0x1FF));
  298. return 0;
  299. out:
  300. strcpy (str, "ERROR");
  301. return -1;
  302. }
  303. static int hwc_board_type (char **str)
  304. {
  305. ushort id = 0;
  306. if (seeprom_read (7, (uchar *) & id, sizeof (id)) == 0) {
  307. switch (id) {
  308. case 0x9080:
  309. *str = "4532-002";
  310. break;
  311. case 0x9081:
  312. *str = "4532-001";
  313. break;
  314. case 0x9082:
  315. *str = "4532-000";
  316. break;
  317. default:
  318. *str = "Unknown";
  319. }
  320. } else {
  321. *str = "Unknown";
  322. }
  323. return id;
  324. }
  325. long int initdram (int board_type)
  326. {
  327. long maxsize = hwc_main_sdram_size();
  328. #if !defined(CFG_RAMBOOT) && !defined(CFG_USE_FIRMWARE)
  329. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  330. volatile memctl8260_t *memctl = &immap->im_memctl;
  331. volatile uchar *base;
  332. int i;
  333. immap->im_siu_conf.sc_ppc_acr = 0x00000026;
  334. immap->im_siu_conf.sc_ppc_alrh = 0x01276345;
  335. immap->im_siu_conf.sc_ppc_alrl = 0x89ABCDEF;
  336. immap->im_siu_conf.sc_lcl_acr = 0x00000000;
  337. immap->im_siu_conf.sc_lcl_alrh = 0x01234567;
  338. immap->im_siu_conf.sc_lcl_alrl = 0x89ABCDEF;
  339. immap->im_siu_conf.sc_tescr1 = 0x00004000;
  340. immap->im_siu_conf.sc_ltescr1 = 0x00004000;
  341. memctl->memc_mptpr = CFG_MPTPR;
  342. /* Initialise 60x bus SDRAM */
  343. base = (uchar *)(CFG_SDRAM_BASE | 0x110);
  344. memctl->memc_psrt = CFG_PSRT;
  345. memctl->memc_or1 = CFG_60x_OR;
  346. memctl->memc_br1 = CFG_SDRAM_BASE | CFG_60x_BR;
  347. memctl->memc_psdmr = CFG_PSDMR | 0x28000000;
  348. *base = 0xFF;
  349. memctl->memc_psdmr = CFG_PSDMR | 0x08000000;
  350. for (i = 0; i < 8; i++)
  351. *base = 0xFF;
  352. memctl->memc_psdmr = CFG_PSDMR | 0x18000000;
  353. *base = 0xFF;
  354. memctl->memc_psdmr = CFG_PSDMR | 0x40000000;
  355. /* Initialise local bus SDRAM */
  356. base = (uchar *)CFG_LSDRAM_BASE;
  357. memctl->memc_lsrt = CFG_LSRT;
  358. memctl->memc_or2 = CFG_LOC_OR;
  359. memctl->memc_br2 = CFG_LSDRAM_BASE | CFG_LOC_BR;
  360. memctl->memc_lsdmr = CFG_LSDMR | 0x28000000;
  361. *base = 0xFF;
  362. memctl->memc_lsdmr = CFG_LSDMR | 0x08000000;
  363. for (i = 0; i < 8; i++)
  364. *base = 0xFF;
  365. memctl->memc_lsdmr = CFG_LSDMR | 0x18000000;
  366. *base = 0xFF;
  367. memctl->memc_lsdmr = CFG_LSDMR | 0x40000000;
  368. /* We must be able to test a location outsize the maximum legal size
  369. * to find out THAT we are outside; but this address still has to be
  370. * mapped by the controller. That means, that the initial mapping has
  371. * to be (at least) twice as large as the maximum expected size.
  372. */
  373. maxsize = (~(memctl->memc_or1 & BRx_BA_MSK) + 1) / 2;
  374. maxsize = get_ram_size((long *)(memctl->memc_br1 & BRx_BA_MSK), maxsize);
  375. memctl->memc_or1 |= ~(maxsize - 1);
  376. if (maxsize != hwc_main_sdram_size())
  377. puts("Oops: memory test has not found all memory!\n");
  378. #endif /* !CFG_RAMBOOT && !CFG_USE_FIRMWARE */
  379. /* Return total RAM size (size of 60x SDRAM) */
  380. return maxsize;
  381. }
  382. int checkboard(void)
  383. {
  384. char string[32], *id;
  385. hwc_manufact_date(string);
  386. hwc_board_type(&id);
  387. printf("Board: Interphase iSPAN %s (#%d %s)\n",
  388. id, hwc_serial_number(), string);
  389. #ifdef DEBUG
  390. printf("Manufacturing date: %s\n", string);
  391. printf("Serial number : %d\n", hwc_serial_number());
  392. printf("FLASH size : %d MB\n", hwc_flash_size() >> 20);
  393. printf("Main SDRAM size : %d MB\n", hwc_main_sdram_size() >> 20);
  394. printf("Local SDRAM size : %d MB\n", hwc_local_sdram_size() >> 20);
  395. hwc_mac_address(string);
  396. printf("MAC address : %s\n", string);
  397. #endif
  398. return 0;
  399. }
  400. int misc_init_r(void)
  401. {
  402. char *s, str[32];
  403. int num;
  404. if ((s = getenv("serial#")) == NULL &&
  405. (num = hwc_serial_number()) != -1) {
  406. sprintf(str, "%06d", num);
  407. setenv("serial#", str);
  408. }
  409. if ((s = getenv("ethaddr")) == NULL && hwc_mac_address(str) == 0) {
  410. setenv("ethaddr", str);
  411. }
  412. return 0;
  413. }