blob: 438b14b162eb76317e192990c69a28c24e2dd2ec [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>
Kim Phillips328040a2009-09-25 18:19:44 -050012#ifdef CONFIG_USB_EHCI_FSL
Mateusz Kulikowski3add69e2016-03-31 23:12:23 +020013#include <usb/ehci-ci.h>
Vivek Mahajan288f7fb2009-05-25 17:23:16 +053014#endif
Simon Glassdbd79542020-05-10 11:40:11 -060015#include <linux/delay.h>
Eran Liberty9095d4a2005-07-28 10:08:46 -050016
Mario Sixb47839c2019-01-21 09:17:58 +010017#include "lblaw/lblaw.h"
Mario Six1faf95d2019-01-21 09:18:03 +010018#include "elbc/elbc.h"
Mario Six636c1082019-01-21 09:18:11 +010019#include "sysio/sysio.h"
Mario Sixaa502542019-01-21 09:18:12 +010020#include "arbiter/arbiter.h"
Mario Sixf62074e2019-01-21 09:18:13 +010021#include "initreg/initreg.h"
Mario Sixb47839c2019-01-21 09:17:58 +010022
Wolfgang Denk6405a152006-03-31 18:32:53 +020023DECLARE_GLOBAL_DATA_PTR;
24
Dave Liue732e9c2006-11-03 12:11:15 -060025#ifdef CONFIG_QE
26extern qe_iop_conf_t qe_iop_conf_tab[];
27extern void qe_config_iopin(u8 port, u8 pin, int dir,
28 int open_drain, int assign);
29extern void qe_init(uint qe_base);
30extern void qe_reset(void);
31
32static void config_qe_ioports(void)
33{
34 u8 port, pin;
35 int dir, open_drain, assign;
36 int i;
37
38 for (i = 0; qe_iop_conf_tab[i].assign != QE_IOP_TAB_END; i++) {
39 port = qe_iop_conf_tab[i].port;
40 pin = qe_iop_conf_tab[i].pin;
41 dir = qe_iop_conf_tab[i].dir;
42 open_drain = qe_iop_conf_tab[i].open_drain;
43 assign = qe_iop_conf_tab[i].assign;
44 qe_config_iopin(port, pin, dir, open_drain, assign);
45 }
46}
47#endif
48
Eran Liberty9095d4a2005-07-28 10:08:46 -050049/*
50 * Breathe some life into the CPU...
51 *
52 * Set up the memory map,
53 * initialize a bunch of registers,
54 * initialize the UPM's
55 */
56void cpu_init_f (volatile immap_t * im)
57{
Kim Phillips328040a2009-09-25 18:19:44 -050058 __be32 sccr_mask =
59#ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050060 SCCR_ENCCM |
Kim Phillips19a91de2008-01-16 12:06:16 -060061#endif
Kim Phillips328040a2009-09-25 18:19:44 -050062#ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050063 SCCR_PCICM |
Kim Phillips19a91de2008-01-16 12:06:16 -060064#endif
Ilya Yanoka4f3ed32010-09-17 23:41:47 +020065#ifdef CONFIG_SYS_SCCR_PCIEXP1CM /* PCIE1 clock mode */
66 SCCR_PCIEXP1CM |
67#endif
68#ifdef CONFIG_SYS_SCCR_PCIEXP2CM /* PCIE2 clock mode */
69 SCCR_PCIEXP2CM |
70#endif
Kim Phillips328040a2009-09-25 18:19:44 -050071#ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050072 SCCR_TSECCM |
Timur Tabi054838e2006-10-31 18:44:42 -060073#endif
Kim Phillips328040a2009-09-25 18:19:44 -050074#ifdef CONFIG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050075 SCCR_TSEC1CM |
Timur Tabi054838e2006-10-31 18:44:42 -060076#endif
Kim Phillips328040a2009-09-25 18:19:44 -050077#ifdef CONFIG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050078 SCCR_TSEC2CM |
Kumar Gala15c3f692007-02-27 23:51:42 -060079#endif
Kim Phillips328040a2009-09-25 18:19:44 -050080#ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050081 SCCR_TSEC1ON |
Timur Tabi0b2deff2007-07-03 13:04:34 -050082#endif
Kim Phillips328040a2009-09-25 18:19:44 -050083#ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050084 SCCR_TSEC2ON |
Timur Tabi0b2deff2007-07-03 13:04:34 -050085#endif
Kim Phillips328040a2009-09-25 18:19:44 -050086#ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050087 SCCR_USBMPHCM |
Kumar Gala15c3f692007-02-27 23:51:42 -060088#endif
Kim Phillips328040a2009-09-25 18:19:44 -050089#ifdef CONFIG_SYS_SCCR_USBDRCM /* USB DR clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050090 SCCR_USBDRCM |
Kumar Gala15c3f692007-02-27 23:51:42 -060091#endif
Kim Phillips328040a2009-09-25 18:19:44 -050092#ifdef CONFIG_SYS_SCCR_SATACM /* SATA controller clock mode */
Kim Phillips8d5fa6a2010-05-19 17:06:46 -050093 SCCR_SATACM |
Timur Tabi054838e2006-10-31 18:44:42 -060094#endif
Kim Phillips328040a2009-09-25 18:19:44 -050095 0;
96 __be32 sccr_val =
97#ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */
98 (CONFIG_SYS_SCCR_ENCCM << SCCR_ENCCM_SHIFT) |
99#endif
100#ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */
101 (CONFIG_SYS_SCCR_PCICM << SCCR_PCICM_SHIFT) |
102#endif
Ilya Yanoka4f3ed32010-09-17 23:41:47 +0200103#ifdef CONFIG_SYS_SCCR_PCIEXP1CM /* PCIE1 clock mode */
104 (CONFIG_SYS_SCCR_PCIEXP1CM << SCCR_PCIEXP1CM_SHIFT) |
105#endif
106#ifdef CONFIG_SYS_SCCR_PCIEXP2CM /* PCIE2 clock mode */
107 (CONFIG_SYS_SCCR_PCIEXP2CM << SCCR_PCIEXP2CM_SHIFT) |
108#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500109#ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */
110 (CONFIG_SYS_SCCR_TSECCM << SCCR_TSECCM_SHIFT) |
111#endif
112#ifdef CONFIG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */
113 (CONFIG_SYS_SCCR_TSEC1CM << SCCR_TSEC1CM_SHIFT) |
114#endif
115#ifdef CONFIG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */
116 (CONFIG_SYS_SCCR_TSEC2CM << SCCR_TSEC2CM_SHIFT) |
117#endif
118#ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */
119 (CONFIG_SYS_SCCR_TSEC1ON << SCCR_TSEC1ON_SHIFT) |
120#endif
121#ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */
122 (CONFIG_SYS_SCCR_TSEC2ON << SCCR_TSEC2ON_SHIFT) |
123#endif
124#ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */
125 (CONFIG_SYS_SCCR_USBMPHCM << SCCR_USBMPHCM_SHIFT) |
126#endif
127#ifdef CONFIG_SYS_SCCR_USBDRCM /* USB DR clock mode */
128 (CONFIG_SYS_SCCR_USBDRCM << SCCR_USBDRCM_SHIFT) |
129#endif
130#ifdef CONFIG_SYS_SCCR_SATACM /* SATA controller clock mode */
131 (CONFIG_SYS_SCCR_SATACM << SCCR_SATACM_SHIFT) |
132#endif
133 0;
134
135 /* Pointer is writable since we allocated a register for it */
136 gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
137
mario.six@gdsys.cc85df7b42017-01-17 08:33:48 +0100138 /* global data region was cleared in start.S */
Kim Phillips328040a2009-09-25 18:19:44 -0500139
140 /* system performance tweaking */
141 clrsetbits_be32(&im->arbiter.acr, acr_mask, acr_val);
142
143 clrsetbits_be32(&im->sysconf.spcr, spcr_mask, spcr_val);
144
145 clrsetbits_be32(&im->clk.sccr, sccr_mask, sccr_val);
Timur Tabi054838e2006-10-31 18:44:42 -0600146
Eran Liberty9095d4a2005-07-28 10:08:46 -0500147 /* RSR - Reset Status Register - clear all status (4.6.1.3) */
Simon Glass4d6eaa32012-12-13 20:48:56 +0000148 gd->arch.reset_status = __raw_readl(&im->reset.rsr);
Kim Phillips328040a2009-09-25 18:19:44 -0500149 __raw_writel(~(RSR_RES), &im->reset.rsr);
Eran Liberty9095d4a2005-07-28 10:08:46 -0500150
Nick Spence56fd3c22008-08-28 14:09:19 -0700151 /* AER - Arbiter Event Register - store status */
Simon Glass387a1f22012-12-13 20:48:57 +0000152 gd->arch.arbiter_event_attributes = __raw_readl(&im->arbiter.aeatr);
153 gd->arch.arbiter_event_address = __raw_readl(&im->arbiter.aeadr);
Nick Spence56fd3c22008-08-28 14:09:19 -0700154
Eran Liberty9095d4a2005-07-28 10:08:46 -0500155 /*
156 * RMR - Reset Mode Register
157 * contains checkstop reset enable (4.6.1.4)
158 */
Kim Phillips328040a2009-09-25 18:19:44 -0500159 __raw_writel(RMR_CSRE & (1<<RMR_CSRE_SHIFT), &im->reset.rmr);
Eran Liberty9095d4a2005-07-28 10:08:46 -0500160
Peter Korsgaard2a483ee2009-12-08 22:20:34 +0100161 /* LCRR - Clock Ratio Register (10.3.1.16)
162 * write, read, and isync per MPC8379ERM rev.1 CLKDEV field description
163 */
Becky Bruce0d4cee12010-06-17 11:37:20 -0500164 clrsetbits_be32(&im->im_lbc.lcrr, lcrr_mask, lcrr_val);
165 __raw_readl(&im->im_lbc.lcrr);
Peter Korsgaard2a483ee2009-12-08 22:20:34 +0100166 isync();
167
Kim Phillips328040a2009-09-25 18:19:44 -0500168 /* Enable Time Base & Decrementer ( so we will have udelay() )*/
169 setbits_be32(&im->sysconf.spcr, SPCR_TBEN);
Eran Liberty9095d4a2005-07-28 10:08:46 -0500170
171 /* System General Purpose Register */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200172#ifdef CONFIG_SYS_SICRH
Mario Six0344f5e2019-01-21 09:17:27 +0100173#if defined(CONFIG_ARCH_MPC834X) || defined(CONFIG_ARCH_MPC8313)
Andre Schwarzcea66482008-06-23 11:40:56 +0200174 /* regarding to MPC34x manual rev.1 bits 28..29 must be preserved */
Kim Phillips328040a2009-09-25 18:19:44 -0500175 __raw_writel((im->sysconf.sicrh & 0x0000000C) | CONFIG_SYS_SICRH,
176 &im->sysconf.sicrh);
Andre Schwarzcea66482008-06-23 11:40:56 +0200177#else
Kim Phillips328040a2009-09-25 18:19:44 -0500178 __raw_writel(CONFIG_SYS_SICRH, &im->sysconf.sicrh);
Kumar Galae5221432006-01-11 11:12:57 -0600179#endif
Andre Schwarzcea66482008-06-23 11:40:56 +0200180#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200181#ifdef CONFIG_SYS_SICRL
Kim Phillips328040a2009-09-25 18:19:44 -0500182 __raw_writel(CONFIG_SYS_SICRL, &im->sysconf.sicrl);
Kumar Galae5221432006-01-11 11:12:57 -0600183#endif
Gerlando Falautofe201cb2012-10-10 22:13:08 +0000184#ifdef CONFIG_SYS_GPR1
185 __raw_writel(CONFIG_SYS_GPR1, &im->sysconf.gpr1);
186#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500187#ifdef CONFIG_SYS_DDRCDR /* DDR control driver register */
188 __raw_writel(CONFIG_SYS_DDRCDR, &im->sysconf.ddrcdr);
Dave Liue740c462006-12-07 21:13:15 +0800189#endif
Kim Phillips328040a2009-09-25 18:19:44 -0500190#ifdef CONFIG_SYS_OBIR /* Output buffer impedance register */
191 __raw_writel(CONFIG_SYS_OBIR, &im->sysconf.obir);
Dave Liub19ecd32007-09-18 12:37:57 +0800192#endif
Dave Liue740c462006-12-07 21:13:15 +0800193
Dave Liue732e9c2006-11-03 12:11:15 -0600194#ifdef CONFIG_QE
195 /* Config QE ioports */
196 config_qe_ioports();
197#endif
Becky Bruce0d4cee12010-06-17 11:37:20 -0500198 /* Set up preliminary BR/OR regs */
199 init_early_memctl_regs();
Eran Liberty9095d4a2005-07-28 10:08:46 -0500200
Becky Bruce0d4cee12010-06-17 11:37:20 -0500201 /* Local Access window setup */
202#if defined(CONFIG_SYS_LBLAWBAR0_PRELIM) && defined(CONFIG_SYS_LBLAWAR0_PRELIM)
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200203 im->sysconf.lblaw[0].bar = CONFIG_SYS_LBLAWBAR0_PRELIM;
204 im->sysconf.lblaw[0].ar = CONFIG_SYS_LBLAWAR0_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500205#else
Becky Bruce0d4cee12010-06-17 11:37:20 -0500206#error CONFIG_SYS_LBLAWBAR0_PRELIM & CONFIG_SYS_LBLAWAR0_PRELIM must be defined
Eran Liberty9095d4a2005-07-28 10:08:46 -0500207#endif
208
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200209#if defined(CONFIG_SYS_LBLAWBAR1_PRELIM) && defined(CONFIG_SYS_LBLAWAR1_PRELIM)
210 im->sysconf.lblaw[1].bar = CONFIG_SYS_LBLAWBAR1_PRELIM;
211 im->sysconf.lblaw[1].ar = CONFIG_SYS_LBLAWAR1_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500212#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200213#if defined(CONFIG_SYS_LBLAWBAR2_PRELIM) && defined(CONFIG_SYS_LBLAWAR2_PRELIM)
214 im->sysconf.lblaw[2].bar = CONFIG_SYS_LBLAWBAR2_PRELIM;
215 im->sysconf.lblaw[2].ar = CONFIG_SYS_LBLAWAR2_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500216#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200217#if defined(CONFIG_SYS_LBLAWBAR3_PRELIM) && defined(CONFIG_SYS_LBLAWAR3_PRELIM)
218 im->sysconf.lblaw[3].bar = CONFIG_SYS_LBLAWBAR3_PRELIM;
219 im->sysconf.lblaw[3].ar = CONFIG_SYS_LBLAWAR3_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500220#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200221#if defined(CONFIG_SYS_LBLAWBAR4_PRELIM) && defined(CONFIG_SYS_LBLAWAR4_PRELIM)
222 im->sysconf.lblaw[4].bar = CONFIG_SYS_LBLAWBAR4_PRELIM;
223 im->sysconf.lblaw[4].ar = CONFIG_SYS_LBLAWAR4_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500224#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200225#if defined(CONFIG_SYS_LBLAWBAR5_PRELIM) && defined(CONFIG_SYS_LBLAWAR5_PRELIM)
226 im->sysconf.lblaw[5].bar = CONFIG_SYS_LBLAWBAR5_PRELIM;
227 im->sysconf.lblaw[5].ar = CONFIG_SYS_LBLAWAR5_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500228#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200229#if defined(CONFIG_SYS_LBLAWBAR6_PRELIM) && defined(CONFIG_SYS_LBLAWAR6_PRELIM)
230 im->sysconf.lblaw[6].bar = CONFIG_SYS_LBLAWBAR6_PRELIM;
231 im->sysconf.lblaw[6].ar = CONFIG_SYS_LBLAWAR6_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500232#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200233#if defined(CONFIG_SYS_LBLAWBAR7_PRELIM) && defined(CONFIG_SYS_LBLAWAR7_PRELIM)
234 im->sysconf.lblaw[7].bar = CONFIG_SYS_LBLAWBAR7_PRELIM;
235 im->sysconf.lblaw[7].ar = CONFIG_SYS_LBLAWAR7_PRELIM;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500236#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200237#ifdef CONFIG_SYS_GPIO1_PRELIM
238 im->gpio[0].dat = CONFIG_SYS_GPIO1_DAT;
239 im->gpio[0].dir = CONFIG_SYS_GPIO1_DIR;
Kumar Galaab7ec4f2006-01-11 11:21:14 -0600240#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200241#ifdef CONFIG_SYS_GPIO2_PRELIM
242 im->gpio[1].dat = CONFIG_SYS_GPIO2_DAT;
243 im->gpio[1].dir = CONFIG_SYS_GPIO2_DIR;
Kumar Galaab7ec4f2006-01-11 11:21:14 -0600244#endif
Mario Six9164bdd2019-01-21 09:17:25 +0100245#if defined(CONFIG_USB_EHCI_FSL) && defined(CONFIG_ARCH_MPC831X)
Vivek Mahajan288f7fb2009-05-25 17:23:16 +0530246 uint32_t temp;
ramneek mehresh16b08062013-09-12 16:35:49 +0530247 struct usb_ehci *ehci = (struct usb_ehci *)CONFIG_SYS_FSL_USB1_ADDR;
Vivek Mahajan288f7fb2009-05-25 17:23:16 +0530248
249 /* Configure interface. */
Vivek Mahajan2d421c12009-06-24 10:08:40 +0530250 setbits_be32(&ehci->control, REFSEL_16MHZ | UTMI_PHY_EN);
Vivek Mahajan288f7fb2009-05-25 17:23:16 +0530251
252 /* Wait for clock to stabilize */
253 do {
Kim Phillips328040a2009-09-25 18:19:44 -0500254 temp = __raw_readl(&ehci->control);
Vivek Mahajan288f7fb2009-05-25 17:23:16 +0530255 udelay(1000);
256 } while (!(temp & PHY_CLK_VALID));
257#endif
Eran Liberty9095d4a2005-07-28 10:08:46 -0500258}
259
Eran Liberty9095d4a2005-07-28 10:08:46 -0500260int cpu_init_r (void)
261{
Dave Liue732e9c2006-11-03 12:11:15 -0600262#ifdef CONFIG_QE
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200263 uint qe_base = CONFIG_SYS_IMMR + 0x00100000; /* QE immr base */
Kim Phillips328040a2009-09-25 18:19:44 -0500264
Dave Liue732e9c2006-11-03 12:11:15 -0600265 qe_init(qe_base);
266 qe_reset();
267#endif
Eran Liberty9095d4a2005-07-28 10:08:46 -0500268 return 0;
269}
Dave Liuebd35f82007-06-25 10:41:56 +0800270
Nick Spence56fd3c22008-08-28 14:09:19 -0700271/*
272 * Print out the bus arbiter event
273 */
274#if defined(CONFIG_DISPLAY_AER_FULL)
275static int print_83xx_arb_event(int force)
276{
277 static char* event[] = {
278 "Address Time Out",
279 "Data Time Out",
280 "Address Only Transfer Type",
281 "External Control Word Transfer Type",
282 "Reserved Transfer Type",
283 "Transfer Error",
284 "reserved",
285 "reserved"
286 };
287 static char* master[] = {
288 "e300 Core Data Transaction",
289 "reserved",
290 "e300 Core Instruction Fetch",
291 "reserved",
292 "TSEC1",
293 "TSEC2",
294 "USB MPH",
295 "USB DR",
296 "Encryption Core",
297 "I2C Boot Sequencer",
298 "JTAG",
299 "reserved",
300 "eSDHC",
301 "PCI1",
302 "PCI2",
303 "DMA",
304 "QUICC Engine 00",
305 "QUICC Engine 01",
306 "QUICC Engine 10",
307 "QUICC Engine 11",
308 "reserved",
309 "reserved",
310 "reserved",
311 "reserved",
312 "SATA1",
313 "SATA2",
314 "SATA3",
315 "SATA4",
316 "reserved",
317 "PCI Express 1",
318 "PCI Express 2",
319 "TDM-DMAC"
320 };
321 static char *transfer[] = {
322 "Address-only, Clean Block",
323 "Address-only, lwarx reservation set",
324 "Single-beat or Burst write",
325 "reserved",
326 "Address-only, Flush Block",
327 "reserved",
328 "Burst write",
329 "reserved",
330 "Address-only, sync",
331 "Address-only, tlbsync",
332 "Single-beat or Burst read",
333 "Single-beat or Burst read",
334 "Address-only, Kill Block",
335 "Address-only, icbi",
336 "Burst read",
337 "reserved",
338 "Address-only, eieio",
339 "reserved",
340 "Single-beat write",
341 "reserved",
342 "ecowx - Illegal single-beat write",
343 "reserved",
344 "reserved",
345 "reserved",
346 "Address-only, TLB Invalidate",
347 "reserved",
348 "Single-beat or Burst read",
349 "reserved",
350 "eciwx - Illegal single-beat read",
351 "reserved",
352 "Burst read",
353 "reserved"
354 };
355
Simon Glass387a1f22012-12-13 20:48:57 +0000356 int etype = (gd->arch.arbiter_event_attributes & AEATR_EVENT)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200357 >> AEATR_EVENT_SHIFT;
Simon Glass387a1f22012-12-13 20:48:57 +0000358 int mstr_id = (gd->arch.arbiter_event_attributes & AEATR_MSTR_ID)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200359 >> AEATR_MSTR_ID_SHIFT;
Simon Glass387a1f22012-12-13 20:48:57 +0000360 int tbst = (gd->arch.arbiter_event_attributes & AEATR_TBST)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200361 >> AEATR_TBST_SHIFT;
Simon Glass387a1f22012-12-13 20:48:57 +0000362 int tsize = (gd->arch.arbiter_event_attributes & AEATR_TSIZE)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200363 >> AEATR_TSIZE_SHIFT;
Simon Glass387a1f22012-12-13 20:48:57 +0000364 int ttype = (gd->arch.arbiter_event_attributes & AEATR_TTYPE)
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200365 >> AEATR_TTYPE_SHIFT;
Nick Spence56fd3c22008-08-28 14:09:19 -0700366
Simon Glass387a1f22012-12-13 20:48:57 +0000367 if (!force && !gd->arch.arbiter_event_address)
Nick Spence56fd3c22008-08-28 14:09:19 -0700368 return 0;
369
370 puts("Arbiter Event Status:\n");
Simon Glass387a1f22012-12-13 20:48:57 +0000371 printf(" Event Address: 0x%08lX\n",
372 gd->arch.arbiter_event_address);
Nick Spence56fd3c22008-08-28 14:09:19 -0700373 printf(" Event Type: 0x%1x = %s\n", etype, event[etype]);
374 printf(" Master ID: 0x%02x = %s\n", mstr_id, master[mstr_id]);
375 printf(" Transfer Size: 0x%1x = %d bytes\n", (tbst<<3) | tsize,
376 tbst ? (tsize ? tsize : 8) : 16 + 8 * tsize);
377 printf(" Transfer Type: 0x%02x = %s\n", ttype, transfer[ttype]);
378
Simon Glass387a1f22012-12-13 20:48:57 +0000379 return gd->arch.arbiter_event_address;
Nick Spence56fd3c22008-08-28 14:09:19 -0700380}
381
382#elif defined(CONFIG_DISPLAY_AER_BRIEF)
383
384static int print_83xx_arb_event(int force)
385{
Simon Glass387a1f22012-12-13 20:48:57 +0000386 if (!force && !gd->arch.arbiter_event_address)
Nick Spence56fd3c22008-08-28 14:09:19 -0700387 return 0;
388
389 printf("Arbiter Event Status: AEATR=0x%08lX, AEADR=0x%08lX\n",
Simon Glass387a1f22012-12-13 20:48:57 +0000390 gd->arch.arbiter_event_attributes,
391 gd->arch.arbiter_event_address);
Nick Spence56fd3c22008-08-28 14:09:19 -0700392
Simon Glass387a1f22012-12-13 20:48:57 +0000393 return gd->arch.arbiter_event_address;
Nick Spence56fd3c22008-08-28 14:09:19 -0700394}
395#endif /* CONFIG_DISPLAY_AER_xxxx */
396
Mario Six28fbefa2018-08-06 10:23:45 +0200397#ifndef CONFIG_CPU_MPC83XX
Dave Liuebd35f82007-06-25 10:41:56 +0800398/*
399 * Figure out the cause of the reset
400 */
401int prt_83xx_rsr(void)
402{
403 static struct {
404 ulong mask;
405 char *desc;
406 } bits[] = {
407 {
408 RSR_SWSR, "Software Soft"}, {
409 RSR_SWHR, "Software Hard"}, {
410 RSR_JSRS, "JTAG Soft"}, {
411 RSR_CSHR, "Check Stop"}, {
412 RSR_SWRS, "Software Watchdog"}, {
413 RSR_BMRS, "Bus Monitor"}, {
414 RSR_SRS, "External/Internal Soft"}, {
415 RSR_HRS, "External/Internal Hard"}
416 };
Robert P. J. Day0c911592016-05-23 06:49:21 -0400417 static int n = ARRAY_SIZE(bits);
Simon Glass4d6eaa32012-12-13 20:48:56 +0000418 ulong rsr = gd->arch.reset_status;
Dave Liuebd35f82007-06-25 10:41:56 +0800419 int i;
420 char *sep;
421
422 puts("Reset Status:");
423
424 sep = " ";
425 for (i = 0; i < n; i++)
426 if (rsr & bits[i].mask) {
427 printf("%s%s", sep, bits[i].desc);
428 sep = ", ";
429 }
Nick Spence56fd3c22008-08-28 14:09:19 -0700430 puts("\n");
431
432#if defined(CONFIG_DISPLAY_AER_FULL) || defined(CONFIG_DISPLAY_AER_BRIEF)
433 print_83xx_arb_event(rsr & RSR_BMRS);
434#endif
435 puts("\n");
436
Dave Liuebd35f82007-06-25 10:41:56 +0800437 return 0;
438}
Mario Six28fbefa2018-08-06 10:23:45 +0200439#endif