cpciiser4.c 4.5 KB

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