TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000-2003 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 5 | * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc. |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 6 | * TsiChung Liew (Tsi-Chung.Liew@freescale.com) |
| 7 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 8 | * SPDX-License-Identifier: GPL-2.0+ |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <config.h> |
| 12 | #include <common.h> |
| 13 | #include <pci.h> |
| 14 | #include <asm/immap.h> |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 15 | #include <asm/io.h> |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 16 | |
| 17 | DECLARE_GLOBAL_DATA_PTR; |
| 18 | |
| 19 | int checkboard(void) |
| 20 | { |
| 21 | puts("Board: "); |
| 22 | puts("Freescale FireEngine 5485 EVB\n"); |
| 23 | return 0; |
| 24 | }; |
| 25 | |
Simon Glass | b4de3f3 | 2017-03-31 08:40:24 -0600 | [diff] [blame^] | 26 | phys_size_t initdram(void) |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 27 | { |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 28 | siu_t *siu = (siu_t *) (MMAP_SIU); |
| 29 | sdram_t *sdram = (sdram_t *)(MMAP_SDRAM); |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 30 | u32 dramsize, i; |
stany MARCEL | fba9314 | 2011-10-14 04:38:06 +0000 | [diff] [blame] | 31 | #ifdef CONFIG_SYS_DRAMSZ1 |
| 32 | u32 temp; |
| 33 | #endif |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 34 | |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 35 | out_be32(&siu->drv, CONFIG_SYS_SDRAM_DRVSTRENGTH); |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 36 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 37 | dramsize = CONFIG_SYS_DRAMSZ * 0x100000; |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 38 | for (i = 0x13; i < 0x20; i++) { |
| 39 | if (dramsize == (1 << i)) |
| 40 | break; |
| 41 | } |
| 42 | i--; |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 43 | out_be32(&siu->cs0cfg, CONFIG_SYS_SDRAM_BASE | i); |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 44 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 45 | #ifdef CONFIG_SYS_DRAMSZ1 |
| 46 | temp = CONFIG_SYS_DRAMSZ1 * 0x100000; |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 47 | for (i = 0x13; i < 0x20; i++) { |
| 48 | if (temp == (1 << i)) |
| 49 | break; |
| 50 | } |
| 51 | i--; |
| 52 | dramsize += temp; |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 53 | out_be32(&siu->cs1cfg, (CONFIG_SYS_SDRAM_BASE + temp) | i); |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 54 | #endif |
| 55 | |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 56 | out_be32(&sdram->cfg1, CONFIG_SYS_SDRAM_CFG1); |
| 57 | out_be32(&sdram->cfg2, CONFIG_SYS_SDRAM_CFG2); |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 58 | |
| 59 | /* Issue PALL */ |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 60 | out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2); |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 61 | |
| 62 | /* Issue LEMR */ |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 63 | out_be32(&sdram->mode, CONFIG_SYS_SDRAM_EMOD); |
| 64 | out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE | 0x04000000); |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 65 | |
| 66 | udelay(500); |
| 67 | |
| 68 | /* Issue PALL */ |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 69 | out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2); |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 70 | |
| 71 | /* Perform two refresh cycles */ |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 72 | out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4); |
| 73 | out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4); |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 74 | |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 75 | out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE); |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 76 | |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 77 | out_be32(&sdram->ctrl, |
| 78 | (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000F00); |
TsiChungLiew | 5b8943a | 2008-01-15 14:02:49 -0600 | [diff] [blame] | 79 | |
| 80 | udelay(100); |
| 81 | |
| 82 | return dramsize; |
| 83 | }; |
| 84 | |
| 85 | int testdram(void) |
| 86 | { |
| 87 | /* TODO: XXX XXX XXX */ |
| 88 | printf("DRAM test not implemented!\n"); |
| 89 | |
| 90 | return (0); |
| 91 | } |
| 92 | |
| 93 | #if defined(CONFIG_PCI) |
| 94 | /* |
| 95 | * Initialize PCI devices, report devices found. |
| 96 | */ |
| 97 | static struct pci_controller hose; |
| 98 | extern void pci_mcf547x_8x_init(struct pci_controller *hose); |
| 99 | |
| 100 | void pci_init_board(void) |
| 101 | { |
| 102 | pci_mcf547x_8x_init(&hose); |
| 103 | } |
| 104 | #endif /* CONFIG_PCI */ |