PPChameleonEVB.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. DECLARE_GLOBAL_DATA_PTR;
  31. /* ------------------------------------------------------------------------- */
  32. int board_early_init_f (void)
  33. {
  34. out32(GPIO0_OR, CONFIG_SYS_NAND0_CE); /* set initial outputs */
  35. out32(GPIO0_OR, CONFIG_SYS_NAND1_CE); /* set initial outputs */
  36. /*
  37. * IRQ 0-15 405GP internally generated; active high; level sensitive
  38. * IRQ 16 405GP internally generated; active low; level sensitive
  39. * IRQ 17-24 RESERVED
  40. * IRQ 25 (EXT IRQ 0)
  41. * IRQ 26 (EXT IRQ 1)
  42. * IRQ 27 (EXT IRQ 2)
  43. * IRQ 28 (EXT IRQ 3)
  44. * IRQ 29 (EXT IRQ 4)
  45. * IRQ 30 (EXT IRQ 5)
  46. * IRQ 31 (EXT IRQ 6)
  47. */
  48. mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
  49. mtdcr(UIC0ER, 0x00000000); /* disable all ints */
  50. mtdcr(UIC0CR, 0x00000000); /* set all to be non-critical*/
  51. mtdcr(UIC0PR, 0xFFFFFF80); /* set int polarities */
  52. mtdcr(UIC0TR, 0x10000000); /* set int trigger levels */
  53. mtdcr(UIC0VCR, 0x00000001); /* set vect base=0,INT0 highest priority*/
  54. mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
  55. /*
  56. * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us
  57. */
  58. #if 1 /* test-only */
  59. mtebc (EBC0_CFG, 0xa8400000); /* ebc always driven */
  60. #else
  61. mtebc (EBC0_CFG, 0x28400000); /* ebc in high-z */
  62. #endif
  63. return 0;
  64. }
  65. /* ------------------------------------------------------------------------- */
  66. int misc_init_f (void)
  67. {
  68. return 0; /* dummy implementation */
  69. }
  70. extern flash_info_t flash_info[]; /* info for FLASH chips */
  71. int misc_init_r (void)
  72. {
  73. /* adjust flash start and size as well as the offset */
  74. gd->bd->bi_flashstart = 0 - flash_info[0].size;
  75. gd->bd->bi_flashoffset= flash_info[0].size - CONFIG_SYS_MONITOR_LEN;
  76. #if 0
  77. volatile unsigned short *fpga_mode =
  78. (unsigned short *)((ulong)CONFIG_SYS_FPGA_BASE_ADDR + CONFIG_SYS_FPGA_CTRL);
  79. volatile unsigned char *duart0_mcr =
  80. (unsigned char *)((ulong)DUART0_BA + 4);
  81. volatile unsigned char *duart1_mcr =
  82. (unsigned char *)((ulong)DUART1_BA + 4);
  83. bd_t *bd = gd->bd;
  84. char * tmp; /* Temporary char pointer */
  85. unsigned char *dst;
  86. ulong len = sizeof(fpgadata);
  87. int status;
  88. int index;
  89. int i;
  90. unsigned long CPC0_CR0Reg;
  91. dst = malloc(CONFIG_SYS_FPGA_MAX_SIZE);
  92. if (gunzip (dst, CONFIG_SYS_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
  93. printf ("GUNZIP ERROR - must RESET board to recover\n");
  94. do_reset (NULL, 0, 0, NULL);
  95. }
  96. status = fpga_boot(dst, len);
  97. if (status != 0) {
  98. printf("\nFPGA: Booting failed ");
  99. switch (status) {
  100. case ERROR_FPGA_PRG_INIT_LOW:
  101. printf("(Timeout: INIT not low after asserting PROGRAM*)\n ");
  102. break;
  103. case ERROR_FPGA_PRG_INIT_HIGH:
  104. printf("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
  105. break;
  106. case ERROR_FPGA_PRG_DONE:
  107. printf("(Timeout: DONE not high after programming FPGA)\n ");
  108. break;
  109. }
  110. /* display infos on fpgaimage */
  111. index = 15;
  112. for (i=0; i<4; i++) {
  113. len = dst[index];
  114. printf("FPGA: %s\n", &(dst[index+1]));
  115. index += len+3;
  116. }
  117. putc ('\n');
  118. /* delayed reboot */
  119. for (i=20; i>0; i--) {
  120. printf("Rebooting in %2d seconds \r",i);
  121. for (index=0;index<1000;index++)
  122. udelay(1000);
  123. }
  124. putc ('\n');
  125. do_reset(NULL, 0, 0, NULL);
  126. }
  127. puts("FPGA: ");
  128. /* display infos on fpgaimage */
  129. index = 15;
  130. for (i=0; i<4; i++) {
  131. len = dst[index];
  132. printf("%s ", &(dst[index+1]));
  133. index += len+3;
  134. }
  135. putc ('\n');
  136. free(dst);
  137. /*
  138. * Reset FPGA via FPGA_DATA pin
  139. */
  140. SET_FPGA(FPGA_PRG | FPGA_CLK);
  141. udelay(1000); /* wait 1ms */
  142. SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA);
  143. udelay(1000); /* wait 1ms */
  144. #endif
  145. #if 0
  146. /*
  147. * Enable power on PS/2 interface
  148. */
  149. *fpga_mode |= CONFIG_SYS_FPGA_CTRL_PS2_RESET;
  150. /*
  151. * Enable interrupts in exar duart mcr[3]
  152. */
  153. *duart0_mcr = 0x08;
  154. *duart1_mcr = 0x08;
  155. #endif
  156. return (0);
  157. }
  158. /*
  159. * Check Board Identity:
  160. */
  161. int checkboard (void)
  162. {
  163. char str[64];
  164. int i = getenv_f("serial#", str, sizeof(str));
  165. puts ("Board: ");
  166. if (i == -1) {
  167. puts ("### No HW ID - assuming PPChameleonEVB");
  168. } else {
  169. puts(str);
  170. }
  171. putc ('\n');
  172. return 0;
  173. }
  174. /* ------------------------------------------------------------------------- */
  175. int testdram (void)
  176. {
  177. /* TODO: XXX XXX XXX */
  178. printf ("test: 16 MB - ok\n");
  179. return (0);
  180. }
  181. /* ------------------------------------------------------------------------- */
  182. #ifdef CONFIG_CFB_CONSOLE
  183. # ifdef CONFIG_CONSOLE_EXTRA_INFO
  184. # include <video_fb.h>
  185. extern GraphicDevice smi;
  186. void video_get_info_str (int line_number, char *info)
  187. {
  188. uint pvr = get_pvr ();
  189. /* init video info strings for graphic console */
  190. switch (line_number) {
  191. case 1:
  192. switch (pvr) {
  193. case PVR_405EP_RB:
  194. sprintf (info, " AMCC PowerPC 405EP Rev. B");
  195. break;
  196. default:
  197. sprintf (info, " AMCC PowerPC 405EP Rev. <unknown>");
  198. break;
  199. }
  200. return;
  201. case 2:
  202. sprintf (info, " DAVE Srl PPChameleonEVB - www.dave-tech.it");
  203. return;
  204. case 3:
  205. sprintf (info, " %s", smi.modeIdent);
  206. return;
  207. }
  208. /* no more info lines */
  209. *info = 0;
  210. return;
  211. }
  212. # endif /* CONFIG_CONSOLE_EXTRA_INFO */
  213. #endif /* CONFIG_CFB_CONSOLE */