blob: c9f89353ce4bccf74e44f72d74024ff4e213037f [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
TsiChung Liew536e7da2008-10-22 11:38:21 +00002/*
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-2008, 2012 Freescale Semiconductor, Inc.
TsiChung Liew536e7da2008-10-22 11:38:21 +00007 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
TsiChung Liew536e7da2008-10-22 11:38:21 +00008 */
9
10#include <config.h>
11#include <common.h>
Simon Glass49acd562019-12-28 10:45:06 -070012#include <init.h>
Simon Glass401d1c42020-10-30 21:38:53 -060013#include <asm/global_data.h>
TsiChung Liew536e7da2008-10-22 11:38:21 +000014#include <asm/immap.h>
Alison Wangaa0d99f2012-03-26 21:49:05 +000015#include <asm/io.h>
Simon Glassc05ed002020-05-10 11:40:11 -060016#include <linux/delay.h>
TsiChung Liew536e7da2008-10-22 11:38:21 +000017
18DECLARE_GLOBAL_DATA_PTR;
19
20int checkboard(void)
21{
22 puts("Board: ");
23 puts("Freescale M53017EVB\n");
24 return 0;
25};
26
Simon Glassf1683aa2017-04-06 12:47:05 -060027int dram_init(void)
TsiChung Liew536e7da2008-10-22 11:38:21 +000028{
Alison Wangaa0d99f2012-03-26 21:49:05 +000029 sdram_t *sdram = (sdram_t *)(MMAP_SDRAM);
TsiChung Liew536e7da2008-10-22 11:38:21 +000030 u32 dramsize, i;
31
32 dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
33
34 for (i = 0x13; i < 0x20; i++) {
35 if (dramsize == (1 << i))
36 break;
37 }
38 i--;
39
Alison Wangaa0d99f2012-03-26 21:49:05 +000040 out_be32(&sdram->cs0, CONFIG_SYS_SDRAM_BASE | i);
TsiChung Liew536e7da2008-10-22 11:38:21 +000041#ifdef CONFIG_SYS_SDRAM_BASE1
Alison Wangaa0d99f2012-03-26 21:49:05 +000042 out_be32(&sdram->cs1, CONFIG_SYS_SDRAM_BASE | i);
TsiChung Liew536e7da2008-10-22 11:38:21 +000043#endif
Alison Wangaa0d99f2012-03-26 21:49:05 +000044 out_be32(&sdram->cfg1, CONFIG_SYS_SDRAM_CFG1);
45 out_be32(&sdram->cfg2, CONFIG_SYS_SDRAM_CFG2);
TsiChung Liew536e7da2008-10-22 11:38:21 +000046
47 udelay(500);
48
49 /* Issue PALL */
Alison Wangaa0d99f2012-03-26 21:49:05 +000050 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChung Liew536e7da2008-10-22 11:38:21 +000051 asm("nop");
52
53 /* Perform two refresh cycles */
Alison Wangaa0d99f2012-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 Liew536e7da2008-10-22 11:38:21 +000056 asm("nop");
57
58 /* Issue LEMR */
Alison Wangaa0d99f2012-03-26 21:49:05 +000059 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE);
TsiChung Liew536e7da2008-10-22 11:38:21 +000060 asm("nop");
Alison Wangaa0d99f2012-03-26 21:49:05 +000061 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_EMOD);
TsiChung Liew536e7da2008-10-22 11:38:21 +000062 asm("nop");
63
Alison Wangaa0d99f2012-03-26 21:49:05 +000064 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChung Liew536e7da2008-10-22 11:38:21 +000065 asm("nop");
66
Alison Wangaa0d99f2012-03-26 21:49:05 +000067 out_be32(&sdram->ctrl,
68 (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000c00);
TsiChung Liew536e7da2008-10-22 11:38:21 +000069 asm("nop");
70
71 udelay(100);
72
Simon Glass088454c2017-03-31 08:40:25 -060073 gd->ram_size = dramsize;
74
75 return 0;
TsiChung Liew536e7da2008-10-22 11:38:21 +000076};
77
78int testdram(void)
79{
80 /* TODO: XXX XXX XXX */
81 printf("DRAM test not implemented!\n");
82
83 return (0);
84}