1
2
3
4
5
6
7
8
9
10
11
12#include <common.h>
13#include <asm/immap.h>
14#include <asm/io.h>
15
16DECLARE_GLOBAL_DATA_PTR;
17
18#define PERIOD 13
19#define SDRAM_TREFI 7800
20
21int checkboard(void)
22{
23 puts("Board: ");
24 puts("Freescale MCF5275 EVB\n");
25 return 0;
26};
27
28int dram_init(void)
29{
30 sdramctrl_t *sdp = (sdramctrl_t *)(MMAP_SDRAM);
31 gpio_t *gpio_reg = (gpio_t *)(MMAP_GPIO);
32
33
34 out_be16(&gpio_reg->par_sdram, 0x3FF);
35
36
37 out_be32(&sdp->sdbar0, CONFIG_SYS_SDRAM_BASE);
38 out_be32(&sdp->sdbmr0, MCF_SDRAMC_SDMRn_BAM_32M | MCF_SDRAMC_SDMRn_V);
39
40
41 out_be32(&sdp->sdcfg1, 0x83711630);
42 out_be32(&sdp->sdcfg2, 0x46770000);
43
44
45 out_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_MODE_EN | MCF_SDRAMC_SDCR_CKE);
46
47
48 setbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IPALL);
49
50
51 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
52
53
54 setbits_be32(&sdp->sdmr,
55 MCF_SDRAMC_SDMR_BNKAD_LEMR | MCF_SDRAMC_SDMR_AD(0x0) |
56 MCF_SDRAMC_SDMR_CMD);
57 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
58
59
60 out_be32(&sdp->sdmr, 0x058d0000);
61 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
62
63
64 clrbits_be32(&sdp->sdmr, MCF_SDRAMC_SDMR_CMD);
65
66
67 setbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IPALL);
68 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
69
70
71 clrbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IPALL);
72 setbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IREF);
73 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
74 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
75
76
77 out_be32(&sdp->sdmr, 0x018d0000);
78 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
79
80
81 clrbits_be32(&sdp->sdmr, MCF_SDRAMC_SDMR_CMD);
82 clrbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_MODE_EN);
83
84
85 out_be32(&sdp->sdcr,
86 MCF_SDRAMC_SDCR_CKE
87 | MCF_SDRAMC_SDCR_REF
88 | MCF_SDRAMC_SDCR_MUX(1)
89
90 | MCF_SDRAMC_SDCR_RCNT((SDRAM_TREFI/(PERIOD*64)) - 1 + 1)
91 | MCF_SDRAMC_SDCR_DQS_OE(0x3));
92
93 gd->ram_size = CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
94
95 return 0;
96};
97
98int testdram(void)
99{
100
101 printf("DRAM test not implemented!\n");
102
103 return (0);
104}
105