]>
git.ipfire.org Git - people/ms/u-boot.git/blob - cpu/ppc4xx/cpu_init.c
79cfba3a4511d1892c967e012ba5b352b5878a55
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,
26 #include <ppc4xx_enet.h>
27 #include <asm/processor.h>
31 #define mtebc(reg, data) mtdcr(ebccfga,reg);mtdcr(ebccfgd,data)
33 #ifdef CFG_INIT_DCACHE_CS
34 # if (CFG_INIT_DCACHE_CS == 0)
37 # if (defined(CFG_EBC_PB0AP) && defined(CFG_EBC_PB0CR))
38 # define PBxAP_VAL CFG_EBC_PB0AP
39 # define PBxCR_VAL CFG_EBC_PB0CR
42 # if (CFG_INIT_DCACHE_CS == 1)
45 # if (defined(CFG_EBC_PB1AP) && defined(CFG_EBC_PB1CR))
46 # define PBxAP_VAL CFG_EBC_PB1AP
47 # define PBxCR_VAL CFG_EBC_PB1CR
50 # if (CFG_INIT_DCACHE_CS == 2)
53 # if (defined(CFG_EBC_PB2AP) && defined(CFG_EBC_PB2CR))
54 # define PBxAP_VAL CFG_EBC_PB2AP
55 # define PBxCR_VAL CFG_EBC_PB2CR
58 # if (CFG_INIT_DCACHE_CS == 3)
61 # if (defined(CFG_EBC_PB3AP) && defined(CFG_EBC_PB3CR))
62 # define PBxAP_VAL CFG_EBC_PB3AP
63 # define PBxCR_VAL CFG_EBC_PB3CR
66 # if (CFG_INIT_DCACHE_CS == 4)
69 # if (defined(CFG_EBC_PB4AP) && defined(CFG_EBC_PB4CR))
70 # define PBxAP_VAL CFG_EBC_PB4AP
71 # define PBxCR_VAL CFG_EBC_PB4CR
74 # if (CFG_INIT_DCACHE_CS == 5)
77 # if (defined(CFG_EBC_PB5AP) && defined(CFG_EBC_PB5CR))
78 # define PBxAP_VAL CFG_EBC_PB5AP
79 # define PBxCR_VAL CFG_EBC_PB5CR
82 # if (CFG_INIT_DCACHE_CS == 6)
85 # if (defined(CFG_EBC_PB6AP) && defined(CFG_EBC_PB6CR))
86 # define PBxAP_VAL CFG_EBC_PB6AP
87 # define PBxCR_VAL CFG_EBC_PB6CR
90 # if (CFG_INIT_DCACHE_CS == 7)
93 # if (defined(CFG_EBC_PB7AP) && defined(CFG_EBC_PB7CR))
94 # define PBxAP_VAL CFG_EBC_PB7AP
95 # define PBxCR_VAL CFG_EBC_PB7CR
98 #endif /* CFG_INIT_DCACHE_CS */
102 * Breath some life into the CPU...
104 * Set up the memory map,
105 * initialize a bunch of registers
110 #if defined(CONFIG_405EP)
112 * GPIO0 setup (select GPIO or alternate function)
114 out32(GPIO0_OSRH
, CFG_GPIO0_OSRH
); /* output select */
115 out32(GPIO0_OSRL
, CFG_GPIO0_OSRL
);
116 out32(GPIO0_ISR1H
, CFG_GPIO0_ISR1H
); /* input select */
117 out32(GPIO0_ISR1L
, CFG_GPIO0_ISR1L
);
118 out32(GPIO0_TSRH
, CFG_GPIO0_TSRH
); /* three-state select */
119 out32(GPIO0_TSRL
, CFG_GPIO0_TSRL
);
120 out32(GPIO0_TCR
, CFG_GPIO0_TCR
); /* enable output driver for outputs */
123 * Set EMAC noise filter bits
125 mtdcr(cpc0_epctl
, CPC0_EPRCSR_E0NFE
| CPC0_EPRCSR_E1NFE
);
126 #endif /* CONFIG_405EP */
129 * External Bus Controller (EBC) Setup
131 #if (defined(CFG_EBC_PB0AP) && defined(CFG_EBC_PB0CR))
133 * Move the next instructions into icache, since these modify the flash
134 * we are running from!
136 asm volatile(" bl 0f" ::: "lr");
137 asm volatile("0: mflr 3" ::: "r3");
138 asm volatile(" addi 4, 0, 14" ::: "r4");
139 asm volatile(" mtctr 4" ::: "ctr");
140 asm volatile("1: icbt 0, 3");
141 asm volatile(" addi 3, 3, 32" ::: "r3");
142 asm volatile(" bdnz 1b" ::: "ctr", "cr0");
143 asm volatile(" addis 3, 0, 0x0" ::: "r3");
144 asm volatile(" ori 3, 3, 0xA000" ::: "r3");
145 asm volatile(" mtctr 3" ::: "ctr");
146 asm volatile("2: bdnz 2b" ::: "ctr", "cr0");
148 mtebc(pb0ap
, CFG_EBC_PB0AP
);
149 mtebc(pb0cr
, CFG_EBC_PB0CR
);
152 #if (defined(CFG_EBC_PB1AP) && defined(CFG_EBC_PB1CR) && !(CFG_INIT_DCACHE_CS == 1))
153 mtebc(pb1ap
, CFG_EBC_PB1AP
);
154 mtebc(pb1cr
, CFG_EBC_PB1CR
);
157 #if (defined(CFG_EBC_PB2AP) && defined(CFG_EBC_PB2CR) && !(CFG_INIT_DCACHE_CS == 2))
158 mtebc(pb2ap
, CFG_EBC_PB2AP
);
159 mtebc(pb2cr
, CFG_EBC_PB2CR
);
162 #if (defined(CFG_EBC_PB3AP) && defined(CFG_EBC_PB3CR) && !(CFG_INIT_DCACHE_CS == 3))
163 mtebc(pb3ap
, CFG_EBC_PB3AP
);
164 mtebc(pb3cr
, CFG_EBC_PB3CR
);
167 #if (defined(CFG_EBC_PB4AP) && defined(CFG_EBC_PB4CR) && !(CFG_INIT_DCACHE_CS == 4))
168 mtebc(pb4ap
, CFG_EBC_PB4AP
);
169 mtebc(pb4cr
, CFG_EBC_PB4CR
);
172 #if (defined(CFG_EBC_PB5AP) && defined(CFG_EBC_PB5CR) && !(CFG_INIT_DCACHE_CS == 5))
173 mtebc(pb5ap
, CFG_EBC_PB5AP
);
174 mtebc(pb5cr
, CFG_EBC_PB5CR
);
177 #if (defined(CFG_EBC_PB6AP) && defined(CFG_EBC_PB6CR) && !(CFG_INIT_DCACHE_CS == 6))
178 mtebc(pb6ap
, CFG_EBC_PB6AP
);
179 mtebc(pb6cr
, CFG_EBC_PB6CR
);
182 #if (defined(CFG_EBC_PB7AP) && defined(CFG_EBC_PB7CR) && !(CFG_INIT_DCACHE_CS == 7))
183 mtebc(pb7ap
, CFG_EBC_PB7AP
);
184 mtebc(pb7cr
, CFG_EBC_PB7CR
);
187 #if defined(CONFIG_WATCHDOG)
191 #if defined(CONFIG_440EP) || defined(CONFIG_440GR)
192 val
|= 0xb8000000; /* generate system reset after 1.34 seconds */
194 val
|= 0xf0000000; /* generate system reset after 2.684 seconds */
199 val
|= 0x80000000; /* enable watchdog timer */
202 reset_4xx_watchdog();
203 #endif /* CONFIG_WATCHDOG */
207 * initialize higher level parts of CPU like time base and timers
209 int cpu_init_r (void)
211 #if defined(CONFIG_405GP) || defined(CONFIG_405EP)
212 DECLARE_GLOBAL_DATA_PTR
;
216 #if defined(CONFIG_405GP)
217 uint pvr
= get_pvr();
220 #ifdef CFG_INIT_DCACHE_CS
222 * Flush and invalidate dcache, then disable CS for temporary stack.
223 * Afterwards, this CS can be used for other purposes
225 dcache_disable(); /* flush and invalidate dcache */
227 mtebc(PBxCR
, 0); /* disable CS for temporary stack */
229 #if (defined(PBxAP_VAL) && defined(PBxCR_VAL))
231 * Write new value into CS register
233 mtebc(PBxAP
, PBxAP_VAL
);
234 mtebc(PBxCR
, PBxCR_VAL
);
236 #endif /* CFG_INIT_DCACHE_CS */
239 * Write Ethernetaddress into on-chip register
242 reg
|= bd
->bi_enetaddr
[0]; /* set high address */
244 reg
|= bd
->bi_enetaddr
[1];
245 out32 (EMAC_IAH
, reg
);
248 reg
|= bd
->bi_enetaddr
[2]; /* set low address */
250 reg
|= bd
->bi_enetaddr
[3];
252 reg
|= bd
->bi_enetaddr
[4];
254 reg
|= bd
->bi_enetaddr
[5];
255 out32 (EMAC_IAL
, reg
);
257 #if defined(CONFIG_405GP)
259 * Set edge conditioning circuitry on PPC405GPr
260 * for compatibility to existing PPC405GP designs.
262 if ((pvr
& 0xfffffff0) == (PVR_405GPR_RB
& 0xfffffff0)) {
263 mtdcr(ecr
, 0x60606000);
265 #endif /* defined(CONFIG_405GP) */
266 #endif /* defined(CONFIG_405GP) || defined(CONFIG_405EP) */