mpc832xemds.c 4.4 KB

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