blob: b21b0b03249afb9a50deb3a9cb1dd54102c4daa7 [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>
Simon Glass40d9b242020-05-10 11:40:07 -06007#include <asm-offsets.h>
Eran Liberty9095d4a2005-07-28 10:08:46 -05008#include <mpc83xx.h>
9#include <ioports.h>
Vivek Mahajan288f7fb2009-05-25 17:23:16 +053010#include <asm/io.h>
Simon Glass156283f2017-03-28 10:27:27 -060011#include <asm/processor.h>
Heiko Schocher3b767732020-04-15 10:35:40 +020012#include <fsl_qe.h>
Kim Phillips328040a2009-09-25 18:19:44 -050013#ifdef CONFIG_USB_EHCI_FSL
Mateusz Kulikowski3add69e2016-03-31 23:12:23 +020014#include <usb/ehci-ci.h>
Vivek Mahajan288f7fb2009-05-25 17:23:16 +053015#endif
Simon Glassdbd79542020-05-10 11:40:11 -060016#include <linux/delay.h>
Eran Liberty9095d4a2005-07-28 10:08:46 -050017
Mario Sixb47839c2019-01-21 09:17:58 +010018#include "lblaw/lblaw.h"
Mario Six1faf95d2019-01-21 09:18:03 +010019#include "elbc/elbc.h"
Mario Six636c1082019-01-21 09:18:11 +010020#include "sysio/sysio.h"
Mario Sixaa502542019-01-21 09:18:12 +010021#include "arbiter/arbiter.h"
Mario Sixf62074e2019-01-21 09:18:13 +010022#include "initreg/initreg.h"
Mario Sixb47839c2019-01-21 09:17:58 +010023
Wolfgang Denk6405a152006-03-31 18:32:53 +020024DECLARE_GLOBAL_DATA_PTR;
25
Dave Liue732e9c2006-11-03 12:11:15 -060026#ifdef CONFIG_QE
27extern qe_iop_conf_t qe_iop_conf_tab[];
28extern void qe_config_iopin(u8 port, u8 pin, int dir,
29 int open_drain, int assign);
Dave Liue732e9c2006-11-03 12:11:15 -060030
31static void config_qe_ioports(void)
32{
33 u8 port, pin;
34 int dir, open_drain, assign;
35 int i;
36
37 for (i = 0; qe_iop_conf_tab[i].assign != QE_IOP_TAB_END; i++) {
38 port = qe_iop_conf_tab[i].port;
39 pin = qe_iop_conf_tab[i].pin;
40 dir = qe_iop_conf_tab[i].dir;
41 open_drain = qe_iop_conf_tab[i].open_drain;
42 assign = qe_iop_conf_tab[i].assign;
43 qe_config_iopin(port, pin, dir, open_drain, assign);
44 }
45}
46#endif
47
Eran Liberty9095d4a2005-07-28 10:08:46 -050048/*
49 * Breathe some life into the CPU...
50 *
51 * Set up the memory map,
52 * initialize a bunch of registers,
53 * initialize the UPM's
54 */
55void cpu_init_f (volatile immap_t * im)
56{
Kim Phillips328040a2009-09-25 18:19:44 -050057 __be32 sccr_mask =
58#ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050059 SCCR_ENCCM |
Kim Phillips19a91de2008-01-16 12:06:16 -060060#endif
Kim Phillips328040a2009-09-25 18:19:44 -050061#ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050062 SCCR_PCICM |
Kim Phillips19a91de2008-01-16 12:06:16 -060063#endif
Ilya Yanoka4f3ed32010-09-17 23:41:47 +020064#ifdef CONFIG_SYS_SCCR_PCIEXP1CM /* PCIE1 clock mode */
65 SCCR_PCIEXP1CM |
66#endif
67#ifdef CONFIG_SYS_SCCR_PCIEXP2CM /* PCIE2 clock mode */
68 SCCR_PCIEXP2CM |
69#endif
Kim Phillips328040a2009-09-25 18:19:44 -050070#ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050071 SCCR_TSECCM |
Timur Tabi054838e2006-10-31 18:44:42 -060072#endif
Kim Phillips328040a2009-09-25 18:19:44 -050073#ifdef CONFIG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050074 SCCR_TSEC1CM |
Timur Tabi054838e2006-10-31 18:44:42 -060075#endif
Kim Phillips328040a2009-09-25 18:19:44 -050076#ifdef CONFIG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050077 SCCR_TSEC2CM |
Kumar Gala15c3f692007-02-27 23:51:42 -060078#endif
Kim Phillips328040a2009-09-25 18:19:44 -050079#ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050080 SCCR_TSEC1ON |
Timur Tabi0b2deff2007-07-03 13:04:34 -050081#endif
Kim Phillips328040a2009-09-25 18:19:44 -050082#ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050083 SCCR_TSEC2ON |
Timur Tabi0b2deff2007-07-03 13:04:34 -050084#endif
Kim Phillips328040a2009-09-25 18:19:44 -050085#ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050086 SCCR_USBMPHCM |
Kumar Gala15c3f692007-02-27 23:51:42 -060087#endif
Kim Phillips328040a2009-09-25 18:19:44 -050088#ifdef CONFIG_SYS_SCCR_USBDRCM /* USB DR clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050089 SCCR_USBDRCM |
Kumar Gala15c3f692007-02-27 23:51:42 -060090#endif
Kim Phillips328040a2009-09-25 18:19:44 -050091#ifdef CONFIG_SYS_SCCR_SATACM /* SATA controller clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050092 SCCR_SATACM |
Timur Tabi054838e2006-10-31 18:44:42 -060093#endif
Kim Phillips328040a2009-09-25 18:19:44 -050094 0;
95 __be32 sccr_val =
96#ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */
97 (CONFIG_SYS_SCCR_ENCCM << SCCR_ENCCM_SHIFT) |
98#endif
99#ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */
100 (CONFIG_SYS_SCCR_PCICM << SCCR_PCICM_SHIFT) |
101#endif
Ilya Yanoka4f3ed32010-09-17 23:41:47 +0200102#ifdef CONFIG_SYS_SCCR_PCIEXP1CM /* PCIE1 clock mode */
103 (CONFIG_SYS_SCCR_PCIEXP1CM << SCCR_PCIEXP1CM_SHIFT) |
104#endif
105#ifdef CONFIG_SYS_SCCR_PCIEXP2CM /* PCIE2 clock mode */
106 (CONFIG_SYS_SCCR_PCIEXP2CM << SCCR_PCIEXP2CM_SHIFT) |
107#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500108#ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */
109 (CONFIG_SYS_SCCR_TSECCM << SCCR_TSECCM_SHIFT) |
110#endif
111#ifdef CONFIG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */
112 (CONFIG_SYS_SCCR_TSEC1CM << SCCR_TSEC1CM_SHIFT) |
113#endif
114#ifdef CONFIG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */
115 (CONFIG_SYS_SCCR_TSEC2CM << SCCR_TSEC2CM_SHIFT) |
116#endif
117#ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */
118 (CONFIG_SYS_SCCR_TSEC1ON << SCCR_TSEC1ON_SHIFT) |
119#endif
120#ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */
121 (CONFIG_SYS_SCCR_TSEC2ON << SCCR_TSEC2ON_SHIFT) |
122#endif
123#ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */
124 (CONFIG_SYS_SCCR_USBMPHCM << SCCR_USBMPHCM_SHIFT) |
125#endif
126#ifdef CONFIG_SYS_SCCR_USBDRCM /* USB DR clock mode */
127 (CONFIG_SYS_SCCR_USBDRCM << SCCR_USBDRCM_SHIFT) |
128#endif
129#ifdef CONFIG_SYS_SCCR_SATACM /* SATA controller clock mode */
130 (CONFIG_SYS_SCCR_SATACM << SCCR_SATACM_SHIFT) |
131#endif
132 0;
133
134 /* Pointer is writable since we allocated a register for it */
135 gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
136
mario.six@gdsys.cc85df7b42017-01-17 08:33:48 +0100137 /* global data region was cleared in start.S */
Kim Phillips328040a2009-09-25 18:19:44 -0500138
139 /* system performance tweaking */
140 clrsetbits_be32(&im->arbiter.acr, acr_mask, acr_val);
141
142 clrsetbits_be32(&im->sysconf.spcr, spcr_mask, spcr_val);
143
144 clrsetbits_be32(&im->clk.sccr, sccr_mask, sccr_val);
Timur Tabi054838e2006-10-31 18:44:42 -0600145
Eran Liberty9095d4a2005-07-28 10:08:46 -0500146 /* RSR - Reset Status Register - clear all status (4.6.1.3) */
Simon Glass4d6eaa32012-12-13 20:48:56 +0000147 gd->arch.reset_status = __raw_readl(&im->reset.rsr);
Kim Phillips328040a2009-09-25 18:19:44 -0500148 __raw_writel(~(RSR_RES), &im->reset.rsr);
Eran Liberty9095d4a2005-07-28 10:08:46 -0500149
Nick Spence56fd3c22008-08-28 14:09:19 -0700150 /* AER - Arbiter Event Register - store status */
Simon Glass387a1f22012-12-13 20:48:57 +0000151 gd->arch.arbiter_event_attributes = __raw_readl(&im->arbiter.aeatr);
152 gd->arch.arbiter_event_address = __raw_readl(&im->arbiter.aeadr);
Nick Spence56fd3c22008-08-28 14:09:19 -0700153
Eran Liberty9095d4a2005-07-28 10:08:46 -0500154 /*
155 * RMR - Reset Mode Register
156 * contains checkstop reset enable (4.6.1.4)
157 */
Kim Phillips328040a2009-09-25 18:19:44 -0500158 __raw_writel(RMR_CSRE & (1<<RMR_CSRE_SHIFT), &im->reset.rmr);
Eran Liberty9095d4a2005-07-28 10:08:46 -0500159
Peter Korsgaard2a483ee2009-12-08 22:20:34 +0100160 /* LCRR - Clock Ratio Register (10.3.1.16)
161 * write, read, and isync per MPC8379ERM rev.1 CLKDEV field description
162 */
Becky Bruce0d4cee12010-06-17 11:37:20 -0500163 clrsetbits_be32(&im->im_lbc.lcrr, lcrr_mask, lcrr_val);
164 __raw_readl(&im->im_lbc.lcrr);
Peter Korsgaard2a483ee2009-12-08 22:20:34 +0100165 isync();
166
Kim Phillips328040a2009-09-25 18:19:44 -0500167 /* Enable Time Base & Decrementer ( so we will have udelay() )*/
168 setbits_be32(&im->sysconf.spcr, SPCR_TBEN);
Eran Liberty9095d4a2005-07-28 10:08:46 -0500169
170 /* System General Purpose Register */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200171#ifdef CONFIG_SYS_SICRH
Mario Six0344f5e2019-01-21 09:17:27 +0100172#if defined(CONFIG_ARCH_MPC834X) || defined(CONFIG_ARCH_MPC8313)
Andre Schwarzcea66482008-06-23 11:40:56 +0200173 /* regarding to MPC34x manual rev.1 bits 28..29 must be preserved */
Kim Phillips328040a2009-09-25 18:19:44 -0500174 __raw_writel((im->sysconf.sicrh & 0x0000000C) | CONFIG_SYS_SICRH,
175 &im->sysconf.sicrh);
Andre Schwarzcea66482008-06-23 11:40:56 +0200176#else
Kim Phillips328040a2009-09-25 18:19:44 -0500177 __raw_writel(CONFIG_SYS_SICRH, &im->sysconf.sicrh);
Kumar Galae5221432006-01-11 11:12:57 -0600178#endif
Andre Schwarzcea66482008-06-23 11:40:56 +0200179#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200180#ifdef CONFIG_SYS_SICRL
Kim Phillips328040a2009-09-25 18:19:44 -0500181 __raw_writel(CONFIG_SYS_SICRL, &im->sysconf.sicrl);
Kumar Galae5221432006-01-11 11:12:57 -0600182#endif
Gerlando Falautofe201cb2012-10-10 22:13:08 +0000183#ifdef CONFIG_SYS_GPR1
184 __raw_writel(CONFIG_SYS_GPR1, &im->sysconf.gpr1);
185#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500186#ifdef CONFIG_SYS_DDRCDR /* DDR control driver register */
187 __raw_writel(CONFIG_SYS_DDRCDR, &im->sysconf.ddrcdr);
Dave Liue740c462006-12-07 21:13:15 +0800188#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500189#ifdef CONFIG_SYS_OBIR /* Output buffer impedance register */
190 __raw_writel(CONFIG_SYS_OBIR, &im->sysconf.obir);
Dave Liub19ecd32007-09-18 12:37:57 +0800191#endif
Dave Liue740c462006-12-07 21:13:15 +0800192
Dave Liue732e9c2006-11-03 12:11:15 -0600193#ifdef CONFIG_QE
194 /* Config QE ioports */
195 config_qe_ioports();
196#endif
Becky Bruce0d4cee12010-06-17 11:37:20 -0500197 /* Set up preliminary BR/OR regs */
198 init_early_memctl_regs();
Eran Liberty9095d4a2005-07-28 10:08:46 -0500199
Becky Bruce0d4cee12010-06-17 11:37:20 -0500200 /* Local Access window setup */
201#if defined(CONFIG_SYS_LBLAWBAR0_PRELIM) && defined(CONFIG_SYS_LBLAWAR0_PRELIM)
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200202 im->sysconf.lblaw[0].bar = CONFIG_SYS_LBLAWBAR0_PRELIM;
203 im->sysconf.lblaw[0].ar = CONFIG_SYS_LBLAWAR0_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500204#else
Becky Bruce0d4cee12010-06-17 11:37:20 -0500205#error CONFIG_SYS_LBLAWBAR0_PRELIM & CONFIG_SYS_LBLAWAR0_PRELIM must be defined
Eran Liberty9095d4a2005-07-28 10:08:46 -0500206#endif
207
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200208#if defined(CONFIG_SYS_LBLAWBAR1_PRELIM) && defined(CONFIG_SYS_LBLAWAR1_PRELIM)
209 im->sysconf.lblaw[1].bar = CONFIG_SYS_LBLAWBAR1_PRELIM;
210 im->sysconf.lblaw[1].ar = CONFIG_SYS_LBLAWAR1_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500211#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200212#if defined(CONFIG_SYS_LBLAWBAR2_PRELIM) && defined(CONFIG_SYS_LBLAWAR2_PRELIM)
213 im->sysconf.lblaw[2].bar = CONFIG_SYS_LBLAWBAR2_PRELIM;
214 im->sysconf.lblaw[2].ar = CONFIG_SYS_LBLAWAR2_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500215#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200216#if defined(CONFIG_SYS_LBLAWBAR3_PRELIM) && defined(CONFIG_SYS_LBLAWAR3_PRELIM)
217 im->sysconf.lblaw[3].bar = CONFIG_SYS_LBLAWBAR3_PRELIM;
218 im->sysconf.lblaw[3].ar = CONFIG_SYS_LBLAWAR3_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500219#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200220#if defined(CONFIG_SYS_LBLAWBAR4_PRELIM) && defined(CONFIG_SYS_LBLAWAR4_PRELIM)
221 im->sysconf.lblaw[4].bar = CONFIG_SYS_LBLAWBAR4_PRELIM;
222 im->sysconf.lblaw[4].ar = CONFIG_SYS_LBLAWAR4_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500223#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200224#if defined(CONFIG_SYS_LBLAWBAR5_PRELIM) && defined(CONFIG_SYS_LBLAWAR5_PRELIM)
225 im->sysconf.lblaw[5].bar = CONFIG_SYS_LBLAWBAR5_PRELIM;
226 im->sysconf.lblaw[5].ar = CONFIG_SYS_LBLAWAR5_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500227#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200228#if defined(CONFIG_SYS_LBLAWBAR6_PRELIM) && defined(CONFIG_SYS_LBLAWAR6_PRELIM)
229 im->sysconf.lblaw[6].bar = CONFIG_SYS_LBLAWBAR6_PRELIM;
230 im->sysconf.lblaw[6].ar = CONFIG_SYS_LBLAWAR6_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500231#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200232#if defined(CONFIG_SYS_LBLAWBAR7_PRELIM) && defined(CONFIG_SYS_LBLAWAR7_PRELIM)
233 im->sysconf.lblaw[7].bar = CONFIG_SYS_LBLAWBAR7_PRELIM;
234 im->sysconf.lblaw[7].ar = CONFIG_SYS_LBLAWAR7_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500235#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200236#ifdef CONFIG_SYS_GPIO1_PRELIM
237 im->gpio[0].dat = CONFIG_SYS_GPIO1_DAT;
238 im->gpio[0].dir = CONFIG_SYS_GPIO1_DIR;
Kumar Galaab7ec4f2006-01-11 11:21:14 -0600239#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200240#ifdef CONFIG_SYS_GPIO2_PRELIM
241 im->gpio[1].dat = CONFIG_SYS_GPIO2_DAT;
242 im->gpio[1].dir = CONFIG_SYS_GPIO2_DIR;
Kumar Galaab7ec4f2006-01-11 11:21:14 -0600243#endif
Mario Six9164bdd2019-01-21 09:17:25 +0100244#if defined(CONFIG_USB_EHCI_FSL) && defined(CONFIG_ARCH_MPC831X)
Vivek Mahajan288f7fb2009-05-25 17:23:16 +0530245 uint32_t temp;
ramneek mehresh16b08062013-09-12 16:35:49 +0530246 struct usb_ehci *ehci = (struct usb_ehci *)CONFIG_SYS_FSL_USB1_ADDR;
Vivek Mahajan288f7fb2009-05-25 17:23:16 +0530247
248 /* Configure interface. */
Vivek Mahajan2d421c12009-06-24 10:08:40 +0530249 setbits_be32(&ehci->control, REFSEL_16MHZ | UTMI_PHY_EN);
Vivek Mahajan288f7fb2009-05-25 17:23:16 +0530250
251 /* Wait for clock to stabilize */
252 do {
Kim Phillips328040a2009-09-25 18:19:44 -0500253 temp = __raw_readl(&ehci->control);
Vivek Mahajan288f7fb2009-05-25 17:23:16 +0530254 udelay(1000);
255 } while (!(temp & PHY_CLK_VALID));
256#endif
Eran Liberty9095d4a2005-07-28 10:08:46 -0500257}
258
Eran Liberty9095d4a2005-07-28 10:08:46 -0500259int cpu_init_r (void)
260{
Dave Liue732e9c2006-11-03 12:11:15 -0600261#ifdef CONFIG_QE
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200262 uint qe_base = CONFIG_SYS_IMMR + 0x00100000; /* QE immr base */
Kim Phillips328040a2009-09-25 18:19:44 -0500263
Dave Liue732e9c2006-11-03 12:11:15 -0600264 qe_init(qe_base);
265 qe_reset();
266#endif
Eran Liberty9095d4a2005-07-28 10:08:46 -0500267 return 0;
268}
Dave Liuebd35f82007-06-25 10:41:56 +0800269
Nick Spence56fd3c22008-08-28 14:09:19 -0700270/*
271 * Print out the bus arbiter event
272 */
273#if defined(CONFIG_DISPLAY_AER_FULL)
274static int print_83xx_arb_event(int force)
275{
276 static char* event[] = {
277 "Address Time Out",
278 "Data Time Out",
279 "Address Only Transfer Type",
280 "External Control Word Transfer Type",
281 "Reserved Transfer Type",
282 "Transfer Error",
283 "reserved",
284 "reserved"
285 };
286 static char* master[] = {
287 "e300 Core Data Transaction",
288 "reserved",
289 "e300 Core Instruction Fetch",
290 "reserved",
291 "TSEC1",
292 "TSEC2",
293 "USB MPH",
294 "USB DR",
295 "Encryption Core",
296 "I2C Boot Sequencer",
297 "JTAG",
298 "reserved",
299 "eSDHC",
300 "PCI1",
301 "PCI2",
302 "DMA",
303 "QUICC Engine 00",
304 "QUICC Engine 01",
305 "QUICC Engine 10",
306 "QUICC Engine 11",
307 "reserved",
308 "reserved",
309 "reserved",
310 "reserved",
311 "SATA1",
312 "SATA2",
313 "SATA3",
314 "SATA4",
315 "reserved",
316 "PCI Express 1",
317 "PCI Express 2",
318 "TDM-DMAC"
319 };
320 static char *transfer[] = {
321 "Address-only, Clean Block",
322 "Address-only, lwarx reservation set",
323 "Single-beat or Burst write",
324 "reserved",
325 "Address-only, Flush Block",
326 "reserved",
327 "Burst write",
328 "reserved",
329 "Address-only, sync",
330 "Address-only, tlbsync",
331 "Single-beat or Burst read",
332 "Single-beat or Burst read",
333 "Address-only, Kill Block",
334 "Address-only, icbi",
335 "Burst read",
336 "reserved",
337 "Address-only, eieio",
338 "reserved",
339 "Single-beat write",
340 "reserved",
341 "ecowx - Illegal single-beat write",
342 "reserved",
343 "reserved",
344 "reserved",
345 "Address-only, TLB Invalidate",
346 "reserved",
347 "Single-beat or Burst read",
348 "reserved",
349 "eciwx - Illegal single-beat read",
350 "reserved",
351 "Burst read",
352 "reserved"
353 };
354
Simon Glass387a1f22012-12-13 20:48:57 +0000355 int etype = (gd->arch.arbiter_event_attributes & AEATR_EVENT)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200356 >> AEATR_EVENT_SHIFT;
Simon Glass387a1f22012-12-13 20:48:57 +0000357 int mstr_id = (gd->arch.arbiter_event_attributes & AEATR_MSTR_ID)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200358 >> AEATR_MSTR_ID_SHIFT;
Simon Glass387a1f22012-12-13 20:48:57 +0000359 int tbst = (gd->arch.arbiter_event_attributes & AEATR_TBST)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200360 >> AEATR_TBST_SHIFT;
Simon Glass387a1f22012-12-13 20:48:57 +0000361 int tsize = (gd->arch.arbiter_event_attributes & AEATR_TSIZE)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200362 >> AEATR_TSIZE_SHIFT;
Simon Glass387a1f22012-12-13 20:48:57 +0000363 int ttype = (gd->arch.arbiter_event_attributes & AEATR_TTYPE)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200364 >> AEATR_TTYPE_SHIFT;
Nick Spence56fd3c22008-08-28 14:09:19 -0700365
Simon Glass387a1f22012-12-13 20:48:57 +0000366 if (!force && !gd->arch.arbiter_event_address)
Nick Spence56fd3c22008-08-28 14:09:19 -0700367 return 0;
368
369 puts("Arbiter Event Status:\n");
Simon Glass387a1f22012-12-13 20:48:57 +0000370 printf(" Event Address: 0x%08lX\n",
371 gd->arch.arbiter_event_address);
Nick Spence56fd3c22008-08-28 14:09:19 -0700372 printf(" Event Type: 0x%1x = %s\n", etype, event[etype]);
373 printf(" Master ID: 0x%02x = %s\n", mstr_id, master[mstr_id]);
374 printf(" Transfer Size: 0x%1x = %d bytes\n", (tbst<<3) | tsize,
375 tbst ? (tsize ? tsize : 8) : 16 + 8 * tsize);
376 printf(" Transfer Type: 0x%02x = %s\n", ttype, transfer[ttype]);
377
Simon Glass387a1f22012-12-13 20:48:57 +0000378 return gd->arch.arbiter_event_address;
Nick Spence56fd3c22008-08-28 14:09:19 -0700379}
380
381#elif defined(CONFIG_DISPLAY_AER_BRIEF)
382
383static int print_83xx_arb_event(int force)
384{
Simon Glass387a1f22012-12-13 20:48:57 +0000385 if (!force && !gd->arch.arbiter_event_address)
Nick Spence56fd3c22008-08-28 14:09:19 -0700386 return 0;
387
388 printf("Arbiter Event Status: AEATR=0x%08lX, AEADR=0x%08lX\n",
Simon Glass387a1f22012-12-13 20:48:57 +0000389 gd->arch.arbiter_event_attributes,
390 gd->arch.arbiter_event_address);
Nick Spence56fd3c22008-08-28 14:09:19 -0700391
Simon Glass387a1f22012-12-13 20:48:57 +0000392 return gd->arch.arbiter_event_address;
Nick Spence56fd3c22008-08-28 14:09:19 -0700393}
394#endif /* CONFIG_DISPLAY_AER_xxxx */
395
Mario Six28fbefa2018-08-06 10:23:45 +0200396#ifndef CONFIG_CPU_MPC83XX
Dave Liuebd35f82007-06-25 10:41:56 +0800397/*
398 * Figure out the cause of the reset
399 */
400int prt_83xx_rsr(void)
401{
402 static struct {
403 ulong mask;
404 char *desc;
405 } bits[] = {
406 {
407 RSR_SWSR, "Software Soft"}, {
408 RSR_SWHR, "Software Hard"}, {
409 RSR_JSRS, "JTAG Soft"}, {
410 RSR_CSHR, "Check Stop"}, {
411 RSR_SWRS, "Software Watchdog"}, {
412 RSR_BMRS, "Bus Monitor"}, {
413 RSR_SRS, "External/Internal Soft"}, {
414 RSR_HRS, "External/Internal Hard"}
415 };
Robert P. J. Day0c911592016-05-23 06:49:21 -0400416 static int n = ARRAY_SIZE(bits);
Simon Glass4d6eaa32012-12-13 20:48:56 +0000417 ulong rsr = gd->arch.reset_status;
Dave Liuebd35f82007-06-25 10:41:56 +0800418 int i;
419 char *sep;
420
421 puts("Reset Status:");
422
423 sep = " ";
424 for (i = 0; i < n; i++)
425 if (rsr & bits[i].mask) {
426 printf("%s%s", sep, bits[i].desc);
427 sep = ", ";
428 }
Nick Spence56fd3c22008-08-28 14:09:19 -0700429 puts("\n");
430
431#if defined(CONFIG_DISPLAY_AER_FULL) || defined(CONFIG_DISPLAY_AER_BRIEF)
432 print_83xx_arb_event(rsr & RSR_BMRS);
433#endif
434 puts("\n");
435
Dave Liuebd35f82007-06-25 10:41:56 +0800436 return 0;
437}
Mario Six28fbefa2018-08-06 10:23:45 +0200438#endif