mpc837xemds.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 <spd.h>
  15. #if defined(CONFIG_SPD_EEPROM)
  16. #include <spd_sdram.h>
  17. #endif
  18. #if defined(CONFIG_OF_LIBFDT)
  19. #include <libfdt.h>
  20. #endif
  21. #if defined(CONFIG_PQ_MDS_PIB)
  22. #include "../common/pq-mds-pib.h"
  23. #endif
  24. int board_early_init_f(void)
  25. {
  26. u8 *bcsr = (u8 *)CFG_BCSR;
  27. /* Enable flash write */
  28. bcsr[0x9] &= ~0x04;
  29. /* Clear all of the interrupt of BCSR */
  30. bcsr[0xe] = 0xff;
  31. return 0;
  32. }
  33. int board_early_init_r(void)
  34. {
  35. #ifdef CONFIG_PQ_MDS_PIB
  36. pib_init();
  37. #endif
  38. return 0;
  39. }
  40. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
  41. extern void ddr_enable_ecc(unsigned int dram_size);
  42. #endif
  43. int fixed_sdram(void);
  44. long int initdram(int board_type)
  45. {
  46. volatile immap_t *im = (immap_t *) CFG_IMMR;
  47. u32 msize = 0;
  48. if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
  49. return -1;
  50. #if defined(CONFIG_SPD_EEPROM)
  51. msize = spd_sdram();
  52. #else
  53. msize = fixed_sdram();
  54. #endif
  55. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
  56. /* Initialize DDR ECC byte */
  57. ddr_enable_ecc(msize * 1024 * 1024);
  58. #endif
  59. /* return total bus DDR size(bytes) */
  60. return (msize * 1024 * 1024);
  61. }
  62. #if !defined(CONFIG_SPD_EEPROM)
  63. /*************************************************************************
  64. * fixed sdram init -- doesn't use serial presence detect.
  65. ************************************************************************/
  66. int fixed_sdram(void)
  67. {
  68. volatile immap_t *im = (immap_t *) CFG_IMMR;
  69. u32 msize = CFG_DDR_SIZE * 1024 * 1024;
  70. u32 msize_log2 = __ilog2(msize);
  71. im->sysconf.ddrlaw[0].bar = CFG_DDR_SDRAM_BASE >> 12;
  72. im->sysconf.ddrlaw[0].ar = LBLAWAR_EN | (msize_log2 - 1);
  73. #if (CFG_DDR_SIZE != 512)
  74. #warning Currenly any ddr size other than 512 is not supported
  75. #endif
  76. im->sysconf.ddrcdr = CFG_DDRCDR_VALUE;
  77. udelay(50000);
  78. im->ddr.sdram_clk_cntl = CFG_DDR_SDRAM_CLK_CNTL;
  79. udelay(1000);
  80. im->ddr.csbnds[0].csbnds = CFG_DDR_CS0_BNDS;
  81. im->ddr.cs_config[0] = CFG_DDR_CS0_CONFIG;
  82. udelay(1000);
  83. im->ddr.timing_cfg_0 = CFG_DDR_TIMING_0;
  84. im->ddr.timing_cfg_1 = CFG_DDR_TIMING_1;
  85. im->ddr.timing_cfg_2 = CFG_DDR_TIMING_2;
  86. im->ddr.timing_cfg_3 = CFG_DDR_TIMING_3;
  87. im->ddr.sdram_cfg = CFG_DDR_SDRAM_CFG;
  88. im->ddr.sdram_cfg2 = CFG_DDR_SDRAM_CFG2;
  89. im->ddr.sdram_mode = CFG_DDR_MODE;
  90. im->ddr.sdram_mode2 = CFG_DDR_MODE2;
  91. im->ddr.sdram_interval = CFG_DDR_INTERVAL;
  92. __asm__ __volatile__("sync");
  93. udelay(1000);
  94. im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
  95. udelay(2000);
  96. return CFG_DDR_SIZE;
  97. }
  98. #endif /*!CFG_SPD_EEPROM */
  99. int checkboard(void)
  100. {
  101. puts("Board: Freescale MPC837xEMDS\n");
  102. return 0;
  103. }
  104. #if defined(CONFIG_OF_BOARD_SETUP)
  105. void ft_board_setup(void *blob, bd_t *bd)
  106. {
  107. ft_cpu_setup(blob, bd);
  108. #ifdef CONFIG_PCI
  109. ft_pci_setup(blob, bd);
  110. #endif
  111. }
  112. #endif /* CONFIG_OF_BOARD_SETUP */