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