blob: 88cdba719c429e7ccbd643589b619964ca266860 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
TsiChung Liewf6afe722007-06-18 13:50:13 -05002/*
3 * (C) Copyright 2000-2003
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 *
Alison Wang35d23df2012-03-26 21:49:05 +00006 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
TsiChung Liewf6afe722007-06-18 13:50:13 -05007 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
TsiChung Liewf6afe722007-06-18 13:50:13 -05008 */
9
TsiChung Liewf6afe722007-06-18 13:50:13 -050010#include <config.h>
TsiChungLiew16723332007-07-05 22:54:42 -050011#include <common.h>
12#include <asm/immap.h>
Alison Wang35d23df2012-03-26 21:49:05 +000013#include <asm/io.h>
TsiChung Liewf6afe722007-06-18 13:50:13 -050014
15DECLARE_GLOBAL_DATA_PTR;
16
17int checkboard(void)
18{
19 puts("Board: ");
20 puts("Freescale FireEngine 5329 EVB\n");
21 return 0;
22};
23
Simon Glassd35f3382017-04-06 12:47:05 -060024int dram_init(void)
TsiChung Liewf6afe722007-06-18 13:50:13 -050025{
Alison Wang35d23df2012-03-26 21:49:05 +000026 sdram_t *sdram = (sdram_t *)(MMAP_SDRAM);
TsiChung Liewf6afe722007-06-18 13:50:13 -050027 u32 dramsize, i;
28
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020029 dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
TsiChung Liewf6afe722007-06-18 13:50:13 -050030
31 for (i = 0x13; i < 0x20; i++) {
32 if (dramsize == (1 << i))
33 break;
34 }
35 i--;
36
Alison Wang35d23df2012-03-26 21:49:05 +000037 out_be32(&sdram->cs0, CONFIG_SYS_SDRAM_BASE | i);
38 out_be32(&sdram->cfg1, CONFIG_SYS_SDRAM_CFG1);
39 out_be32(&sdram->cfg2, CONFIG_SYS_SDRAM_CFG2);
TsiChung Liewf6afe722007-06-18 13:50:13 -050040
41 /* Issue PALL */
Alison Wang35d23df2012-03-26 21:49:05 +000042 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChung Liewf6afe722007-06-18 13:50:13 -050043
44 /* Issue LEMR */
Alison Wang35d23df2012-03-26 21:49:05 +000045 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_EMOD);
46 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE | 0x04000000);
TsiChung Liewf6afe722007-06-18 13:50:13 -050047
48 udelay(500);
49
50 /* Issue PALL */
Alison Wang35d23df2012-03-26 21:49:05 +000051 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChung Liewf6afe722007-06-18 13:50:13 -050052
53 /* Perform two refresh cycles */
Alison Wang35d23df2012-03-26 21:49:05 +000054 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
55 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
TsiChung Liewf6afe722007-06-18 13:50:13 -050056
Alison Wang35d23df2012-03-26 21:49:05 +000057 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE);
TsiChung Liewf6afe722007-06-18 13:50:13 -050058
Alison Wang35d23df2012-03-26 21:49:05 +000059 out_be32(&sdram->ctrl,
60 (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000c00);
TsiChung Liewf6afe722007-06-18 13:50:13 -050061
62 udelay(100);
63
Simon Glass39f90ba2017-03-31 08:40:25 -060064 gd->ram_size = dramsize;
65
66 return 0;
TsiChung Liewf6afe722007-06-18 13:50:13 -050067};
68
69int testdram(void)
70{
71 /* TODO: XXX XXX XXX */
72 printf("DRAM test not implemented!\n");
73
74 return (0);
75}