blob: bfcc4b23b00e0d686e1a57078d07bcb1cc95d878 [file] [log] [blame]
TsiChungLiew1ac559d2008-01-14 17:19:54 -06001/*
2 * (C) Copyright 2000-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Alison Wangaa0d99f2012-03-26 21:49:05 +00005 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
TsiChungLiew1ac559d2008-01-14 17:19:54 -06006 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
7 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
TsiChungLiew1ac559d2008-01-14 17:19:54 -06009 */
10
11#include <config.h>
12#include <common.h>
13#include <asm/immap.h>
Alison Wangaa0d99f2012-03-26 21:49:05 +000014#include <asm/io.h>
TsiChungLiew1ac559d2008-01-14 17:19:54 -060015
16DECLARE_GLOBAL_DATA_PTR;
17
18int checkboard(void)
19{
20 puts("Board: ");
21 puts("Freescale FireEngine 5373 EVB\n");
22 return 0;
23};
24
Becky Bruce9973e3c2008-06-09 16:03:40 -050025phys_size_t initdram(int board_type)
TsiChungLiew1ac559d2008-01-14 17:19:54 -060026{
Alison Wangaa0d99f2012-03-26 21:49:05 +000027 sdram_t *sdram = (sdram_t *)(MMAP_SDRAM);
TsiChungLiew1ac559d2008-01-14 17:19:54 -060028 u32 dramsize, i;
29
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020030 dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
TsiChungLiew1ac559d2008-01-14 17:19:54 -060031
32 for (i = 0x13; i < 0x20; i++) {
33 if (dramsize == (1 << i))
34 break;
35 }
36 i--;
37
Alison Wangaa0d99f2012-03-26 21:49:05 +000038 out_be32(&sdram->cs0, CONFIG_SYS_SDRAM_BASE | i);
39 out_be32(&sdram->cfg1, CONFIG_SYS_SDRAM_CFG1);
40 out_be32(&sdram->cfg2, CONFIG_SYS_SDRAM_CFG2);
TsiChungLiew1ac559d2008-01-14 17:19:54 -060041
42 /* Issue PALL */
Alison Wangaa0d99f2012-03-26 21:49:05 +000043 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChungLiew1ac559d2008-01-14 17:19:54 -060044
45 /* Issue LEMR */
Alison Wangaa0d99f2012-03-26 21:49:05 +000046 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_EMOD);
47 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE | 0x04000000);
TsiChungLiew1ac559d2008-01-14 17:19:54 -060048
49 udelay(500);
50
51 /* Issue PALL */
Alison Wangaa0d99f2012-03-26 21:49:05 +000052 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChungLiew1ac559d2008-01-14 17:19:54 -060053
54 /* Perform two refresh cycles */
Alison Wangaa0d99f2012-03-26 21:49:05 +000055 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
56 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
TsiChungLiew1ac559d2008-01-14 17:19:54 -060057
Alison Wangaa0d99f2012-03-26 21:49:05 +000058 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE);
TsiChungLiew1ac559d2008-01-14 17:19:54 -060059
Alison Wangaa0d99f2012-03-26 21:49:05 +000060 out_be32(&sdram->ctrl,
61 (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000c00);
TsiChungLiew1ac559d2008-01-14 17:19:54 -060062
63 udelay(100);
64
65 return dramsize;
66};
67
68int testdram(void)
69{
70 /* TODO: XXX XXX XXX */
71 printf("DRAM test not implemented!\n");
72
73 return (0);
74}