2 * (C) Copyright 2000-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
11 DECLARE_GLOBAL_DATA_PTR;
15 puts ("Board: Freescale M5282EVB Evaluation Board\n");
21 u32 dramsize, i, dramclk;
23 dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
24 for (i = 0x13; i < 0x20; i++) {
25 if (dramsize == (1 << i))
30 if (!(MCFSDRAMC_DACR0 & MCFSDRAMC_DACR_RE))
32 dramclk = gd->bus_clk / (CONFIG_SYS_HZ * CONFIG_SYS_HZ);
34 /* Initialize DRAM Control Register: DCR */
36 | MCFSDRAMC_DCR_RTIM_6
37 | MCFSDRAMC_DCR_RC((15 * dramclk)>>4));
40 /* Initialize DACR0 */
42 | MCFSDRAMC_DACR_BASE(CONFIG_SYS_SDRAM_BASE)
43 | MCFSDRAMC_DACR_CASL(1)
44 | MCFSDRAMC_DACR_CBM(3)
45 | MCFSDRAMC_DACR_PS_32);
50 | ((dramsize - 1) & 0xFFFC0000)
54 /* Set IP (bit 3) in DACR */
55 MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IP;
58 /* Wait 30ns to allow banks to precharge */
59 for (i = 0; i < 5; i++) {
63 /* Write to this block to initiate precharge */
64 *(u32 *)(CONFIG_SYS_SDRAM_BASE) = 0xA5A59696;
67 /* Set RE (bit 15) in DACR */
68 MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_RE;
71 /* Wait for at least 8 auto refresh cycles to occur */
72 for (i = 0; i < 2000; i++) {
76 /* Finish the configuration by issuing the IMRS. */
77 MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IMRS;
80 /* Write to the SDRAM Mode Register */
81 *(u32 *)(CONFIG_SYS_SDRAM_BASE + 0x400) = 0xA5A59696;
83 gd->ram_size = dramsize;