cpciiser4.c 4.8 KB

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