csb472.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * (C) Copyright 2004
  3. * Tolunay Orkun, Nextio Inc., torkun@nextio.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 <i2c.h>
  26. #include <miiphy.h>
  27. #include <ppc4xx_enet.h>
  28. void sdram_init(void);
  29. /*
  30. * board_early_init_f: do early board initialization
  31. *
  32. */
  33. int board_early_init_f(void)
  34. {
  35. /*-------------------------------------------------------------------------+
  36. | Interrupt controller setup for the Walnut board.
  37. | Note: IRQ 0-15 405GP internally generated; active high; level sensitive
  38. | IRQ 16 405GP internally generated; active low; level sensitive
  39. | IRQ 17-24 RESERVED
  40. | IRQ 25 (EXT IRQ 0) FPGA; active high; level sensitive
  41. | IRQ 26 (EXT IRQ 1) SMI; active high; level sensitive
  42. | IRQ 27 (EXT IRQ 2) Not Used
  43. | IRQ 28 (EXT IRQ 3) PCI SLOT 3; active low; level sensitive
  44. | IRQ 29 (EXT IRQ 4) PCI SLOT 2; active low; level sensitive
  45. | IRQ 30 (EXT IRQ 5) PCI SLOT 1; active low; level sensitive
  46. | IRQ 31 (EXT IRQ 6) PCI SLOT 0; active low; level sensitive
  47. | Note for Walnut board:
  48. | An interrupt taken for the FPGA (IRQ 25) indicates that either
  49. | the Mouse, Keyboard, IRDA, or External Expansion caused the
  50. | interrupt. The FPGA must be read to determine which device
  51. | caused the interrupt. The default setting of the FPGA clears
  52. |
  53. +-------------------------------------------------------------------------*/
  54. mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
  55. mtdcr (uicer, 0x00000000); /* disable all ints */
  56. mtdcr (uiccr, 0x00000000); /* set all to be non-critical */
  57. mtdcr (uicpr, 0xFFFFFF83); /* set int polarities */
  58. mtdcr (uictr, 0x10000000); /* set int trigger levels */
  59. mtdcr (uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority */
  60. mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
  61. mtebc (epcr, 0xa8400000); /* EBC always driven */
  62. return 0; /* success */
  63. }
  64. /*
  65. * checkboard: identify/verify the board we are running
  66. *
  67. * Remark: we just assume it is correct board here!
  68. *
  69. */
  70. int checkboard(void)
  71. {
  72. printf("BOARD: Cogent CSB472\n");
  73. return 0; /* success */
  74. }
  75. /*
  76. * initram: Determine the size of mounted DRAM
  77. *
  78. * Size is determined by reading SDRAM configuration registers as
  79. * configured by initialization code
  80. *
  81. */
  82. phys_size_t initdram (int board_type)
  83. {
  84. ulong tot_size;
  85. ulong bank_size;
  86. ulong tmp;
  87. /*
  88. * ToDo: Move the asm init routine sdram_init() to this C file,
  89. * or even better use some common ppc4xx code available
  90. * in cpu/ppc4xx
  91. */
  92. sdram_init();
  93. tot_size = 0;
  94. mtdcr (memcfga, mem_mb0cf);
  95. tmp = mfdcr (memcfgd);
  96. if (tmp & 0x00000001) {
  97. bank_size = 0x00400000 << ((tmp >> 17) & 0x7);
  98. tot_size += bank_size;
  99. }
  100. mtdcr (memcfga, mem_mb1cf);
  101. tmp = mfdcr (memcfgd);
  102. if (tmp & 0x00000001) {
  103. bank_size = 0x00400000 << ((tmp >> 17) & 0x7);
  104. tot_size += bank_size;
  105. }
  106. mtdcr (memcfga, mem_mb2cf);
  107. tmp = mfdcr (memcfgd);
  108. if (tmp & 0x00000001) {
  109. bank_size = 0x00400000 << ((tmp >> 17) & 0x7);
  110. tot_size += bank_size;
  111. }
  112. mtdcr (memcfga, mem_mb3cf);
  113. tmp = mfdcr (memcfgd);
  114. if (tmp & 0x00000001) {
  115. bank_size = 0x00400000 << ((tmp >> 17) & 0x7);
  116. tot_size += bank_size;
  117. }
  118. return tot_size;
  119. }
  120. /*
  121. * last_stage_init: final configurations (such as PHY etc)
  122. *
  123. */
  124. int last_stage_init(void)
  125. {
  126. /* initialize the PHY */
  127. miiphy_reset("ppc_4xx_eth0", CONFIG_PHY_ADDR);
  128. /* AUTO neg */
  129. miiphy_write("ppc_4xx_eth0", CONFIG_PHY_ADDR, PHY_BMCR,
  130. PHY_BMCR_AUTON | PHY_BMCR_RST_NEG);
  131. /* LEDs */
  132. miiphy_write("ppc_4xx_eth0", CONFIG_PHY_ADDR, PHY_FCSCR, 0x0d08);
  133. return 0; /* success */
  134. }