Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 2 | /* |
Vivek Mahajan | 288f7fb | 2009-05-25 17:23:16 +0530 | [diff] [blame] | 3 | * Copyright (C) 2004-2009 Freescale Semiconductor, Inc. |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 4 | */ |
| 5 | |
Simon Glass | 40d9b24 | 2020-05-10 11:40:07 -0600 | [diff] [blame] | 6 | #include <asm-offsets.h> |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 7 | #include <mpc83xx.h> |
Tom Rini | 4ddbade | 2022-05-25 12:16:03 -0400 | [diff] [blame] | 8 | #include <system-constants.h> |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 9 | #include <ioports.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 10 | #include <asm/global_data.h> |
Vivek Mahajan | 288f7fb | 2009-05-25 17:23:16 +0530 | [diff] [blame] | 11 | #include <asm/io.h> |
Simon Glass | 156283f | 2017-03-28 10:27:27 -0600 | [diff] [blame] | 12 | #include <asm/processor.h> |
Heiko Schocher | 3b76773 | 2020-04-15 10:35:40 +0200 | [diff] [blame] | 13 | #include <fsl_qe.h> |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 14 | #ifdef CONFIG_USB_EHCI_FSL |
Mateusz Kulikowski | 3add69e | 2016-03-31 23:12:23 +0200 | [diff] [blame] | 15 | #include <usb/ehci-ci.h> |
Vivek Mahajan | 288f7fb | 2009-05-25 17:23:16 +0530 | [diff] [blame] | 16 | #endif |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 17 | #include <linux/delay.h> |
Heiko Schocher | 3b07a13 | 2020-02-03 10:23:53 +0100 | [diff] [blame] | 18 | #ifdef CONFIG_QE |
| 19 | #include <fsl_qe.h> |
| 20 | #endif |
Tom Rini | 7a21355 | 2023-11-01 12:28:11 -0400 | [diff] [blame] | 21 | #include <asm/ppc.h> |
| 22 | #include <asm/fsl_lbc.h> |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 23 | |
Mario Six | b47839c | 2019-01-21 09:17:58 +0100 | [diff] [blame] | 24 | #include "lblaw/lblaw.h" |
Mario Six | 1faf95d | 2019-01-21 09:18:03 +0100 | [diff] [blame] | 25 | #include "elbc/elbc.h" |
Mario Six | 636c108 | 2019-01-21 09:18:11 +0100 | [diff] [blame] | 26 | #include "sysio/sysio.h" |
Mario Six | aa50254 | 2019-01-21 09:18:12 +0100 | [diff] [blame] | 27 | #include "arbiter/arbiter.h" |
Mario Six | f62074e | 2019-01-21 09:18:13 +0100 | [diff] [blame] | 28 | #include "initreg/initreg.h" |
Mario Six | b47839c | 2019-01-21 09:17:58 +0100 | [diff] [blame] | 29 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 30 | DECLARE_GLOBAL_DATA_PTR; |
| 31 | |
Dave Liu | e732e9c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 32 | #ifdef CONFIG_QE |
| 33 | extern qe_iop_conf_t qe_iop_conf_tab[]; |
| 34 | extern void qe_config_iopin(u8 port, u8 pin, int dir, |
| 35 | int open_drain, int assign); |
Dave Liu | e732e9c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 36 | |
Heiko Schocher | 3b07a13 | 2020-02-03 10:23:53 +0100 | [diff] [blame] | 37 | #if !defined(CONFIG_PINCTRL) |
Dave Liu | e732e9c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 38 | static void config_qe_ioports(void) |
| 39 | { |
| 40 | u8 port, pin; |
| 41 | int dir, open_drain, assign; |
| 42 | int i; |
| 43 | |
| 44 | for (i = 0; qe_iop_conf_tab[i].assign != QE_IOP_TAB_END; i++) { |
| 45 | port = qe_iop_conf_tab[i].port; |
| 46 | pin = qe_iop_conf_tab[i].pin; |
| 47 | dir = qe_iop_conf_tab[i].dir; |
| 48 | open_drain = qe_iop_conf_tab[i].open_drain; |
| 49 | assign = qe_iop_conf_tab[i].assign; |
| 50 | qe_config_iopin(port, pin, dir, open_drain, assign); |
| 51 | } |
| 52 | } |
| 53 | #endif |
Heiko Schocher | 3b07a13 | 2020-02-03 10:23:53 +0100 | [diff] [blame] | 54 | #endif |
Dave Liu | e732e9c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 55 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 56 | /* |
| 57 | * Breathe some life into the CPU... |
| 58 | * |
| 59 | * Set up the memory map, |
| 60 | * initialize a bunch of registers, |
| 61 | * initialize the UPM's |
| 62 | */ |
| 63 | void cpu_init_f (volatile immap_t * im) |
| 64 | { |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 65 | __be32 sccr_mask = |
| 66 | #ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 67 | SCCR_ENCCM | |
Kim Phillips | 19a91de | 2008-01-16 12:06:16 -0600 | [diff] [blame] | 68 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 69 | #ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 70 | SCCR_PCICM | |
Kim Phillips | 19a91de | 2008-01-16 12:06:16 -0600 | [diff] [blame] | 71 | #endif |
Ilya Yanok | a4f3ed3 | 2010-09-17 23:41:47 +0200 | [diff] [blame] | 72 | #ifdef CONFIG_SYS_SCCR_PCIEXP1CM /* PCIE1 clock mode */ |
| 73 | SCCR_PCIEXP1CM | |
| 74 | #endif |
| 75 | #ifdef CONFIG_SYS_SCCR_PCIEXP2CM /* PCIE2 clock mode */ |
| 76 | SCCR_PCIEXP2CM | |
| 77 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 78 | #ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 79 | SCCR_TSECCM | |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 80 | #endif |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 81 | #ifdef CFG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 82 | SCCR_TSEC1CM | |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 83 | #endif |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 84 | #ifdef CFG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 85 | SCCR_TSEC2CM | |
Kumar Gala | 15c3f69 | 2007-02-27 23:51:42 -0600 | [diff] [blame] | 86 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 87 | #ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 88 | SCCR_TSEC1ON | |
Timur Tabi | 0b2deff | 2007-07-03 13:04:34 -0500 | [diff] [blame] | 89 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 90 | #ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 91 | SCCR_TSEC2ON | |
Timur Tabi | 0b2deff | 2007-07-03 13:04:34 -0500 | [diff] [blame] | 92 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 93 | #ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 94 | SCCR_USBMPHCM | |
Kumar Gala | 15c3f69 | 2007-02-27 23:51:42 -0600 | [diff] [blame] | 95 | #endif |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 96 | #ifdef CFG_SYS_SCCR_USBDRCM /* USB DR clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 97 | SCCR_USBDRCM | |
Kumar Gala | 15c3f69 | 2007-02-27 23:51:42 -0600 | [diff] [blame] | 98 | #endif |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 99 | #ifdef CFG_SYS_SCCR_SATACM /* SATA controller clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 100 | SCCR_SATACM | |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 101 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 102 | 0; |
| 103 | __be32 sccr_val = |
| 104 | #ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */ |
| 105 | (CONFIG_SYS_SCCR_ENCCM << SCCR_ENCCM_SHIFT) | |
| 106 | #endif |
| 107 | #ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */ |
| 108 | (CONFIG_SYS_SCCR_PCICM << SCCR_PCICM_SHIFT) | |
| 109 | #endif |
Ilya Yanok | a4f3ed3 | 2010-09-17 23:41:47 +0200 | [diff] [blame] | 110 | #ifdef CONFIG_SYS_SCCR_PCIEXP1CM /* PCIE1 clock mode */ |
| 111 | (CONFIG_SYS_SCCR_PCIEXP1CM << SCCR_PCIEXP1CM_SHIFT) | |
| 112 | #endif |
| 113 | #ifdef CONFIG_SYS_SCCR_PCIEXP2CM /* PCIE2 clock mode */ |
| 114 | (CONFIG_SYS_SCCR_PCIEXP2CM << SCCR_PCIEXP2CM_SHIFT) | |
| 115 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 116 | #ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */ |
| 117 | (CONFIG_SYS_SCCR_TSECCM << SCCR_TSECCM_SHIFT) | |
| 118 | #endif |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 119 | #ifdef CFG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */ |
| 120 | (CFG_SYS_SCCR_TSEC1CM << SCCR_TSEC1CM_SHIFT) | |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 121 | #endif |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 122 | #ifdef CFG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */ |
| 123 | (CFG_SYS_SCCR_TSEC2CM << SCCR_TSEC2CM_SHIFT) | |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 124 | #endif |
| 125 | #ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */ |
| 126 | (CONFIG_SYS_SCCR_TSEC1ON << SCCR_TSEC1ON_SHIFT) | |
| 127 | #endif |
| 128 | #ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */ |
| 129 | (CONFIG_SYS_SCCR_TSEC2ON << SCCR_TSEC2ON_SHIFT) | |
| 130 | #endif |
| 131 | #ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */ |
| 132 | (CONFIG_SYS_SCCR_USBMPHCM << SCCR_USBMPHCM_SHIFT) | |
| 133 | #endif |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 134 | #ifdef CFG_SYS_SCCR_USBDRCM /* USB DR clock mode */ |
| 135 | (CFG_SYS_SCCR_USBDRCM << SCCR_USBDRCM_SHIFT) | |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 136 | #endif |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 137 | #ifdef CFG_SYS_SCCR_SATACM /* SATA controller clock mode */ |
| 138 | (CFG_SYS_SCCR_SATACM << SCCR_SATACM_SHIFT) | |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 139 | #endif |
| 140 | 0; |
| 141 | |
| 142 | /* Pointer is writable since we allocated a register for it */ |
Tom Rini | 4ddbade | 2022-05-25 12:16:03 -0400 | [diff] [blame] | 143 | gd = (gd_t *)SYS_INIT_SP_ADDR; |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 144 | |
mario.six@gdsys.cc | 85df7b4 | 2017-01-17 08:33:48 +0100 | [diff] [blame] | 145 | /* global data region was cleared in start.S */ |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 146 | |
| 147 | /* system performance tweaking */ |
| 148 | clrsetbits_be32(&im->arbiter.acr, acr_mask, acr_val); |
| 149 | |
| 150 | clrsetbits_be32(&im->sysconf.spcr, spcr_mask, spcr_val); |
| 151 | |
| 152 | clrsetbits_be32(&im->clk.sccr, sccr_mask, sccr_val); |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 153 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 154 | /* RSR - Reset Status Register - clear all status (4.6.1.3) */ |
Simon Glass | 4d6eaa3 | 2012-12-13 20:48:56 +0000 | [diff] [blame] | 155 | gd->arch.reset_status = __raw_readl(&im->reset.rsr); |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 156 | __raw_writel(~(RSR_RES), &im->reset.rsr); |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 157 | |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 158 | /* AER - Arbiter Event Register - store status */ |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 159 | gd->arch.arbiter_event_attributes = __raw_readl(&im->arbiter.aeatr); |
| 160 | gd->arch.arbiter_event_address = __raw_readl(&im->arbiter.aeadr); |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 161 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 162 | /* |
| 163 | * RMR - Reset Mode Register |
| 164 | * contains checkstop reset enable (4.6.1.4) |
| 165 | */ |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 166 | __raw_writel(RMR_CSRE & (1<<RMR_CSRE_SHIFT), &im->reset.rmr); |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 167 | |
Peter Korsgaard | 2a483ee | 2009-12-08 22:20:34 +0100 | [diff] [blame] | 168 | /* LCRR - Clock Ratio Register (10.3.1.16) |
| 169 | * write, read, and isync per MPC8379ERM rev.1 CLKDEV field description |
| 170 | */ |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 171 | clrsetbits_be32(&im->im_lbc.lcrr, lcrr_mask, lcrr_val); |
| 172 | __raw_readl(&im->im_lbc.lcrr); |
Peter Korsgaard | 2a483ee | 2009-12-08 22:20:34 +0100 | [diff] [blame] | 173 | isync(); |
| 174 | |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 175 | /* Enable Time Base & Decrementer ( so we will have udelay() )*/ |
| 176 | setbits_be32(&im->sysconf.spcr, SPCR_TBEN); |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 177 | |
| 178 | /* System General Purpose Register */ |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 179 | #ifdef CFG_SYS_SICRH |
Mario Six | 0344f5e | 2019-01-21 09:17:27 +0100 | [diff] [blame] | 180 | #if defined(CONFIG_ARCH_MPC834X) || defined(CONFIG_ARCH_MPC8313) |
Andre Schwarz | cea6648 | 2008-06-23 11:40:56 +0200 | [diff] [blame] | 181 | /* regarding to MPC34x manual rev.1 bits 28..29 must be preserved */ |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 182 | __raw_writel((im->sysconf.sicrh & 0x0000000C) | CFG_SYS_SICRH, |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 183 | &im->sysconf.sicrh); |
Andre Schwarz | cea6648 | 2008-06-23 11:40:56 +0200 | [diff] [blame] | 184 | #else |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 185 | __raw_writel(CFG_SYS_SICRH, &im->sysconf.sicrh); |
Kumar Gala | e522143 | 2006-01-11 11:12:57 -0600 | [diff] [blame] | 186 | #endif |
Andre Schwarz | cea6648 | 2008-06-23 11:40:56 +0200 | [diff] [blame] | 187 | #endif |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 188 | #ifdef CFG_SYS_SICRL |
| 189 | __raw_writel(CFG_SYS_SICRL, &im->sysconf.sicrl); |
Kumar Gala | e522143 | 2006-01-11 11:12:57 -0600 | [diff] [blame] | 190 | #endif |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 191 | #ifdef CFG_SYS_GPR1 |
| 192 | __raw_writel(CFG_SYS_GPR1, &im->sysconf.gpr1); |
Gerlando Falauto | fe201cb | 2012-10-10 22:13:08 +0000 | [diff] [blame] | 193 | #endif |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 194 | #ifdef CFG_SYS_DDRCDR /* DDR control driver register */ |
| 195 | __raw_writel(CFG_SYS_DDRCDR, &im->sysconf.ddrcdr); |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 196 | #endif |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 197 | #ifdef CFG_SYS_OBIR /* Output buffer impedance register */ |
| 198 | __raw_writel(CFG_SYS_OBIR, &im->sysconf.obir); |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 199 | #endif |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 200 | |
Heiko Schocher | 3b07a13 | 2020-02-03 10:23:53 +0100 | [diff] [blame] | 201 | #if !defined(CONFIG_PINCTRL) |
Dave Liu | e732e9c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 202 | #ifdef CONFIG_QE |
| 203 | /* Config QE ioports */ |
| 204 | config_qe_ioports(); |
| 205 | #endif |
Heiko Schocher | 3b07a13 | 2020-02-03 10:23:53 +0100 | [diff] [blame] | 206 | #endif |
| 207 | |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 208 | /* Set up preliminary BR/OR regs */ |
| 209 | init_early_memctl_regs(); |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 210 | |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 211 | /* Local Access window setup */ |
Tom Rini | 364d002 | 2023-01-10 11:19:45 -0500 | [diff] [blame] | 212 | #if defined(CFG_SYS_LBLAWBAR0_PRELIM) && defined(CFG_SYS_LBLAWAR0_PRELIM) |
| 213 | im->sysconf.lblaw[0].bar = CFG_SYS_LBLAWBAR0_PRELIM; |
| 214 | im->sysconf.lblaw[0].ar = CFG_SYS_LBLAWAR0_PRELIM; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 215 | #else |
Tom Rini | 364d002 | 2023-01-10 11:19:45 -0500 | [diff] [blame] | 216 | #error CFG_SYS_LBLAWBAR0_PRELIM & CFG_SYS_LBLAWAR0_PRELIM must be defined |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 217 | #endif |
| 218 | |
Tom Rini | 364d002 | 2023-01-10 11:19:45 -0500 | [diff] [blame] | 219 | #if defined(CFG_SYS_LBLAWBAR1_PRELIM) && defined(CFG_SYS_LBLAWAR1_PRELIM) |
| 220 | im->sysconf.lblaw[1].bar = CFG_SYS_LBLAWBAR1_PRELIM; |
| 221 | im->sysconf.lblaw[1].ar = CFG_SYS_LBLAWAR1_PRELIM; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 222 | #endif |
Tom Rini | 364d002 | 2023-01-10 11:19:45 -0500 | [diff] [blame] | 223 | #if defined(CFG_SYS_LBLAWBAR2_PRELIM) && defined(CFG_SYS_LBLAWAR2_PRELIM) |
| 224 | im->sysconf.lblaw[2].bar = CFG_SYS_LBLAWBAR2_PRELIM; |
| 225 | im->sysconf.lblaw[2].ar = CFG_SYS_LBLAWAR2_PRELIM; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 226 | #endif |
Tom Rini | 364d002 | 2023-01-10 11:19:45 -0500 | [diff] [blame] | 227 | #if defined(CFG_SYS_LBLAWBAR3_PRELIM) && defined(CFG_SYS_LBLAWAR3_PRELIM) |
| 228 | im->sysconf.lblaw[3].bar = CFG_SYS_LBLAWBAR3_PRELIM; |
| 229 | im->sysconf.lblaw[3].ar = CFG_SYS_LBLAWAR3_PRELIM; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 230 | #endif |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 231 | } |
| 232 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 233 | int cpu_init_r (void) |
| 234 | { |
Dave Liu | e732e9c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 235 | #ifdef CONFIG_QE |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 236 | uint qe_base = CONFIG_SYS_IMMR + 0x00100000; /* QE immr base */ |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 237 | |
Dave Liu | e732e9c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 238 | qe_init(qe_base); |
| 239 | qe_reset(); |
| 240 | #endif |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 241 | return 0; |
| 242 | } |
Dave Liu | ebd35f8 | 2007-06-25 10:41:56 +0800 | [diff] [blame] | 243 | |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 244 | /* |
| 245 | * Print out the bus arbiter event |
| 246 | */ |
| 247 | #if defined(CONFIG_DISPLAY_AER_FULL) |
| 248 | static int print_83xx_arb_event(int force) |
| 249 | { |
| 250 | static char* event[] = { |
| 251 | "Address Time Out", |
| 252 | "Data Time Out", |
| 253 | "Address Only Transfer Type", |
| 254 | "External Control Word Transfer Type", |
| 255 | "Reserved Transfer Type", |
| 256 | "Transfer Error", |
| 257 | "reserved", |
| 258 | "reserved" |
| 259 | }; |
| 260 | static char* master[] = { |
| 261 | "e300 Core Data Transaction", |
| 262 | "reserved", |
| 263 | "e300 Core Instruction Fetch", |
| 264 | "reserved", |
| 265 | "TSEC1", |
| 266 | "TSEC2", |
| 267 | "USB MPH", |
| 268 | "USB DR", |
| 269 | "Encryption Core", |
| 270 | "I2C Boot Sequencer", |
| 271 | "JTAG", |
| 272 | "reserved", |
| 273 | "eSDHC", |
| 274 | "PCI1", |
| 275 | "PCI2", |
| 276 | "DMA", |
| 277 | "QUICC Engine 00", |
| 278 | "QUICC Engine 01", |
| 279 | "QUICC Engine 10", |
| 280 | "QUICC Engine 11", |
| 281 | "reserved", |
| 282 | "reserved", |
| 283 | "reserved", |
| 284 | "reserved", |
| 285 | "SATA1", |
| 286 | "SATA2", |
| 287 | "SATA3", |
| 288 | "SATA4", |
| 289 | "reserved", |
| 290 | "PCI Express 1", |
| 291 | "PCI Express 2", |
| 292 | "TDM-DMAC" |
| 293 | }; |
| 294 | static char *transfer[] = { |
| 295 | "Address-only, Clean Block", |
| 296 | "Address-only, lwarx reservation set", |
| 297 | "Single-beat or Burst write", |
| 298 | "reserved", |
| 299 | "Address-only, Flush Block", |
| 300 | "reserved", |
| 301 | "Burst write", |
| 302 | "reserved", |
| 303 | "Address-only, sync", |
| 304 | "Address-only, tlbsync", |
| 305 | "Single-beat or Burst read", |
| 306 | "Single-beat or Burst read", |
| 307 | "Address-only, Kill Block", |
| 308 | "Address-only, icbi", |
| 309 | "Burst read", |
| 310 | "reserved", |
| 311 | "Address-only, eieio", |
| 312 | "reserved", |
| 313 | "Single-beat write", |
| 314 | "reserved", |
| 315 | "ecowx - Illegal single-beat write", |
| 316 | "reserved", |
| 317 | "reserved", |
| 318 | "reserved", |
| 319 | "Address-only, TLB Invalidate", |
| 320 | "reserved", |
| 321 | "Single-beat or Burst read", |
| 322 | "reserved", |
| 323 | "eciwx - Illegal single-beat read", |
| 324 | "reserved", |
| 325 | "Burst read", |
| 326 | "reserved" |
| 327 | }; |
| 328 | |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 329 | int etype = (gd->arch.arbiter_event_attributes & AEATR_EVENT) |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 330 | >> AEATR_EVENT_SHIFT; |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 331 | int mstr_id = (gd->arch.arbiter_event_attributes & AEATR_MSTR_ID) |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 332 | >> AEATR_MSTR_ID_SHIFT; |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 333 | int tbst = (gd->arch.arbiter_event_attributes & AEATR_TBST) |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 334 | >> AEATR_TBST_SHIFT; |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 335 | int tsize = (gd->arch.arbiter_event_attributes & AEATR_TSIZE) |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 336 | >> AEATR_TSIZE_SHIFT; |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 337 | int ttype = (gd->arch.arbiter_event_attributes & AEATR_TTYPE) |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 338 | >> AEATR_TTYPE_SHIFT; |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 339 | |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 340 | if (!force && !gd->arch.arbiter_event_address) |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 341 | return 0; |
| 342 | |
| 343 | puts("Arbiter Event Status:\n"); |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 344 | printf(" Event Address: 0x%08lX\n", |
| 345 | gd->arch.arbiter_event_address); |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 346 | printf(" Event Type: 0x%1x = %s\n", etype, event[etype]); |
| 347 | printf(" Master ID: 0x%02x = %s\n", mstr_id, master[mstr_id]); |
| 348 | printf(" Transfer Size: 0x%1x = %d bytes\n", (tbst<<3) | tsize, |
| 349 | tbst ? (tsize ? tsize : 8) : 16 + 8 * tsize); |
| 350 | printf(" Transfer Type: 0x%02x = %s\n", ttype, transfer[ttype]); |
| 351 | |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 352 | return gd->arch.arbiter_event_address; |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | #elif defined(CONFIG_DISPLAY_AER_BRIEF) |
| 356 | |
| 357 | static int print_83xx_arb_event(int force) |
| 358 | { |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 359 | if (!force && !gd->arch.arbiter_event_address) |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 360 | return 0; |
| 361 | |
| 362 | printf("Arbiter Event Status: AEATR=0x%08lX, AEADR=0x%08lX\n", |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 363 | gd->arch.arbiter_event_attributes, |
| 364 | gd->arch.arbiter_event_address); |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 365 | |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 366 | return gd->arch.arbiter_event_address; |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 367 | } |
| 368 | #endif /* CONFIG_DISPLAY_AER_xxxx */ |
| 369 | |
Mario Six | 28fbefa | 2018-08-06 10:23:45 +0200 | [diff] [blame] | 370 | #ifndef CONFIG_CPU_MPC83XX |
Dave Liu | ebd35f8 | 2007-06-25 10:41:56 +0800 | [diff] [blame] | 371 | /* |
| 372 | * Figure out the cause of the reset |
| 373 | */ |
| 374 | int prt_83xx_rsr(void) |
| 375 | { |
| 376 | static struct { |
| 377 | ulong mask; |
| 378 | char *desc; |
| 379 | } bits[] = { |
| 380 | { |
| 381 | RSR_SWSR, "Software Soft"}, { |
| 382 | RSR_SWHR, "Software Hard"}, { |
| 383 | RSR_JSRS, "JTAG Soft"}, { |
| 384 | RSR_CSHR, "Check Stop"}, { |
| 385 | RSR_SWRS, "Software Watchdog"}, { |
| 386 | RSR_BMRS, "Bus Monitor"}, { |
| 387 | RSR_SRS, "External/Internal Soft"}, { |
| 388 | RSR_HRS, "External/Internal Hard"} |
| 389 | }; |
Robert P. J. Day | 0c91159 | 2016-05-23 06:49:21 -0400 | [diff] [blame] | 390 | static int n = ARRAY_SIZE(bits); |
Simon Glass | 4d6eaa3 | 2012-12-13 20:48:56 +0000 | [diff] [blame] | 391 | ulong rsr = gd->arch.reset_status; |
Dave Liu | ebd35f8 | 2007-06-25 10:41:56 +0800 | [diff] [blame] | 392 | int i; |
| 393 | char *sep; |
| 394 | |
| 395 | puts("Reset Status:"); |
| 396 | |
| 397 | sep = " "; |
| 398 | for (i = 0; i < n; i++) |
| 399 | if (rsr & bits[i].mask) { |
| 400 | printf("%s%s", sep, bits[i].desc); |
| 401 | sep = ", "; |
| 402 | } |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 403 | puts("\n"); |
| 404 | |
| 405 | #if defined(CONFIG_DISPLAY_AER_FULL) || defined(CONFIG_DISPLAY_AER_BRIEF) |
| 406 | print_83xx_arb_event(rsr & RSR_BMRS); |
| 407 | #endif |
| 408 | puts("\n"); |
| 409 | |
Dave Liu | ebd35f8 | 2007-06-25 10:41:56 +0800 | [diff] [blame] | 410 | return 0; |
| 411 | } |
Mario Six | 28fbefa | 2018-08-06 10:23:45 +0200 | [diff] [blame] | 412 | #endif |