m5282evb.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * (C) Copyright 2000-2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <asm/immap.h>
  25. DECLARE_GLOBAL_DATA_PTR;
  26. int checkboard (void)
  27. {
  28. puts ("Board: Freescale M5282EVB Evaluation Board\n");
  29. return 0;
  30. }
  31. phys_size_t initdram (int board_type)
  32. {
  33. u32 dramsize, i, dramclk;
  34. dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
  35. for (i = 0x13; i < 0x20; i++) {
  36. if (dramsize == (1 << i))
  37. break;
  38. }
  39. i--;
  40. if (!(MCFSDRAMC_DACR0 & MCFSDRAMC_DACR_RE))
  41. {
  42. dramclk = gd->bus_clk / (CONFIG_SYS_HZ * CONFIG_SYS_HZ);
  43. /* Initialize DRAM Control Register: DCR */
  44. MCFSDRAMC_DCR = (0
  45. | MCFSDRAMC_DCR_RTIM_6
  46. | MCFSDRAMC_DCR_RC((15 * dramclk)>>4));
  47. asm("nop");
  48. /* Initialize DACR0 */
  49. MCFSDRAMC_DACR0 = (0
  50. | MCFSDRAMC_DACR_BASE(CONFIG_SYS_SDRAM_BASE)
  51. | MCFSDRAMC_DACR_CASL(1)
  52. | MCFSDRAMC_DACR_CBM(3)
  53. | MCFSDRAMC_DACR_PS_32);
  54. asm("nop");
  55. /* Initialize DMR0 */
  56. MCFSDRAMC_DMR0 = (0
  57. | ((dramsize - 1) & 0xFFFC0000)
  58. | MCFSDRAMC_DMR_V);
  59. asm("nop");
  60. /* Set IP (bit 3) in DACR */
  61. MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IP;
  62. asm("nop");
  63. /* Wait 30ns to allow banks to precharge */
  64. for (i = 0; i < 5; i++) {
  65. asm ("nop");
  66. }
  67. /* Write to this block to initiate precharge */
  68. *(u32 *)(CONFIG_SYS_SDRAM_BASE) = 0xA5A59696;
  69. asm("nop");
  70. /* Set RE (bit 15) in DACR */
  71. MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_RE;
  72. asm("nop");
  73. /* Wait for at least 8 auto refresh cycles to occur */
  74. for (i = 0; i < 2000; i++) {
  75. asm(" nop");
  76. }
  77. /* Finish the configuration by issuing the IMRS. */
  78. MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IMRS;
  79. asm("nop");
  80. /* Write to the SDRAM Mode Register */
  81. *(u32 *)(CONFIG_SYS_SDRAM_BASE + 0x400) = 0xA5A59696;
  82. }
  83. return dramsize;
  84. }