blob: a1127e52a39d56887bd85f3b8d88ce7a02d65d86 [file] [log] [blame]
TsiChungLiew1552af72008-01-14 17:43:33 -06001/*
2 * (C) Copyright 2000-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Alison Wang849fc422012-03-26 21:49:03 +00005 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
TsiChungLiew1552af72008-01-14 17:43:33 -06006 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
7 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
TsiChungLiew1552af72008-01-14 17:43:33 -06009 */
10
11#include <common.h>
12#include <asm/immap.h>
Alison Wang849fc422012-03-26 21:49:03 +000013#include <asm/io.h>
TsiChungLiew1552af72008-01-14 17:43:33 -060014
15DECLARE_GLOBAL_DATA_PTR;
16
17int checkboard(void)
18{
19 puts("Board: ");
20 puts("Freescale M52277 EVB\n");
21 return 0;
22};
23
Becky Bruce9973e3c2008-06-09 16:03:40 -050024phys_size_t initdram(int board_type)
TsiChungLiew1552af72008-01-14 17:43:33 -060025{
TsiChung Liewa21d0c22008-10-21 15:37:02 +000026 u32 dramsize;
27
28#ifdef CONFIG_CF_SBF
29 /*
30 * Serial Boot: The dram is already initialized in start.S
31 * only require to return DRAM size
32 */
33 dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
34#else
Alison Wang849fc422012-03-26 21:49:03 +000035 sdramc_t *sdram = (sdramc_t *)(MMAP_SDRAM);
36 gpio_t *gpio = (gpio_t *)(MMAP_GPIO);
TsiChung Liewa21d0c22008-10-21 15:37:02 +000037 u32 i;
TsiChungLiew1552af72008-01-14 17:43:33 -060038
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020039 dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
TsiChungLiew1552af72008-01-14 17:43:33 -060040
41 for (i = 0x13; i < 0x20; i++) {
42 if (dramsize == (1 << i))
43 break;
44 }
45 i--;
46
Alison Wang849fc422012-03-26 21:49:03 +000047 out_8(&gpio->mscr_sdram, CONFIG_SYS_SDRAM_DRV_STRENGTH);
TsiChung Liewa21d0c22008-10-21 15:37:02 +000048
Alison Wang849fc422012-03-26 21:49:03 +000049 out_be32(&sdram->sdcs0, CONFIG_SYS_SDRAM_BASE | i);
TsiChungLiew1552af72008-01-14 17:43:33 -060050
Alison Wang849fc422012-03-26 21:49:03 +000051 out_be32(&sdram->sdcfg1, CONFIG_SYS_SDRAM_CFG1);
52 out_be32(&sdram->sdcfg2, CONFIG_SYS_SDRAM_CFG2);
TsiChungLiew1552af72008-01-14 17:43:33 -060053
54 /* Issue PALL */
Alison Wang849fc422012-03-26 21:49:03 +000055 out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChung Liewa21d0c22008-10-21 15:37:02 +000056 __asm__("nop");
TsiChungLiew1552af72008-01-14 17:43:33 -060057
58 /* Issue LEMR */
Alison Wang849fc422012-03-26 21:49:03 +000059 out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_MODE);
TsiChung Liewa21d0c22008-10-21 15:37:02 +000060 __asm__("nop");
Alison Wang849fc422012-03-26 21:49:03 +000061 out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_EMOD);
TsiChung Liewa21d0c22008-10-21 15:37:02 +000062 __asm__("nop");
TsiChungLiew1552af72008-01-14 17:43:33 -060063
64 udelay(1000);
65
66 /* Issue PALL */
Alison Wang849fc422012-03-26 21:49:03 +000067 out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChung Liewa21d0c22008-10-21 15:37:02 +000068 __asm__("nop");
TsiChungLiew1552af72008-01-14 17:43:33 -060069
70 /* Perform two refresh cycles */
Alison Wang849fc422012-03-26 21:49:03 +000071 out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 4);
TsiChung Liewa21d0c22008-10-21 15:37:02 +000072 __asm__("nop");
Alison Wang849fc422012-03-26 21:49:03 +000073 out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 4);
TsiChung Liewa21d0c22008-10-21 15:37:02 +000074 __asm__("nop");
TsiChungLiew1552af72008-01-14 17:43:33 -060075
Alison Wang849fc422012-03-26 21:49:03 +000076 out_be32(&sdram->sdcr,
77 (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000c00);
TsiChungLiew1552af72008-01-14 17:43:33 -060078
79 udelay(100);
TsiChung Liewa21d0c22008-10-21 15:37:02 +000080#endif
TsiChungLiew1552af72008-01-14 17:43:33 -060081 return (dramsize);
82};
83
84int testdram(void)
85{
86 /* TODO: XXX XXX XXX */
87 printf("DRAM test not implemented!\n");
88
89 return (0);
90}