1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2000-2003
4  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5  *
6  * Copyright (C) 2004-2008, 2012 Freescale Semiconductor, Inc.
7  * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
8  */
9 
10 #include <config.h>
11 #include <common.h>
12 #include <asm/immap.h>
13 #include <asm/io.h>
14 
15 DECLARE_GLOBAL_DATA_PTR;
16 
checkboard(void)17 int checkboard(void)
18 {
19 	puts("Board: ");
20 	puts("Freescale M53017EVB\n");
21 	return 0;
22 };
23 
dram_init(void)24 int dram_init(void)
25 {
26 	sdram_t *sdram = (sdram_t *)(MMAP_SDRAM);
27 	u32 dramsize, i;
28 
29 	dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
30 
31 	for (i = 0x13; i < 0x20; i++) {
32 		if (dramsize == (1 << i))
33 			break;
34 	}
35 	i--;
36 
37 	out_be32(&sdram->cs0, CONFIG_SYS_SDRAM_BASE | i);
38 #ifdef CONFIG_SYS_SDRAM_BASE1
39 	out_be32(&sdram->cs1, CONFIG_SYS_SDRAM_BASE | i);
40 #endif
41 	out_be32(&sdram->cfg1, CONFIG_SYS_SDRAM_CFG1);
42 	out_be32(&sdram->cfg2, CONFIG_SYS_SDRAM_CFG2);
43 
44 	udelay(500);
45 
46 	/* Issue PALL */
47 	out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
48 	asm("nop");
49 
50 	/* Perform two refresh cycles */
51 	out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
52 	out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
53 	asm("nop");
54 
55 	/* Issue LEMR */
56 	out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE);
57 	asm("nop");
58 	out_be32(&sdram->mode, CONFIG_SYS_SDRAM_EMOD);
59 	asm("nop");
60 
61 	out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
62 	asm("nop");
63 
64 	out_be32(&sdram->ctrl,
65 		(CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000c00);
66 	asm("nop");
67 
68 	udelay(100);
69 
70 	gd->ram_size = dramsize;
71 
72 	return 0;
73 };
74 
testdram(void)75 int testdram(void)
76 {
77 	/* TODO: XXX XXX XXX */
78 	printf("DRAM test not implemented!\n");
79 
80 	return (0);
81 }
82