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