vme8349.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * vme8349.c -- esd VME8349 board support
  3. *
  4. * Copyright (c) 2008-2009 esd gmbh.
  5. *
  6. * (C) Copyright 2006
  7. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  8. *
  9. * Reinhard Arlt <reinhard.arlt@esd-electronics.com>
  10. * Based on board/mpc8349emds/mpc8349emds.c (and previous 834x releases.)
  11. *
  12. * See file CREDITS for list of people who contributed to this
  13. * project.
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License as
  17. * published by the Free Software Foundation; either version 2 of
  18. * the License, or (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  28. * MA 02111-1307 USA
  29. *
  30. */
  31. #include <common.h>
  32. #include <ioports.h>
  33. #include <mpc83xx.h>
  34. #include <asm/mpc8349_pci.h>
  35. #if defined(CONFIG_OF_LIBFDT)
  36. #include <libfdt.h>
  37. #endif
  38. #include <asm/io.h>
  39. #include <asm/mmu.h>
  40. void ddr_enable_ecc(unsigned int dram_size);
  41. int fixed_sdram(void)
  42. {
  43. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  44. u32 msize = 0;
  45. u32 ddr_size;
  46. u32 ddr_size_log2;
  47. msize = CONFIG_SYS_DDR_SIZE;
  48. for (ddr_size = msize << 20, ddr_size_log2 = 0;
  49. (ddr_size > 1);
  50. ddr_size = ddr_size>>1, ddr_size_log2++) {
  51. if (ddr_size & 1)
  52. return -1;
  53. }
  54. im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_SDRAM_BASE & 0xfffff000;
  55. im->sysconf.ddrlaw[0].ar = LAWAR_EN | ((ddr_size_log2 - 1) &
  56. LAWAR_SIZE);
  57. #if (CONFIG_SYS_DDR_SIZE == 512)
  58. im->ddr.csbnds[0].csbnds = 0x0000001f;
  59. #else
  60. #warning Currently any DDR size other than 512MiB is not supported
  61. #endif
  62. im->ddr.cs_config[0] = CONFIG_SYS_DDR_CONFIG | 0x00330000;
  63. /* currently we use only one CS, so disable the other banks */
  64. im->ddr.csbnds[1].csbnds = 0x00000000;
  65. im->ddr.csbnds[2].csbnds = 0x00000000;
  66. im->ddr.csbnds[3].csbnds = 0x00000000;
  67. im->ddr.cs_config[1] = 0;
  68. im->ddr.cs_config[2] = 0;
  69. im->ddr.cs_config[3] = 0;
  70. im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
  71. im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
  72. im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
  73. im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
  74. im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
  75. im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
  76. im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
  77. im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
  78. im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
  79. sync();
  80. udelay(200);
  81. /* enable DDR controller */
  82. im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
  83. return msize;
  84. }
  85. phys_size_t initdram(int board_type)
  86. {
  87. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  88. u32 msize = 0;
  89. if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32)im)
  90. return -1;
  91. /* DDR SDRAM - Main SODIMM */
  92. im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
  93. msize = fixed_sdram();
  94. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  95. /*
  96. * Initialize and enable DDR ECC.
  97. */
  98. ddr_enable_ecc(msize * 1024 * 1024);
  99. #endif
  100. /* Now check memory size (after ECC is initialized) */
  101. msize = get_ram_size(0, msize);
  102. /* return total bus SDRAM size(bytes) -- DDR */
  103. return msize * 1024 * 1024;
  104. }
  105. int checkboard(void)
  106. {
  107. puts("Board: esd VME8349\n");
  108. return 0;
  109. }
  110. #if defined(CONFIG_OF_BOARD_SETUP)
  111. void ft_board_setup(void *blob, bd_t *bd)
  112. {
  113. ft_cpu_setup(blob, bd);
  114. #ifdef CONFIG_PCI
  115. ft_pci_setup(blob, bd);
  116. #endif
  117. }
  118. #endif