TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000-2003 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 5 | * Copyright (C) 2004-2008, 2012 Freescale Semiconductor, Inc. |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 6 | * TsiChung Liew (Tsi-Chung.Liew@freescale.com) |
| 7 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 8 | * SPDX-License-Identifier: GPL-2.0+ |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <config.h> |
| 12 | #include <common.h> |
| 13 | #include <asm/immap.h> |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 14 | #include <asm/io.h> |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 15 | |
| 16 | DECLARE_GLOBAL_DATA_PTR; |
| 17 | |
| 18 | int checkboard(void) |
| 19 | { |
| 20 | puts("Board: "); |
| 21 | puts("Freescale M5208EVBe\n"); |
| 22 | return 0; |
| 23 | }; |
| 24 | |
Simon Glass | 088454c | 2017-03-31 08:40:25 -0600 | [diff] [blame^] | 25 | int initdram(void) |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 26 | { |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 27 | sdram_t *sdram = (sdram_t *)(MMAP_SDRAM); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 28 | u32 dramsize, i; |
| 29 | |
| 30 | dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000; |
| 31 | |
| 32 | for (i = 0x13; i < 0x20; i++) { |
| 33 | if (dramsize == (1 << i)) |
| 34 | break; |
| 35 | } |
| 36 | i--; |
| 37 | |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 38 | out_be32(&sdram->cs0, CONFIG_SYS_SDRAM_BASE | i); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 39 | #ifdef CONFIG_SYS_SDRAM_BASE1 |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 40 | out_be32(&sdram->cs1, CONFIG_SYS_SDRAM_BASE | i); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 41 | #endif |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 42 | out_be32(&sdram->cfg1, CONFIG_SYS_SDRAM_CFG1); |
| 43 | out_be32(&sdram->cfg2, CONFIG_SYS_SDRAM_CFG2); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 44 | |
| 45 | udelay(500); |
| 46 | |
| 47 | /* Issue PALL */ |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 48 | out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 49 | asm("nop"); |
| 50 | |
| 51 | /* Perform two refresh cycles */ |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 52 | out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4); |
| 53 | out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 54 | asm("nop"); |
| 55 | |
| 56 | /* Issue LEMR */ |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 57 | out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 58 | asm("nop"); |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 59 | out_be32(&sdram->mode, CONFIG_SYS_SDRAM_EMOD); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 60 | asm("nop"); |
| 61 | |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 62 | out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 63 | asm("nop"); |
| 64 | |
Alison Wang | 32dbaaf | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 65 | out_be32(&sdram->ctrl, |
| 66 | (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000F00); |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 67 | asm("nop"); |
| 68 | |
| 69 | udelay(100); |
| 70 | |
Simon Glass | 088454c | 2017-03-31 08:40:25 -0600 | [diff] [blame^] | 71 | gd->ram_size = dramsize; |
| 72 | |
| 73 | return 0; |
TsiChung Liew | bf9a521 | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | int testdram(void) |
| 77 | { |
| 78 | /* TODO: XXX XXX XXX */ |
| 79 | printf("DRAM test not implemented!\n"); |
| 80 | |
| 81 | return (0); |
| 82 | } |