2008-01-24 20:02:32 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2000-2003
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005-2008 Arthur Shipkowski (art@videon-central.com)
|
|
|
|
*
|
2012-03-26 21:49:04 +00:00
|
|
|
* Copyright (C) 2012 Freescale Semiconductor, Inc. All Rights Reserved.
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2008-01-24 20:02:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/immap.h>
|
2012-03-26 21:49:04 +00:00
|
|
|
#include <asm/io.h>
|
2008-01-24 20:02:32 +00:00
|
|
|
|
2017-03-31 14:40:25 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2008-01-24 20:02:32 +00:00
|
|
|
#define PERIOD 13 /* system bus period in ns */
|
|
|
|
#define SDRAM_TREFI 7800 /* in ns */
|
|
|
|
|
|
|
|
int checkboard(void)
|
|
|
|
{
|
|
|
|
puts("Board: ");
|
|
|
|
puts("Freescale MCF5275 EVB\n");
|
|
|
|
return 0;
|
|
|
|
};
|
|
|
|
|
2017-04-06 18:47:05 +00:00
|
|
|
int dram_init(void)
|
2008-01-24 20:02:32 +00:00
|
|
|
{
|
2012-03-26 21:49:04 +00:00
|
|
|
sdramctrl_t *sdp = (sdramctrl_t *)(MMAP_SDRAM);
|
|
|
|
gpio_t *gpio_reg = (gpio_t *)(MMAP_GPIO);
|
2008-01-24 20:02:32 +00:00
|
|
|
|
2012-03-26 21:49:04 +00:00
|
|
|
/* Enable SDRAM */
|
|
|
|
out_be16(&gpio_reg->par_sdram, 0x3FF);
|
2008-01-24 20:02:32 +00:00
|
|
|
|
|
|
|
/* Set up chip select */
|
2012-03-26 21:49:04 +00:00
|
|
|
out_be32(&sdp->sdbar0, CONFIG_SYS_SDRAM_BASE);
|
|
|
|
out_be32(&sdp->sdbmr0, MCF_SDRAMC_SDMRn_BAM_32M | MCF_SDRAMC_SDMRn_V);
|
2008-01-24 20:02:32 +00:00
|
|
|
|
|
|
|
/* Set up timing */
|
2012-03-26 21:49:04 +00:00
|
|
|
out_be32(&sdp->sdcfg1, 0x83711630);
|
|
|
|
out_be32(&sdp->sdcfg2, 0x46770000);
|
2008-01-24 20:02:32 +00:00
|
|
|
|
|
|
|
/* Enable clock */
|
2012-03-26 21:49:04 +00:00
|
|
|
out_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_MODE_EN | MCF_SDRAMC_SDCR_CKE);
|
2008-01-24 20:02:32 +00:00
|
|
|
|
|
|
|
/* Set precharge */
|
2012-03-26 21:49:04 +00:00
|
|
|
setbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IPALL);
|
2008-01-24 20:02:32 +00:00
|
|
|
|
|
|
|
/* Dummy write to start SDRAM */
|
2008-10-16 13:01:15 +00:00
|
|
|
*((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
|
2008-01-24 20:02:32 +00:00
|
|
|
|
|
|
|
/* Send LEMR */
|
2012-03-26 21:49:04 +00:00
|
|
|
setbits_be32(&sdp->sdmr,
|
|
|
|
MCF_SDRAMC_SDMR_BNKAD_LEMR | MCF_SDRAMC_SDMR_AD(0x0) |
|
|
|
|
MCF_SDRAMC_SDMR_CMD);
|
2008-10-16 13:01:15 +00:00
|
|
|
*((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
|
2008-01-24 20:02:32 +00:00
|
|
|
|
|
|
|
/* Send LMR */
|
2012-03-26 21:49:04 +00:00
|
|
|
out_be32(&sdp->sdmr, 0x058d0000);
|
2008-10-16 13:01:15 +00:00
|
|
|
*((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
|
2008-01-24 20:02:32 +00:00
|
|
|
|
|
|
|
/* Stop sending commands */
|
2012-03-26 21:49:04 +00:00
|
|
|
clrbits_be32(&sdp->sdmr, MCF_SDRAMC_SDMR_CMD);
|
2008-01-24 20:02:32 +00:00
|
|
|
|
|
|
|
/* Set precharge */
|
2012-03-26 21:49:04 +00:00
|
|
|
setbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IPALL);
|
2008-10-16 13:01:15 +00:00
|
|
|
*((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
|
2008-01-24 20:02:32 +00:00
|
|
|
|
|
|
|
/* Stop manual precharge, send 2 IREF */
|
2012-03-26 21:49:04 +00:00
|
|
|
clrbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IPALL);
|
|
|
|
setbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IREF);
|
2008-10-16 13:01:15 +00:00
|
|
|
*((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
|
|
|
|
*((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
|
2008-01-24 20:02:32 +00:00
|
|
|
|
2012-03-26 21:49:04 +00:00
|
|
|
|
|
|
|
out_be32(&sdp->sdmr, 0x018d0000);
|
2008-10-16 13:01:15 +00:00
|
|
|
*((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
|
2008-01-24 20:02:32 +00:00
|
|
|
|
|
|
|
/* Stop sending commands */
|
2012-03-26 21:49:04 +00:00
|
|
|
clrbits_be32(&sdp->sdmr, MCF_SDRAMC_SDMR_CMD);
|
|
|
|
clrbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_MODE_EN);
|
2008-01-24 20:02:32 +00:00
|
|
|
|
|
|
|
/* Turn on auto refresh, lock SDMR */
|
2012-03-26 21:49:04 +00:00
|
|
|
out_be32(&sdp->sdcr,
|
2008-01-24 20:02:32 +00:00
|
|
|
MCF_SDRAMC_SDCR_CKE
|
|
|
|
| MCF_SDRAMC_SDCR_REF
|
|
|
|
| MCF_SDRAMC_SDCR_MUX(1)
|
|
|
|
/* 1 added to round up */
|
|
|
|
| MCF_SDRAMC_SDCR_RCNT((SDRAM_TREFI/(PERIOD*64)) - 1 + 1)
|
2012-03-26 21:49:04 +00:00
|
|
|
| MCF_SDRAMC_SDCR_DQS_OE(0x3));
|
2008-01-24 20:02:32 +00:00
|
|
|
|
2017-03-31 14:40:25 +00:00
|
|
|
gd->ram_size = CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
|
|
|
|
|
|
|
|
return 0;
|
2008-01-24 20:02:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int testdram(void)
|
|
|
|
{
|
|
|
|
/* TODO: XXX XXX XXX */
|
|
|
|
printf("DRAM test not implemented!\n");
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|