blob: 00572de121d51dbe90946f51c27e915358de2ed2 [file] [log] [blame]
Eran Liberty9095d4a2005-07-28 10:08:46 -05001/*
Vivek Mahajan288f7fb2009-05-25 17:23:16 +05302 * Copyright (C) 2004-2009 Freescale Semiconductor, Inc.
Eran Liberty9095d4a2005-07-28 10:08:46 -05003 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Eran Liberty9095d4a2005-07-28 10:08:46 -05005 */
6
7#include <common.h>
8#include <mpc83xx.h>
9#include <ioports.h>
Vivek Mahajan288f7fb2009-05-25 17:23:16 +053010#include <asm/io.h>
Kim Phillips328040a2009-09-25 18:19:44 -050011#ifdef CONFIG_USB_EHCI_FSL
Vivek Mahajan288f7fb2009-05-25 17:23:16 +053012#include <usb/ehci-fsl.h>
13#endif
Eran Liberty9095d4a2005-07-28 10:08:46 -050014
Wolfgang Denk6405a152006-03-31 18:32:53 +020015DECLARE_GLOBAL_DATA_PTR;
16
Dave Liue732e9c2006-11-03 12:11:15 -060017#ifdef CONFIG_QE
18extern qe_iop_conf_t qe_iop_conf_tab[];
19extern void qe_config_iopin(u8 port, u8 pin, int dir,
20 int open_drain, int assign);
21extern void qe_init(uint qe_base);
22extern void qe_reset(void);
23
24static void config_qe_ioports(void)
25{
26 u8 port, pin;
27 int dir, open_drain, assign;
28 int i;
29
30 for (i = 0; qe_iop_conf_tab[i].assign != QE_IOP_TAB_END; i++) {
31 port = qe_iop_conf_tab[i].port;
32 pin = qe_iop_conf_tab[i].pin;
33 dir = qe_iop_conf_tab[i].dir;
34 open_drain = qe_iop_conf_tab[i].open_drain;
35 assign = qe_iop_conf_tab[i].assign;
36 qe_config_iopin(port, pin, dir, open_drain, assign);
37 }
38}
39#endif
40
Eran Liberty9095d4a2005-07-28 10:08:46 -050041/*
42 * Breathe some life into the CPU...
43 *
44 * Set up the memory map,
45 * initialize a bunch of registers,
46 * initialize the UPM's
47 */
48void cpu_init_f (volatile immap_t * im)
49{
Kim Phillips328040a2009-09-25 18:19:44 -050050 __be32 acr_mask =
51#ifdef CONFIG_SYS_ACR_PIPE_DEP /* Arbiter pipeline depth */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050052 ACR_PIPE_DEP |
Timur Tabi054838e2006-10-31 18:44:42 -060053#endif
Kim Phillips328040a2009-09-25 18:19:44 -050054#ifdef CONFIG_SYS_ACR_RPTCNT /* Arbiter repeat count */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050055 ACR_RPTCNT |
Kim Phillips19a91de2008-01-16 12:06:16 -060056#endif
Heiko Schocher5318b082010-01-07 08:56:00 +010057#ifdef CONFIG_SYS_ACR_APARK /* Arbiter address parking mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050058 ACR_APARK |
Heiko Schocher5318b082010-01-07 08:56:00 +010059#endif
60#ifdef CONFIG_SYS_ACR_PARKM /* Arbiter parking master */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050061 ACR_PARKM |
Heiko Schocher5318b082010-01-07 08:56:00 +010062#endif
Kim Phillips328040a2009-09-25 18:19:44 -050063 0;
64 __be32 acr_val =
65#ifdef CONFIG_SYS_ACR_PIPE_DEP /* Arbiter pipeline depth */
66 (CONFIG_SYS_ACR_PIPE_DEP << ACR_PIPE_DEP_SHIFT) |
67#endif
68#ifdef CONFIG_SYS_ACR_RPTCNT /* Arbiter repeat count */
69 (CONFIG_SYS_ACR_RPTCNT << ACR_RPTCNT_SHIFT) |
70#endif
Heiko Schocher5318b082010-01-07 08:56:00 +010071#ifdef CONFIG_SYS_ACR_APARK /* Arbiter address parking mode */
72 (CONFIG_SYS_ACR_APARK << ACR_APARK_SHIFT) |
73#endif
74#ifdef CONFIG_SYS_ACR_PARKM /* Arbiter parking master */
75 (CONFIG_SYS_ACR_PARKM << ACR_PARKM_SHIFT) |
76#endif
Kim Phillips328040a2009-09-25 18:19:44 -050077 0;
78 __be32 spcr_mask =
79#ifdef CONFIG_SYS_SPCR_OPT /* Optimize transactions between CSB and other dev */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050080 SPCR_OPT |
Kim Phillips328040a2009-09-25 18:19:44 -050081#endif
82#ifdef CONFIG_SYS_SPCR_TSECEP /* all eTSEC's Emergency priority */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050083 SPCR_TSECEP |
Kim Phillips328040a2009-09-25 18:19:44 -050084#endif
85#ifdef CONFIG_SYS_SPCR_TSEC1EP /* TSEC1 Emergency priority */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050086 SPCR_TSEC1EP |
Kim Phillips328040a2009-09-25 18:19:44 -050087#endif
88#ifdef CONFIG_SYS_SPCR_TSEC2EP /* TSEC2 Emergency priority */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050089 SPCR_TSEC2EP |
Kim Phillips328040a2009-09-25 18:19:44 -050090#endif
91 0;
92 __be32 spcr_val =
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020093#ifdef CONFIG_SYS_SPCR_OPT
Kim Phillips328040a2009-09-25 18:19:44 -050094 (CONFIG_SYS_SPCR_OPT << SPCR_OPT_SHIFT) |
Michael Barkowski06e2e192008-03-20 13:15:34 -040095#endif
Kim Phillips328040a2009-09-25 18:19:44 -050096#ifdef CONFIG_SYS_SPCR_TSECEP /* all eTSEC's Emergency priority */
97 (CONFIG_SYS_SPCR_TSECEP << SPCR_TSECEP_SHIFT) |
Kim Phillips19a91de2008-01-16 12:06:16 -060098#endif
Kim Phillips328040a2009-09-25 18:19:44 -050099#ifdef CONFIG_SYS_SPCR_TSEC1EP /* TSEC1 Emergency priority */
100 (CONFIG_SYS_SPCR_TSEC1EP << SPCR_TSEC1EP_SHIFT) |
Timur Tabi054838e2006-10-31 18:44:42 -0600101#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500102#ifdef CONFIG_SYS_SPCR_TSEC2EP /* TSEC2 Emergency priority */
103 (CONFIG_SYS_SPCR_TSEC2EP << SPCR_TSEC2EP_SHIFT) |
Kim Phillips19a91de2008-01-16 12:06:16 -0600104#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500105 0;
106 __be32 sccr_mask =
107#ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -0500108 SCCR_ENCCM |
Kim Phillips19a91de2008-01-16 12:06:16 -0600109#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500110#ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -0500111 SCCR_PCICM |
Kim Phillips19a91de2008-01-16 12:06:16 -0600112#endif
Ilya Yanoka4f3ed32010-09-17 23:41:47 +0200113#ifdef CONFIG_SYS_SCCR_PCIEXP1CM /* PCIE1 clock mode */
114 SCCR_PCIEXP1CM |
115#endif
116#ifdef CONFIG_SYS_SCCR_PCIEXP2CM /* PCIE2 clock mode */
117 SCCR_PCIEXP2CM |
118#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500119#ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -0500120 SCCR_TSECCM |
Timur Tabi054838e2006-10-31 18:44:42 -0600121#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500122#ifdef CONFIG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -0500123 SCCR_TSEC1CM |
Timur Tabi054838e2006-10-31 18:44:42 -0600124#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500125#ifdef CONFIG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -0500126 SCCR_TSEC2CM |
Kumar Gala15c3f692007-02-27 23:51:42 -0600127#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500128#ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -0500129 SCCR_TSEC1ON |
Timur Tabi0b2deff2007-07-03 13:04:34 -0500130#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500131#ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -0500132 SCCR_TSEC2ON |
Timur Tabi0b2deff2007-07-03 13:04:34 -0500133#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500134#ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -0500135 SCCR_USBMPHCM |
Kumar Gala15c3f692007-02-27 23:51:42 -0600136#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500137#ifdef CONFIG_SYS_SCCR_USBDRCM /* USB DR clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -0500138 SCCR_USBDRCM |
Kumar Gala15c3f692007-02-27 23:51:42 -0600139#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500140#ifdef CONFIG_SYS_SCCR_SATACM /* SATA controller clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -0500141 SCCR_SATACM |
Timur Tabi054838e2006-10-31 18:44:42 -0600142#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500143 0;
144 __be32 sccr_val =
145#ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */
146 (CONFIG_SYS_SCCR_ENCCM << SCCR_ENCCM_SHIFT) |
147#endif
148#ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */
149 (CONFIG_SYS_SCCR_PCICM << SCCR_PCICM_SHIFT) |
150#endif
Ilya Yanoka4f3ed32010-09-17 23:41:47 +0200151#ifdef CONFIG_SYS_SCCR_PCIEXP1CM /* PCIE1 clock mode */
152 (CONFIG_SYS_SCCR_PCIEXP1CM << SCCR_PCIEXP1CM_SHIFT) |
153#endif
154#ifdef CONFIG_SYS_SCCR_PCIEXP2CM /* PCIE2 clock mode */
155 (CONFIG_SYS_SCCR_PCIEXP2CM << SCCR_PCIEXP2CM_SHIFT) |
156#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500157#ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */
158 (CONFIG_SYS_SCCR_TSECCM << SCCR_TSECCM_SHIFT) |
159#endif
160#ifdef CONFIG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */
161 (CONFIG_SYS_SCCR_TSEC1CM << SCCR_TSEC1CM_SHIFT) |
162#endif
163#ifdef CONFIG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */
164 (CONFIG_SYS_SCCR_TSEC2CM << SCCR_TSEC2CM_SHIFT) |
165#endif
166#ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */
167 (CONFIG_SYS_SCCR_TSEC1ON << SCCR_TSEC1ON_SHIFT) |
168#endif
169#ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */
170 (CONFIG_SYS_SCCR_TSEC2ON << SCCR_TSEC2ON_SHIFT) |
171#endif
172#ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */
173 (CONFIG_SYS_SCCR_USBMPHCM << SCCR_USBMPHCM_SHIFT) |
174#endif
175#ifdef CONFIG_SYS_SCCR_USBDRCM /* USB DR clock mode */
176 (CONFIG_SYS_SCCR_USBDRCM << SCCR_USBDRCM_SHIFT) |
177#endif
178#ifdef CONFIG_SYS_SCCR_SATACM /* SATA controller clock mode */
179 (CONFIG_SYS_SCCR_SATACM << SCCR_SATACM_SHIFT) |
180#endif
181 0;
Peter Korsgaard2a483ee2009-12-08 22:20:34 +0100182 __be32 lcrr_mask =
183#ifdef CONFIG_SYS_LCRR_DBYP /* PLL bypass */
184 LCRR_DBYP |
185#endif
186#ifdef CONFIG_SYS_LCRR_EADC /* external address delay */
187 LCRR_EADC |
188#endif
189#ifdef CONFIG_SYS_LCRR_CLKDIV /* system clock divider */
190 LCRR_CLKDIV |
191#endif
192 0;
193 __be32 lcrr_val =
194#ifdef CONFIG_SYS_LCRR_DBYP /* PLL bypass */
195 CONFIG_SYS_LCRR_DBYP |
196#endif
197#ifdef CONFIG_SYS_LCRR_EADC
198 CONFIG_SYS_LCRR_EADC |
199#endif
200#ifdef CONFIG_SYS_LCRR_CLKDIV /* system clock divider */
201 CONFIG_SYS_LCRR_CLKDIV |
202#endif
203 0;
Kim Phillips328040a2009-09-25 18:19:44 -0500204
205 /* Pointer is writable since we allocated a register for it */
206 gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
207
208 /* Clear initial global data */
209 memset ((void *) gd, 0, sizeof (gd_t));
210
211 /* system performance tweaking */
212 clrsetbits_be32(&im->arbiter.acr, acr_mask, acr_val);
213
214 clrsetbits_be32(&im->sysconf.spcr, spcr_mask, spcr_val);
215
216 clrsetbits_be32(&im->clk.sccr, sccr_mask, sccr_val);
Timur Tabi054838e2006-10-31 18:44:42 -0600217
Eran Liberty9095d4a2005-07-28 10:08:46 -0500218 /* RSR - Reset Status Register - clear all status (4.6.1.3) */
Simon Glass4d6eaa32012-12-13 20:48:56 +0000219 gd->arch.reset_status = __raw_readl(&im->reset.rsr);
Kim Phillips328040a2009-09-25 18:19:44 -0500220 __raw_writel(~(RSR_RES), &im->reset.rsr);
Eran Liberty9095d4a2005-07-28 10:08:46 -0500221
Nick Spence56fd3c22008-08-28 14:09:19 -0700222 /* AER - Arbiter Event Register - store status */
Simon Glass387a1f22012-12-13 20:48:57 +0000223 gd->arch.arbiter_event_attributes = __raw_readl(&im->arbiter.aeatr);
224 gd->arch.arbiter_event_address = __raw_readl(&im->arbiter.aeadr);
Nick Spence56fd3c22008-08-28 14:09:19 -0700225
Eran Liberty9095d4a2005-07-28 10:08:46 -0500226 /*
227 * RMR - Reset Mode Register
228 * contains checkstop reset enable (4.6.1.4)
229 */
Kim Phillips328040a2009-09-25 18:19:44 -0500230 __raw_writel(RMR_CSRE & (1<<RMR_CSRE_SHIFT), &im->reset.rmr);
Eran Liberty9095d4a2005-07-28 10:08:46 -0500231
Peter Korsgaard2a483ee2009-12-08 22:20:34 +0100232 /* LCRR - Clock Ratio Register (10.3.1.16)
233 * write, read, and isync per MPC8379ERM rev.1 CLKDEV field description
234 */
Becky Bruce0d4cee12010-06-17 11:37:20 -0500235 clrsetbits_be32(&im->im_lbc.lcrr, lcrr_mask, lcrr_val);
236 __raw_readl(&im->im_lbc.lcrr);
Peter Korsgaard2a483ee2009-12-08 22:20:34 +0100237 isync();
238
Kim Phillips328040a2009-09-25 18:19:44 -0500239 /* Enable Time Base & Decrementer ( so we will have udelay() )*/
240 setbits_be32(&im->sysconf.spcr, SPCR_TBEN);
Eran Liberty9095d4a2005-07-28 10:08:46 -0500241
242 /* System General Purpose Register */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200243#ifdef CONFIG_SYS_SICRH
Peter Tyser72f2d392009-05-22 17:23:25 -0500244#if defined(CONFIG_MPC834x) || defined(CONFIG_MPC8313)
Andre Schwarzcea66482008-06-23 11:40:56 +0200245 /* regarding to MPC34x manual rev.1 bits 28..29 must be preserved */
Kim Phillips328040a2009-09-25 18:19:44 -0500246 __raw_writel((im->sysconf.sicrh & 0x0000000C) | CONFIG_SYS_SICRH,
247 &im->sysconf.sicrh);
Andre Schwarzcea66482008-06-23 11:40:56 +0200248#else
Kim Phillips328040a2009-09-25 18:19:44 -0500249 __raw_writel(CONFIG_SYS_SICRH, &im->sysconf.sicrh);
Kumar Galae5221432006-01-11 11:12:57 -0600250#endif
Andre Schwarzcea66482008-06-23 11:40:56 +0200251#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200252#ifdef CONFIG_SYS_SICRL
Kim Phillips328040a2009-09-25 18:19:44 -0500253 __raw_writel(CONFIG_SYS_SICRL, &im->sysconf.sicrl);
Kumar Galae5221432006-01-11 11:12:57 -0600254#endif
Gerlando Falautofe201cb2012-10-10 22:13:08 +0000255#ifdef CONFIG_SYS_GPR1
256 __raw_writel(CONFIG_SYS_GPR1, &im->sysconf.gpr1);
257#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500258#ifdef CONFIG_SYS_DDRCDR /* DDR control driver register */
259 __raw_writel(CONFIG_SYS_DDRCDR, &im->sysconf.ddrcdr);
Dave Liue740c462006-12-07 21:13:15 +0800260#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500261#ifdef CONFIG_SYS_OBIR /* Output buffer impedance register */
262 __raw_writel(CONFIG_SYS_OBIR, &im->sysconf.obir);
Dave Liub19ecd32007-09-18 12:37:57 +0800263#endif
Dave Liue740c462006-12-07 21:13:15 +0800264
Dave Liue732e9c2006-11-03 12:11:15 -0600265#ifdef CONFIG_QE
266 /* Config QE ioports */
267 config_qe_ioports();
268#endif
Becky Bruce0d4cee12010-06-17 11:37:20 -0500269 /* Set up preliminary BR/OR regs */
270 init_early_memctl_regs();
Eran Liberty9095d4a2005-07-28 10:08:46 -0500271
Becky Bruce0d4cee12010-06-17 11:37:20 -0500272 /* Local Access window setup */
273#if defined(CONFIG_SYS_LBLAWBAR0_PRELIM) && defined(CONFIG_SYS_LBLAWAR0_PRELIM)
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200274 im->sysconf.lblaw[0].bar = CONFIG_SYS_LBLAWBAR0_PRELIM;
275 im->sysconf.lblaw[0].ar = CONFIG_SYS_LBLAWAR0_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500276#else
Becky Bruce0d4cee12010-06-17 11:37:20 -0500277#error CONFIG_SYS_LBLAWBAR0_PRELIM & CONFIG_SYS_LBLAWAR0_PRELIM must be defined
Eran Liberty9095d4a2005-07-28 10:08:46 -0500278#endif
279
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200280#if defined(CONFIG_SYS_LBLAWBAR1_PRELIM) && defined(CONFIG_SYS_LBLAWAR1_PRELIM)
281 im->sysconf.lblaw[1].bar = CONFIG_SYS_LBLAWBAR1_PRELIM;
282 im->sysconf.lblaw[1].ar = CONFIG_SYS_LBLAWAR1_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500283#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200284#if defined(CONFIG_SYS_LBLAWBAR2_PRELIM) && defined(CONFIG_SYS_LBLAWAR2_PRELIM)
285 im->sysconf.lblaw[2].bar = CONFIG_SYS_LBLAWBAR2_PRELIM;
286 im->sysconf.lblaw[2].ar = CONFIG_SYS_LBLAWAR2_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500287#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200288#if defined(CONFIG_SYS_LBLAWBAR3_PRELIM) && defined(CONFIG_SYS_LBLAWAR3_PRELIM)
289 im->sysconf.lblaw[3].bar = CONFIG_SYS_LBLAWBAR3_PRELIM;
290 im->sysconf.lblaw[3].ar = CONFIG_SYS_LBLAWAR3_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500291#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200292#if defined(CONFIG_SYS_LBLAWBAR4_PRELIM) && defined(CONFIG_SYS_LBLAWAR4_PRELIM)
293 im->sysconf.lblaw[4].bar = CONFIG_SYS_LBLAWBAR4_PRELIM;
294 im->sysconf.lblaw[4].ar = CONFIG_SYS_LBLAWAR4_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500295#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200296#if defined(CONFIG_SYS_LBLAWBAR5_PRELIM) && defined(CONFIG_SYS_LBLAWAR5_PRELIM)
297 im->sysconf.lblaw[5].bar = CONFIG_SYS_LBLAWBAR5_PRELIM;
298 im->sysconf.lblaw[5].ar = CONFIG_SYS_LBLAWAR5_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500299#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200300#if defined(CONFIG_SYS_LBLAWBAR6_PRELIM) && defined(CONFIG_SYS_LBLAWAR6_PRELIM)
301 im->sysconf.lblaw[6].bar = CONFIG_SYS_LBLAWBAR6_PRELIM;
302 im->sysconf.lblaw[6].ar = CONFIG_SYS_LBLAWAR6_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500303#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200304#if defined(CONFIG_SYS_LBLAWBAR7_PRELIM) && defined(CONFIG_SYS_LBLAWAR7_PRELIM)
305 im->sysconf.lblaw[7].bar = CONFIG_SYS_LBLAWBAR7_PRELIM;
306 im->sysconf.lblaw[7].ar = CONFIG_SYS_LBLAWAR7_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500307#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200308#ifdef CONFIG_SYS_GPIO1_PRELIM
309 im->gpio[0].dat = CONFIG_SYS_GPIO1_DAT;
310 im->gpio[0].dir = CONFIG_SYS_GPIO1_DIR;
Kumar Galaab7ec4f2006-01-11 11:21:14 -0600311#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200312#ifdef CONFIG_SYS_GPIO2_PRELIM
313 im->gpio[1].dat = CONFIG_SYS_GPIO2_DAT;
314 im->gpio[1].dir = CONFIG_SYS_GPIO2_DIR;
Kumar Galaab7ec4f2006-01-11 11:21:14 -0600315#endif
Kim Phillips17ab5a92011-04-01 16:53:18 -0500316#if defined(CONFIG_USB_EHCI_FSL) && defined(CONFIG_MPC831x)
Vivek Mahajan288f7fb2009-05-25 17:23:16 +0530317 uint32_t temp;
ramneek mehresh16b08062013-09-12 16:35:49 +0530318 struct usb_ehci *ehci = (struct usb_ehci *)CONFIG_SYS_FSL_USB1_ADDR;
Vivek Mahajan288f7fb2009-05-25 17:23:16 +0530319
320 /* Configure interface. */
Vivek Mahajan2d421c12009-06-24 10:08:40 +0530321 setbits_be32(&ehci->control, REFSEL_16MHZ | UTMI_PHY_EN);
Vivek Mahajan288f7fb2009-05-25 17:23:16 +0530322
323 /* Wait for clock to stabilize */
324 do {
Kim Phillips328040a2009-09-25 18:19:44 -0500325 temp = __raw_readl(&ehci->control);
Vivek Mahajan288f7fb2009-05-25 17:23:16 +0530326 udelay(1000);
327 } while (!(temp & PHY_CLK_VALID));
328#endif
Eran Liberty9095d4a2005-07-28 10:08:46 -0500329}
330
Eran Liberty9095d4a2005-07-28 10:08:46 -0500331int cpu_init_r (void)
332{
Dave Liue732e9c2006-11-03 12:11:15 -0600333#ifdef CONFIG_QE
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200334 uint qe_base = CONFIG_SYS_IMMR + 0x00100000; /* QE immr base */
Kim Phillips328040a2009-09-25 18:19:44 -0500335
Dave Liue732e9c2006-11-03 12:11:15 -0600336 qe_init(qe_base);
337 qe_reset();
338#endif
Eran Liberty9095d4a2005-07-28 10:08:46 -0500339 return 0;
340}
Dave Liuebd35f82007-06-25 10:41:56 +0800341
Nick Spence56fd3c22008-08-28 14:09:19 -0700342/*
343 * Print out the bus arbiter event
344 */
345#if defined(CONFIG_DISPLAY_AER_FULL)
346static int print_83xx_arb_event(int force)
347{
348 static char* event[] = {
349 "Address Time Out",
350 "Data Time Out",
351 "Address Only Transfer Type",
352 "External Control Word Transfer Type",
353 "Reserved Transfer Type",
354 "Transfer Error",
355 "reserved",
356 "reserved"
357 };
358 static char* master[] = {
359 "e300 Core Data Transaction",
360 "reserved",
361 "e300 Core Instruction Fetch",
362 "reserved",
363 "TSEC1",
364 "TSEC2",
365 "USB MPH",
366 "USB DR",
367 "Encryption Core",
368 "I2C Boot Sequencer",
369 "JTAG",
370 "reserved",
371 "eSDHC",
372 "PCI1",
373 "PCI2",
374 "DMA",
375 "QUICC Engine 00",
376 "QUICC Engine 01",
377 "QUICC Engine 10",
378 "QUICC Engine 11",
379 "reserved",
380 "reserved",
381 "reserved",
382 "reserved",
383 "SATA1",
384 "SATA2",
385 "SATA3",
386 "SATA4",
387 "reserved",
388 "PCI Express 1",
389 "PCI Express 2",
390 "TDM-DMAC"
391 };
392 static char *transfer[] = {
393 "Address-only, Clean Block",
394 "Address-only, lwarx reservation set",
395 "Single-beat or Burst write",
396 "reserved",
397 "Address-only, Flush Block",
398 "reserved",
399 "Burst write",
400 "reserved",
401 "Address-only, sync",
402 "Address-only, tlbsync",
403 "Single-beat or Burst read",
404 "Single-beat or Burst read",
405 "Address-only, Kill Block",
406 "Address-only, icbi",
407 "Burst read",
408 "reserved",
409 "Address-only, eieio",
410 "reserved",
411 "Single-beat write",
412 "reserved",
413 "ecowx - Illegal single-beat write",
414 "reserved",
415 "reserved",
416 "reserved",
417 "Address-only, TLB Invalidate",
418 "reserved",
419 "Single-beat or Burst read",
420 "reserved",
421 "eciwx - Illegal single-beat read",
422 "reserved",
423 "Burst read",
424 "reserved"
425 };
426
Simon Glass387a1f22012-12-13 20:48:57 +0000427 int etype = (gd->arch.arbiter_event_attributes & AEATR_EVENT)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200428 >> AEATR_EVENT_SHIFT;
Simon Glass387a1f22012-12-13 20:48:57 +0000429 int mstr_id = (gd->arch.arbiter_event_attributes & AEATR_MSTR_ID)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200430 >> AEATR_MSTR_ID_SHIFT;
Simon Glass387a1f22012-12-13 20:48:57 +0000431 int tbst = (gd->arch.arbiter_event_attributes & AEATR_TBST)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200432 >> AEATR_TBST_SHIFT;
Simon Glass387a1f22012-12-13 20:48:57 +0000433 int tsize = (gd->arch.arbiter_event_attributes & AEATR_TSIZE)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200434 >> AEATR_TSIZE_SHIFT;
Simon Glass387a1f22012-12-13 20:48:57 +0000435 int ttype = (gd->arch.arbiter_event_attributes & AEATR_TTYPE)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200436 >> AEATR_TTYPE_SHIFT;
Nick Spence56fd3c22008-08-28 14:09:19 -0700437
Simon Glass387a1f22012-12-13 20:48:57 +0000438 if (!force && !gd->arch.arbiter_event_address)
Nick Spence56fd3c22008-08-28 14:09:19 -0700439 return 0;
440
441 puts("Arbiter Event Status:\n");
Simon Glass387a1f22012-12-13 20:48:57 +0000442 printf(" Event Address: 0x%08lX\n",
443 gd->arch.arbiter_event_address);
Nick Spence56fd3c22008-08-28 14:09:19 -0700444 printf(" Event Type: 0x%1x = %s\n", etype, event[etype]);
445 printf(" Master ID: 0x%02x = %s\n", mstr_id, master[mstr_id]);
446 printf(" Transfer Size: 0x%1x = %d bytes\n", (tbst<<3) | tsize,
447 tbst ? (tsize ? tsize : 8) : 16 + 8 * tsize);
448 printf(" Transfer Type: 0x%02x = %s\n", ttype, transfer[ttype]);
449
Simon Glass387a1f22012-12-13 20:48:57 +0000450 return gd->arch.arbiter_event_address;
Nick Spence56fd3c22008-08-28 14:09:19 -0700451}
452
453#elif defined(CONFIG_DISPLAY_AER_BRIEF)
454
455static int print_83xx_arb_event(int force)
456{
Simon Glass387a1f22012-12-13 20:48:57 +0000457 if (!force && !gd->arch.arbiter_event_address)
Nick Spence56fd3c22008-08-28 14:09:19 -0700458 return 0;
459
460 printf("Arbiter Event Status: AEATR=0x%08lX, AEADR=0x%08lX\n",
Simon Glass387a1f22012-12-13 20:48:57 +0000461 gd->arch.arbiter_event_attributes,
462 gd->arch.arbiter_event_address);
Nick Spence56fd3c22008-08-28 14:09:19 -0700463
Simon Glass387a1f22012-12-13 20:48:57 +0000464 return gd->arch.arbiter_event_address;
Nick Spence56fd3c22008-08-28 14:09:19 -0700465}
466#endif /* CONFIG_DISPLAY_AER_xxxx */
467
Dave Liuebd35f82007-06-25 10:41:56 +0800468/*
469 * Figure out the cause of the reset
470 */
471int prt_83xx_rsr(void)
472{
473 static struct {
474 ulong mask;
475 char *desc;
476 } bits[] = {
477 {
478 RSR_SWSR, "Software Soft"}, {
479 RSR_SWHR, "Software Hard"}, {
480 RSR_JSRS, "JTAG Soft"}, {
481 RSR_CSHR, "Check Stop"}, {
482 RSR_SWRS, "Software Watchdog"}, {
483 RSR_BMRS, "Bus Monitor"}, {
484 RSR_SRS, "External/Internal Soft"}, {
485 RSR_HRS, "External/Internal Hard"}
486 };
487 static int n = sizeof bits / sizeof bits[0];
Simon Glass4d6eaa32012-12-13 20:48:56 +0000488 ulong rsr = gd->arch.reset_status;
Dave Liuebd35f82007-06-25 10:41:56 +0800489 int i;
490 char *sep;
491
492 puts("Reset Status:");
493
494 sep = " ";
495 for (i = 0; i < n; i++)
496 if (rsr & bits[i].mask) {
497 printf("%s%s", sep, bits[i].desc);
498 sep = ", ";
499 }
Nick Spence56fd3c22008-08-28 14:09:19 -0700500 puts("\n");
501
502#if defined(CONFIG_DISPLAY_AER_FULL) || defined(CONFIG_DISPLAY_AER_BRIEF)
503 print_83xx_arb_event(rsr & RSR_BMRS);
504#endif
505 puts("\n");
506
Dave Liuebd35f82007-06-25 10:41:56 +0800507 return 0;
508}