ash405.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. * (C) Copyright 2001-2003
  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 <asm/processor.h>
  25. #include <asm/io.h>
  26. #include <command.h>
  27. #include <malloc.h>
  28. /* ------------------------------------------------------------------------- */
  29. #if 0
  30. #define FPGA_DEBUG
  31. #endif
  32. extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
  33. extern void lxt971_no_sleep(void);
  34. /* fpga configuration data - gzip compressed and generated by bin2c */
  35. const unsigned char fpgadata[] =
  36. {
  37. #include "fpgadata.c"
  38. };
  39. /*
  40. * include common fpga code (for esd boards)
  41. */
  42. #include "../common/fpga.c"
  43. /* Prototypes */
  44. int gunzip(void *, int, unsigned char *, unsigned long *);
  45. int board_early_init_f (void)
  46. {
  47. /*
  48. * IRQ 0-15 405GP internally generated; active high; level sensitive
  49. * IRQ 16 405GP internally generated; active low; level sensitive
  50. * IRQ 17-24 RESERVED
  51. * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
  52. * IRQ 26 (EXT IRQ 1) SER0 ; active low; level sensitive
  53. * IRQ 27 (EXT IRQ 2) SER1; active low; level sensitive
  54. * IRQ 28 (EXT IRQ 3) FPGA 0; active low; level sensitive
  55. * IRQ 29 (EXT IRQ 4) FPGA 1; active low; level sensitive
  56. * IRQ 30 (EXT IRQ 5) PCI INTA; active low; level sensitive
  57. * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
  58. */
  59. mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
  60. mtdcr(uicer, 0x00000000); /* disable all ints */
  61. mtdcr(uiccr, 0x00000000); /* set all to be non-critical*/
  62. mtdcr(uicpr, 0xFFFFFF9F); /* set int polarities */
  63. mtdcr(uictr, 0x10000000); /* set int trigger levels */
  64. mtdcr(uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority*/
  65. mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
  66. /*
  67. * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us
  68. */
  69. mtebc (epcr, 0xa8400000); /* ebc always driven */
  70. return 0;
  71. }
  72. int misc_init_r (void)
  73. {
  74. unsigned char *dst;
  75. ulong len = sizeof(fpgadata);
  76. int status;
  77. int index;
  78. int i;
  79. dst = malloc(CONFIG_SYS_FPGA_MAX_SIZE);
  80. if (gunzip (dst, CONFIG_SYS_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
  81. printf ("GUNZIP ERROR - must RESET board to recover\n");
  82. do_reset (NULL, 0, 0, NULL);
  83. }
  84. status = fpga_boot(dst, len);
  85. if (status != 0) {
  86. printf("\nFPGA: Booting failed ");
  87. switch (status) {
  88. case ERROR_FPGA_PRG_INIT_LOW:
  89. printf("(Timeout: INIT not low after asserting PROGRAM*)\n ");
  90. break;
  91. case ERROR_FPGA_PRG_INIT_HIGH:
  92. printf("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
  93. break;
  94. case ERROR_FPGA_PRG_DONE:
  95. printf("(Timeout: DONE not high after programming FPGA)\n ");
  96. break;
  97. }
  98. /* display infos on fpgaimage */
  99. index = 15;
  100. for (i=0; i<4; i++) {
  101. len = dst[index];
  102. printf("FPGA: %s\n", &(dst[index+1]));
  103. index += len+3;
  104. }
  105. putc ('\n');
  106. /* delayed reboot */
  107. for (i=20; i>0; i--) {
  108. printf("Rebooting in %2d seconds \r",i);
  109. for (index=0;index<1000;index++)
  110. udelay(1000);
  111. }
  112. putc ('\n');
  113. do_reset(NULL, 0, 0, NULL);
  114. }
  115. puts("FPGA: ");
  116. /* display infos on fpgaimage */
  117. index = 15;
  118. for (i=0; i<4; i++) {
  119. len = dst[index];
  120. printf("%s ", &(dst[index+1]));
  121. index += len+3;
  122. }
  123. putc ('\n');
  124. free(dst);
  125. /*
  126. * Reset FPGA via FPGA_DATA pin
  127. */
  128. SET_FPGA(FPGA_PRG | FPGA_CLK);
  129. udelay(1000); /* wait 1ms */
  130. SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA);
  131. udelay(1000); /* wait 1ms */
  132. /*
  133. * Reset external DUARTs
  134. */
  135. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_DUART_RST);
  136. udelay(10); /* wait 10us */
  137. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CONFIG_SYS_DUART_RST);
  138. udelay(1000); /* wait 1ms */
  139. /*
  140. * Enable interrupts in exar duart mcr[3]
  141. */
  142. out_8((void *)(DUART0_BA + 4), 0x08);
  143. out_8((void *)(DUART1_BA + 4), 0x08);
  144. out_8((void *)(DUART2_BA + 4), 0x08);
  145. out_8((void *)(DUART3_BA + 4), 0x08);
  146. return (0);
  147. }
  148. /*
  149. * Check Board Identity:
  150. */
  151. int checkboard (void)
  152. {
  153. char str[64];
  154. int i = getenv_r ("serial#", str, sizeof(str));
  155. puts ("Board: ");
  156. if (i == -1) {
  157. puts ("### No HW ID - assuming ASH405");
  158. } else {
  159. puts(str);
  160. }
  161. putc ('\n');
  162. return 0;
  163. }
  164. void reset_phy(void)
  165. {
  166. #ifdef CONFIG_LXT971_NO_SLEEP
  167. /*
  168. * Disable sleep mode in LXT971
  169. */
  170. lxt971_no_sleep();
  171. #endif
  172. }