ar405.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /*
  2. * (C) Copyright 2001-2004
  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 "ar405.h"
  25. #include <asm/processor.h>
  26. #include <command.h>
  27. /*cmd_boot.c*/
  28. extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
  29. extern void lxt971_no_sleep(void);
  30. /* ------------------------------------------------------------------------- */
  31. #if 0
  32. #define FPGA_DEBUG
  33. #endif
  34. /* fpga configuration data - generated by bin2cc */
  35. const unsigned char fpgadata[] = {
  36. #include "fpgadata.c"
  37. };
  38. const unsigned char fpgadata_xl30[] = {
  39. #include "fpgadata_xl30.c"
  40. };
  41. /*
  42. * include common fpga code (for esd boards)
  43. */
  44. #include "../common/fpga.c"
  45. int board_early_init_f (void)
  46. {
  47. DECLARE_GLOBAL_DATA_PTR;
  48. int index, len, i;
  49. int status;
  50. #ifdef FPGA_DEBUG
  51. /* set up serial port with default baudrate */
  52. (void) get_clocks ();
  53. gd->baudrate = CONFIG_BAUDRATE;
  54. serial_init ();
  55. console_init_f ();
  56. #endif
  57. /*
  58. * Boot onboard FPGA
  59. */
  60. /* first try 40er image */
  61. gd->board_type = 40;
  62. status = fpga_boot ((unsigned char *) fpgadata, sizeof (fpgadata));
  63. if (status != 0) {
  64. /* try xl30er image */
  65. gd->board_type = 30;
  66. status = fpga_boot ((unsigned char *) fpgadata_xl30, sizeof (fpgadata_xl30));
  67. if (status != 0) {
  68. /* booting FPGA failed */
  69. #ifndef FPGA_DEBUG
  70. /* set up serial port with default baudrate */
  71. (void) get_clocks ();
  72. gd->baudrate = CONFIG_BAUDRATE;
  73. serial_init ();
  74. console_init_f ();
  75. #endif
  76. printf ("\nFPGA: Booting failed ");
  77. switch (status) {
  78. case ERROR_FPGA_PRG_INIT_LOW:
  79. printf ("(Timeout: INIT not low after asserting PROGRAM*)\n ");
  80. break;
  81. case ERROR_FPGA_PRG_INIT_HIGH:
  82. printf ("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
  83. break;
  84. case ERROR_FPGA_PRG_DONE:
  85. printf ("(Timeout: DONE not high after programming FPGA)\n ");
  86. break;
  87. }
  88. /* display infos on fpgaimage */
  89. index = 15;
  90. for (i = 0; i < 4; i++) {
  91. len = fpgadata[index];
  92. printf ("FPGA: %s\n", &(fpgadata[index + 1]));
  93. index += len + 3;
  94. }
  95. putc ('\n');
  96. /* delayed reboot */
  97. for (i = 20; i > 0; i--) {
  98. printf ("Rebooting in %2d seconds \r", i);
  99. for (index = 0; index < 1000; index++)
  100. udelay (1000);
  101. }
  102. putc ('\n');
  103. do_reset (NULL, 0, 0, NULL);
  104. }
  105. }
  106. /*
  107. * IRQ 0-15 405GP internally generated; active high; level sensitive
  108. * IRQ 16 405GP internally generated; active low; level sensitive
  109. * IRQ 17-24 RESERVED
  110. * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
  111. * IRQ 26 (EXT IRQ 1) CAN1; active low; level sensitive
  112. * IRQ 27 (EXT IRQ 2) PCI SLOT 0; active low; level sensitive
  113. * IRQ 28 (EXT IRQ 3) PCI SLOT 1; active low; level sensitive
  114. * IRQ 29 (EXT IRQ 4) PCI SLOT 2; active low; level sensitive
  115. * IRQ 30 (EXT IRQ 5) PCI SLOT 3; active low; level sensitive
  116. * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
  117. */
  118. mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
  119. mtdcr (uicer, 0x00000000); /* disable all ints */
  120. mtdcr (uiccr, 0x00000000); /* set all to be non-critical */
  121. mtdcr (uicpr, 0xFFFFFF81); /* set int polarities */
  122. mtdcr (uictr, 0x10000000); /* set int trigger levels */
  123. mtdcr (uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority */
  124. mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
  125. *(ushort *) 0xf03000ec = 0x0fff; /* enable all interrupts in fpga */
  126. return 0;
  127. }
  128. /* ------------------------------------------------------------------------- */
  129. /*
  130. * Check Board Identity:
  131. */
  132. int checkboard (void)
  133. {
  134. DECLARE_GLOBAL_DATA_PTR;
  135. int index;
  136. int len;
  137. unsigned char str[64];
  138. int i = getenv_r ("serial#", str, sizeof (str));
  139. const unsigned char *fpga;
  140. puts ("Board: ");
  141. if (i == -1) {
  142. puts ("### No HW ID - assuming AR405");
  143. } else {
  144. puts(str);
  145. }
  146. puts ("\nFPGA: ");
  147. /* display infos on fpgaimage */
  148. if (gd->board_type == 30) {
  149. fpga = fpgadata_xl30;
  150. } else {
  151. fpga = fpgadata;
  152. }
  153. index = 15;
  154. for (i = 0; i < 4; i++) {
  155. len = fpga[index];
  156. printf ("%s ", &(fpga[index + 1]));
  157. index += len + 3;
  158. }
  159. putc ('\n');
  160. /*
  161. * Disable sleep mode in LXT971
  162. */
  163. lxt971_no_sleep();
  164. return 0;
  165. }
  166. /* ------------------------------------------------------------------------- */
  167. long int initdram (int board_type)
  168. {
  169. return (16 * 1024 * 1024);
  170. }
  171. /* ------------------------------------------------------------------------- */
  172. int testdram (void)
  173. {
  174. /* TODO: XXX XXX XXX */
  175. printf ("test: 16 MB - ok\n");
  176. return (0);
  177. }
  178. /* ------------------------------------------------------------------------- */