blob: 29ff55f15966a6a368a11b0d7ba37627c9fc3a69 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
TsiChungLiew1ac559d2008-01-14 17:19:54 -06002/*
3 * (C) Copyright 2000-2003
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 *
Alison Wangaa0d99f2012-03-26 21:49:05 +00006 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
TsiChungLiew1ac559d2008-01-14 17:19:54 -06007 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
TsiChungLiew1ac559d2008-01-14 17:19:54 -06008 */
9
10#include <config.h>
11#include <common.h>
Simon Glass49acd562019-12-28 10:45:06 -070012#include <init.h>
TsiChungLiew1ac559d2008-01-14 17:19:54 -060013#include <asm/immap.h>
Alison Wangaa0d99f2012-03-26 21:49:05 +000014#include <asm/io.h>
Simon Glassc05ed002020-05-10 11:40:11 -060015#include <linux/delay.h>
TsiChungLiew1ac559d2008-01-14 17:19:54 -060016
17DECLARE_GLOBAL_DATA_PTR;
18
19int checkboard(void)
20{
21 puts("Board: ");
22 puts("Freescale FireEngine 5373 EVB\n");
23 return 0;
24};
25
Simon Glassf1683aa2017-04-06 12:47:05 -060026int dram_init(void)
TsiChungLiew1ac559d2008-01-14 17:19:54 -060027{
Alison Wangaa0d99f2012-03-26 21:49:05 +000028 sdram_t *sdram = (sdram_t *)(MMAP_SDRAM);
TsiChungLiew1ac559d2008-01-14 17:19:54 -060029 u32 dramsize, i;
30
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020031 dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
TsiChungLiew1ac559d2008-01-14 17:19:54 -060032
33 for (i = 0x13; i < 0x20; i++) {
34 if (dramsize == (1 << i))
35 break;
36 }
37 i--;
38
Alison Wangaa0d99f2012-03-26 21:49:05 +000039 out_be32(&sdram->cs0, CONFIG_SYS_SDRAM_BASE | i);
40 out_be32(&sdram->cfg1, CONFIG_SYS_SDRAM_CFG1);
41 out_be32(&sdram->cfg2, CONFIG_SYS_SDRAM_CFG2);
TsiChungLiew1ac559d2008-01-14 17:19:54 -060042
43 /* Issue PALL */
Alison Wangaa0d99f2012-03-26 21:49:05 +000044 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChungLiew1ac559d2008-01-14 17:19:54 -060045
46 /* Issue LEMR */
Alison Wangaa0d99f2012-03-26 21:49:05 +000047 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_EMOD);
48 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE | 0x04000000);
TsiChungLiew1ac559d2008-01-14 17:19:54 -060049
50 udelay(500);
51
52 /* Issue PALL */
Alison Wangaa0d99f2012-03-26 21:49:05 +000053 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChungLiew1ac559d2008-01-14 17:19:54 -060054
55 /* Perform two refresh cycles */
Alison Wangaa0d99f2012-03-26 21:49:05 +000056 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
57 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
TsiChungLiew1ac559d2008-01-14 17:19:54 -060058
Alison Wangaa0d99f2012-03-26 21:49:05 +000059 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE);
TsiChungLiew1ac559d2008-01-14 17:19:54 -060060
Alison Wangaa0d99f2012-03-26 21:49:05 +000061 out_be32(&sdram->ctrl,
62 (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000c00);
TsiChungLiew1ac559d2008-01-14 17:19:54 -060063
64 udelay(100);
65
Simon Glass088454c2017-03-31 08:40:25 -060066 gd->ram_size = dramsize;
67
68 return 0;
TsiChungLiew1ac559d2008-01-14 17:19:54 -060069};
70
71int testdram(void)
72{
73 /* TODO: XXX XXX XXX */
74 printf("DRAM test not implemented!\n");
75
76 return (0);
77}