ar405.c 4.7 KB

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