pmc405.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * (C) Copyright 2001-2003
  3. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  4. *
  5. * (C) Copyright 2005
  6. * Matthias Fuchs, esd gmbh germany, matthias.fuchs@esd-electronics.com
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <asm/processor.h>
  28. #include <command.h>
  29. #include <malloc.h>
  30. DECLARE_GLOBAL_DATA_PTR;
  31. extern void lxt971_no_sleep(void);
  32. /* fpga configuration data - not compressed, generated by bin2c */
  33. const unsigned char fpgadata[] =
  34. {
  35. #include "fpgadata.c"
  36. };
  37. int filesize = sizeof(fpgadata);
  38. int board_early_init_f (void)
  39. {
  40. /*
  41. * IRQ 0-15 405GP internally generated; active high; level sensitive
  42. * IRQ 16 405GP internally generated; active low; level sensitive
  43. * IRQ 17-24 RESERVED
  44. * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
  45. * IRQ 26 (EXT IRQ 1) SER0 ; active low; level sensitive
  46. * IRQ 27 (EXT IRQ 2) SER1; active low; level sensitive
  47. * IRQ 28 (EXT IRQ 3) FPGA 0; active low; level sensitive
  48. * IRQ 29 (EXT IRQ 4) FPGA 1; active low; level sensitive
  49. * IRQ 30 (EXT IRQ 5) PCI INTA; active low; level sensitive
  50. * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
  51. */
  52. mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
  53. mtdcr(uicer, 0x00000000); /* disable all ints */
  54. mtdcr(uiccr, 0x00000000); /* set all to be non-critical*/
  55. mtdcr(uicpr, 0xFFFFFF81); /* set int polarities */
  56. mtdcr(uictr, 0x10000000); /* set int trigger levels */
  57. mtdcr(uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority*/
  58. mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
  59. /*
  60. * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us
  61. */
  62. mtebc (epcr, 0xa8400000);
  63. /*
  64. * Setup GPIO pins
  65. */
  66. mtdcr(cntrl0, mfdcr(cntrl0) | ((CFG_FPGA_INIT | \
  67. CFG_FPGA_DONE | \
  68. CFG_XEREADY | \
  69. CFG_NONMONARCH | \
  70. CFG_REV1_2) << 5));
  71. if (!(in32(GPIO0_IR) & CFG_REV1_2)) {
  72. /* rev 1.2 boards */
  73. mtdcr(cntrl0, mfdcr(cntrl0) | ((CFG_INTA_FAKE | \
  74. CFG_SELF_RST) << 5));
  75. }
  76. out32(GPIO0_OR, 0);
  77. out32(GPIO0_TCR, CFG_FPGA_PRG | CFG_FPGA_CLK | CFG_FPGA_DATA | CFG_XEREADY); /* setup for output */
  78. /* - check if rev1_2 is low, then:
  79. * - set/reset CFG_INTA_FAKE/CFG_SELF_RST in TCR to assert INTA# or SELFRST#
  80. */
  81. return 0;
  82. }
  83. /* ------------------------------------------------------------------------- */
  84. int misc_init_r (void)
  85. {
  86. /* adjust flash start and offset */
  87. gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
  88. gd->bd->bi_flashoffset = 0;
  89. out32(GPIO0_OR, in32(GPIO0_OR) | CFG_XEREADY); /* deassert EREADY# */
  90. return (0);
  91. }
  92. ushort pmc405_pci_subsys_deviceid(void)
  93. {
  94. ulong val;
  95. val = in32(GPIO0_IR);
  96. if (!(val & CFG_REV1_2)) { /* low=rev1.2 */
  97. if (val & CFG_NONMONARCH) { /* monarch# signal */
  98. return CFG_PCI_SUBSYS_DEVICEID_NONMONARCH;
  99. }
  100. return CFG_PCI_SUBSYS_DEVICEID_MONARCH;
  101. }
  102. return CFG_PCI_SUBSYS_DEVICEID_NONMONARCH;
  103. }
  104. /*
  105. * Check Board Identity:
  106. */
  107. int checkboard (void)
  108. {
  109. ulong val;
  110. char str[64];
  111. int i = getenv_r ("serial#", str, sizeof(str));
  112. puts ("Board: ");
  113. if (i == -1) {
  114. puts ("### No HW ID - assuming PMC405");
  115. } else {
  116. puts(str);
  117. }
  118. val = in32(GPIO0_IR);
  119. if (!(val & CFG_REV1_2)) { /* low=rev1.2 */
  120. puts(" rev1.2 (");
  121. if (val & CFG_NONMONARCH) { /* monarch# signal */
  122. puts("non-");
  123. }
  124. puts("monarch)");
  125. } else {
  126. puts(" <=rev1.1");
  127. }
  128. putc ('\n');
  129. return 0;
  130. }
  131. /* ------------------------------------------------------------------------- */
  132. long int initdram (int board_type)
  133. {
  134. unsigned long val;
  135. mtdcr(memcfga, mem_mb0cf);
  136. val = mfdcr(memcfgd);
  137. #if 0
  138. printf("\nmb0cf=%x\n", val); /* test-only */
  139. printf("strap=%x\n", mfdcr(strap)); /* test-only */
  140. #endif
  141. return (4*1024*1024 << ((val & 0x000e0000) >> 17));
  142. }
  143. /* ------------------------------------------------------------------------- */
  144. void reset_phy(void)
  145. {
  146. #ifdef CONFIG_LXT971_NO_SLEEP
  147. /*
  148. * Disable sleep mode in LXT971
  149. */
  150. lxt971_no_sleep();
  151. #endif
  152. }
  153. int do_cantest(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  154. {
  155. ulong addr;
  156. volatile uchar *ptr;
  157. volatile uchar val;
  158. int i;
  159. addr = simple_strtol (argv[1], NULL, 16) + 0x16;
  160. i = 0;
  161. for (;;) {
  162. ptr = (uchar *)addr;
  163. for (i=0; i<8; i++) {
  164. *ptr = i;
  165. val = *ptr;
  166. if (val != i) {
  167. printf("ERROR: addr=%p write=0x%02X, read=0x%02X\n", ptr, i, val);
  168. return 0;
  169. }
  170. /* Abort if ctrl-c was pressed */
  171. if (ctrlc()) {
  172. puts("\nAbort\n");
  173. return 0;
  174. }
  175. ptr++;
  176. }
  177. }
  178. return 0;
  179. }
  180. U_BOOT_CMD(
  181. cantest, 3, 1, do_cantest,
  182. "cantest - Test CAN controller",
  183. NULL
  184. );