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