ar405.c 4.7 KB

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