1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2000-2003
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * Copyright (C) 2004-2008, 2012 Freescale Semiconductor, Inc.
7 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
13 #include <asm/global_data.h>
14 #include <asm/immap.h>
16 #include <linux/delay.h>
18 DECLARE_GLOBAL_DATA_PTR;
24 * Check serial flash size. if 2mb evb, else 8mb demo
27 puts("Freescale M54451 EVB\n");
36 * Serial Boot: The dram is already initialized in start.S
37 * only require to return DRAM size
39 dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
41 sdramc_t *sdram = (sdramc_t *)(MMAP_SDRAM);
42 gpio_t *gpio = (gpio_t *)(MMAP_GPIO);
45 dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
47 if ((in_be32(&sdram->sdcfg1) == CONFIG_SYS_SDRAM_CFG1) &&
48 (in_be32(&sdram->sdcfg2) == CONFIG_SYS_SDRAM_CFG2))
51 for (i = 0x13; i < 0x20; i++) {
52 if (dramsize == (1 << i))
57 out_8(&gpio->mscr_sdram, CONFIG_SYS_SDRAM_DRV_STRENGTH);
59 out_be32(&sdram->sdcs0, CONFIG_SYS_SDRAM_BASE | i);
61 out_be32(&sdram->sdcfg1, CONFIG_SYS_SDRAM_CFG1);
62 out_be32(&sdram->sdcfg2, CONFIG_SYS_SDRAM_CFG2);
67 out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 2);
70 /* Perform two refresh cycles */
71 out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 4);
73 out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 4);
77 out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_MODE);
79 out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_MODE);
82 out_be32(&sdram->sdcr,
83 (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000000);
87 gd->ram_size = dramsize;
94 /* TODO: XXX XXX XXX */
95 printf("DRAM test not implemented!\n");