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