mpc837xemds.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * Copyright (C) 2007 Freescale Semiconductor, Inc.
  3. * Dave Liu <daveliu@freescale.com>
  4. *
  5. * CREDITS: Kim Phillips contribute to LIBFDT code
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. */
  12. #include <common.h>
  13. #include <i2c.h>
  14. #include <asm/io.h>
  15. #include <asm/fsl_serdes.h>
  16. #include <spd_sdram.h>
  17. #if defined(CONFIG_OF_LIBFDT)
  18. #include <libfdt.h>
  19. #endif
  20. #if defined(CONFIG_PQ_MDS_PIB)
  21. #include "../common/pq-mds-pib.h"
  22. #endif
  23. int board_early_init_f(void)
  24. {
  25. u8 *bcsr = (u8 *)CFG_BCSR;
  26. /* Enable flash write */
  27. bcsr[0x9] &= ~0x04;
  28. /* Clear all of the interrupt of BCSR */
  29. bcsr[0xe] = 0xff;
  30. #ifdef CONFIG_FSL_SERDES
  31. immap_t *immr = (immap_t *)CFG_IMMR;
  32. u32 spridr = in_be32(&immr->sysconf.spridr);
  33. /* we check only part num, and don't look for CPU revisions */
  34. switch (spridr >> 16) {
  35. case SPR_8379E_REV10 >> 16:
  36. case SPR_8379_REV10 >> 16:
  37. fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_SATA,
  38. FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
  39. fsl_setup_serdes(CONFIG_FSL_SERDES2, FSL_SERDES_PROTO_SATA,
  40. FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
  41. break;
  42. case SPR_8378E_REV10 >> 16:
  43. case SPR_8378_REV10 >> 16:
  44. fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_PEX,
  45. FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
  46. break;
  47. case SPR_8377E_REV10 >> 16:
  48. case SPR_8377_REV10 >> 16:
  49. fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_SATA,
  50. FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
  51. fsl_setup_serdes(CONFIG_FSL_SERDES2, FSL_SERDES_PROTO_PEX,
  52. FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
  53. break;
  54. default:
  55. printf("serdes not configured: unknown CPU part number: "
  56. "%04x\n", spridr >> 16);
  57. break;
  58. }
  59. #endif /* CONFIG_FSL_SERDES */
  60. return 0;
  61. }
  62. int board_early_init_r(void)
  63. {
  64. #ifdef CONFIG_PQ_MDS_PIB
  65. pib_init();
  66. #endif
  67. return 0;
  68. }
  69. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
  70. extern void ddr_enable_ecc(unsigned int dram_size);
  71. #endif
  72. int fixed_sdram(void);
  73. long int initdram(int board_type)
  74. {
  75. volatile immap_t *im = (immap_t *) CFG_IMMR;
  76. u32 msize = 0;
  77. if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
  78. return -1;
  79. #if defined(CONFIG_SPD_EEPROM)
  80. msize = spd_sdram();
  81. #else
  82. msize = fixed_sdram();
  83. #endif
  84. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
  85. /* Initialize DDR ECC byte */
  86. ddr_enable_ecc(msize * 1024 * 1024);
  87. #endif
  88. /* return total bus DDR size(bytes) */
  89. return (msize * 1024 * 1024);
  90. }
  91. #if !defined(CONFIG_SPD_EEPROM)
  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 = CFG_DDR_SIZE * 1024 * 1024;
  99. u32 msize_log2 = __ilog2(msize);
  100. im->sysconf.ddrlaw[0].bar = CFG_DDR_SDRAM_BASE >> 12;
  101. im->sysconf.ddrlaw[0].ar = LBLAWAR_EN | (msize_log2 - 1);
  102. #if (CFG_DDR_SIZE != 512)
  103. #warning Currenly any ddr size other than 512 is not supported
  104. #endif
  105. im->sysconf.ddrcdr = CFG_DDRCDR_VALUE;
  106. udelay(50000);
  107. im->ddr.sdram_clk_cntl = CFG_DDR_SDRAM_CLK_CNTL;
  108. udelay(1000);
  109. im->ddr.csbnds[0].csbnds = CFG_DDR_CS0_BNDS;
  110. im->ddr.cs_config[0] = CFG_DDR_CS0_CONFIG;
  111. udelay(1000);
  112. im->ddr.timing_cfg_0 = CFG_DDR_TIMING_0;
  113. im->ddr.timing_cfg_1 = CFG_DDR_TIMING_1;
  114. im->ddr.timing_cfg_2 = CFG_DDR_TIMING_2;
  115. im->ddr.timing_cfg_3 = CFG_DDR_TIMING_3;
  116. im->ddr.sdram_cfg = CFG_DDR_SDRAM_CFG;
  117. im->ddr.sdram_cfg2 = CFG_DDR_SDRAM_CFG2;
  118. im->ddr.sdram_mode = CFG_DDR_MODE;
  119. im->ddr.sdram_mode2 = CFG_DDR_MODE2;
  120. im->ddr.sdram_interval = CFG_DDR_INTERVAL;
  121. __asm__ __volatile__("sync");
  122. udelay(1000);
  123. im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
  124. udelay(2000);
  125. return CFG_DDR_SIZE;
  126. }
  127. #endif /*!CFG_SPD_EEPROM */
  128. int checkboard(void)
  129. {
  130. puts("Board: Freescale MPC837xEMDS\n");
  131. return 0;
  132. }
  133. #if defined(CONFIG_OF_BOARD_SETUP)
  134. void ft_board_setup(void *blob, bd_t *bd)
  135. {
  136. ft_cpu_setup(blob, bd);
  137. #ifdef CONFIG_PCI
  138. ft_pci_setup(blob, bd);
  139. #endif
  140. }
  141. #endif /* CONFIG_OF_BOARD_SETUP */