canbt.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. * (C) Copyright 2001
  3. * Matthias Fuchs, esd gmbh germany, matthias.fuchs@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 "canbt.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 */
  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. unsigned long cntrl0Reg;
  45. int index, len, i;
  46. int status;
  47. /*
  48. * Setup GPIO pins
  49. */
  50. cntrl0Reg = mfdcr (cntrl0) & 0xf0001fff;
  51. cntrl0Reg |= 0x0070f000;
  52. mtdcr (cntrl0, cntrl0Reg);
  53. #ifdef FPGA_DEBUG
  54. /* set up serial port with default baudrate */
  55. (void) get_clocks ();
  56. gd->baudrate = CONFIG_BAUDRATE;
  57. serial_init ();
  58. console_init_f ();
  59. #endif
  60. /*
  61. * Boot onboard FPGA
  62. */
  63. status = fpga_boot ((unsigned char *) fpgadata, sizeof (fpgadata));
  64. if (status != 0) {
  65. /* booting FPGA failed */
  66. #ifndef FPGA_DEBUG
  67. /* set up serial port with default baudrate */
  68. (void) get_clocks ();
  69. gd->baudrate = CONFIG_BAUDRATE;
  70. serial_init ();
  71. console_init_f ();
  72. #endif
  73. printf ("\nFPGA: Booting failed ");
  74. switch (status) {
  75. case ERROR_FPGA_PRG_INIT_LOW:
  76. printf ("(Timeout: INIT not low after asserting PROGRAM*)\n ");
  77. break;
  78. case ERROR_FPGA_PRG_INIT_HIGH:
  79. printf ("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
  80. break;
  81. case ERROR_FPGA_PRG_DONE:
  82. printf ("(Timeout: DONE not high after programming FPGA)\n ");
  83. break;
  84. }
  85. /* display infos on fpgaimage */
  86. index = 15;
  87. for (i = 0; i < 4; i++) {
  88. len = fpgadata[index];
  89. printf ("FPGA: %s\n", &(fpgadata[index + 1]));
  90. index += len + 3;
  91. }
  92. putc ('\n');
  93. /* delayed reboot */
  94. for (i = 20; i > 0; i--) {
  95. printf ("Rebooting in %2d seconds \r", i);
  96. for (index = 0; index < 1000; index++)
  97. udelay (1000);
  98. }
  99. putc ('\n');
  100. do_reset (NULL, 0, 0, NULL);
  101. }
  102. /*
  103. * Setup port pins for normal operation
  104. */
  105. out32 (GPIO0_ODR, 0x00000000); /* no open drain pins */
  106. out32 (GPIO0_TCR, 0x07038100); /* setup for output */
  107. out32 (GPIO0_OR, 0x07030100); /* set output pins to high (default) */
  108. /*
  109. * IRQ 0-15 405GP internally generated; active high; level sensitive
  110. * IRQ 16 405GP internally generated; active low; level sensitive
  111. * IRQ 17-24 RESERVED
  112. * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
  113. * IRQ 26 (EXT IRQ 1) CAN1; active low; level sensitive
  114. * IRQ 27 (EXT IRQ 2) PCI SLOT 0; active low; level sensitive
  115. * IRQ 28 (EXT IRQ 3) PCI SLOT 1; active low; level sensitive
  116. * IRQ 29 (EXT IRQ 4) PCI SLOT 2; active low; level sensitive
  117. * IRQ 30 (EXT IRQ 5) PCI SLOT 3; active low; level sensitive
  118. * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
  119. */
  120. mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
  121. mtdcr (uicer, 0x00000000); /* disable all ints */
  122. mtdcr (uiccr, 0x00000000); /* set all to be non-critical */
  123. mtdcr (uicpr, 0xFFFFFF81); /* set int polarities */
  124. mtdcr (uictr, 0x10000000); /* set int trigger levels */
  125. mtdcr (uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority */
  126. mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
  127. return 0;
  128. }
  129. /* ------------------------------------------------------------------------- */
  130. /*
  131. * Check Board Identity:
  132. */
  133. int checkboard (void)
  134. {
  135. int index;
  136. int len;
  137. char str[64];
  138. int i = getenv_r ("serial#", str, sizeof (str));
  139. puts ("Board: ");
  140. if (!i || strncmp (str, "CANBT", 5)) {
  141. puts ("### No HW ID - assuming CANBT\n");
  142. return (0);
  143. }
  144. puts (str);
  145. puts ("\nFPGA: ");
  146. /* display infos on fpgaimage */
  147. index = 15;
  148. for (i = 0; i < 4; i++) {
  149. len = fpgadata[index];
  150. printf ("%s ", &(fpgadata[index + 1]));
  151. index += len + 3;
  152. }
  153. putc ('\n');
  154. return 0;
  155. }
  156. /* ------------------------------------------------------------------------- */
  157. long int initdram (int board_type)
  158. {
  159. return (16 * 1024 * 1024);
  160. }
  161. /* ------------------------------------------------------------------------- */
  162. int testdram (void)
  163. {
  164. /* TODO: XXX XXX XXX */
  165. printf ("test: 16 MB - ok\n");
  166. return (0);
  167. }
  168. /* ------------------------------------------------------------------------- */