2 * (C) Copyright 2000-2006
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 #include <asm/m5271.h>
26 #include <asm/immap_5271.h>
28 int checkboard (void) {
29 puts ("Board: iDMR\n");
33 long int initdram (int board_type) {
37 * After reset, CS0 is configured to cover entire address space. We
38 * need to configure it to its proper values, so that writes to
39 * CFG_SDRAM_BASE and vicinity during SDRAM controller setup below do
40 * now fall under CS0 (see 16.3.1 of the MCF5271 Reference Manual).
43 /* Flash chipselect, CS0 */
44 /* ;CSAR0: Flash at 0xFF800000 */
45 mbar_writeShort(0x0080, 0xFF80);
47 /* CSCR0: Flash 6 waits, 16bit */
48 mbar_writeShort(0x008A, 0x1980);
50 /* CSMR0: Flash 8MB, R/W, valid */
51 mbar_writeLong(0x0084, 0x007F0001);
55 * SDRAM configuration proper
59 * Address/Data Pin Assignment Reg.: enable address lines 23-21; do
60 * not enable data pins D[15:0], as we have 16 bit port to SDRAM
62 mbar_writeByte(MCF_GPIO_PAR_AD,
67 /* No need to configure BS pins - reset values are OK */
69 /* Chip Select Pin Assignment Reg.: set CS[1-7] to GPIO */
70 mbar_writeByte(MCF_GPIO_PAR_CS, 0x00);
72 /* SDRAM Control Pin Assignment Reg. */
73 mbar_writeByte(MCF_GPIO_PAR_SDRAM,
74 MCF_GPIO_SDRAM_CSSDCS_00 | /* no matter: PAR_CS=0 */
79 MCF_GPIO_SDRAM_SDCS_01);
82 * Wait 100us. We run the bus at 50Mhz, one cycle is 20ns. So 5
83 * iterations will do, but we do 10 just to be safe.
85 for (i = 0; i < 10; ++i)
89 /* 1. Initialize DRAM Control Register: DCR */
90 mbar_writeShort(MCF_SDRAMC_DCR,
91 MCF_SDRAMC_DCR_RTIM(0x10) | /* 65ns */
92 MCF_SDRAMC_DCR_RC(0x60)); /* 1562 cycles */
98 * CL: 11 (CL=3: 0x03, 0x02; CL=2: 0x1)
99 * CBM: cmd at A20, bank select bits 21 and up
102 mbar_writeLong(MCF_SDRAMC_DACR0,
103 MCF_SDRAMC_DACRn_BA(CFG_SDRAM_BASE>>18) |
104 MCF_SDRAMC_DACRn_BA(0x00) |
105 MCF_SDRAMC_DACRn_CASL(0x03) |
106 MCF_SDRAMC_DACRn_CBM(0x03) |
107 MCF_SDRAMC_DACRn_PS(0x03));
109 /* Initialize DMR0 */
110 mbar_writeLong(MCF_SDRAMC_DMR0,
111 MCF_SDRAMC_DMRn_BAM_16M |
115 /* 3. Set IP bit in DACR to initiate PALL command */
116 mbar_writeLong(MCF_SDRAMC_DACR0,
117 mbar_readLong(MCF_SDRAMC_DACR0) |
118 MCF_SDRAMC_DACRn_IP);
120 /* Write to this block to initiate precharge */
121 *(volatile u16 *)(CFG_SDRAM_BASE) = 0xa5a5;
124 * Wait at least 20ns to allow banks to precharge (t_RP = 20ns). We
125 * wait a wee longer, just to be safe.
127 for (i = 0; i < 5; ++i)
131 /* 4. Set RE bit in DACR */
132 mbar_writeLong(MCF_SDRAMC_DACR0,
133 mbar_readLong(MCF_SDRAMC_DACR0) |
134 MCF_SDRAMC_DACRn_RE);
137 * Wait for at least 8 auto refresh cycles to occur, i.e. at least
140 for (i = 0; i < 1000; ++i)
143 /* Finish the configuration by issuing the MRS */
144 mbar_writeLong(MCF_SDRAMC_DACR0,
145 mbar_readLong(MCF_SDRAMC_DACR0) |
146 MCF_SDRAMC_DACRn_MRS);
149 * Write to the SDRAM Mode Register A0-A11 = 0x400
151 * Write Burst Mode = Programmed Burst Length
152 * Op Mode = Standard Op
154 * Burst Type = Sequential
157 *(volatile u32 *)(CFG_SDRAM_BASE + 0x1800) = 0xa5a5a5a5;
159 return CFG_SDRAM_SIZE * 1024 * 1024;
163 int testdram (void) {
165 /* TODO: XXX XXX XXX */
166 printf ("DRAM test not implemented!\n");