m5282evb.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2000-2003
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. */
  6. #include <common.h>
  7. #include <init.h>
  8. #include <asm/immap.h>
  9. DECLARE_GLOBAL_DATA_PTR;
  10. int checkboard (void)
  11. {
  12. puts ("Board: Freescale M5282EVB Evaluation Board\n");
  13. return 0;
  14. }
  15. int dram_init(void)
  16. {
  17. u32 dramsize, i, dramclk;
  18. dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
  19. for (i = 0x13; i < 0x20; i++) {
  20. if (dramsize == (1 << i))
  21. break;
  22. }
  23. i--;
  24. if (!(MCFSDRAMC_DACR0 & MCFSDRAMC_DACR_RE))
  25. {
  26. dramclk = gd->bus_clk / (CONFIG_SYS_HZ * CONFIG_SYS_HZ);
  27. /* Initialize DRAM Control Register: DCR */
  28. MCFSDRAMC_DCR = (0
  29. | MCFSDRAMC_DCR_RTIM_6
  30. | MCFSDRAMC_DCR_RC((15 * dramclk)>>4));
  31. asm("nop");
  32. /* Initialize DACR0 */
  33. MCFSDRAMC_DACR0 = (0
  34. | MCFSDRAMC_DACR_BASE(CONFIG_SYS_SDRAM_BASE)
  35. | MCFSDRAMC_DACR_CASL(1)
  36. | MCFSDRAMC_DACR_CBM(3)
  37. | MCFSDRAMC_DACR_PS_32);
  38. asm("nop");
  39. /* Initialize DMR0 */
  40. MCFSDRAMC_DMR0 = (0
  41. | ((dramsize - 1) & 0xFFFC0000)
  42. | MCFSDRAMC_DMR_V);
  43. asm("nop");
  44. /* Set IP (bit 3) in DACR */
  45. MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IP;
  46. asm("nop");
  47. /* Wait 30ns to allow banks to precharge */
  48. for (i = 0; i < 5; i++) {
  49. asm ("nop");
  50. }
  51. /* Write to this block to initiate precharge */
  52. *(u32 *)(CONFIG_SYS_SDRAM_BASE) = 0xA5A59696;
  53. asm("nop");
  54. /* Set RE (bit 15) in DACR */
  55. MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_RE;
  56. asm("nop");
  57. /* Wait for at least 8 auto refresh cycles to occur */
  58. for (i = 0; i < 2000; i++) {
  59. asm(" nop");
  60. }
  61. /* Finish the configuration by issuing the IMRS. */
  62. MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IMRS;
  63. asm("nop");
  64. /* Write to the SDRAM Mode Register */
  65. *(u32 *)(CONFIG_SYS_SDRAM_BASE + 0x400) = 0xA5A59696;
  66. }
  67. gd->ram_size = dramsize;
  68. return 0;
  69. }