PPChameleonEVB.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. /*
  2. * (C) Copyright 2003
  3. * DAVE Srl
  4. * http://www.dave-tech.it
  5. * http://www.wawnet.biz
  6. * mailto:info@wawnet.biz
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <asm/processor.h>
  28. #include <command.h>
  29. #include <malloc.h>
  30. /* ------------------------------------------------------------------------- */
  31. /* Prototypes */
  32. int gunzip(void *, int, unsigned char *, unsigned long *);
  33. int board_early_init_f (void)
  34. {
  35. out32(GPIO0_OR, CFG_NAND0_CE); /* set initial outputs */
  36. out32(GPIO0_OR, CFG_NAND1_CE); /* set initial outputs */
  37. /*
  38. * IRQ 0-15 405GP internally generated; active high; level sensitive
  39. * IRQ 16 405GP internally generated; active low; level sensitive
  40. * IRQ 17-24 RESERVED
  41. * IRQ 25 (EXT IRQ 0)
  42. * IRQ 26 (EXT IRQ 1)
  43. * IRQ 27 (EXT IRQ 2)
  44. * IRQ 28 (EXT IRQ 3)
  45. * IRQ 29 (EXT IRQ 4)
  46. * IRQ 30 (EXT IRQ 5)
  47. * IRQ 31 (EXT IRQ 6)
  48. */
  49. mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
  50. mtdcr(uicer, 0x00000000); /* disable all ints */
  51. mtdcr(uiccr, 0x00000000); /* set all to be non-critical*/
  52. mtdcr(uicpr, 0xFFFFFF80); /* set int polarities */
  53. mtdcr(uictr, 0x10000000); /* set int trigger levels */
  54. mtdcr(uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority*/
  55. mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
  56. /*
  57. * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us
  58. */
  59. #if 1 /* test-only */
  60. mtebc (epcr, 0xa8400000); /* ebc always driven */
  61. #else
  62. mtebc (epcr, 0x28400000); /* ebc in high-z */
  63. #endif
  64. return 0;
  65. }
  66. /* ------------------------------------------------------------------------- */
  67. int misc_init_f (void)
  68. {
  69. return 0; /* dummy implementation */
  70. }
  71. extern flash_info_t flash_info[]; /* info for FLASH chips */
  72. int misc_init_r (void)
  73. {
  74. DECLARE_GLOBAL_DATA_PTR;
  75. /* adjust flash start and size as well as the offset */
  76. gd->bd->bi_flashstart = 0 - flash_info[0].size;
  77. gd->bd->bi_flashoffset= flash_info[0].size - CFG_MONITOR_LEN;
  78. #if 0
  79. volatile unsigned short *fpga_mode =
  80. (unsigned short *)((ulong)CFG_FPGA_BASE_ADDR + CFG_FPGA_CTRL);
  81. volatile unsigned char *duart0_mcr =
  82. (unsigned char *)((ulong)DUART0_BA + 4);
  83. volatile unsigned char *duart1_mcr =
  84. (unsigned char *)((ulong)DUART1_BA + 4);
  85. bd_t *bd = gd->bd;
  86. char * tmp; /* Temporary char pointer */
  87. unsigned char *dst;
  88. ulong len = sizeof(fpgadata);
  89. int status;
  90. int index;
  91. int i;
  92. unsigned long cntrl0Reg;
  93. dst = malloc(CFG_FPGA_MAX_SIZE);
  94. if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
  95. printf ("GUNZIP ERROR - must RESET board to recover\n");
  96. do_reset (NULL, 0, 0, NULL);
  97. }
  98. status = fpga_boot(dst, len);
  99. if (status != 0) {
  100. printf("\nFPGA: Booting failed ");
  101. switch (status) {
  102. case ERROR_FPGA_PRG_INIT_LOW:
  103. printf("(Timeout: INIT not low after asserting PROGRAM*)\n ");
  104. break;
  105. case ERROR_FPGA_PRG_INIT_HIGH:
  106. printf("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
  107. break;
  108. case ERROR_FPGA_PRG_DONE:
  109. printf("(Timeout: DONE not high after programming FPGA)\n ");
  110. break;
  111. }
  112. /* display infos on fpgaimage */
  113. index = 15;
  114. for (i=0; i<4; i++) {
  115. len = dst[index];
  116. printf("FPGA: %s\n", &(dst[index+1]));
  117. index += len+3;
  118. }
  119. putc ('\n');
  120. /* delayed reboot */
  121. for (i=20; i>0; i--) {
  122. printf("Rebooting in %2d seconds \r",i);
  123. for (index=0;index<1000;index++)
  124. udelay(1000);
  125. }
  126. putc ('\n');
  127. do_reset(NULL, 0, 0, NULL);
  128. }
  129. puts("FPGA: ");
  130. /* display infos on fpgaimage */
  131. index = 15;
  132. for (i=0; i<4; i++) {
  133. len = dst[index];
  134. printf("%s ", &(dst[index+1]));
  135. index += len+3;
  136. }
  137. putc ('\n');
  138. free(dst);
  139. /*
  140. * Reset FPGA via FPGA_DATA pin
  141. */
  142. SET_FPGA(FPGA_PRG | FPGA_CLK);
  143. udelay(1000); /* wait 1ms */
  144. SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA);
  145. udelay(1000); /* wait 1ms */
  146. #endif
  147. #if 0
  148. /*
  149. * Enable power on PS/2 interface
  150. */
  151. *fpga_mode |= CFG_FPGA_CTRL_PS2_RESET;
  152. /*
  153. * Enable interrupts in exar duart mcr[3]
  154. */
  155. *duart0_mcr = 0x08;
  156. *duart1_mcr = 0x08;
  157. #endif
  158. return (0);
  159. }
  160. /*
  161. * Check Board Identity:
  162. */
  163. int checkboard (void)
  164. {
  165. unsigned char str[64];
  166. int i = getenv_r ("serial#", str, sizeof(str));
  167. puts ("Board: ");
  168. if (i == -1) {
  169. puts ("### No HW ID - assuming PPChameleonEVB");
  170. } else {
  171. puts(str);
  172. }
  173. putc ('\n');
  174. return 0;
  175. }
  176. /* ------------------------------------------------------------------------- */
  177. long int initdram (int board_type)
  178. {
  179. unsigned long val;
  180. mtdcr(memcfga, mem_mb0cf);
  181. val = mfdcr(memcfgd);
  182. #if 0 /* test-only */
  183. for (;;) {
  184. NAND_DISABLE_CE(1);
  185. udelay(100);
  186. NAND_ENABLE_CE(1);
  187. udelay(100);
  188. }
  189. #endif
  190. #if 0
  191. printf("\nmb0cf=%x\n", val); /* test-only */
  192. printf("strap=%x\n", mfdcr(strap)); /* test-only */
  193. #endif
  194. return (4*1024*1024 << ((val & 0x000e0000) >> 17));
  195. }
  196. /* ------------------------------------------------------------------------- */
  197. int testdram (void)
  198. {
  199. /* TODO: XXX XXX XXX */
  200. printf ("test: 16 MB - ok\n");
  201. return (0);
  202. }
  203. /* ------------------------------------------------------------------------- */
  204. #if (CONFIG_COMMANDS & CFG_CMD_NAND)
  205. extern ulong
  206. nand_probe(ulong physadr);
  207. void
  208. nand_init(void)
  209. {
  210. ulong totlen = 0;
  211. /*
  212. The HI model is equipped with a large block NAND chip not supported yet
  213. by U-Boot
  214. (CONFIG_PPCHAMELEON_MODULE_MODEL == CONFIG_PPCHAMELEON_MODULE_HI)
  215. */
  216. #if (CONFIG_PPCHAMELEON_MODULE_MODEL == CONFIG_PPCHAMELEON_MODULE_ME)
  217. debug ("Probing at 0x%.8x\n", CFG_NAND0_BASE);
  218. totlen += nand_probe (CFG_NAND0_BASE);
  219. #endif /* CONFIG_PPCHAMELEON_MODULE_ME, CONFIG_PPCHAMELEON_MODULE_HI */
  220. debug ("Probing at 0x%.8x\n", CFG_NAND1_BASE);
  221. totlen += nand_probe (CFG_NAND1_BASE);
  222. printf ("%3lu MB\n", totlen >>20);
  223. }
  224. #endif
  225. #ifdef CONFIG_CFB_CONSOLE
  226. # ifdef CONFIG_CONSOLE_EXTRA_INFO
  227. # include <video_fb.h>
  228. extern GraphicDevice smi;
  229. void video_get_info_str (int line_number, char *info)
  230. {
  231. uint pvr = get_pvr ();
  232. /* init video info strings for graphic console */
  233. switch (line_number) {
  234. case 1:
  235. switch (pvr) {
  236. case PVR_405EP_RB:
  237. sprintf (info, " AMCC PowerPC 405EP Rev. B");
  238. break;
  239. default:
  240. sprintf (info, " AMCC PowerPC 405EP Rev. <unknown>");
  241. break;
  242. }
  243. return;
  244. case 2:
  245. sprintf (info, " DAVE Srl PPChameleonEVB - www.dave-tech.it");
  246. return;
  247. case 3:
  248. sprintf (info, " %s", smi.modeIdent);
  249. return;
  250. }
  251. /* no more info lines */
  252. *info = 0;
  253. return;
  254. }
  255. # endif /* CONFIG_CONSOLE_EXTRA_INFO */
  256. #endif /* CONFIG_CFB_CONSOLE */