blob: d93800b364bffb8ae76f294377341040036ff0fb [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>
Simon Glass0ffd9db2019-12-28 10:45:06 -070012#include <init.h>
TsiChungLiew16723332007-07-05 22:54:42 -050013#include <asm/immap.h>
Alison Wang35d23df2012-03-26 21:49:05 +000014#include <asm/io.h>
TsiChung Liewf6afe722007-06-18 13:50:13 -050015
16DECLARE_GLOBAL_DATA_PTR;
17
18int checkboard(void)
19{
20 puts("Board: ");
21 puts("Freescale FireEngine 5329 EVB\n");
22 return 0;
23};
24
Simon Glassd35f3382017-04-06 12:47:05 -060025int dram_init(void)
TsiChung Liewf6afe722007-06-18 13:50:13 -050026{
Alison Wang35d23df2012-03-26 21:49:05 +000027 sdram_t *sdram = (sdram_t *)(MMAP_SDRAM);
TsiChung Liewf6afe722007-06-18 13:50:13 -050028 u32 dramsize, i;
29
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020030 dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
TsiChung Liewf6afe722007-06-18 13:50:13 -050031
32 for (i = 0x13; i < 0x20; i++) {
33 if (dramsize == (1 << i))
34 break;
35 }
36 i--;
37
Alison Wang35d23df2012-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);
TsiChung Liewf6afe722007-06-18 13:50:13 -050041
42 /* Issue PALL */
Alison Wang35d23df2012-03-26 21:49:05 +000043 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChung Liewf6afe722007-06-18 13:50:13 -050044
45 /* Issue LEMR */
Alison Wang35d23df2012-03-26 21:49:05 +000046 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_EMOD);
47 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE | 0x04000000);
TsiChung Liewf6afe722007-06-18 13:50:13 -050048
49 udelay(500);
50
51 /* Issue PALL */
Alison Wang35d23df2012-03-26 21:49:05 +000052 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChung Liewf6afe722007-06-18 13:50:13 -050053
54 /* Perform two refresh cycles */
Alison Wang35d23df2012-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);
TsiChung Liewf6afe722007-06-18 13:50:13 -050057
Alison Wang35d23df2012-03-26 21:49:05 +000058 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE);
TsiChung Liewf6afe722007-06-18 13:50:13 -050059
Alison Wang35d23df2012-03-26 21:49:05 +000060 out_be32(&sdram->ctrl,
61 (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000c00);
TsiChung Liewf6afe722007-06-18 13:50:13 -050062
63 udelay(100);
64
Simon Glass39f90ba2017-03-31 08:40:25 -060065 gd->ram_size = dramsize;
66
67 return 0;
TsiChung Liewf6afe722007-06-18 13:50:13 -050068};
69
70int testdram(void)
71{
72 /* TODO: XXX XXX XXX */
73 printf("DRAM test not implemented!\n");
74
75 return (0);
76}