2 * (C) Copyright 2000-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * Copyright (C) 2005-2008 Arthur Shipkowski (art@videon-central.com)
7 * Copyright (C) 2012 Freescale Semiconductor, Inc. All Rights Reserved.
9 * SPDX-License-Identifier: GPL-2.0+
13 #include <asm/immap.h>
16 DECLARE_GLOBAL_DATA_PTR;
18 #define PERIOD 13 /* system bus period in ns */
19 #define SDRAM_TREFI 7800 /* in ns */
24 puts("Freescale MCF5275 EVB\n");
30 sdramctrl_t *sdp = (sdramctrl_t *)(MMAP_SDRAM);
31 gpio_t *gpio_reg = (gpio_t *)(MMAP_GPIO);
34 out_be16(&gpio_reg->par_sdram, 0x3FF);
36 /* Set up chip select */
37 out_be32(&sdp->sdbar0, CONFIG_SYS_SDRAM_BASE);
38 out_be32(&sdp->sdbmr0, MCF_SDRAMC_SDMRn_BAM_32M | MCF_SDRAMC_SDMRn_V);
41 out_be32(&sdp->sdcfg1, 0x83711630);
42 out_be32(&sdp->sdcfg2, 0x46770000);
45 out_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_MODE_EN | MCF_SDRAMC_SDCR_CKE);
48 setbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IPALL);
50 /* Dummy write to start SDRAM */
51 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
54 setbits_be32(&sdp->sdmr,
55 MCF_SDRAMC_SDMR_BNKAD_LEMR | MCF_SDRAMC_SDMR_AD(0x0) |
57 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
60 out_be32(&sdp->sdmr, 0x058d0000);
61 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
63 /* Stop sending commands */
64 clrbits_be32(&sdp->sdmr, MCF_SDRAMC_SDMR_CMD);
67 setbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IPALL);
68 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
70 /* Stop manual precharge, send 2 IREF */
71 clrbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IPALL);
72 setbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IREF);
73 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
74 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
77 out_be32(&sdp->sdmr, 0x018d0000);
78 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
80 /* Stop sending commands */
81 clrbits_be32(&sdp->sdmr, MCF_SDRAMC_SDMR_CMD);
82 clrbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_MODE_EN);
84 /* Turn on auto refresh, lock SDMR */
88 | MCF_SDRAMC_SDCR_MUX(1)
89 /* 1 added to round up */
90 | MCF_SDRAMC_SDCR_RCNT((SDRAM_TREFI/(PERIOD*64)) - 1 + 1)
91 | MCF_SDRAMC_SDCR_DQS_OE(0x3));
93 gd->ram_size = CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
100 /* TODO: XXX XXX XXX */
101 printf("DRAM test not implemented!\n");