2 * (C) Copyright 2000-2002
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,
30 #if defined(CFG_I2C_UCODE_PATCH) || defined(CFG_SPI_UCODE_PATCH)
31 void cpm_load_patch (volatile immap_t * immr);
35 * Breath some life into the CPU...
37 * Set up the memory map,
38 * initialize a bunch of registers,
39 * initialize the UPM's
41 void cpu_init_f (volatile immap_t * immr)
44 volatile memctl8xx_t *memctl = &immr->im_memctl;
48 /* SYPCR - contains watchdog control (11-9) */
50 immr->im_siu_conf.sc_sypcr = CFG_SYPCR;
52 #if defined(CONFIG_WATCHDOG)
53 reset_8xx_watchdog (immr);
54 #endif /* CONFIG_WATCHDOG */
56 /* SIUMCR - contains debug pin configuration (11-6) */
58 immr->im_siu_conf.sc_siumcr |= CFG_SIUMCR;
60 /* initialize timebase status and control register (11-26) */
63 immr->im_sitk.sitk_tbscrk = KAPWR_KEY;
64 immr->im_sit.sit_tbscr = CFG_TBSCR;
66 /* initialize the PIT (11-31) */
68 immr->im_sitk.sitk_piscrk = KAPWR_KEY;
69 immr->im_sit.sit_piscr = CFG_PISCR;
71 /* PLL (CPU clock) settings (15-30) */
73 immr->im_clkrstk.cark_plprcrk = KAPWR_KEY;
75 #ifndef CONFIG_MBX /* MBX board does things different */
77 /* If CFG_PLPRCR (set in the various *_config.h files) tries to
78 * set the MF field, then just copy CFG_PLPRCR over car_plprcr,
79 * otherwise OR in CFG_PLPRCR so we do not change the currentMF
82 #if ((CFG_PLPRCR & PLPRCR_MF_MSK) != 0)
83 reg = CFG_PLPRCR; /* reset control bits */
85 reg = immr->im_clkrst.car_plprcr;
86 reg &= PLPRCR_MF_MSK; /* isolate MF field */
87 reg |= CFG_PLPRCR; /* reset control bits */
89 immr->im_clkrst.car_plprcr = reg;
91 /* System integration timers. Don't change EBDF! (15-27) */
93 immr->im_clkrstk.cark_sccrk = KAPWR_KEY;
94 reg = immr->im_clkrst.car_sccr;
97 immr->im_clkrst.car_sccr = reg;
103 /* perform BR0 reset that MPC850 Rev. A can't guarantee */
104 reg = memctl->memc_br0;
105 reg &= BR_PS_MSK; /* Clear everything except Port Size bits */
106 reg |= BR_V; /* then add just the "Bank Valid" bit */
107 memctl->memc_br0 = reg;
109 /* Map banks 0 (and maybe 1) to the FLASH banks 0 (and 1) at
110 * preliminary addresses - these have to be modified later
111 * when FLASH size has been determined
113 * Depending on the size of the memory region defined by
114 * CFG_OR0_REMAP some boards (wide address mask) allow to map the
115 * CFG_MONITOR_BASE, while others (narrower address mask) can't
116 * map CFG_MONITOR_BASE.
118 * For example, for CONFIG_IVMS8, the CFG_MONITOR_BASE is
119 * 0xff000000, but CFG_OR0_REMAP's address mask is 0xfff80000.
121 * If BR0 wasn't loaded with address base 0xff000000, then BR0's
122 * base address remains as 0x00000000. However, the address mask
123 * have been narrowed to 512Kb, so CFG_MONITOR_BASE wasn't mapped
126 * This is why CONFIG_IVMS8 and similar boards must load BR0 with
127 * CFG_BR0_PRELIM in advance.
129 * [Thanks to Michael Liao for this explanation.
130 * I owe him a free beer. - wd]
133 #if defined(CONFIG_GTH) || \
134 defined(CONFIG_HERMES) || \
135 defined(CONFIG_ICU862) || \
136 defined(CONFIG_IP860) || \
137 defined(CONFIG_IVML24) || \
138 defined(CONFIG_IVMS8) || \
139 defined(CONFIG_LWMON) || \
140 defined(CONFIG_MHPC) || \
141 defined(CONFIG_PCU_E) || \
142 defined(CONFIG_R360MPI) || \
143 defined(CONFIG_RPXCLASSIC) || \
144 defined(CONFIG_RPXLITE) || \
145 defined(CONFIG_SPD823TS) || \
146 (defined(CONFIG_MPC860T) && defined(CONFIG_FADS))
148 memctl->memc_br0 = CFG_BR0_PRELIM;
151 #if defined(CFG_OR0_REMAP)
152 memctl->memc_or0 = CFG_OR0_REMAP;
154 #if defined(CFG_OR1_REMAP)
155 memctl->memc_or1 = CFG_OR1_REMAP;
157 #if defined(CFG_OR5_REMAP)
158 memctl->memc_or5 = CFG_OR5_REMAP;
161 /* now restrict to preliminary range */
162 memctl->memc_br0 = CFG_BR0_PRELIM;
163 memctl->memc_or0 = CFG_OR0_PRELIM;
165 #if (defined(CFG_OR1_PRELIM) && defined(CFG_BR1_PRELIM))
166 memctl->memc_or1 = CFG_OR1_PRELIM;
167 memctl->memc_br1 = CFG_BR1_PRELIM;
170 #if defined(CONFIG_IP860) /* disable CS0 now that Flash is mapped on CS1 */
171 memctl->memc_br0 = 0;
174 #if defined(CFG_OR2_PRELIM) && defined(CFG_BR2_PRELIM)
175 memctl->memc_or2 = CFG_OR2_PRELIM;
176 memctl->memc_br2 = CFG_BR2_PRELIM;
179 #if defined(CFG_OR3_PRELIM) && defined(CFG_BR3_PRELIM)
180 memctl->memc_or3 = CFG_OR3_PRELIM;
181 memctl->memc_br3 = CFG_BR3_PRELIM;
184 #if defined(CFG_OR4_PRELIM) && defined(CFG_BR4_PRELIM)
185 memctl->memc_or4 = CFG_OR4_PRELIM;
186 memctl->memc_br4 = CFG_BR4_PRELIM;
189 #if defined(CFG_OR5_PRELIM) && defined(CFG_BR5_PRELIM)
190 memctl->memc_or5 = CFG_OR5_PRELIM;
191 memctl->memc_br5 = CFG_BR5_PRELIM;
194 #if defined(CFG_OR6_PRELIM) && defined(CFG_BR6_PRELIM)
195 memctl->memc_or6 = CFG_OR6_PRELIM;
196 memctl->memc_br6 = CFG_BR6_PRELIM;
199 #if defined(CFG_OR7_PRELIM) && defined(CFG_BR7_PRELIM)
200 memctl->memc_or7 = CFG_OR7_PRELIM;
201 memctl->memc_br7 = CFG_BR7_PRELIM;
204 #endif /* ! CONFIG_MBX */
209 immr->im_cpm.cp_cpcr = CPM_CR_RST | CPM_CR_FLG;
210 do { /* Spin until command processed */
212 } while (immr->im_cpm.cp_cpcr & CPM_CR_FLG);
216 * on the MBX, things are a little bit different:
217 * - we need to read the VPD to get board information
218 * - the plprcr is set up dynamically
219 * - the memory controller is set up dynamically
222 #endif /* CONFIG_MBX */
224 #ifdef CONFIG_RPXCLASSIC
228 #ifdef CFG_RCCR /* must be done before cpm_load_patch() */
229 /* write config value */
230 immr->im_cpm.cp_rccr = CFG_RCCR;
233 #if defined(CFG_I2C_UCODE_PATCH) || defined(CFG_SPI_UCODE_PATCH)
234 cpm_load_patch (immr); /* load mpc8xx microcode patch */
239 * initialize higher level parts of CPU like timers
241 int cpu_init_r (void)
243 #if defined(CFG_RTCSC) || defined(CFG_RMDS)
244 DECLARE_GLOBAL_DATA_PTR;
247 volatile immap_t *immr = (volatile immap_t *) (bd->bi_immr_base);
251 /* Unlock RTSC register */
252 immr->im_sitk.sitk_rtcsck = KAPWR_KEY;
253 /* write config value */
254 immr->im_sit.sit_rtcsc = CFG_RTCSC;
258 /* write config value */
259 immr->im_cpm.cp_rmds = CFG_RMDS;