blob: 796b808e6f90ce600bd29b302c318df14a84000d [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
TsiChungLiew1aee1112008-01-15 14:02:49 -06002/*
3 * (C) Copyright 2000-2003
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 *
Alison Wanga4110ee2012-03-26 21:49:07 +00006 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
TsiChungLiew1aee1112008-01-15 14:02:49 -06007 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
TsiChungLiew1aee1112008-01-15 14:02:49 -06008 */
9
10#include <config.h>
11#include <common.h>
Simon Glass2cf431c2019-11-14 12:57:47 -070012#include <init.h>
TsiChungLiew1aee1112008-01-15 14:02:49 -060013#include <pci.h>
14#include <asm/immap.h>
Alison Wanga4110ee2012-03-26 21:49:07 +000015#include <asm/io.h>
Simon Glassc05ed002020-05-10 11:40:11 -060016#include <linux/delay.h>
TsiChungLiew1aee1112008-01-15 14:02:49 -060017
18DECLARE_GLOBAL_DATA_PTR;
19
20int checkboard(void)
21{
22 puts("Board: ");
23 puts("Freescale FireEngine 5485 EVB\n");
24 return 0;
25};
26
Simon Glassf1683aa2017-04-06 12:47:05 -060027int dram_init(void)
TsiChungLiew1aee1112008-01-15 14:02:49 -060028{
Alison Wanga4110ee2012-03-26 21:49:07 +000029 siu_t *siu = (siu_t *) (MMAP_SIU);
30 sdram_t *sdram = (sdram_t *)(MMAP_SDRAM);
TsiChungLiew1aee1112008-01-15 14:02:49 -060031 u32 dramsize, i;
stany MARCEL606667d2011-10-14 04:38:06 +000032#ifdef CONFIG_SYS_DRAMSZ1
33 u32 temp;
34#endif
TsiChungLiew1aee1112008-01-15 14:02:49 -060035
Alison Wanga4110ee2012-03-26 21:49:07 +000036 out_be32(&siu->drv, CONFIG_SYS_SDRAM_DRVSTRENGTH);
TsiChungLiew1aee1112008-01-15 14:02:49 -060037
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020038 dramsize = CONFIG_SYS_DRAMSZ * 0x100000;
TsiChungLiew1aee1112008-01-15 14:02:49 -060039 for (i = 0x13; i < 0x20; i++) {
40 if (dramsize == (1 << i))
41 break;
42 }
43 i--;
Alison Wanga4110ee2012-03-26 21:49:07 +000044 out_be32(&siu->cs0cfg, CONFIG_SYS_SDRAM_BASE | i);
TsiChungLiew1aee1112008-01-15 14:02:49 -060045
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020046#ifdef CONFIG_SYS_DRAMSZ1
47 temp = CONFIG_SYS_DRAMSZ1 * 0x100000;
TsiChungLiew1aee1112008-01-15 14:02:49 -060048 for (i = 0x13; i < 0x20; i++) {
49 if (temp == (1 << i))
50 break;
51 }
52 i--;
53 dramsize += temp;
Alison Wanga4110ee2012-03-26 21:49:07 +000054 out_be32(&siu->cs1cfg, (CONFIG_SYS_SDRAM_BASE + temp) | i);
TsiChungLiew1aee1112008-01-15 14:02:49 -060055#endif
56
Alison Wanga4110ee2012-03-26 21:49:07 +000057 out_be32(&sdram->cfg1, CONFIG_SYS_SDRAM_CFG1);
58 out_be32(&sdram->cfg2, CONFIG_SYS_SDRAM_CFG2);
TsiChungLiew1aee1112008-01-15 14:02:49 -060059
60 /* Issue PALL */
Alison Wanga4110ee2012-03-26 21:49:07 +000061 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChungLiew1aee1112008-01-15 14:02:49 -060062
63 /* Issue LEMR */
Alison Wanga4110ee2012-03-26 21:49:07 +000064 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_EMOD);
65 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE | 0x04000000);
TsiChungLiew1aee1112008-01-15 14:02:49 -060066
67 udelay(500);
68
69 /* Issue PALL */
Alison Wanga4110ee2012-03-26 21:49:07 +000070 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
TsiChungLiew1aee1112008-01-15 14:02:49 -060071
72 /* Perform two refresh cycles */
Alison Wanga4110ee2012-03-26 21:49:07 +000073 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
74 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
TsiChungLiew1aee1112008-01-15 14:02:49 -060075
Alison Wanga4110ee2012-03-26 21:49:07 +000076 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE);
TsiChungLiew1aee1112008-01-15 14:02:49 -060077
Alison Wanga4110ee2012-03-26 21:49:07 +000078 out_be32(&sdram->ctrl,
79 (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000F00);
TsiChungLiew1aee1112008-01-15 14:02:49 -060080
81 udelay(100);
82
Simon Glass088454c2017-03-31 08:40:25 -060083 gd->ram_size = dramsize;
84
85 return 0;
TsiChungLiew1aee1112008-01-15 14:02:49 -060086};
87
88int testdram(void)
89{
90 /* TODO: XXX XXX XXX */
91 printf("DRAM test not implemented!\n");
92
93 return (0);
94}
95
96#if defined(CONFIG_PCI)
97/*
98 * Initialize PCI devices, report devices found.
99 */
100static struct pci_controller hose;
101extern void pci_mcf547x_8x_init(struct pci_controller *hose);
102
103void pci_init_board(void)
104{
105 pci_mcf547x_8x_init(&hose);
106}
107#endif /* CONFIG_PCI */