csb272.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. /*
  29. * Configuration data for AMIS FS6377-01 Programmable 3-PLL Clock Generator
  30. *
  31. * CLKA output => Epson LCD Controller
  32. * CLKB output => Not Connected
  33. * CLKC output => Ethernet
  34. * CLKD output => UART external clock
  35. *
  36. * Note: these values are obtained from device after init by micromonitor
  37. */
  38. uchar pll_fs6377_regs[16] = {
  39. 0x28, 0xef, 0x53, 0x03, 0x4b, 0x80, 0x32, 0x80,
  40. 0x94, 0x32, 0x80, 0xd4, 0x56, 0xf6, 0xf6, 0xe0 };
  41. /*
  42. * pll_init: Initialize AMIS IC FS6377-01 PLL
  43. *
  44. * PLL supplies Epson LCD Clock, Ethernet Clock and UART external clock
  45. *
  46. */
  47. int pll_init(void)
  48. {
  49. i2c_init(CFG_I2C_SPEED, CFG_I2C_SLAVE);
  50. return i2c_write(CFG_I2C_PLL_ADDR, 0, 1,
  51. (uchar *) pll_fs6377_regs, sizeof(pll_fs6377_regs));
  52. }
  53. /*
  54. * board_early_init_f: do early board initialization
  55. *
  56. */
  57. int board_early_init_f(void)
  58. {
  59. /* initialize PLL so UART, LCD, Ethernet clocked at correctly */
  60. (void) get_clocks();
  61. pll_init();
  62. /*-------------------------------------------------------------------------+
  63. | Interrupt controller setup for the Walnut board.
  64. | Note: IRQ 0-15 405GP internally generated; active high; level sensitive
  65. | IRQ 16 405GP internally generated; active low; level sensitive
  66. | IRQ 17-24 RESERVED
  67. | IRQ 25 (EXT IRQ 0) FPGA; active high; level sensitive
  68. | IRQ 26 (EXT IRQ 1) SMI; active high; level sensitive
  69. | IRQ 27 (EXT IRQ 2) Not Used
  70. | IRQ 28 (EXT IRQ 3) PCI SLOT 3; active low; level sensitive
  71. | IRQ 29 (EXT IRQ 4) PCI SLOT 2; active low; level sensitive
  72. | IRQ 30 (EXT IRQ 5) PCI SLOT 1; active low; level sensitive
  73. | IRQ 31 (EXT IRQ 6) PCI SLOT 0; active low; level sensitive
  74. | Note for Walnut board:
  75. | An interrupt taken for the FPGA (IRQ 25) indicates that either
  76. | the Mouse, Keyboard, IRDA, or External Expansion caused the
  77. | interrupt. The FPGA must be read to determine which device
  78. | caused the interrupt. The default setting of the FPGA clears
  79. |
  80. +-------------------------------------------------------------------------*/
  81. mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
  82. mtdcr (uicer, 0x00000000); /* disable all ints */
  83. mtdcr (uiccr, 0x00000000); /* set all to be non-critical */
  84. mtdcr (uicpr, 0xFFFFFF83); /* set int polarities */
  85. mtdcr (uictr, 0x10000000); /* set int trigger levels */
  86. mtdcr (uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority */
  87. mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
  88. mtebc (epcr, 0xa8400000); /* EBC always driven */
  89. return 0; /* success */
  90. }
  91. /*
  92. * checkboard: identify/verify the board we are running
  93. *
  94. * Remark: we just assume it is correct board here!
  95. *
  96. */
  97. int checkboard(void)
  98. {
  99. printf("BOARD: Cogent CSB272\n");
  100. return 0; /* success */
  101. }
  102. /*
  103. * initram: Determine the size of mounted DRAM
  104. *
  105. * Size is determined by reading SDRAM configuration registers as
  106. * configured by initialization code
  107. *
  108. */
  109. long initdram (int board_type)
  110. {
  111. ulong tot_size;
  112. ulong bank_size;
  113. ulong tmp;
  114. tot_size = 0;
  115. mtdcr (memcfga, mem_mb0cf);
  116. tmp = mfdcr (memcfgd);
  117. if (tmp & 0x00000001) {
  118. bank_size = 0x00400000 << ((tmp >> 17) & 0x7);
  119. tot_size += bank_size;
  120. }
  121. mtdcr (memcfga, mem_mb1cf);
  122. tmp = mfdcr (memcfgd);
  123. if (tmp & 0x00000001) {
  124. bank_size = 0x00400000 << ((tmp >> 17) & 0x7);
  125. tot_size += bank_size;
  126. }
  127. mtdcr (memcfga, mem_mb2cf);
  128. tmp = mfdcr (memcfgd);
  129. if (tmp & 0x00000001) {
  130. bank_size = 0x00400000 << ((tmp >> 17) & 0x7);
  131. tot_size += bank_size;
  132. }
  133. mtdcr (memcfga, mem_mb3cf);
  134. tmp = mfdcr (memcfgd);
  135. if (tmp & 0x00000001) {
  136. bank_size = 0x00400000 << ((tmp >> 17) & 0x7);
  137. tot_size += bank_size;
  138. }
  139. return tot_size;
  140. }
  141. /*
  142. * last_stage_init: final configurations (such as PHY etc)
  143. *
  144. */
  145. int last_stage_init(void)
  146. {
  147. /* initialize the PHY */
  148. miiphy_reset("ppc_4xx_eth0", CONFIG_PHY_ADDR);
  149. /* AUTO neg */
  150. miiphy_write("ppc_4xx_eth0", CONFIG_PHY_ADDR, PHY_BMCR,
  151. PHY_BMCR_AUTON | PHY_BMCR_RST_NEG);
  152. /* LEDs */
  153. miiphy_write("ppc_4xx_eth0", CONFIG_PHY_ADDR, PHY_FCSCR, 0x0d08);
  154. return 0; /* success */
  155. }