PPChameleonEVB.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. /*
  2. * (C) Copyright 2001-2003
  3. * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
  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 <asm/processor.h>
  25. #include <command.h>
  26. #include <malloc.h>
  27. /* ------------------------------------------------------------------------- */
  28. #if 0
  29. #define FPGA_DEBUG
  30. #endif
  31. /* fpga configuration data - gzip compressed and generated by bin2c */
  32. const unsigned char fpgadata[] =
  33. {
  34. #include "fpgadata.c"
  35. };
  36. /*
  37. * include common fpga code (for esd boards)
  38. */
  39. #include "../common/fpga.c"
  40. /* Prototypes */
  41. int gunzip(void *, int, unsigned char *, int *);
  42. int board_pre_init (void)
  43. {
  44. out32(GPIO0_OR, CFG_NAND0_CE); /* set initial outputs */
  45. out32(GPIO0_OR, CFG_NAND1_CE); /* set initial outputs */
  46. /*
  47. * IRQ 0-15 405GP internally generated; active high; level sensitive
  48. * IRQ 16 405GP internally generated; active low; level sensitive
  49. * IRQ 17-24 RESERVED
  50. * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
  51. * IRQ 26 (EXT IRQ 1) SER0 ; active low; level sensitive
  52. * IRQ 27 (EXT IRQ 2) SER1; active low; level sensitive
  53. * IRQ 28 (EXT IRQ 3) FPGA 0; active low; level sensitive
  54. * IRQ 29 (EXT IRQ 4) FPGA 1; active low; level sensitive
  55. * IRQ 30 (EXT IRQ 5) PCI INTA; active low; level sensitive
  56. * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
  57. */
  58. mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
  59. mtdcr(uicer, 0x00000000); /* disable all ints */
  60. mtdcr(uiccr, 0x00000000); /* set all to be non-critical*/
  61. mtdcr(uicpr, 0xFFFFFF81); /* set int polarities */
  62. mtdcr(uictr, 0x10000000); /* set int trigger levels */
  63. mtdcr(uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority*/
  64. mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
  65. /*
  66. * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us
  67. */
  68. #if 1 /* test-only */
  69. mtebc (epcr, 0xa8400000); /* ebc always driven */
  70. #else
  71. mtebc (epcr, 0x28400000); /* ebc in high-z */
  72. #endif
  73. return 0;
  74. }
  75. /* ------------------------------------------------------------------------- */
  76. int misc_init_f (void)
  77. {
  78. return 0; /* dummy implementation */
  79. }
  80. int misc_init_r (void)
  81. {
  82. #if 0 /* test-only */
  83. DECLARE_GLOBAL_DATA_PTR;
  84. #if 0
  85. volatile unsigned short *fpga_mode =
  86. (unsigned short *)((ulong)CFG_FPGA_BASE_ADDR + CFG_FPGA_CTRL);
  87. volatile unsigned char *duart0_mcr =
  88. (unsigned char *)((ulong)DUART0_BA + 4);
  89. volatile unsigned char *duart1_mcr =
  90. (unsigned char *)((ulong)DUART1_BA + 4);
  91. bd_t *bd = gd->bd;
  92. char * tmp; /* Temporary char pointer */
  93. unsigned char *dst;
  94. ulong len = sizeof(fpgadata);
  95. int status;
  96. int index;
  97. int i;
  98. unsigned long cntrl0Reg;
  99. dst = malloc(CFG_FPGA_MAX_SIZE);
  100. if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, (int *)&len) != 0) {
  101. printf ("GUNZIP ERROR - must RESET board to recover\n");
  102. do_reset (NULL, 0, 0, NULL);
  103. }
  104. status = fpga_boot(dst, len);
  105. if (status != 0) {
  106. printf("\nFPGA: Booting failed ");
  107. switch (status) {
  108. case ERROR_FPGA_PRG_INIT_LOW:
  109. printf("(Timeout: INIT not low after asserting PROGRAM*)\n ");
  110. break;
  111. case ERROR_FPGA_PRG_INIT_HIGH:
  112. printf("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
  113. break;
  114. case ERROR_FPGA_PRG_DONE:
  115. printf("(Timeout: DONE not high after programming FPGA)\n ");
  116. break;
  117. }
  118. /* display infos on fpgaimage */
  119. index = 15;
  120. for (i=0; i<4; i++) {
  121. len = dst[index];
  122. printf("FPGA: %s\n", &(dst[index+1]));
  123. index += len+3;
  124. }
  125. putc ('\n');
  126. /* delayed reboot */
  127. for (i=20; i>0; i--) {
  128. printf("Rebooting in %2d seconds \r",i);
  129. for (index=0;index<1000;index++)
  130. udelay(1000);
  131. }
  132. putc ('\n');
  133. do_reset(NULL, 0, 0, NULL);
  134. }
  135. puts("FPGA: ");
  136. /* display infos on fpgaimage */
  137. index = 15;
  138. for (i=0; i<4; i++) {
  139. len = dst[index];
  140. printf("%s ", &(dst[index+1]));
  141. index += len+3;
  142. }
  143. putc ('\n');
  144. free(dst);
  145. /*
  146. * Reset FPGA via FPGA_DATA pin
  147. */
  148. SET_FPGA(FPGA_PRG | FPGA_CLK);
  149. udelay(1000); /* wait 1ms */
  150. SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA);
  151. udelay(1000); /* wait 1ms */
  152. #endif
  153. #if 0
  154. /*
  155. * Enable power on PS/2 interface
  156. */
  157. *fpga_mode |= CFG_FPGA_CTRL_PS2_RESET;
  158. /*
  159. * Enable interrupts in exar duart mcr[3]
  160. */
  161. *duart0_mcr = 0x08;
  162. *duart1_mcr = 0x08;
  163. #endif
  164. #endif
  165. return (0);
  166. }
  167. /*
  168. * Check Board Identity:
  169. */
  170. int checkboard (void)
  171. {
  172. unsigned char str[64];
  173. int i = getenv_r ("serial#", str, sizeof(str));
  174. puts ("Board: ");
  175. if (i == -1) {
  176. puts ("### No HW ID - assuming PPChameleonEVB");
  177. } else {
  178. puts(str);
  179. }
  180. putc ('\n');
  181. return 0;
  182. }
  183. /* ------------------------------------------------------------------------- */
  184. long int initdram (int board_type)
  185. {
  186. unsigned long val;
  187. mtdcr(memcfga, mem_mb0cf);
  188. val = mfdcr(memcfgd);
  189. #if 0 /* test-only */
  190. for (;;) {
  191. NAND_DISABLE_CE(1);
  192. udelay(100);
  193. NAND_ENABLE_CE(1);
  194. udelay(100);
  195. }
  196. #endif
  197. #if 0
  198. printf("\nmb0cf=%x\n", val); /* test-only */
  199. printf("strap=%x\n", mfdcr(strap)); /* test-only */
  200. #endif
  201. return (4*1024*1024 << ((val & 0x000e0000) >> 17));
  202. }
  203. /* ------------------------------------------------------------------------- */
  204. int testdram (void)
  205. {
  206. /* TODO: XXX XXX XXX */
  207. printf ("test: 16 MB - ok\n");
  208. return (0);
  209. }
  210. /* ------------------------------------------------------------------------- */
  211. #if (CONFIG_COMMANDS & CFG_CMD_NAND)
  212. extern ulong
  213. nand_probe(ulong physadr);
  214. void
  215. nand_init(void)
  216. {
  217. ulong totlen = 0;
  218. #if (CONFIG_PPCHAMELEON_MODULE_MODEL == CONFIG_PPCHAMELEON_MODULE_ME) || \
  219. (CONFIG_PPCHAMELEON_MODULE_MODEL == CONFIG_PPCHAMELEON_MODULE_HI)
  220. debug ("Probing at 0x%.8x\n", CFG_NAND0_BASE);
  221. totlen += nand_probe (CFG_NAND0_BASE);
  222. #endif /* CONFIG_PPCHAMELEON_MODULE_ME, CONFIG_PPCHAMELEON_MODULE_HI */
  223. debug ("Probing at 0x%.8x\n", CFG_NAND1_BASE);
  224. totlen += nand_probe (CFG_NAND1_BASE);
  225. printf ("%4lu MB\n", totlen >>20);
  226. }
  227. #endif