blob: 59faa78d24cb1fec878dcd19328afa810626deef [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Eran Liberty9095d4a2005-07-28 10:08:46 -05002/*
Vivek Mahajan288f7fb2009-05-25 17:23:16 +05303 * Copyright (C) 2004-2009 Freescale Semiconductor, Inc.
Eran Liberty9095d4a2005-07-28 10:08:46 -05004 */
5
6#include <common.h>
7#include <mpc83xx.h>
8#include <ioports.h>
Vivek Mahajan288f7fb2009-05-25 17:23:16 +05309#include <asm/io.h>
Simon Glass156283f2017-03-28 10:27:27 -060010#include <asm/processor.h>
Kim Phillips328040a2009-09-25 18:19:44 -050011#ifdef CONFIG_USB_EHCI_FSL
Mateusz Kulikowski3add69e2016-03-31 23:12:23 +020012#include <usb/ehci-ci.h>
Vivek Mahajan288f7fb2009-05-25 17:23:16 +053013#endif
Eran Liberty9095d4a2005-07-28 10:08:46 -050014
Mario Sixb47839c2019-01-21 09:17:58 +010015#include "lblaw/lblaw.h"
Mario Six1faf95d2019-01-21 09:18:03 +010016#include "elbc/elbc.h"
Mario Six636c1082019-01-21 09:18:11 +010017#include "sysio/sysio.h"
Mario Sixaa502542019-01-21 09:18:12 +010018#include "arbiter/arbiter.h"
Mario Sixf62074e2019-01-21 09:18:13 +010019#include "initreg/initreg.h"
Mario Sixb47839c2019-01-21 09:17:58 +010020
Wolfgang Denk6405a152006-03-31 18:32:53 +020021DECLARE_GLOBAL_DATA_PTR;
22
Dave Liue732e9c2006-11-03 12:11:15 -060023#ifdef CONFIG_QE
24extern qe_iop_conf_t qe_iop_conf_tab[];
25extern void qe_config_iopin(u8 port, u8 pin, int dir,
26 int open_drain, int assign);
27extern void qe_init(uint qe_base);
28extern void qe_reset(void);
29
30static void config_qe_ioports(void)
31{
32 u8 port, pin;
33 int dir, open_drain, assign;
34 int i;
35
36 for (i = 0; qe_iop_conf_tab[i].assign != QE_IOP_TAB_END; i++) {
37 port = qe_iop_conf_tab[i].port;
38 pin = qe_iop_conf_tab[i].pin;
39 dir = qe_iop_conf_tab[i].dir;
40 open_drain = qe_iop_conf_tab[i].open_drain;
41 assign = qe_iop_conf_tab[i].assign;
42 qe_config_iopin(port, pin, dir, open_drain, assign);
43 }
44}
45#endif
46
Eran Liberty9095d4a2005-07-28 10:08:46 -050047/*
48 * Breathe some life into the CPU...
49 *
50 * Set up the memory map,
51 * initialize a bunch of registers,
52 * initialize the UPM's
53 */
54void cpu_init_f (volatile immap_t * im)
55{
Kim Phillips328040a2009-09-25 18:19:44 -050056 __be32 sccr_mask =
57#ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050058 SCCR_ENCCM |
Kim Phillips19a91de2008-01-16 12:06:16 -060059#endif
Kim Phillips328040a2009-09-25 18:19:44 -050060#ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050061 SCCR_PCICM |
Kim Phillips19a91de2008-01-16 12:06:16 -060062#endif
Ilya Yanoka4f3ed32010-09-17 23:41:47 +020063#ifdef CONFIG_SYS_SCCR_PCIEXP1CM /* PCIE1 clock mode */
64 SCCR_PCIEXP1CM |
65#endif
66#ifdef CONFIG_SYS_SCCR_PCIEXP2CM /* PCIE2 clock mode */
67 SCCR_PCIEXP2CM |
68#endif
Kim Phillips328040a2009-09-25 18:19:44 -050069#ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050070 SCCR_TSECCM |
Timur Tabi054838e2006-10-31 18:44:42 -060071#endif
Kim Phillips328040a2009-09-25 18:19:44 -050072#ifdef CONFIG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050073 SCCR_TSEC1CM |
Timur Tabi054838e2006-10-31 18:44:42 -060074#endif
Kim Phillips328040a2009-09-25 18:19:44 -050075#ifdef CONFIG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050076 SCCR_TSEC2CM |
Kumar Gala15c3f692007-02-27 23:51:42 -060077#endif
Kim Phillips328040a2009-09-25 18:19:44 -050078#ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050079 SCCR_TSEC1ON |
Timur Tabi0b2deff2007-07-03 13:04:34 -050080#endif
Kim Phillips328040a2009-09-25 18:19:44 -050081#ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050082 SCCR_TSEC2ON |
Timur Tabi0b2deff2007-07-03 13:04:34 -050083#endif
Kim Phillips328040a2009-09-25 18:19:44 -050084#ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050085 SCCR_USBMPHCM |
Kumar Gala15c3f692007-02-27 23:51:42 -060086#endif
Kim Phillips328040a2009-09-25 18:19:44 -050087#ifdef CONFIG_SYS_SCCR_USBDRCM /* USB DR clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050088 SCCR_USBDRCM |
Kumar Gala15c3f692007-02-27 23:51:42 -060089#endif
Kim Phillips328040a2009-09-25 18:19:44 -050090#ifdef CONFIG_SYS_SCCR_SATACM /* SATA controller clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050091 SCCR_SATACM |
Timur Tabi054838e2006-10-31 18:44:42 -060092#endif
Kim Phillips328040a2009-09-25 18:19:44 -050093 0;
94 __be32 sccr_val =
95#ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */
96 (CONFIG_SYS_SCCR_ENCCM << SCCR_ENCCM_SHIFT) |
97#endif
98#ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */
99 (CONFIG_SYS_SCCR_PCICM << SCCR_PCICM_SHIFT) |
100#endif
Ilya Yanoka4f3ed32010-09-17 23:41:47 +0200101#ifdef CONFIG_SYS_SCCR_PCIEXP1CM /* PCIE1 clock mode */
102 (CONFIG_SYS_SCCR_PCIEXP1CM << SCCR_PCIEXP1CM_SHIFT) |
103#endif
104#ifdef CONFIG_SYS_SCCR_PCIEXP2CM /* PCIE2 clock mode */
105 (CONFIG_SYS_SCCR_PCIEXP2CM << SCCR_PCIEXP2CM_SHIFT) |
106#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500107#ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */
108 (CONFIG_SYS_SCCR_TSECCM << SCCR_TSECCM_SHIFT) |
109#endif
110#ifdef CONFIG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */
111 (CONFIG_SYS_SCCR_TSEC1CM << SCCR_TSEC1CM_SHIFT) |
112#endif
113#ifdef CONFIG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */
114 (CONFIG_SYS_SCCR_TSEC2CM << SCCR_TSEC2CM_SHIFT) |
115#endif
116#ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */
117 (CONFIG_SYS_SCCR_TSEC1ON << SCCR_TSEC1ON_SHIFT) |
118#endif
119#ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */
120 (CONFIG_SYS_SCCR_TSEC2ON << SCCR_TSEC2ON_SHIFT) |
121#endif
122#ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */
123 (CONFIG_SYS_SCCR_USBMPHCM << SCCR_USBMPHCM_SHIFT) |
124#endif
125#ifdef CONFIG_SYS_SCCR_USBDRCM /* USB DR clock mode */
126 (CONFIG_SYS_SCCR_USBDRCM << SCCR_USBDRCM_SHIFT) |
127#endif
128#ifdef CONFIG_SYS_SCCR_SATACM /* SATA controller clock mode */
129 (CONFIG_SYS_SCCR_SATACM << SCCR_SATACM_SHIFT) |
130#endif
131 0;
Peter Korsgaard2a483ee2009-12-08 22:20:34 +0100132 __be32 lcrr_mask =
133#ifdef CONFIG_SYS_LCRR_DBYP /* PLL bypass */
134 LCRR_DBYP |
135#endif
136#ifdef CONFIG_SYS_LCRR_EADC /* external address delay */
137 LCRR_EADC |
138#endif
139#ifdef CONFIG_SYS_LCRR_CLKDIV /* system clock divider */
140 LCRR_CLKDIV |
141#endif
142 0;
143 __be32 lcrr_val =
144#ifdef CONFIG_SYS_LCRR_DBYP /* PLL bypass */
145 CONFIG_SYS_LCRR_DBYP |
146#endif
147#ifdef CONFIG_SYS_LCRR_EADC
148 CONFIG_SYS_LCRR_EADC |
149#endif
150#ifdef CONFIG_SYS_LCRR_CLKDIV /* system clock divider */
151 CONFIG_SYS_LCRR_CLKDIV |
152#endif
153 0;
Kim Phillips328040a2009-09-25 18:19:44 -0500154
155 /* Pointer is writable since we allocated a register for it */
156 gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
157
mario.six@gdsys.cc85df7b42017-01-17 08:33:48 +0100158 /* global data region was cleared in start.S */
Kim Phillips328040a2009-09-25 18:19:44 -0500159
160 /* system performance tweaking */
161 clrsetbits_be32(&im->arbiter.acr, acr_mask, acr_val);
162
163 clrsetbits_be32(&im->sysconf.spcr, spcr_mask, spcr_val);
164
165 clrsetbits_be32(&im->clk.sccr, sccr_mask, sccr_val);
Timur Tabi054838e2006-10-31 18:44:42 -0600166
Eran Liberty9095d4a2005-07-28 10:08:46 -0500167 /* RSR - Reset Status Register - clear all status (4.6.1.3) */
Simon Glass4d6eaa32012-12-13 20:48:56 +0000168 gd->arch.reset_status = __raw_readl(&im->reset.rsr);
Kim Phillips328040a2009-09-25 18:19:44 -0500169 __raw_writel(~(RSR_RES), &im->reset.rsr);
Eran Liberty9095d4a2005-07-28 10:08:46 -0500170
Nick Spence56fd3c22008-08-28 14:09:19 -0700171 /* AER - Arbiter Event Register - store status */
Simon Glass387a1f22012-12-13 20:48:57 +0000172 gd->arch.arbiter_event_attributes = __raw_readl(&im->arbiter.aeatr);
173 gd->arch.arbiter_event_address = __raw_readl(&im->arbiter.aeadr);
Nick Spence56fd3c22008-08-28 14:09:19 -0700174
Eran Liberty9095d4a2005-07-28 10:08:46 -0500175 /*
176 * RMR - Reset Mode Register
177 * contains checkstop reset enable (4.6.1.4)
178 */
Kim Phillips328040a2009-09-25 18:19:44 -0500179 __raw_writel(RMR_CSRE & (1<<RMR_CSRE_SHIFT), &im->reset.rmr);
Eran Liberty9095d4a2005-07-28 10:08:46 -0500180
Peter Korsgaard2a483ee2009-12-08 22:20:34 +0100181 /* LCRR - Clock Ratio Register (10.3.1.16)
182 * write, read, and isync per MPC8379ERM rev.1 CLKDEV field description
183 */
Becky Bruce0d4cee12010-06-17 11:37:20 -0500184 clrsetbits_be32(&im->im_lbc.lcrr, lcrr_mask, lcrr_val);
185 __raw_readl(&im->im_lbc.lcrr);
Peter Korsgaard2a483ee2009-12-08 22:20:34 +0100186 isync();
187
Kim Phillips328040a2009-09-25 18:19:44 -0500188 /* Enable Time Base & Decrementer ( so we will have udelay() )*/
189 setbits_be32(&im->sysconf.spcr, SPCR_TBEN);
Eran Liberty9095d4a2005-07-28 10:08:46 -0500190
191 /* System General Purpose Register */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200192#ifdef CONFIG_SYS_SICRH
Mario Six0344f5e2019-01-21 09:17:27 +0100193#if defined(CONFIG_ARCH_MPC834X) || defined(CONFIG_ARCH_MPC8313)
Andre Schwarzcea66482008-06-23 11:40:56 +0200194 /* regarding to MPC34x manual rev.1 bits 28..29 must be preserved */
Kim Phillips328040a2009-09-25 18:19:44 -0500195 __raw_writel((im->sysconf.sicrh & 0x0000000C) | CONFIG_SYS_SICRH,
196 &im->sysconf.sicrh);
Andre Schwarzcea66482008-06-23 11:40:56 +0200197#else
Kim Phillips328040a2009-09-25 18:19:44 -0500198 __raw_writel(CONFIG_SYS_SICRH, &im->sysconf.sicrh);
Kumar Galae5221432006-01-11 11:12:57 -0600199#endif
Andre Schwarzcea66482008-06-23 11:40:56 +0200200#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200201#ifdef CONFIG_SYS_SICRL
Kim Phillips328040a2009-09-25 18:19:44 -0500202 __raw_writel(CONFIG_SYS_SICRL, &im->sysconf.sicrl);
Kumar Galae5221432006-01-11 11:12:57 -0600203#endif
Gerlando Falautofe201cb2012-10-10 22:13:08 +0000204#ifdef CONFIG_SYS_GPR1
205 __raw_writel(CONFIG_SYS_GPR1, &im->sysconf.gpr1);
206#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500207#ifdef CONFIG_SYS_DDRCDR /* DDR control driver register */
208 __raw_writel(CONFIG_SYS_DDRCDR, &im->sysconf.ddrcdr);
Dave Liue740c462006-12-07 21:13:15 +0800209#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500210#ifdef CONFIG_SYS_OBIR /* Output buffer impedance register */
211 __raw_writel(CONFIG_SYS_OBIR, &im->sysconf.obir);
Dave Liub19ecd32007-09-18 12:37:57 +0800212#endif
Dave Liue740c462006-12-07 21:13:15 +0800213
Dave Liue732e9c2006-11-03 12:11:15 -0600214#ifdef CONFIG_QE
215 /* Config QE ioports */
216 config_qe_ioports();
217#endif
Becky Bruce0d4cee12010-06-17 11:37:20 -0500218 /* Set up preliminary BR/OR regs */
219 init_early_memctl_regs();
Eran Liberty9095d4a2005-07-28 10:08:46 -0500220
Becky Bruce0d4cee12010-06-17 11:37:20 -0500221 /* Local Access window setup */
222#if defined(CONFIG_SYS_LBLAWBAR0_PRELIM) && defined(CONFIG_SYS_LBLAWAR0_PRELIM)
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200223 im->sysconf.lblaw[0].bar = CONFIG_SYS_LBLAWBAR0_PRELIM;
224 im->sysconf.lblaw[0].ar = CONFIG_SYS_LBLAWAR0_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500225#else
Becky Bruce0d4cee12010-06-17 11:37:20 -0500226#error CONFIG_SYS_LBLAWBAR0_PRELIM & CONFIG_SYS_LBLAWAR0_PRELIM must be defined
Eran Liberty9095d4a2005-07-28 10:08:46 -0500227#endif
228
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200229#if defined(CONFIG_SYS_LBLAWBAR1_PRELIM) && defined(CONFIG_SYS_LBLAWAR1_PRELIM)
230 im->sysconf.lblaw[1].bar = CONFIG_SYS_LBLAWBAR1_PRELIM;
231 im->sysconf.lblaw[1].ar = CONFIG_SYS_LBLAWAR1_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500232#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200233#if defined(CONFIG_SYS_LBLAWBAR2_PRELIM) && defined(CONFIG_SYS_LBLAWAR2_PRELIM)
234 im->sysconf.lblaw[2].bar = CONFIG_SYS_LBLAWBAR2_PRELIM;
235 im->sysconf.lblaw[2].ar = CONFIG_SYS_LBLAWAR2_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500236#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200237#if defined(CONFIG_SYS_LBLAWBAR3_PRELIM) && defined(CONFIG_SYS_LBLAWAR3_PRELIM)
238 im->sysconf.lblaw[3].bar = CONFIG_SYS_LBLAWBAR3_PRELIM;
239 im->sysconf.lblaw[3].ar = CONFIG_SYS_LBLAWAR3_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500240#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200241#if defined(CONFIG_SYS_LBLAWBAR4_PRELIM) && defined(CONFIG_SYS_LBLAWAR4_PRELIM)
242 im->sysconf.lblaw[4].bar = CONFIG_SYS_LBLAWBAR4_PRELIM;
243 im->sysconf.lblaw[4].ar = CONFIG_SYS_LBLAWAR4_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500244#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200245#if defined(CONFIG_SYS_LBLAWBAR5_PRELIM) && defined(CONFIG_SYS_LBLAWAR5_PRELIM)
246 im->sysconf.lblaw[5].bar = CONFIG_SYS_LBLAWBAR5_PRELIM;
247 im->sysconf.lblaw[5].ar = CONFIG_SYS_LBLAWAR5_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500248#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200249#if defined(CONFIG_SYS_LBLAWBAR6_PRELIM) && defined(CONFIG_SYS_LBLAWAR6_PRELIM)
250 im->sysconf.lblaw[6].bar = CONFIG_SYS_LBLAWBAR6_PRELIM;
251 im->sysconf.lblaw[6].ar = CONFIG_SYS_LBLAWAR6_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500252#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200253#if defined(CONFIG_SYS_LBLAWBAR7_PRELIM) && defined(CONFIG_SYS_LBLAWAR7_PRELIM)
254 im->sysconf.lblaw[7].bar = CONFIG_SYS_LBLAWBAR7_PRELIM;
255 im->sysconf.lblaw[7].ar = CONFIG_SYS_LBLAWAR7_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500256#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200257#ifdef CONFIG_SYS_GPIO1_PRELIM
258 im->gpio[0].dat = CONFIG_SYS_GPIO1_DAT;
259 im->gpio[0].dir = CONFIG_SYS_GPIO1_DIR;
Kumar Galaab7ec4f2006-01-11 11:21:14 -0600260#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200261#ifdef CONFIG_SYS_GPIO2_PRELIM
262 im->gpio[1].dat = CONFIG_SYS_GPIO2_DAT;
263 im->gpio[1].dir = CONFIG_SYS_GPIO2_DIR;
Kumar Galaab7ec4f2006-01-11 11:21:14 -0600264#endif
Mario Six9164bdd2019-01-21 09:17:25 +0100265#if defined(CONFIG_USB_EHCI_FSL) && defined(CONFIG_ARCH_MPC831X)
Vivek Mahajan288f7fb2009-05-25 17:23:16 +0530266 uint32_t temp;
ramneek mehresh16b08062013-09-12 16:35:49 +0530267 struct usb_ehci *ehci = (struct usb_ehci *)CONFIG_SYS_FSL_USB1_ADDR;
Vivek Mahajan288f7fb2009-05-25 17:23:16 +0530268
269 /* Configure interface. */
Vivek Mahajan2d421c12009-06-24 10:08:40 +0530270 setbits_be32(&ehci->control, REFSEL_16MHZ | UTMI_PHY_EN);
Vivek Mahajan288f7fb2009-05-25 17:23:16 +0530271
272 /* Wait for clock to stabilize */
273 do {
Kim Phillips328040a2009-09-25 18:19:44 -0500274 temp = __raw_readl(&ehci->control);
Vivek Mahajan288f7fb2009-05-25 17:23:16 +0530275 udelay(1000);
276 } while (!(temp & PHY_CLK_VALID));
277#endif
Eran Liberty9095d4a2005-07-28 10:08:46 -0500278}
279
Eran Liberty9095d4a2005-07-28 10:08:46 -0500280int cpu_init_r (void)
281{
Dave Liue732e9c2006-11-03 12:11:15 -0600282#ifdef CONFIG_QE
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200283 uint qe_base = CONFIG_SYS_IMMR + 0x00100000; /* QE immr base */
Kim Phillips328040a2009-09-25 18:19:44 -0500284
Dave Liue732e9c2006-11-03 12:11:15 -0600285 qe_init(qe_base);
286 qe_reset();
287#endif
Eran Liberty9095d4a2005-07-28 10:08:46 -0500288 return 0;
289}
Dave Liuebd35f82007-06-25 10:41:56 +0800290
Nick Spence56fd3c22008-08-28 14:09:19 -0700291/*
292 * Print out the bus arbiter event
293 */
294#if defined(CONFIG_DISPLAY_AER_FULL)
295static int print_83xx_arb_event(int force)
296{
297 static char* event[] = {
298 "Address Time Out",
299 "Data Time Out",
300 "Address Only Transfer Type",
301 "External Control Word Transfer Type",
302 "Reserved Transfer Type",
303 "Transfer Error",
304 "reserved",
305 "reserved"
306 };
307 static char* master[] = {
308 "e300 Core Data Transaction",
309 "reserved",
310 "e300 Core Instruction Fetch",
311 "reserved",
312 "TSEC1",
313 "TSEC2",
314 "USB MPH",
315 "USB DR",
316 "Encryption Core",
317 "I2C Boot Sequencer",
318 "JTAG",
319 "reserved",
320 "eSDHC",
321 "PCI1",
322 "PCI2",
323 "DMA",
324 "QUICC Engine 00",
325 "QUICC Engine 01",
326 "QUICC Engine 10",
327 "QUICC Engine 11",
328 "reserved",
329 "reserved",
330 "reserved",
331 "reserved",
332 "SATA1",
333 "SATA2",
334 "SATA3",
335 "SATA4",
336 "reserved",
337 "PCI Express 1",
338 "PCI Express 2",
339 "TDM-DMAC"
340 };
341 static char *transfer[] = {
342 "Address-only, Clean Block",
343 "Address-only, lwarx reservation set",
344 "Single-beat or Burst write",
345 "reserved",
346 "Address-only, Flush Block",
347 "reserved",
348 "Burst write",
349 "reserved",
350 "Address-only, sync",
351 "Address-only, tlbsync",
352 "Single-beat or Burst read",
353 "Single-beat or Burst read",
354 "Address-only, Kill Block",
355 "Address-only, icbi",
356 "Burst read",
357 "reserved",
358 "Address-only, eieio",
359 "reserved",
360 "Single-beat write",
361 "reserved",
362 "ecowx - Illegal single-beat write",
363 "reserved",
364 "reserved",
365 "reserved",
366 "Address-only, TLB Invalidate",
367 "reserved",
368 "Single-beat or Burst read",
369 "reserved",
370 "eciwx - Illegal single-beat read",
371 "reserved",
372 "Burst read",
373 "reserved"
374 };
375
Simon Glass387a1f22012-12-13 20:48:57 +0000376 int etype = (gd->arch.arbiter_event_attributes & AEATR_EVENT)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200377 >> AEATR_EVENT_SHIFT;
Simon Glass387a1f22012-12-13 20:48:57 +0000378 int mstr_id = (gd->arch.arbiter_event_attributes & AEATR_MSTR_ID)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200379 >> AEATR_MSTR_ID_SHIFT;
Simon Glass387a1f22012-12-13 20:48:57 +0000380 int tbst = (gd->arch.arbiter_event_attributes & AEATR_TBST)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200381 >> AEATR_TBST_SHIFT;
Simon Glass387a1f22012-12-13 20:48:57 +0000382 int tsize = (gd->arch.arbiter_event_attributes & AEATR_TSIZE)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200383 >> AEATR_TSIZE_SHIFT;
Simon Glass387a1f22012-12-13 20:48:57 +0000384 int ttype = (gd->arch.arbiter_event_attributes & AEATR_TTYPE)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200385 >> AEATR_TTYPE_SHIFT;
Nick Spence56fd3c22008-08-28 14:09:19 -0700386
Simon Glass387a1f22012-12-13 20:48:57 +0000387 if (!force && !gd->arch.arbiter_event_address)
Nick Spence56fd3c22008-08-28 14:09:19 -0700388 return 0;
389
390 puts("Arbiter Event Status:\n");
Simon Glass387a1f22012-12-13 20:48:57 +0000391 printf(" Event Address: 0x%08lX\n",
392 gd->arch.arbiter_event_address);
Nick Spence56fd3c22008-08-28 14:09:19 -0700393 printf(" Event Type: 0x%1x = %s\n", etype, event[etype]);
394 printf(" Master ID: 0x%02x = %s\n", mstr_id, master[mstr_id]);
395 printf(" Transfer Size: 0x%1x = %d bytes\n", (tbst<<3) | tsize,
396 tbst ? (tsize ? tsize : 8) : 16 + 8 * tsize);
397 printf(" Transfer Type: 0x%02x = %s\n", ttype, transfer[ttype]);
398
Simon Glass387a1f22012-12-13 20:48:57 +0000399 return gd->arch.arbiter_event_address;
Nick Spence56fd3c22008-08-28 14:09:19 -0700400}
401
402#elif defined(CONFIG_DISPLAY_AER_BRIEF)
403
404static int print_83xx_arb_event(int force)
405{
Simon Glass387a1f22012-12-13 20:48:57 +0000406 if (!force && !gd->arch.arbiter_event_address)
Nick Spence56fd3c22008-08-28 14:09:19 -0700407 return 0;
408
409 printf("Arbiter Event Status: AEATR=0x%08lX, AEADR=0x%08lX\n",
Simon Glass387a1f22012-12-13 20:48:57 +0000410 gd->arch.arbiter_event_attributes,
411 gd->arch.arbiter_event_address);
Nick Spence56fd3c22008-08-28 14:09:19 -0700412
Simon Glass387a1f22012-12-13 20:48:57 +0000413 return gd->arch.arbiter_event_address;
Nick Spence56fd3c22008-08-28 14:09:19 -0700414}
415#endif /* CONFIG_DISPLAY_AER_xxxx */
416
Mario Six28fbefa2018-08-06 10:23:45 +0200417#ifndef CONFIG_CPU_MPC83XX
Dave Liuebd35f82007-06-25 10:41:56 +0800418/*
419 * Figure out the cause of the reset
420 */
421int prt_83xx_rsr(void)
422{
423 static struct {
424 ulong mask;
425 char *desc;
426 } bits[] = {
427 {
428 RSR_SWSR, "Software Soft"}, {
429 RSR_SWHR, "Software Hard"}, {
430 RSR_JSRS, "JTAG Soft"}, {
431 RSR_CSHR, "Check Stop"}, {
432 RSR_SWRS, "Software Watchdog"}, {
433 RSR_BMRS, "Bus Monitor"}, {
434 RSR_SRS, "External/Internal Soft"}, {
435 RSR_HRS, "External/Internal Hard"}
436 };
Robert P. J. Day0c911592016-05-23 06:49:21 -0400437 static int n = ARRAY_SIZE(bits);
Simon Glass4d6eaa32012-12-13 20:48:56 +0000438 ulong rsr = gd->arch.reset_status;
Dave Liuebd35f82007-06-25 10:41:56 +0800439 int i;
440 char *sep;
441
442 puts("Reset Status:");
443
444 sep = " ";
445 for (i = 0; i < n; i++)
446 if (rsr & bits[i].mask) {
447 printf("%s%s", sep, bits[i].desc);
448 sep = ", ";
449 }
Nick Spence56fd3c22008-08-28 14:09:19 -0700450 puts("\n");
451
452#if defined(CONFIG_DISPLAY_AER_FULL) || defined(CONFIG_DISPLAY_AER_BRIEF)
453 print_83xx_arb_event(rsr & RSR_BMRS);
454#endif
455 puts("\n");
456
Dave Liuebd35f82007-06-25 10:41:56 +0800457 return 0;
458}
Mario Six28fbefa2018-08-06 10:23:45 +0200459#endif