eric.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * (C) Copyright 2001
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  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 <i2c.h>
  25. #include "eric.h"
  26. #include <asm/processor.h>
  27. #define PPC405GP_GPIO0_OR 0xef600700 /* GPIO Output */
  28. #define PPC405GP_GPIO0_TCR 0xef600704 /* GPIO Three-State Control */
  29. #define PPC405GP_GPIO0_ODR 0xef600718 /* GPIO Open Drain */
  30. #define PPC405GP_GPIO0_IR 0xef60071c /* GPIO Input */
  31. int board_early_init_f (void)
  32. {
  33. /*-------------------------------------------------------------------------+
  34. | Interrupt controller setup for the ERIC board.
  35. | Note: IRQ 0-15 405GP internally generated; active high; level sensitive
  36. | IRQ 16 405GP internally generated; active low; level sensitive
  37. | IRQ 17-24 RESERVED
  38. | IRQ 25 (EXT IRQ 0) FLASH; active low; level sensitive
  39. | IRQ 26 (EXT IRQ 1) PHY ; active low; level sensitive
  40. | IRQ 27 (EXT IRQ 2) HOST FAIL, active low; level sensitive
  41. | indicates NO Power or HOST RESET active
  42. | check GPIO7 (HOST RESET#) and GPIO8 (NO Power#)
  43. | for real IRQ source
  44. | IRQ 28 (EXT IRQ 3) HOST; active high; level sensitive
  45. | IRQ 29 (EXT IRQ 4) PCI INTC#; active low; level sensitive
  46. | IRQ 30 (EXT IRQ 5) PCI INTB#; active low; level sensitive
  47. | IRQ 31 (EXT IRQ 6) PCI INTA#; active low; level sensitive
  48. | -> IRQ6 Pin is NOW GPIO23 and can be activateted by setting
  49. | PPC405GP_GPIO0_TCR Bit 0 = 1 (driving the output as defined in PPC405GP_GPIO0_OR,
  50. | else tristate)
  51. | Note for ERIC board:
  52. | An interrupt taken for the HOST (IRQ 28) indicates that
  53. | the HOST wrote a "1" to one of the following locations
  54. | - VGA CRT_GPIO0 (if R1216 is loaded)
  55. | - VGA CRT_GPIO1 (if R1217 is loaded)
  56. |
  57. +-------------------------------------------------------------------------*/
  58. mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
  59. mtdcr (uicer, 0x00000000); /* disable all ints */
  60. mtdcr (uiccr, 0x00000000); /* set all SMI to be non-critical */
  61. mtdcr (uicpr, 0xFFFFFF88); /* set int polarities; IRQ3 to 1 */
  62. mtdcr (uictr, 0x10000000); /* set int trigger levels, UART0 is EDGE */
  63. mtdcr (uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority */
  64. mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
  65. mtdcr (cntrl0, 0x00002000); /* set IRQ6 as GPIO23 to generate an interrupt request to the PCP2PCI bridge */
  66. out32 (PPC405GP_GPIO0_OR, 0x60000000); /*fixme is SMB_INT high or low active??; IRQ6 is GPIO23 output */
  67. out32 (PPC405GP_GPIO0_TCR, 0x7E400000);
  68. return 0;
  69. }
  70. /* ------------------------------------------------------------------------- */
  71. /*
  72. * Check Board Identity:
  73. */
  74. int checkboard (void)
  75. {
  76. unsigned char *s = getenv ("serial#");
  77. unsigned char *e;
  78. puts ("Board: ");
  79. if (!s || strncmp (s, "ERIC", 9)) {
  80. puts ("### No HW ID - assuming ERIC");
  81. } else {
  82. for (e = s; *e; ++e) {
  83. if (*e == ' ')
  84. break;
  85. }
  86. for (; s < e; ++s) {
  87. putc (*s);
  88. }
  89. }
  90. putc ('\n');
  91. return (0);
  92. }
  93. /* ------------------------------------------------------------------------- */
  94. /* ------------------------------------------------------------------------- */
  95. /* ------------------------------------------------------------------------- */
  96. /*
  97. initdram(int board_type) reads EEPROM via I2c. EEPROM contains all of
  98. the necessary info for SDRAM controller configuration
  99. */
  100. /* ------------------------------------------------------------------------- */
  101. /* ------------------------------------------------------------------------- */
  102. long int initdram (int board_type)
  103. {
  104. #ifndef CONFIG_ERIC
  105. int i;
  106. unsigned char datain[128];
  107. int TotalSize;
  108. #endif
  109. #ifdef CONFIG_ERIC
  110. /*
  111. * we have no EEPROM on ERIC
  112. * so let init.S do the init job for SDRAM
  113. * and simply return 32MByte here
  114. */
  115. return (CFG_SDRAM_SIZE * 1024 * 1024);
  116. #else
  117. /* Read Serial Presence Detect Information */
  118. for (i = 0; i < 128; i++)
  119. datain[i] = 127;
  120. i2c_send (SPD_EEPROM_ADDRESS, 0, 1, datain, 128);
  121. printf ("\nReading DIMM...\n");
  122. #if 0
  123. for (i = 0; i < 128; i++) {
  124. printf ("%d=0x%x ", i, datain[i]);
  125. if (((i + 1) % 10) == 0)
  126. printf ("\n");
  127. }
  128. printf ("\n");
  129. #endif
  130. /*****************************/
  131. /* Retrieve interesting data */
  132. /*****************************/
  133. /* size of a SDRAM bank */
  134. /* Number of bytes per side / number of banks per side */
  135. if (datain[31] == 0x08)
  136. TotalSize = 32;
  137. else if (datain[31] == 0x10)
  138. TotalSize = 64;
  139. else {
  140. printf ("IIC READ ERROR!!!\n");
  141. TotalSize = 32;
  142. }
  143. /* single-sided DIMM or double-sided DIMM? */
  144. if (datain[5] != 1) {
  145. /* double-sided DIMM => SDRAM banks 0..3 are valid */
  146. printf ("double-sided DIMM\n");
  147. TotalSize *= 2;
  148. }
  149. /* else single-sided DIMM => SDRAM bank 0 and bank 2 are valid */
  150. else {
  151. printf ("single-sided DIMM\n");
  152. }
  153. /* return size in Mb unit => *(1024*1024) */
  154. return (TotalSize * 1024 * 1024);
  155. #endif
  156. }
  157. /* ------------------------------------------------------------------------- */
  158. int testdram (void)
  159. {
  160. /* TODO: XXX XXX XXX */
  161. printf ("test: xxx MB - ok\n");
  162. return (0);
  163. }
  164. /* ------------------------------------------------------------------------- */