du405.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. * (C) Copyright 2000, 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 "du405.h"
  25. #include <asm/processor.h>
  26. #include <ppc4xx.h>
  27. #include <405gp_i2c.h>
  28. #include <command.h>
  29. /*cmd_boot.c*/
  30. extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
  31. extern void lxt971_no_sleep(void);
  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. DECLARE_GLOBAL_DATA_PTR;
  49. int index, len, i;
  50. int status;
  51. #ifdef FPGA_DEBUG
  52. /* set up serial port with default baudrate */
  53. (void) get_clocks ();
  54. gd->baudrate = CONFIG_BAUDRATE;
  55. serial_init ();
  56. console_init_f ();
  57. #endif
  58. /*
  59. * Boot onboard FPGA
  60. */
  61. status = fpga_boot ((unsigned char *) fpgadata, sizeof (fpgadata));
  62. if (status != 0) {
  63. /* booting FPGA failed */
  64. #ifndef FPGA_DEBUG
  65. /* set up serial port with default baudrate */
  66. (void) get_clocks ();
  67. gd->baudrate = CONFIG_BAUDRATE;
  68. serial_init ();
  69. console_init_f ();
  70. #endif
  71. printf ("\nFPGA: Booting failed ");
  72. switch (status) {
  73. case ERROR_FPGA_PRG_INIT_LOW:
  74. printf ("(Timeout: INIT not low after asserting PROGRAM*)\n ");
  75. break;
  76. case ERROR_FPGA_PRG_INIT_HIGH:
  77. printf ("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
  78. break;
  79. case ERROR_FPGA_PRG_DONE:
  80. printf ("(Timeout: DONE not high after programming FPGA)\n ");
  81. break;
  82. }
  83. /* display infos on fpgaimage */
  84. index = 15;
  85. for (i = 0; i < 4; i++) {
  86. len = fpgadata[index];
  87. printf ("FPGA: %s\n", &(fpgadata[index + 1]));
  88. index += len + 3;
  89. }
  90. putc ('\n');
  91. /* delayed reboot */
  92. for (i = 20; i > 0; i--) {
  93. printf ("Rebooting in %2d seconds \r", i);
  94. for (index = 0; index < 1000; index++)
  95. udelay (1000);
  96. }
  97. putc ('\n');
  98. do_reset (NULL, 0, 0, NULL);
  99. }
  100. /*
  101. * IRQ 0-15 405GP internally generated; active high; level sensitive
  102. * IRQ 16 405GP internally generated; active low; level sensitive
  103. * IRQ 17-24 RESERVED
  104. * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
  105. * IRQ 26 (EXT IRQ 1) DUART_A; active high; level sensitive
  106. * IRQ 27 (EXT IRQ 2) DUART_B; active high; level sensitive
  107. * IRQ 28 (EXT IRQ 3) unused; active low; level sensitive
  108. * IRQ 29 (EXT IRQ 4) unused; active low; level sensitive
  109. * IRQ 30 (EXT IRQ 5) unused; active low; level sensitive
  110. * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
  111. */
  112. mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
  113. mtdcr (uicer, 0x00000000); /* disable all ints */
  114. mtdcr (uiccr, 0x00000000); /* set all to be non-critical */
  115. mtdcr (uicpr, 0xFFFFFFB1); /* set int polarities */
  116. mtdcr (uictr, 0x10000000); /* set int trigger levels */
  117. mtdcr (uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority */
  118. mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
  119. /*
  120. * EBC Configuration Register: set ready timeout to 100 us
  121. */
  122. mtebc (epcr, 0xb8400000);
  123. return 0;
  124. }
  125. int misc_init_r (void)
  126. {
  127. unsigned long cntrl0Reg;
  128. /*
  129. * Setup UART1 handshaking: use CTS instead of DSR
  130. */
  131. cntrl0Reg = mfdcr(cntrl0);
  132. mtdcr(cntrl0, cntrl0Reg | 0x00001000);
  133. return (0);
  134. }
  135. /*
  136. * Check Board Identity:
  137. */
  138. int checkboard (void)
  139. {
  140. int index;
  141. int len;
  142. char str[64];
  143. int i = getenv_r ("serial#", str, sizeof (str));
  144. puts ("Board: ");
  145. if (i == -1) {
  146. puts ("### No HW ID - assuming DU405");
  147. } else {
  148. puts (str);
  149. }
  150. puts ("\nFPGA: ");
  151. /* display infos on fpgaimage */
  152. index = 15;
  153. for (i = 0; i < 4; i++) {
  154. len = fpgadata[index];
  155. printf ("%s ", &(fpgadata[index + 1]));
  156. index += len + 3;
  157. }
  158. putc ('\n');
  159. /*
  160. * Reset external DUART via FPGA
  161. */
  162. *(volatile unsigned char *) FPGA_MODE_REG = 0xff; /* reset high active */
  163. *(volatile unsigned char *) FPGA_MODE_REG = 0x00; /* low again */
  164. /*
  165. * Disable sleep mode in LXT971
  166. */
  167. lxt971_no_sleep();
  168. return 0;
  169. }
  170. long int initdram (int board_type)
  171. {
  172. return (16 * 1024 * 1024);
  173. }
  174. int testdram (void)
  175. {
  176. /* TODO: XXX XXX XXX */
  177. printf ("test: 16 MB - ok\n");
  178. return (0);
  179. }