pmc405.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * (C) Copyright 2001-2003
  3. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  4. *
  5. * (C) Copyright 2005-2009
  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 <asm/io.h>
  29. #include <command.h>
  30. #include <malloc.h>
  31. DECLARE_GLOBAL_DATA_PTR;
  32. extern void lxt971_no_sleep(void);
  33. int board_early_init_f (void)
  34. {
  35. /*
  36. * IRQ 0-15 405GP internally generated; active high; level sensitive
  37. * IRQ 16 405GP internally generated; active low; level sensitive
  38. * IRQ 17-24 RESERVED
  39. * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
  40. * IRQ 26 (EXT IRQ 1) SER0 ; active low; level sensitive
  41. * IRQ 27 (EXT IRQ 2) SER1; active low; level sensitive
  42. * IRQ 28 (EXT IRQ 3) FPGA 0; active low; level sensitive
  43. * IRQ 29 (EXT IRQ 4) FPGA 1; active low; level sensitive
  44. * IRQ 30 (EXT IRQ 5) PCI INTA; active low; level sensitive
  45. * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
  46. */
  47. mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
  48. mtdcr(uicer, 0x00000000); /* disable all ints */
  49. mtdcr(uiccr, 0x00000000); /* set all to be non-critical*/
  50. mtdcr(uicpr, 0xFFFFFF81); /* set int polarities */
  51. mtdcr(uictr, 0x10000000); /* set int trigger levels */
  52. mtdcr(uicvcr, 0x00000001); /* set vect base=0, INT0 highest priority */
  53. mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
  54. /*
  55. * EBC Configuration Register:
  56. * set ready timeout to 512 ebc-clks -> ca. 15 us
  57. */
  58. mtebc (epcr, 0xa8400000);
  59. /*
  60. * Setup GPIO pins
  61. */
  62. mtdcr(cntrl0, mfdcr(cntrl0) | ((CONFIG_SYS_FPGA_INIT |
  63. CONFIG_SYS_FPGA_DONE |
  64. CONFIG_SYS_XEREADY |
  65. CONFIG_SYS_NONMONARCH |
  66. CONFIG_SYS_REV1_2) << 5));
  67. if (!(in_be32((void *)GPIO0_IR) & CONFIG_SYS_REV1_2)) {
  68. /* rev 1.2 boards */
  69. mtdcr(cntrl0, mfdcr(cntrl0) | ((CONFIG_SYS_INTA_FAKE |
  70. CONFIG_SYS_SELF_RST) << 5));
  71. }
  72. out_be32((void *)GPIO0_OR, CONFIG_SYS_VPEN);
  73. /* setup for output */
  74. out_be32((void *)GPIO0_TCR, CONFIG_SYS_FPGA_PRG | CONFIG_SYS_FPGA_CLK |
  75. CONFIG_SYS_FPGA_DATA | CONFIG_SYS_XEREADY | CONFIG_SYS_VPEN);
  76. /*
  77. * - check if rev1_2 is low, then:
  78. * - set/reset CONFIG_SYS_INTA_FAKE/CONFIG_SYS_SELF_RST
  79. * in TCR to assert INTA# or SELFRST#
  80. */
  81. return 0;
  82. }
  83. int misc_init_r (void)
  84. {
  85. /* adjust flash start and offset */
  86. gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
  87. gd->bd->bi_flashoffset = 0;
  88. /* deassert EREADY# */
  89. out_be32((void *)GPIO0_OR,
  90. in_be32((void *)GPIO0_OR) | CONFIG_SYS_XEREADY);
  91. return (0);
  92. }
  93. ushort pmc405_pci_subsys_deviceid(void)
  94. {
  95. ulong val;
  96. val = in_be32((void *)GPIO0_IR);
  97. if (!(val & CONFIG_SYS_REV1_2)) { /* low=rev1.2 */
  98. /* check monarch# signal */
  99. if (val & CONFIG_SYS_NONMONARCH)
  100. return CONFIG_SYS_PCI_SUBSYS_DEVICEID_NONMONARCH;
  101. return CONFIG_SYS_PCI_SUBSYS_DEVICEID_MONARCH;
  102. }
  103. return CONFIG_SYS_PCI_SUBSYS_DEVICEID_NONMONARCH;
  104. }
  105. /*
  106. * Check Board Identity
  107. */
  108. int checkboard (void)
  109. {
  110. ulong val;
  111. char str[64];
  112. int i = getenv_r("serial#", str, sizeof(str));
  113. puts ("Board: ");
  114. if (i == -1)
  115. puts ("### No HW ID - assuming PMC405");
  116. else
  117. puts(str);
  118. val = in_be32((void *)GPIO0_IR);
  119. if (!(val & CONFIG_SYS_REV1_2)) { /* low=rev1.2 */
  120. puts(" rev1.2 (");
  121. if (val & CONFIG_SYS_NONMONARCH) /* monarch# signal */
  122. puts("non-");
  123. puts("monarch)");
  124. } else
  125. puts(" <=rev1.1");
  126. putc ('\n');
  127. return 0;
  128. }
  129. void reset_phy(void)
  130. {
  131. #ifdef CONFIG_LXT971_NO_SLEEP
  132. /*
  133. * Disable sleep mode in LXT971
  134. */
  135. lxt971_no_sleep();
  136. #endif
  137. }