3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
8 * See file CREDITS for list of people who contributed to this
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 #define SDRAM_MODE 0x00CD0000
32 #define SDRAM_CONTROL 0x504F0000
33 #define SDRAM_CONFIG1 0xD2322800
34 #define SDRAM_CONFIG2 0x8AD70000
36 static void sdram_start (int hi_addr
)
38 long hi_addr_bit
= hi_addr
? 0x01000000 : 0;
40 /* unlock mode register */
41 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| 0x80000000 | hi_addr_bit
;
42 __asm__
volatile ("sync");
44 /* precharge all banks */
45 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| 0x80000002 | hi_addr_bit
;
46 __asm__
volatile ("sync");
48 /* precharge all banks */
49 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| 0x80000002 | hi_addr_bit
;
50 __asm__
volatile ("sync");
53 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| 0x80000004 | hi_addr_bit
;
54 __asm__
volatile ("sync");
56 /* set mode register */
57 *(vu_long
*)MPC5XXX_SDRAM_MODE
= SDRAM_MODE
;
58 __asm__
volatile ("sync");
60 /* normal operation */
61 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| hi_addr_bit
;
62 __asm__
volatile ("sync");
66 * ATTENTION: Although partially referenced initdram does NOT make real use
67 * use of CFG_SDRAM_BASE. The code does not work if CFG_SDRAM_BASE
68 * is something else than 0x00000000.
70 long int initdram (int board_type
)
76 /* setup SDRAM chip selects */
77 *(vu_long
*)MPC5XXX_SDRAM_CS0CFG
= 0x0000001e;/* 2G at 0x0 */
78 *(vu_long
*)MPC5XXX_SDRAM_CS1CFG
= 0x80000000;/* disabled */
79 __asm__
volatile ("sync");
81 /* setup config registers */
82 *(vu_long
*)MPC5XXX_SDRAM_CONFIG1
= SDRAM_CONFIG1
;
83 *(vu_long
*)MPC5XXX_SDRAM_CONFIG2
= SDRAM_CONFIG2
;
84 __asm__
volatile ("sync");
86 /* find RAM size using SDRAM CS0 only */
88 test1
= get_ram_size((long *)CFG_SDRAM_BASE
, 0x80000000);
90 test2
= get_ram_size((long *)CFG_SDRAM_BASE
, 0x80000000);
98 /* memory smaller than 1MB is impossible */
99 if (dramsize
< (1 << 20)) {
103 /* set SDRAM CS0 size according to the amount of RAM found */
105 *(vu_long
*)MPC5XXX_SDRAM_CS0CFG
= 0x13 + __builtin_ffs(dramsize
>> 20) - 1;
107 *(vu_long
*)MPC5XXX_SDRAM_CS0CFG
= 0; /* disabled */
109 /* let SDRAM CS1 start right after CS0 */
110 *(vu_long
*)MPC5XXX_SDRAM_CS1CFG
= dramsize
+ 0x0000001e;/* 2G */
112 /* find RAM size using SDRAM CS1 only */
116 test2
= test1
= get_ram_size((long *)(CFG_SDRAM_BASE
+ dramsize
), 0x80000000);
120 test2
= get_ram_size((long *)(CFG_SDRAM_BASE
+ dramsize
), 0x80000000);
130 /* memory smaller than 1MB is impossible */
131 if (dramsize2
< (1 << 20))
134 /* set SDRAM CS1 size according to the amount of RAM found */
136 *(vu_long
*)MPC5XXX_SDRAM_CS1CFG
= dramsize
137 | (0x13 + __builtin_ffs(dramsize2
>> 20) - 1);
139 *(vu_long
*)MPC5XXX_SDRAM_CS1CFG
= dramsize
; /* disabled */
142 return dramsize
+ dramsize2
;
145 int checkboard (void)
147 puts ("Board: O2DNT\n");
151 void flash_preinit(void)
154 * Now, when we are in RAM, enable flash write
155 * access for detection process.
156 * Note that CS_BOOT cannot be cleared when
157 * executing in flash.
159 *(vu_long
*)MPC5XXX_BOOTCS_CFG
&= ~0x1; /* clear RO */
162 void flash_afterinit(ulong size
)
164 if (size
== 0x800000) { /* adjust mapping */
165 *(vu_long
*)MPC5XXX_BOOTCS_START
= *(vu_long
*)MPC5XXX_CS0_START
=
166 START_REG(CFG_BOOTCS_START
| size
);
168 *(vu_long
*)MPC5XXX_BOOTCS_STOP
= *(vu_long
*)MPC5XXX_CS0_STOP
=
169 STOP_REG(CFG_BOOTCS_START
| size
, size
);
174 static struct pci_controller hose
;
176 extern void pci_mpc5xxx_init(struct pci_controller
*);
178 void pci_init_board(void)
180 pci_mpc5xxx_init(&hose
);