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 <405gp_enet.h>
27 #include <asm/processor.h>
31 #define mtebc(reg, data) mtdcr(ebccfga,reg);mtdcr(ebccfgd,data)
35 * Breath some life into the CPU...
37 * Set up the memory map,
38 * initialize a bunch of registers
43 #if defined(CONFIG_405EP)
45 * GPIO0 setup (select GPIO or alternate function)
47 out32(GPIO0_OSRH, CFG_GPIO0_OSRH); /* output select */
48 out32(GPIO0_OSRL, CFG_GPIO0_OSRL);
49 out32(GPIO0_ISR1H, CFG_GPIO0_ISR1H); /* input select */
50 out32(GPIO0_ISR1L, CFG_GPIO0_ISR1L);
51 out32(GPIO0_TSRH, CFG_GPIO0_TSRH); /* three-state select */
52 out32(GPIO0_TSRL, CFG_GPIO0_TSRL);
53 out32(GPIO0_TCR, CFG_GPIO0_TCR); /* enable output driver for outputs */
56 * Set EMAC noise filter bits
58 mtdcr(cpc0_epctl, CPC0_EPRCSR_E0NFE | CPC0_EPRCSR_E1NFE);
59 #endif /* CONFIG_405EP */
62 * External Bus Controller (EBC) Setup
64 #if (defined(CFG_EBC_PB0AP) && defined(CFG_EBC_PB0CR))
66 * Move the next instructions into icache, since these modify the flash
67 * we are running from!
69 asm volatile(" bl 0f" ::: "lr");
70 asm volatile("0: mflr 3" ::: "r3");
71 asm volatile(" addi 4, 0, 14" ::: "r4");
72 asm volatile(" mtctr 4" ::: "ctr");
73 asm volatile("1: icbt 0, 3");
74 asm volatile(" addi 3, 3, 32" ::: "r3");
75 asm volatile(" bdnz 1b" ::: "ctr", "cr0");
76 asm volatile(" addis 3, 0, 0x0" ::: "r3");
77 asm volatile(" ori 3, 3, 0xA000" ::: "r3");
78 asm volatile(" mtctr 3" ::: "ctr");
79 asm volatile("2: bdnz 2b" ::: "ctr", "cr0");
81 mtebc(pb0ap, CFG_EBC_PB0AP);
82 mtebc(pb0cr, CFG_EBC_PB0CR);
85 #if (defined(CFG_EBC_PB1AP) && defined(CFG_EBC_PB1CR))
86 mtebc(pb1ap, CFG_EBC_PB1AP);
87 mtebc(pb1cr, CFG_EBC_PB1CR);
90 #if (defined(CFG_EBC_PB2AP) && defined(CFG_EBC_PB2CR))
91 mtebc(pb2ap, CFG_EBC_PB2AP);
92 mtebc(pb2cr, CFG_EBC_PB2CR);
95 #if (defined(CFG_EBC_PB3AP) && defined(CFG_EBC_PB3CR))
96 mtebc(pb3ap, CFG_EBC_PB3AP);
97 mtebc(pb3cr, CFG_EBC_PB3CR);
100 #if (defined(CFG_EBC_PB4AP) && defined(CFG_EBC_PB4CR))
101 mtebc(pb4ap, CFG_EBC_PB4AP);
102 mtebc(pb4cr, CFG_EBC_PB4CR);
105 #if (defined(CFG_EBC_PB5AP) && defined(CFG_EBC_PB5CR))
106 mtebc(pb5ap, CFG_EBC_PB5AP);
107 mtebc(pb5cr, CFG_EBC_PB5CR);
110 #if (defined(CFG_EBC_PB6AP) && defined(CFG_EBC_PB6CR))
111 mtebc(pb6ap, CFG_EBC_PB6AP);
112 mtebc(pb6cr, CFG_EBC_PB6CR);
115 #if (defined(CFG_EBC_PB7AP) && defined(CFG_EBC_PB7CR))
116 mtebc(pb7ap, CFG_EBC_PB7AP);
117 mtebc(pb7cr, CFG_EBC_PB7CR);
120 #if defined(CONFIG_WATCHDOG)
124 val |= 0xf0000000; /* generate system reset after 2.684 seconds */
128 val |= 0x80000000; /* enable watchdog timer */
131 reset_4xx_watchdog();
132 #endif /* CONFIG_WATCHDOG */
136 * initialize higher level parts of CPU like time base and timers
138 int cpu_init_r (void)
140 #if defined(CONFIG_405GP) || defined(CONFIG_405EP)
141 DECLARE_GLOBAL_DATA_PTR;
145 #if defined(CONFIG_405GP)
146 uint pvr = get_pvr();
150 * Write Ethernetaddress into on-chip register
153 reg |= bd->bi_enetaddr[0]; /* set high address */
155 reg |= bd->bi_enetaddr[1];
156 out32 (EMAC_IAH, reg);
159 reg |= bd->bi_enetaddr[2]; /* set low address */
161 reg |= bd->bi_enetaddr[3];
163 reg |= bd->bi_enetaddr[4];
165 reg |= bd->bi_enetaddr[5];
166 out32 (EMAC_IAL, reg);
168 #if defined(CONFIG_405GP)
170 * Set edge conditioning circuitry on PPC405GPr
171 * for compatibility to existing PPC405GP designs.
173 if ((pvr & 0xfffffff0) == (PVR_405GPR_RB & 0xfffffff0)) {
174 mtdcr(ecr, 0x60606000);
176 #endif /* defined(CONFIG_405GP) */
177 #endif /* defined(CONFIG_405GP) || defined(CONFIG_405EP) */