mpc832xemds.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * Copyright (C) 2006 Freescale Semiconductor, Inc.
  3. *
  4. * Dave Liu <daveliu@freescale.com>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. */
  14. #include <common.h>
  15. #include <ioports.h>
  16. #include <mpc83xx.h>
  17. #include <i2c.h>
  18. #include <spd.h>
  19. #include <miiphy.h>
  20. #include <command.h>
  21. #if defined(CONFIG_PCI)
  22. #include <pci.h>
  23. #endif
  24. #if defined(CONFIG_SPD_EEPROM)
  25. #include <spd_sdram.h>
  26. #else
  27. #include <asm/mmu.h>
  28. #endif
  29. #if defined(CONFIG_OF_FLAT_TREE)
  30. #include <ft_build.h>
  31. #endif
  32. const qe_iop_conf_t qe_iop_conf_tab[] = {
  33. /* ETH3 */
  34. {1, 0, 1, 0, 1}, /* TxD0 */
  35. {1, 1, 1, 0, 1}, /* TxD1 */
  36. {1, 2, 1, 0, 1}, /* TxD2 */
  37. {1, 3, 1, 0, 1}, /* TxD3 */
  38. {1, 9, 1, 0, 1}, /* TxER */
  39. {1, 12, 1, 0, 1}, /* TxEN */
  40. {3, 24, 2, 0, 1}, /* TxCLK->CLK10 */
  41. {1, 4, 2, 0, 1}, /* RxD0 */
  42. {1, 5, 2, 0, 1}, /* RxD1 */
  43. {1, 6, 2, 0, 1}, /* RxD2 */
  44. {1, 7, 2, 0, 1}, /* RxD3 */
  45. {1, 8, 2, 0, 1}, /* RxER */
  46. {1, 10, 2, 0, 1}, /* RxDV */
  47. {0, 13, 2, 0, 1}, /* RxCLK->CLK9 */
  48. {1, 11, 2, 0, 1}, /* COL */
  49. {1, 13, 2, 0, 1}, /* CRS */
  50. /* ETH4 */
  51. {1, 18, 1, 0, 1}, /* TxD0 */
  52. {1, 19, 1, 0, 1}, /* TxD1 */
  53. {1, 20, 1, 0, 1}, /* TxD2 */
  54. {1, 21, 1, 0, 1}, /* TxD3 */
  55. {1, 27, 1, 0, 1}, /* TxER */
  56. {1, 30, 1, 0, 1}, /* TxEN */
  57. {3, 6, 2, 0, 1}, /* TxCLK->CLK8 */
  58. {1, 22, 2, 0, 1}, /* RxD0 */
  59. {1, 23, 2, 0, 1}, /* RxD1 */
  60. {1, 24, 2, 0, 1}, /* RxD2 */
  61. {1, 25, 2, 0, 1}, /* RxD3 */
  62. {1, 26, 1, 0, 1}, /* RxER */
  63. {1, 28, 2, 0, 1}, /* Rx_DV */
  64. {3, 31, 2, 0, 1}, /* RxCLK->CLK7 */
  65. {1, 29, 2, 0, 1}, /* COL */
  66. {1, 31, 2, 0, 1}, /* CRS */
  67. {3, 4, 3, 0, 2}, /* MDIO */
  68. {3, 5, 1, 0, 2}, /* MDC */
  69. {0, 0, 0, 0, QE_IOP_TAB_END}, /* END of table */
  70. };
  71. int board_early_init_f(void)
  72. {
  73. volatile u8 *bcsr = (volatile u8 *)CFG_BCSR;
  74. /* Enable flash write */
  75. bcsr[9] &= ~0x08;
  76. return 0;
  77. }
  78. int fixed_sdram(void);
  79. long int initdram(int board_type)
  80. {
  81. volatile immap_t *im = (immap_t *) CFG_IMMR;
  82. u32 msize = 0;
  83. if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
  84. return -1;
  85. /* DDR SDRAM - Main SODIMM */
  86. im->sysconf.ddrlaw[0].bar = CFG_DDR_BASE & LAWBAR_BAR;
  87. msize = fixed_sdram();
  88. puts("\n DDR RAM: ");
  89. /* return total bus SDRAM size(bytes) -- DDR */
  90. return (msize * 1024 * 1024);
  91. }
  92. /*************************************************************************
  93. * fixed sdram init -- doesn't use serial presence detect.
  94. ************************************************************************/
  95. int fixed_sdram(void)
  96. {
  97. volatile immap_t *im = (immap_t *) CFG_IMMR;
  98. u32 msize = 0;
  99. u32 ddr_size;
  100. u32 ddr_size_log2;
  101. msize = CFG_DDR_SIZE;
  102. for (ddr_size = msize << 20, ddr_size_log2 = 0;
  103. (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) {
  104. if (ddr_size & 1) {
  105. return -1;
  106. }
  107. }
  108. im->sysconf.ddrlaw[0].ar =
  109. LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
  110. #if (CFG_DDR_SIZE != 128)
  111. #warning Currenly any ddr size other than 128 is not supported
  112. #endif
  113. im->ddr.sdram_clk_cntl = CFG_DDR_CLK_CNTL;
  114. im->ddr.csbnds[0].csbnds = CFG_DDR_CS0_BNDS;
  115. im->ddr.cs_config[0] = CFG_DDR_CS0_CONFIG;
  116. im->ddr.timing_cfg_0 = CFG_DDR_TIMING_0;
  117. im->ddr.timing_cfg_1 = CFG_DDR_TIMING_1;
  118. im->ddr.timing_cfg_2 = CFG_DDR_TIMING_2;
  119. im->ddr.timing_cfg_3 = CFG_DDR_TIMING_3;
  120. im->ddr.sdram_cfg = CFG_DDR_SDRAM_CFG;
  121. im->ddr.sdram_cfg2 = CFG_DDR_SDRAM_CFG2;
  122. im->ddr.sdram_mode = CFG_DDR_MODE;
  123. im->ddr.sdram_mode2 = CFG_DDR_MODE2;
  124. im->ddr.sdram_interval = CFG_DDR_INTERVAL;
  125. __asm__ __volatile__ ("sync");
  126. udelay(200);
  127. im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
  128. __asm__ __volatile__ ("sync");
  129. return msize;
  130. }
  131. int checkboard(void)
  132. {
  133. puts("Board: Freescale MPC832XEMDS\n");
  134. return 0;
  135. }
  136. #if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
  137. void
  138. ft_board_setup(void *blob, bd_t *bd)
  139. {
  140. u32 *p;
  141. int len;
  142. #ifdef CONFIG_PCI
  143. ft_pci_setup(blob, bd);
  144. #endif
  145. ft_cpu_setup(blob, bd);
  146. p = ft_get_prop(blob, "/memory/reg", &len);
  147. if (p != NULL) {
  148. *p++ = cpu_to_be32(bd->bi_memstart);
  149. *p = cpu_to_be32(bd->bi_memsize);
  150. }
  151. }
  152. #endif