2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2003-12-08 01:34:36 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2000-2003
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2007-08-16 01:32:06 +00:00
|
|
|
#include <asm/immap.h>
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
2003-12-08 01:34:36 +00:00
|
|
|
|
|
|
|
int checkboard (void)
|
|
|
|
{
|
2007-08-16 01:32:06 +00:00
|
|
|
puts ("Board: Freescale M5282EVB Evaluation Board\n");
|
2003-12-08 01:34:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-04-06 18:47:05 +00:00
|
|
|
int dram_init(void)
|
2003-12-08 01:34:36 +00:00
|
|
|
{
|
2007-08-16 01:32:06 +00:00
|
|
|
u32 dramsize, i, dramclk;
|
|
|
|
|
2022-11-16 18:10:37 +00:00
|
|
|
dramsize = CFG_SYS_SDRAM_SIZE * 0x100000;
|
2007-08-16 01:32:06 +00:00
|
|
|
for (i = 0x13; i < 0x20; i++) {
|
|
|
|
if (dramsize == (1 << i))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i--;
|
|
|
|
|
|
|
|
if (!(MCFSDRAMC_DACR0 & MCFSDRAMC_DACR_RE))
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
dramclk = gd->bus_clk / (CONFIG_SYS_HZ * CONFIG_SYS_HZ);
|
2007-08-16 01:32:06 +00:00
|
|
|
|
|
|
|
/* Initialize DRAM Control Register: DCR */
|
|
|
|
MCFSDRAMC_DCR = (0
|
|
|
|
| MCFSDRAMC_DCR_RTIM_6
|
|
|
|
| MCFSDRAMC_DCR_RC((15 * dramclk)>>4));
|
2008-08-11 15:54:25 +00:00
|
|
|
asm("nop");
|
2007-08-16 01:32:06 +00:00
|
|
|
|
|
|
|
/* Initialize DACR0 */
|
|
|
|
MCFSDRAMC_DACR0 = (0
|
2022-11-16 18:10:37 +00:00
|
|
|
| MCFSDRAMC_DACR_BASE(CFG_SYS_SDRAM_BASE)
|
2007-08-16 01:32:06 +00:00
|
|
|
| MCFSDRAMC_DACR_CASL(1)
|
|
|
|
| MCFSDRAMC_DACR_CBM(3)
|
|
|
|
| MCFSDRAMC_DACR_PS_32);
|
2008-08-11 15:54:25 +00:00
|
|
|
asm("nop");
|
2007-08-16 01:32:06 +00:00
|
|
|
|
|
|
|
/* Initialize DMR0 */
|
|
|
|
MCFSDRAMC_DMR0 = (0
|
|
|
|
| ((dramsize - 1) & 0xFFFC0000)
|
|
|
|
| MCFSDRAMC_DMR_V);
|
2008-08-11 15:54:25 +00:00
|
|
|
asm("nop");
|
2007-08-16 01:32:06 +00:00
|
|
|
|
|
|
|
/* Set IP (bit 3) in DACR */
|
|
|
|
MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IP;
|
2008-08-11 15:54:25 +00:00
|
|
|
asm("nop");
|
2007-08-16 01:32:06 +00:00
|
|
|
|
|
|
|
/* Wait 30ns to allow banks to precharge */
|
|
|
|
for (i = 0; i < 5; i++) {
|
|
|
|
asm ("nop");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write to this block to initiate precharge */
|
2022-11-16 18:10:37 +00:00
|
|
|
*(u32 *)(CFG_SYS_SDRAM_BASE) = 0xA5A59696;
|
2008-08-11 15:54:25 +00:00
|
|
|
asm("nop");
|
2007-08-16 01:32:06 +00:00
|
|
|
|
|
|
|
/* Set RE (bit 15) in DACR */
|
|
|
|
MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_RE;
|
2008-08-11 15:54:25 +00:00
|
|
|
asm("nop");
|
2007-08-16 01:32:06 +00:00
|
|
|
|
|
|
|
/* Wait for at least 8 auto refresh cycles to occur */
|
|
|
|
for (i = 0; i < 2000; i++) {
|
|
|
|
asm(" nop");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finish the configuration by issuing the IMRS. */
|
|
|
|
MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IMRS;
|
2008-08-11 15:54:25 +00:00
|
|
|
asm("nop");
|
2007-08-16 01:32:06 +00:00
|
|
|
|
|
|
|
/* Write to the SDRAM Mode Register */
|
2022-11-16 18:10:37 +00:00
|
|
|
*(u32 *)(CFG_SYS_SDRAM_BASE + 0x400) = 0xA5A59696;
|
2007-08-16 01:32:06 +00:00
|
|
|
}
|
2017-03-31 14:40:25 +00:00
|
|
|
gd->ram_size = dramsize;
|
|
|
|
|
|
|
|
return 0;
|
2003-12-08 01:34:36 +00:00
|
|
|
}
|