1536e7dacSTsiChung Liew /*
2536e7dacSTsiChung Liew * (C) Copyright 2000-2003
3536e7dacSTsiChung Liew * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4536e7dacSTsiChung Liew *
5aa0d99fcSAlison Wang * Copyright (C) 2004-2008, 2012 Freescale Semiconductor, Inc.
6536e7dacSTsiChung Liew * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
7536e7dacSTsiChung Liew *
81a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+
9536e7dacSTsiChung Liew */
10536e7dacSTsiChung Liew
11536e7dacSTsiChung Liew #include <config.h>
12536e7dacSTsiChung Liew #include <common.h>
13536e7dacSTsiChung Liew #include <asm/immap.h>
14aa0d99fcSAlison Wang #include <asm/io.h>
15536e7dacSTsiChung Liew
16536e7dacSTsiChung Liew DECLARE_GLOBAL_DATA_PTR;
17536e7dacSTsiChung Liew
checkboard(void)18536e7dacSTsiChung Liew int checkboard(void)
19536e7dacSTsiChung Liew {
20536e7dacSTsiChung Liew puts("Board: ");
21536e7dacSTsiChung Liew puts("Freescale M53017EVB\n");
22536e7dacSTsiChung Liew return 0;
23536e7dacSTsiChung Liew };
24536e7dacSTsiChung Liew
dram_init(void)25*f1683aa7SSimon Glass int dram_init(void)
26536e7dacSTsiChung Liew {
27aa0d99fcSAlison Wang sdram_t *sdram = (sdram_t *)(MMAP_SDRAM);
28536e7dacSTsiChung Liew u32 dramsize, i;
29536e7dacSTsiChung Liew
30536e7dacSTsiChung Liew dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
31536e7dacSTsiChung Liew
32536e7dacSTsiChung Liew for (i = 0x13; i < 0x20; i++) {
33536e7dacSTsiChung Liew if (dramsize == (1 << i))
34536e7dacSTsiChung Liew break;
35536e7dacSTsiChung Liew }
36536e7dacSTsiChung Liew i--;
37536e7dacSTsiChung Liew
38aa0d99fcSAlison Wang out_be32(&sdram->cs0, CONFIG_SYS_SDRAM_BASE | i);
39536e7dacSTsiChung Liew #ifdef CONFIG_SYS_SDRAM_BASE1
40aa0d99fcSAlison Wang out_be32(&sdram->cs1, CONFIG_SYS_SDRAM_BASE | i);
41536e7dacSTsiChung Liew #endif
42aa0d99fcSAlison Wang out_be32(&sdram->cfg1, CONFIG_SYS_SDRAM_CFG1);
43aa0d99fcSAlison Wang out_be32(&sdram->cfg2, CONFIG_SYS_SDRAM_CFG2);
44536e7dacSTsiChung Liew
45536e7dacSTsiChung Liew udelay(500);
46536e7dacSTsiChung Liew
47536e7dacSTsiChung Liew /* Issue PALL */
48aa0d99fcSAlison Wang out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
49536e7dacSTsiChung Liew asm("nop");
50536e7dacSTsiChung Liew
51536e7dacSTsiChung Liew /* Perform two refresh cycles */
52aa0d99fcSAlison Wang out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
53aa0d99fcSAlison Wang out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
54536e7dacSTsiChung Liew asm("nop");
55536e7dacSTsiChung Liew
56536e7dacSTsiChung Liew /* Issue LEMR */
57aa0d99fcSAlison Wang out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE);
58536e7dacSTsiChung Liew asm("nop");
59aa0d99fcSAlison Wang out_be32(&sdram->mode, CONFIG_SYS_SDRAM_EMOD);
60536e7dacSTsiChung Liew asm("nop");
61536e7dacSTsiChung Liew
62aa0d99fcSAlison Wang out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
63536e7dacSTsiChung Liew asm("nop");
64536e7dacSTsiChung Liew
65aa0d99fcSAlison Wang out_be32(&sdram->ctrl,
66aa0d99fcSAlison Wang (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000c00);
67536e7dacSTsiChung Liew asm("nop");
68536e7dacSTsiChung Liew
69536e7dacSTsiChung Liew udelay(100);
70536e7dacSTsiChung Liew
71088454cdSSimon Glass gd->ram_size = dramsize;
72088454cdSSimon Glass
73088454cdSSimon Glass return 0;
74536e7dacSTsiChung Liew };
75536e7dacSTsiChung Liew
testdram(void)76536e7dacSTsiChung Liew int testdram(void)
77536e7dacSTsiChung Liew {
78536e7dacSTsiChung Liew /* TODO: XXX XXX XXX */
79536e7dacSTsiChung Liew printf("DRAM test not implemented!\n");
80536e7dacSTsiChung Liew
81536e7dacSTsiChung Liew return (0);
82536e7dacSTsiChung Liew }
83