1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright (C) 2004-2009 Freescale Semiconductor, Inc.
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * SPDX-License-Identifier: GPL-2.0+
5*4882a593Smuzhiyun */
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun #include <common.h>
8*4882a593Smuzhiyun #include <mpc83xx.h>
9*4882a593Smuzhiyun #include <ioports.h>
10*4882a593Smuzhiyun #include <asm/io.h>
11*4882a593Smuzhiyun #include <asm/processor.h>
12*4882a593Smuzhiyun #ifdef CONFIG_USB_EHCI_FSL
13*4882a593Smuzhiyun #include <usb/ehci-ci.h>
14*4882a593Smuzhiyun #endif
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun DECLARE_GLOBAL_DATA_PTR;
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun #ifdef CONFIG_QE
19*4882a593Smuzhiyun extern qe_iop_conf_t qe_iop_conf_tab[];
20*4882a593Smuzhiyun extern void qe_config_iopin(u8 port, u8 pin, int dir,
21*4882a593Smuzhiyun int open_drain, int assign);
22*4882a593Smuzhiyun extern void qe_init(uint qe_base);
23*4882a593Smuzhiyun extern void qe_reset(void);
24*4882a593Smuzhiyun
config_qe_ioports(void)25*4882a593Smuzhiyun static void config_qe_ioports(void)
26*4882a593Smuzhiyun {
27*4882a593Smuzhiyun u8 port, pin;
28*4882a593Smuzhiyun int dir, open_drain, assign;
29*4882a593Smuzhiyun int i;
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun for (i = 0; qe_iop_conf_tab[i].assign != QE_IOP_TAB_END; i++) {
32*4882a593Smuzhiyun port = qe_iop_conf_tab[i].port;
33*4882a593Smuzhiyun pin = qe_iop_conf_tab[i].pin;
34*4882a593Smuzhiyun dir = qe_iop_conf_tab[i].dir;
35*4882a593Smuzhiyun open_drain = qe_iop_conf_tab[i].open_drain;
36*4882a593Smuzhiyun assign = qe_iop_conf_tab[i].assign;
37*4882a593Smuzhiyun qe_config_iopin(port, pin, dir, open_drain, assign);
38*4882a593Smuzhiyun }
39*4882a593Smuzhiyun }
40*4882a593Smuzhiyun #endif
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun /*
43*4882a593Smuzhiyun * Breathe some life into the CPU...
44*4882a593Smuzhiyun *
45*4882a593Smuzhiyun * Set up the memory map,
46*4882a593Smuzhiyun * initialize a bunch of registers,
47*4882a593Smuzhiyun * initialize the UPM's
48*4882a593Smuzhiyun */
cpu_init_f(volatile immap_t * im)49*4882a593Smuzhiyun void cpu_init_f (volatile immap_t * im)
50*4882a593Smuzhiyun {
51*4882a593Smuzhiyun __be32 acr_mask =
52*4882a593Smuzhiyun #ifdef CONFIG_SYS_ACR_PIPE_DEP /* Arbiter pipeline depth */
53*4882a593Smuzhiyun ACR_PIPE_DEP |
54*4882a593Smuzhiyun #endif
55*4882a593Smuzhiyun #ifdef CONFIG_SYS_ACR_RPTCNT /* Arbiter repeat count */
56*4882a593Smuzhiyun ACR_RPTCNT |
57*4882a593Smuzhiyun #endif
58*4882a593Smuzhiyun #ifdef CONFIG_SYS_ACR_APARK /* Arbiter address parking mode */
59*4882a593Smuzhiyun ACR_APARK |
60*4882a593Smuzhiyun #endif
61*4882a593Smuzhiyun #ifdef CONFIG_SYS_ACR_PARKM /* Arbiter parking master */
62*4882a593Smuzhiyun ACR_PARKM |
63*4882a593Smuzhiyun #endif
64*4882a593Smuzhiyun 0;
65*4882a593Smuzhiyun __be32 acr_val =
66*4882a593Smuzhiyun #ifdef CONFIG_SYS_ACR_PIPE_DEP /* Arbiter pipeline depth */
67*4882a593Smuzhiyun (CONFIG_SYS_ACR_PIPE_DEP << ACR_PIPE_DEP_SHIFT) |
68*4882a593Smuzhiyun #endif
69*4882a593Smuzhiyun #ifdef CONFIG_SYS_ACR_RPTCNT /* Arbiter repeat count */
70*4882a593Smuzhiyun (CONFIG_SYS_ACR_RPTCNT << ACR_RPTCNT_SHIFT) |
71*4882a593Smuzhiyun #endif
72*4882a593Smuzhiyun #ifdef CONFIG_SYS_ACR_APARK /* Arbiter address parking mode */
73*4882a593Smuzhiyun (CONFIG_SYS_ACR_APARK << ACR_APARK_SHIFT) |
74*4882a593Smuzhiyun #endif
75*4882a593Smuzhiyun #ifdef CONFIG_SYS_ACR_PARKM /* Arbiter parking master */
76*4882a593Smuzhiyun (CONFIG_SYS_ACR_PARKM << ACR_PARKM_SHIFT) |
77*4882a593Smuzhiyun #endif
78*4882a593Smuzhiyun 0;
79*4882a593Smuzhiyun __be32 spcr_mask =
80*4882a593Smuzhiyun #ifdef CONFIG_SYS_SPCR_OPT /* Optimize transactions between CSB and other dev */
81*4882a593Smuzhiyun SPCR_OPT |
82*4882a593Smuzhiyun #endif
83*4882a593Smuzhiyun #ifdef CONFIG_SYS_SPCR_TSECEP /* all eTSEC's Emergency priority */
84*4882a593Smuzhiyun SPCR_TSECEP |
85*4882a593Smuzhiyun #endif
86*4882a593Smuzhiyun #ifdef CONFIG_SYS_SPCR_TSEC1EP /* TSEC1 Emergency priority */
87*4882a593Smuzhiyun SPCR_TSEC1EP |
88*4882a593Smuzhiyun #endif
89*4882a593Smuzhiyun #ifdef CONFIG_SYS_SPCR_TSEC2EP /* TSEC2 Emergency priority */
90*4882a593Smuzhiyun SPCR_TSEC2EP |
91*4882a593Smuzhiyun #endif
92*4882a593Smuzhiyun 0;
93*4882a593Smuzhiyun __be32 spcr_val =
94*4882a593Smuzhiyun #ifdef CONFIG_SYS_SPCR_OPT
95*4882a593Smuzhiyun (CONFIG_SYS_SPCR_OPT << SPCR_OPT_SHIFT) |
96*4882a593Smuzhiyun #endif
97*4882a593Smuzhiyun #ifdef CONFIG_SYS_SPCR_TSECEP /* all eTSEC's Emergency priority */
98*4882a593Smuzhiyun (CONFIG_SYS_SPCR_TSECEP << SPCR_TSECEP_SHIFT) |
99*4882a593Smuzhiyun #endif
100*4882a593Smuzhiyun #ifdef CONFIG_SYS_SPCR_TSEC1EP /* TSEC1 Emergency priority */
101*4882a593Smuzhiyun (CONFIG_SYS_SPCR_TSEC1EP << SPCR_TSEC1EP_SHIFT) |
102*4882a593Smuzhiyun #endif
103*4882a593Smuzhiyun #ifdef CONFIG_SYS_SPCR_TSEC2EP /* TSEC2 Emergency priority */
104*4882a593Smuzhiyun (CONFIG_SYS_SPCR_TSEC2EP << SPCR_TSEC2EP_SHIFT) |
105*4882a593Smuzhiyun #endif
106*4882a593Smuzhiyun 0;
107*4882a593Smuzhiyun __be32 sccr_mask =
108*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */
109*4882a593Smuzhiyun SCCR_ENCCM |
110*4882a593Smuzhiyun #endif
111*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */
112*4882a593Smuzhiyun SCCR_PCICM |
113*4882a593Smuzhiyun #endif
114*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_PCIEXP1CM /* PCIE1 clock mode */
115*4882a593Smuzhiyun SCCR_PCIEXP1CM |
116*4882a593Smuzhiyun #endif
117*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_PCIEXP2CM /* PCIE2 clock mode */
118*4882a593Smuzhiyun SCCR_PCIEXP2CM |
119*4882a593Smuzhiyun #endif
120*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */
121*4882a593Smuzhiyun SCCR_TSECCM |
122*4882a593Smuzhiyun #endif
123*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */
124*4882a593Smuzhiyun SCCR_TSEC1CM |
125*4882a593Smuzhiyun #endif
126*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */
127*4882a593Smuzhiyun SCCR_TSEC2CM |
128*4882a593Smuzhiyun #endif
129*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */
130*4882a593Smuzhiyun SCCR_TSEC1ON |
131*4882a593Smuzhiyun #endif
132*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */
133*4882a593Smuzhiyun SCCR_TSEC2ON |
134*4882a593Smuzhiyun #endif
135*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */
136*4882a593Smuzhiyun SCCR_USBMPHCM |
137*4882a593Smuzhiyun #endif
138*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_USBDRCM /* USB DR clock mode */
139*4882a593Smuzhiyun SCCR_USBDRCM |
140*4882a593Smuzhiyun #endif
141*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_SATACM /* SATA controller clock mode */
142*4882a593Smuzhiyun SCCR_SATACM |
143*4882a593Smuzhiyun #endif
144*4882a593Smuzhiyun 0;
145*4882a593Smuzhiyun __be32 sccr_val =
146*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */
147*4882a593Smuzhiyun (CONFIG_SYS_SCCR_ENCCM << SCCR_ENCCM_SHIFT) |
148*4882a593Smuzhiyun #endif
149*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */
150*4882a593Smuzhiyun (CONFIG_SYS_SCCR_PCICM << SCCR_PCICM_SHIFT) |
151*4882a593Smuzhiyun #endif
152*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_PCIEXP1CM /* PCIE1 clock mode */
153*4882a593Smuzhiyun (CONFIG_SYS_SCCR_PCIEXP1CM << SCCR_PCIEXP1CM_SHIFT) |
154*4882a593Smuzhiyun #endif
155*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_PCIEXP2CM /* PCIE2 clock mode */
156*4882a593Smuzhiyun (CONFIG_SYS_SCCR_PCIEXP2CM << SCCR_PCIEXP2CM_SHIFT) |
157*4882a593Smuzhiyun #endif
158*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */
159*4882a593Smuzhiyun (CONFIG_SYS_SCCR_TSECCM << SCCR_TSECCM_SHIFT) |
160*4882a593Smuzhiyun #endif
161*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */
162*4882a593Smuzhiyun (CONFIG_SYS_SCCR_TSEC1CM << SCCR_TSEC1CM_SHIFT) |
163*4882a593Smuzhiyun #endif
164*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */
165*4882a593Smuzhiyun (CONFIG_SYS_SCCR_TSEC2CM << SCCR_TSEC2CM_SHIFT) |
166*4882a593Smuzhiyun #endif
167*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */
168*4882a593Smuzhiyun (CONFIG_SYS_SCCR_TSEC1ON << SCCR_TSEC1ON_SHIFT) |
169*4882a593Smuzhiyun #endif
170*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */
171*4882a593Smuzhiyun (CONFIG_SYS_SCCR_TSEC2ON << SCCR_TSEC2ON_SHIFT) |
172*4882a593Smuzhiyun #endif
173*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */
174*4882a593Smuzhiyun (CONFIG_SYS_SCCR_USBMPHCM << SCCR_USBMPHCM_SHIFT) |
175*4882a593Smuzhiyun #endif
176*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_USBDRCM /* USB DR clock mode */
177*4882a593Smuzhiyun (CONFIG_SYS_SCCR_USBDRCM << SCCR_USBDRCM_SHIFT) |
178*4882a593Smuzhiyun #endif
179*4882a593Smuzhiyun #ifdef CONFIG_SYS_SCCR_SATACM /* SATA controller clock mode */
180*4882a593Smuzhiyun (CONFIG_SYS_SCCR_SATACM << SCCR_SATACM_SHIFT) |
181*4882a593Smuzhiyun #endif
182*4882a593Smuzhiyun 0;
183*4882a593Smuzhiyun __be32 lcrr_mask =
184*4882a593Smuzhiyun #ifdef CONFIG_SYS_LCRR_DBYP /* PLL bypass */
185*4882a593Smuzhiyun LCRR_DBYP |
186*4882a593Smuzhiyun #endif
187*4882a593Smuzhiyun #ifdef CONFIG_SYS_LCRR_EADC /* external address delay */
188*4882a593Smuzhiyun LCRR_EADC |
189*4882a593Smuzhiyun #endif
190*4882a593Smuzhiyun #ifdef CONFIG_SYS_LCRR_CLKDIV /* system clock divider */
191*4882a593Smuzhiyun LCRR_CLKDIV |
192*4882a593Smuzhiyun #endif
193*4882a593Smuzhiyun 0;
194*4882a593Smuzhiyun __be32 lcrr_val =
195*4882a593Smuzhiyun #ifdef CONFIG_SYS_LCRR_DBYP /* PLL bypass */
196*4882a593Smuzhiyun CONFIG_SYS_LCRR_DBYP |
197*4882a593Smuzhiyun #endif
198*4882a593Smuzhiyun #ifdef CONFIG_SYS_LCRR_EADC
199*4882a593Smuzhiyun CONFIG_SYS_LCRR_EADC |
200*4882a593Smuzhiyun #endif
201*4882a593Smuzhiyun #ifdef CONFIG_SYS_LCRR_CLKDIV /* system clock divider */
202*4882a593Smuzhiyun CONFIG_SYS_LCRR_CLKDIV |
203*4882a593Smuzhiyun #endif
204*4882a593Smuzhiyun 0;
205*4882a593Smuzhiyun
206*4882a593Smuzhiyun /* Pointer is writable since we allocated a register for it */
207*4882a593Smuzhiyun gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
208*4882a593Smuzhiyun
209*4882a593Smuzhiyun /* global data region was cleared in start.S */
210*4882a593Smuzhiyun
211*4882a593Smuzhiyun /* system performance tweaking */
212*4882a593Smuzhiyun clrsetbits_be32(&im->arbiter.acr, acr_mask, acr_val);
213*4882a593Smuzhiyun
214*4882a593Smuzhiyun clrsetbits_be32(&im->sysconf.spcr, spcr_mask, spcr_val);
215*4882a593Smuzhiyun
216*4882a593Smuzhiyun clrsetbits_be32(&im->clk.sccr, sccr_mask, sccr_val);
217*4882a593Smuzhiyun
218*4882a593Smuzhiyun /* RSR - Reset Status Register - clear all status (4.6.1.3) */
219*4882a593Smuzhiyun gd->arch.reset_status = __raw_readl(&im->reset.rsr);
220*4882a593Smuzhiyun __raw_writel(~(RSR_RES), &im->reset.rsr);
221*4882a593Smuzhiyun
222*4882a593Smuzhiyun /* AER - Arbiter Event Register - store status */
223*4882a593Smuzhiyun gd->arch.arbiter_event_attributes = __raw_readl(&im->arbiter.aeatr);
224*4882a593Smuzhiyun gd->arch.arbiter_event_address = __raw_readl(&im->arbiter.aeadr);
225*4882a593Smuzhiyun
226*4882a593Smuzhiyun /*
227*4882a593Smuzhiyun * RMR - Reset Mode Register
228*4882a593Smuzhiyun * contains checkstop reset enable (4.6.1.4)
229*4882a593Smuzhiyun */
230*4882a593Smuzhiyun __raw_writel(RMR_CSRE & (1<<RMR_CSRE_SHIFT), &im->reset.rmr);
231*4882a593Smuzhiyun
232*4882a593Smuzhiyun /* LCRR - Clock Ratio Register (10.3.1.16)
233*4882a593Smuzhiyun * write, read, and isync per MPC8379ERM rev.1 CLKDEV field description
234*4882a593Smuzhiyun */
235*4882a593Smuzhiyun clrsetbits_be32(&im->im_lbc.lcrr, lcrr_mask, lcrr_val);
236*4882a593Smuzhiyun __raw_readl(&im->im_lbc.lcrr);
237*4882a593Smuzhiyun isync();
238*4882a593Smuzhiyun
239*4882a593Smuzhiyun /* Enable Time Base & Decrementer ( so we will have udelay() )*/
240*4882a593Smuzhiyun setbits_be32(&im->sysconf.spcr, SPCR_TBEN);
241*4882a593Smuzhiyun
242*4882a593Smuzhiyun /* System General Purpose Register */
243*4882a593Smuzhiyun #ifdef CONFIG_SYS_SICRH
244*4882a593Smuzhiyun #if defined(CONFIG_MPC834x) || defined(CONFIG_MPC8313)
245*4882a593Smuzhiyun /* regarding to MPC34x manual rev.1 bits 28..29 must be preserved */
246*4882a593Smuzhiyun __raw_writel((im->sysconf.sicrh & 0x0000000C) | CONFIG_SYS_SICRH,
247*4882a593Smuzhiyun &im->sysconf.sicrh);
248*4882a593Smuzhiyun #else
249*4882a593Smuzhiyun __raw_writel(CONFIG_SYS_SICRH, &im->sysconf.sicrh);
250*4882a593Smuzhiyun #endif
251*4882a593Smuzhiyun #endif
252*4882a593Smuzhiyun #ifdef CONFIG_SYS_SICRL
253*4882a593Smuzhiyun __raw_writel(CONFIG_SYS_SICRL, &im->sysconf.sicrl);
254*4882a593Smuzhiyun #endif
255*4882a593Smuzhiyun #ifdef CONFIG_SYS_GPR1
256*4882a593Smuzhiyun __raw_writel(CONFIG_SYS_GPR1, &im->sysconf.gpr1);
257*4882a593Smuzhiyun #endif
258*4882a593Smuzhiyun #ifdef CONFIG_SYS_DDRCDR /* DDR control driver register */
259*4882a593Smuzhiyun __raw_writel(CONFIG_SYS_DDRCDR, &im->sysconf.ddrcdr);
260*4882a593Smuzhiyun #endif
261*4882a593Smuzhiyun #ifdef CONFIG_SYS_OBIR /* Output buffer impedance register */
262*4882a593Smuzhiyun __raw_writel(CONFIG_SYS_OBIR, &im->sysconf.obir);
263*4882a593Smuzhiyun #endif
264*4882a593Smuzhiyun
265*4882a593Smuzhiyun #ifdef CONFIG_QE
266*4882a593Smuzhiyun /* Config QE ioports */
267*4882a593Smuzhiyun config_qe_ioports();
268*4882a593Smuzhiyun #endif
269*4882a593Smuzhiyun /* Set up preliminary BR/OR regs */
270*4882a593Smuzhiyun init_early_memctl_regs();
271*4882a593Smuzhiyun
272*4882a593Smuzhiyun /* Local Access window setup */
273*4882a593Smuzhiyun #if defined(CONFIG_SYS_LBLAWBAR0_PRELIM) && defined(CONFIG_SYS_LBLAWAR0_PRELIM)
274*4882a593Smuzhiyun im->sysconf.lblaw[0].bar = CONFIG_SYS_LBLAWBAR0_PRELIM;
275*4882a593Smuzhiyun im->sysconf.lblaw[0].ar = CONFIG_SYS_LBLAWAR0_PRELIM;
276*4882a593Smuzhiyun #else
277*4882a593Smuzhiyun #error CONFIG_SYS_LBLAWBAR0_PRELIM & CONFIG_SYS_LBLAWAR0_PRELIM must be defined
278*4882a593Smuzhiyun #endif
279*4882a593Smuzhiyun
280*4882a593Smuzhiyun #if defined(CONFIG_SYS_LBLAWBAR1_PRELIM) && defined(CONFIG_SYS_LBLAWAR1_PRELIM)
281*4882a593Smuzhiyun im->sysconf.lblaw[1].bar = CONFIG_SYS_LBLAWBAR1_PRELIM;
282*4882a593Smuzhiyun im->sysconf.lblaw[1].ar = CONFIG_SYS_LBLAWAR1_PRELIM;
283*4882a593Smuzhiyun #endif
284*4882a593Smuzhiyun #if defined(CONFIG_SYS_LBLAWBAR2_PRELIM) && defined(CONFIG_SYS_LBLAWAR2_PRELIM)
285*4882a593Smuzhiyun im->sysconf.lblaw[2].bar = CONFIG_SYS_LBLAWBAR2_PRELIM;
286*4882a593Smuzhiyun im->sysconf.lblaw[2].ar = CONFIG_SYS_LBLAWAR2_PRELIM;
287*4882a593Smuzhiyun #endif
288*4882a593Smuzhiyun #if defined(CONFIG_SYS_LBLAWBAR3_PRELIM) && defined(CONFIG_SYS_LBLAWAR3_PRELIM)
289*4882a593Smuzhiyun im->sysconf.lblaw[3].bar = CONFIG_SYS_LBLAWBAR3_PRELIM;
290*4882a593Smuzhiyun im->sysconf.lblaw[3].ar = CONFIG_SYS_LBLAWAR3_PRELIM;
291*4882a593Smuzhiyun #endif
292*4882a593Smuzhiyun #if defined(CONFIG_SYS_LBLAWBAR4_PRELIM) && defined(CONFIG_SYS_LBLAWAR4_PRELIM)
293*4882a593Smuzhiyun im->sysconf.lblaw[4].bar = CONFIG_SYS_LBLAWBAR4_PRELIM;
294*4882a593Smuzhiyun im->sysconf.lblaw[4].ar = CONFIG_SYS_LBLAWAR4_PRELIM;
295*4882a593Smuzhiyun #endif
296*4882a593Smuzhiyun #if defined(CONFIG_SYS_LBLAWBAR5_PRELIM) && defined(CONFIG_SYS_LBLAWAR5_PRELIM)
297*4882a593Smuzhiyun im->sysconf.lblaw[5].bar = CONFIG_SYS_LBLAWBAR5_PRELIM;
298*4882a593Smuzhiyun im->sysconf.lblaw[5].ar = CONFIG_SYS_LBLAWAR5_PRELIM;
299*4882a593Smuzhiyun #endif
300*4882a593Smuzhiyun #if defined(CONFIG_SYS_LBLAWBAR6_PRELIM) && defined(CONFIG_SYS_LBLAWAR6_PRELIM)
301*4882a593Smuzhiyun im->sysconf.lblaw[6].bar = CONFIG_SYS_LBLAWBAR6_PRELIM;
302*4882a593Smuzhiyun im->sysconf.lblaw[6].ar = CONFIG_SYS_LBLAWAR6_PRELIM;
303*4882a593Smuzhiyun #endif
304*4882a593Smuzhiyun #if defined(CONFIG_SYS_LBLAWBAR7_PRELIM) && defined(CONFIG_SYS_LBLAWAR7_PRELIM)
305*4882a593Smuzhiyun im->sysconf.lblaw[7].bar = CONFIG_SYS_LBLAWBAR7_PRELIM;
306*4882a593Smuzhiyun im->sysconf.lblaw[7].ar = CONFIG_SYS_LBLAWAR7_PRELIM;
307*4882a593Smuzhiyun #endif
308*4882a593Smuzhiyun #ifdef CONFIG_SYS_GPIO1_PRELIM
309*4882a593Smuzhiyun im->gpio[0].dat = CONFIG_SYS_GPIO1_DAT;
310*4882a593Smuzhiyun im->gpio[0].dir = CONFIG_SYS_GPIO1_DIR;
311*4882a593Smuzhiyun #endif
312*4882a593Smuzhiyun #ifdef CONFIG_SYS_GPIO2_PRELIM
313*4882a593Smuzhiyun im->gpio[1].dat = CONFIG_SYS_GPIO2_DAT;
314*4882a593Smuzhiyun im->gpio[1].dir = CONFIG_SYS_GPIO2_DIR;
315*4882a593Smuzhiyun #endif
316*4882a593Smuzhiyun #if defined(CONFIG_USB_EHCI_FSL) && defined(CONFIG_MPC831x)
317*4882a593Smuzhiyun uint32_t temp;
318*4882a593Smuzhiyun struct usb_ehci *ehci = (struct usb_ehci *)CONFIG_SYS_FSL_USB1_ADDR;
319*4882a593Smuzhiyun
320*4882a593Smuzhiyun /* Configure interface. */
321*4882a593Smuzhiyun setbits_be32(&ehci->control, REFSEL_16MHZ | UTMI_PHY_EN);
322*4882a593Smuzhiyun
323*4882a593Smuzhiyun /* Wait for clock to stabilize */
324*4882a593Smuzhiyun do {
325*4882a593Smuzhiyun temp = __raw_readl(&ehci->control);
326*4882a593Smuzhiyun udelay(1000);
327*4882a593Smuzhiyun } while (!(temp & PHY_CLK_VALID));
328*4882a593Smuzhiyun #endif
329*4882a593Smuzhiyun }
330*4882a593Smuzhiyun
cpu_init_r(void)331*4882a593Smuzhiyun int cpu_init_r (void)
332*4882a593Smuzhiyun {
333*4882a593Smuzhiyun #ifdef CONFIG_QE
334*4882a593Smuzhiyun uint qe_base = CONFIG_SYS_IMMR + 0x00100000; /* QE immr base */
335*4882a593Smuzhiyun
336*4882a593Smuzhiyun qe_init(qe_base);
337*4882a593Smuzhiyun qe_reset();
338*4882a593Smuzhiyun #endif
339*4882a593Smuzhiyun return 0;
340*4882a593Smuzhiyun }
341*4882a593Smuzhiyun
342*4882a593Smuzhiyun /*
343*4882a593Smuzhiyun * Print out the bus arbiter event
344*4882a593Smuzhiyun */
345*4882a593Smuzhiyun #if defined(CONFIG_DISPLAY_AER_FULL)
print_83xx_arb_event(int force)346*4882a593Smuzhiyun static int print_83xx_arb_event(int force)
347*4882a593Smuzhiyun {
348*4882a593Smuzhiyun static char* event[] = {
349*4882a593Smuzhiyun "Address Time Out",
350*4882a593Smuzhiyun "Data Time Out",
351*4882a593Smuzhiyun "Address Only Transfer Type",
352*4882a593Smuzhiyun "External Control Word Transfer Type",
353*4882a593Smuzhiyun "Reserved Transfer Type",
354*4882a593Smuzhiyun "Transfer Error",
355*4882a593Smuzhiyun "reserved",
356*4882a593Smuzhiyun "reserved"
357*4882a593Smuzhiyun };
358*4882a593Smuzhiyun static char* master[] = {
359*4882a593Smuzhiyun "e300 Core Data Transaction",
360*4882a593Smuzhiyun "reserved",
361*4882a593Smuzhiyun "e300 Core Instruction Fetch",
362*4882a593Smuzhiyun "reserved",
363*4882a593Smuzhiyun "TSEC1",
364*4882a593Smuzhiyun "TSEC2",
365*4882a593Smuzhiyun "USB MPH",
366*4882a593Smuzhiyun "USB DR",
367*4882a593Smuzhiyun "Encryption Core",
368*4882a593Smuzhiyun "I2C Boot Sequencer",
369*4882a593Smuzhiyun "JTAG",
370*4882a593Smuzhiyun "reserved",
371*4882a593Smuzhiyun "eSDHC",
372*4882a593Smuzhiyun "PCI1",
373*4882a593Smuzhiyun "PCI2",
374*4882a593Smuzhiyun "DMA",
375*4882a593Smuzhiyun "QUICC Engine 00",
376*4882a593Smuzhiyun "QUICC Engine 01",
377*4882a593Smuzhiyun "QUICC Engine 10",
378*4882a593Smuzhiyun "QUICC Engine 11",
379*4882a593Smuzhiyun "reserved",
380*4882a593Smuzhiyun "reserved",
381*4882a593Smuzhiyun "reserved",
382*4882a593Smuzhiyun "reserved",
383*4882a593Smuzhiyun "SATA1",
384*4882a593Smuzhiyun "SATA2",
385*4882a593Smuzhiyun "SATA3",
386*4882a593Smuzhiyun "SATA4",
387*4882a593Smuzhiyun "reserved",
388*4882a593Smuzhiyun "PCI Express 1",
389*4882a593Smuzhiyun "PCI Express 2",
390*4882a593Smuzhiyun "TDM-DMAC"
391*4882a593Smuzhiyun };
392*4882a593Smuzhiyun static char *transfer[] = {
393*4882a593Smuzhiyun "Address-only, Clean Block",
394*4882a593Smuzhiyun "Address-only, lwarx reservation set",
395*4882a593Smuzhiyun "Single-beat or Burst write",
396*4882a593Smuzhiyun "reserved",
397*4882a593Smuzhiyun "Address-only, Flush Block",
398*4882a593Smuzhiyun "reserved",
399*4882a593Smuzhiyun "Burst write",
400*4882a593Smuzhiyun "reserved",
401*4882a593Smuzhiyun "Address-only, sync",
402*4882a593Smuzhiyun "Address-only, tlbsync",
403*4882a593Smuzhiyun "Single-beat or Burst read",
404*4882a593Smuzhiyun "Single-beat or Burst read",
405*4882a593Smuzhiyun "Address-only, Kill Block",
406*4882a593Smuzhiyun "Address-only, icbi",
407*4882a593Smuzhiyun "Burst read",
408*4882a593Smuzhiyun "reserved",
409*4882a593Smuzhiyun "Address-only, eieio",
410*4882a593Smuzhiyun "reserved",
411*4882a593Smuzhiyun "Single-beat write",
412*4882a593Smuzhiyun "reserved",
413*4882a593Smuzhiyun "ecowx - Illegal single-beat write",
414*4882a593Smuzhiyun "reserved",
415*4882a593Smuzhiyun "reserved",
416*4882a593Smuzhiyun "reserved",
417*4882a593Smuzhiyun "Address-only, TLB Invalidate",
418*4882a593Smuzhiyun "reserved",
419*4882a593Smuzhiyun "Single-beat or Burst read",
420*4882a593Smuzhiyun "reserved",
421*4882a593Smuzhiyun "eciwx - Illegal single-beat read",
422*4882a593Smuzhiyun "reserved",
423*4882a593Smuzhiyun "Burst read",
424*4882a593Smuzhiyun "reserved"
425*4882a593Smuzhiyun };
426*4882a593Smuzhiyun
427*4882a593Smuzhiyun int etype = (gd->arch.arbiter_event_attributes & AEATR_EVENT)
428*4882a593Smuzhiyun >> AEATR_EVENT_SHIFT;
429*4882a593Smuzhiyun int mstr_id = (gd->arch.arbiter_event_attributes & AEATR_MSTR_ID)
430*4882a593Smuzhiyun >> AEATR_MSTR_ID_SHIFT;
431*4882a593Smuzhiyun int tbst = (gd->arch.arbiter_event_attributes & AEATR_TBST)
432*4882a593Smuzhiyun >> AEATR_TBST_SHIFT;
433*4882a593Smuzhiyun int tsize = (gd->arch.arbiter_event_attributes & AEATR_TSIZE)
434*4882a593Smuzhiyun >> AEATR_TSIZE_SHIFT;
435*4882a593Smuzhiyun int ttype = (gd->arch.arbiter_event_attributes & AEATR_TTYPE)
436*4882a593Smuzhiyun >> AEATR_TTYPE_SHIFT;
437*4882a593Smuzhiyun
438*4882a593Smuzhiyun if (!force && !gd->arch.arbiter_event_address)
439*4882a593Smuzhiyun return 0;
440*4882a593Smuzhiyun
441*4882a593Smuzhiyun puts("Arbiter Event Status:\n");
442*4882a593Smuzhiyun printf(" Event Address: 0x%08lX\n",
443*4882a593Smuzhiyun gd->arch.arbiter_event_address);
444*4882a593Smuzhiyun printf(" Event Type: 0x%1x = %s\n", etype, event[etype]);
445*4882a593Smuzhiyun printf(" Master ID: 0x%02x = %s\n", mstr_id, master[mstr_id]);
446*4882a593Smuzhiyun printf(" Transfer Size: 0x%1x = %d bytes\n", (tbst<<3) | tsize,
447*4882a593Smuzhiyun tbst ? (tsize ? tsize : 8) : 16 + 8 * tsize);
448*4882a593Smuzhiyun printf(" Transfer Type: 0x%02x = %s\n", ttype, transfer[ttype]);
449*4882a593Smuzhiyun
450*4882a593Smuzhiyun return gd->arch.arbiter_event_address;
451*4882a593Smuzhiyun }
452*4882a593Smuzhiyun
453*4882a593Smuzhiyun #elif defined(CONFIG_DISPLAY_AER_BRIEF)
454*4882a593Smuzhiyun
print_83xx_arb_event(int force)455*4882a593Smuzhiyun static int print_83xx_arb_event(int force)
456*4882a593Smuzhiyun {
457*4882a593Smuzhiyun if (!force && !gd->arch.arbiter_event_address)
458*4882a593Smuzhiyun return 0;
459*4882a593Smuzhiyun
460*4882a593Smuzhiyun printf("Arbiter Event Status: AEATR=0x%08lX, AEADR=0x%08lX\n",
461*4882a593Smuzhiyun gd->arch.arbiter_event_attributes,
462*4882a593Smuzhiyun gd->arch.arbiter_event_address);
463*4882a593Smuzhiyun
464*4882a593Smuzhiyun return gd->arch.arbiter_event_address;
465*4882a593Smuzhiyun }
466*4882a593Smuzhiyun #endif /* CONFIG_DISPLAY_AER_xxxx */
467*4882a593Smuzhiyun
468*4882a593Smuzhiyun /*
469*4882a593Smuzhiyun * Figure out the cause of the reset
470*4882a593Smuzhiyun */
prt_83xx_rsr(void)471*4882a593Smuzhiyun int prt_83xx_rsr(void)
472*4882a593Smuzhiyun {
473*4882a593Smuzhiyun static struct {
474*4882a593Smuzhiyun ulong mask;
475*4882a593Smuzhiyun char *desc;
476*4882a593Smuzhiyun } bits[] = {
477*4882a593Smuzhiyun {
478*4882a593Smuzhiyun RSR_SWSR, "Software Soft"}, {
479*4882a593Smuzhiyun RSR_SWHR, "Software Hard"}, {
480*4882a593Smuzhiyun RSR_JSRS, "JTAG Soft"}, {
481*4882a593Smuzhiyun RSR_CSHR, "Check Stop"}, {
482*4882a593Smuzhiyun RSR_SWRS, "Software Watchdog"}, {
483*4882a593Smuzhiyun RSR_BMRS, "Bus Monitor"}, {
484*4882a593Smuzhiyun RSR_SRS, "External/Internal Soft"}, {
485*4882a593Smuzhiyun RSR_HRS, "External/Internal Hard"}
486*4882a593Smuzhiyun };
487*4882a593Smuzhiyun static int n = ARRAY_SIZE(bits);
488*4882a593Smuzhiyun ulong rsr = gd->arch.reset_status;
489*4882a593Smuzhiyun int i;
490*4882a593Smuzhiyun char *sep;
491*4882a593Smuzhiyun
492*4882a593Smuzhiyun puts("Reset Status:");
493*4882a593Smuzhiyun
494*4882a593Smuzhiyun sep = " ";
495*4882a593Smuzhiyun for (i = 0; i < n; i++)
496*4882a593Smuzhiyun if (rsr & bits[i].mask) {
497*4882a593Smuzhiyun printf("%s%s", sep, bits[i].desc);
498*4882a593Smuzhiyun sep = ", ";
499*4882a593Smuzhiyun }
500*4882a593Smuzhiyun puts("\n");
501*4882a593Smuzhiyun
502*4882a593Smuzhiyun #if defined(CONFIG_DISPLAY_AER_FULL) || defined(CONFIG_DISPLAY_AER_BRIEF)
503*4882a593Smuzhiyun print_83xx_arb_event(rsr & RSR_BMRS);
504*4882a593Smuzhiyun #endif
505*4882a593Smuzhiyun puts("\n");
506*4882a593Smuzhiyun
507*4882a593Smuzhiyun return 0;
508*4882a593Smuzhiyun }
509