mpc832xemds.c 4.2 KB

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