mpc837xemds.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 *)CONFIG_SYS_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 *)CONFIG_SYS_IMMR;
  32. u32 spridr = in_be32(&immr->sysconf.spridr);
  33. /* we check only part num, and don't look for CPU revisions */
  34. switch (PARTID_NO_E(spridr)) {
  35. case SPR_8377:
  36. fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_SATA,
  37. FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
  38. fsl_setup_serdes(CONFIG_FSL_SERDES2, FSL_SERDES_PROTO_PEX,
  39. FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
  40. break;
  41. case SPR_8378:
  42. fsl_setup_serdes(CONFIG_FSL_SERDES2, FSL_SERDES_PROTO_PEX,
  43. FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
  44. break;
  45. case SPR_8379:
  46. fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_SATA,
  47. FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
  48. fsl_setup_serdes(CONFIG_FSL_SERDES2, FSL_SERDES_PROTO_SATA,
  49. FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
  50. break;
  51. default:
  52. printf("serdes not configured: unknown CPU part number: "
  53. "%04x\n", spridr >> 16);
  54. break;
  55. }
  56. #endif /* CONFIG_FSL_SERDES */
  57. return 0;
  58. }
  59. int board_early_init_r(void)
  60. {
  61. #ifdef CONFIG_PQ_MDS_PIB
  62. pib_init();
  63. #endif
  64. return 0;
  65. }
  66. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
  67. extern void ddr_enable_ecc(unsigned int dram_size);
  68. #endif
  69. int fixed_sdram(void);
  70. phys_size_t initdram(int board_type)
  71. {
  72. volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
  73. u32 msize = 0;
  74. if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
  75. return -1;
  76. #if defined(CONFIG_SPD_EEPROM)
  77. msize = spd_sdram();
  78. #else
  79. msize = fixed_sdram();
  80. #endif
  81. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
  82. /* Initialize DDR ECC byte */
  83. ddr_enable_ecc(msize * 1024 * 1024);
  84. #endif
  85. /* return total bus DDR size(bytes) */
  86. return (msize * 1024 * 1024);
  87. }
  88. #if !defined(CONFIG_SPD_EEPROM)
  89. /*************************************************************************
  90. * fixed sdram init -- doesn't use serial presence detect.
  91. ************************************************************************/
  92. int fixed_sdram(void)
  93. {
  94. volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
  95. u32 msize = CONFIG_SYS_DDR_SIZE * 1024 * 1024;
  96. u32 msize_log2 = __ilog2(msize);
  97. im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_SDRAM_BASE & 0xfffff000;
  98. im->sysconf.ddrlaw[0].ar = LBLAWAR_EN | (msize_log2 - 1);
  99. #if (CONFIG_SYS_DDR_SIZE != 512)
  100. #warning Currenly any ddr size other than 512 is not supported
  101. #endif
  102. im->sysconf.ddrcdr = CONFIG_SYS_DDRCDR_VALUE;
  103. udelay(50000);
  104. im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_SDRAM_CLK_CNTL;
  105. udelay(1000);
  106. im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
  107. im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
  108. udelay(1000);
  109. im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
  110. im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
  111. im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
  112. im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
  113. im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
  114. im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
  115. im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
  116. im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
  117. im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
  118. __asm__ __volatile__("sync");
  119. udelay(1000);
  120. im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
  121. udelay(2000);
  122. return CONFIG_SYS_DDR_SIZE;
  123. }
  124. #endif /*!CONFIG_SYS_SPD_EEPROM */
  125. int checkboard(void)
  126. {
  127. puts("Board: Freescale MPC837xEMDS\n");
  128. return 0;
  129. }
  130. #if defined(CONFIG_OF_BOARD_SETUP)
  131. void ft_board_setup(void *blob, bd_t *bd)
  132. {
  133. ft_cpu_setup(blob, bd);
  134. #ifdef CONFIG_PCI
  135. ft_pci_setup(blob, bd);
  136. #endif
  137. }
  138. #endif /* CONFIG_OF_BOARD_SETUP */