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 | |
| 6 | #include <common.h> |
| 7 | #include <mpc83xx.h> |
| 8 | #include <ioports.h> |
Vivek Mahajan | 288f7fb | 2009-05-25 17:23:16 +0530 | [diff] [blame] | 9 | #include <asm/io.h> |
Simon Glass | 156283f | 2017-03-28 10:27:27 -0600 | [diff] [blame] | 10 | #include <asm/processor.h> |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 11 | #ifdef CONFIG_USB_EHCI_FSL |
Mateusz Kulikowski | 3add69e | 2016-03-31 23:12:23 +0200 | [diff] [blame] | 12 | #include <usb/ehci-ci.h> |
Vivek Mahajan | 288f7fb | 2009-05-25 17:23:16 +0530 | [diff] [blame] | 13 | #endif |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 14 | |
Mario Six | b47839c | 2019-01-21 09:17:58 +0100 | [diff] [blame] | 15 | #include "lblaw/lblaw.h" |
Mario Six | 1faf95d | 2019-01-21 09:18:03 +0100 | [diff] [blame] | 16 | #include "elbc/elbc.h" |
Mario Six | 636c108 | 2019-01-21 09:18:11 +0100 | [diff] [blame] | 17 | #include "sysio/sysio.h" |
Mario Six | aa50254 | 2019-01-21 09:18:12 +0100 | [diff] [blame] | 18 | #include "arbiter/arbiter.h" |
Mario Six | f62074e | 2019-01-21 09:18:13 +0100 | [diff] [blame^] | 19 | #include "initreg/initreg.h" |
Mario Six | b47839c | 2019-01-21 09:17:58 +0100 | [diff] [blame] | 20 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
Dave Liu | e732e9c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 23 | #ifdef CONFIG_QE |
| 24 | extern qe_iop_conf_t qe_iop_conf_tab[]; |
| 25 | extern void qe_config_iopin(u8 port, u8 pin, int dir, |
| 26 | int open_drain, int assign); |
| 27 | extern void qe_init(uint qe_base); |
| 28 | extern void qe_reset(void); |
| 29 | |
| 30 | static 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 Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 47 | /* |
| 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 | */ |
| 54 | void cpu_init_f (volatile immap_t * im) |
| 55 | { |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 56 | __be32 sccr_mask = |
| 57 | #ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 58 | SCCR_ENCCM | |
Kim Phillips | 19a91de | 2008-01-16 12:06:16 -0600 | [diff] [blame] | 59 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 60 | #ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 61 | SCCR_PCICM | |
Kim Phillips | 19a91de | 2008-01-16 12:06:16 -0600 | [diff] [blame] | 62 | #endif |
Ilya Yanok | a4f3ed3 | 2010-09-17 23:41:47 +0200 | [diff] [blame] | 63 | #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 Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 69 | #ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 70 | SCCR_TSECCM | |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 71 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 72 | #ifdef CONFIG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 73 | SCCR_TSEC1CM | |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 74 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 75 | #ifdef CONFIG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 76 | SCCR_TSEC2CM | |
Kumar Gala | 15c3f69 | 2007-02-27 23:51:42 -0600 | [diff] [blame] | 77 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 78 | #ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 79 | SCCR_TSEC1ON | |
Timur Tabi | 0b2deff | 2007-07-03 13:04:34 -0500 | [diff] [blame] | 80 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 81 | #ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 82 | SCCR_TSEC2ON | |
Timur Tabi | 0b2deff | 2007-07-03 13:04:34 -0500 | [diff] [blame] | 83 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 84 | #ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 85 | SCCR_USBMPHCM | |
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_USBDRCM /* USB DR clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 88 | SCCR_USBDRCM | |
Kumar Gala | 15c3f69 | 2007-02-27 23:51:42 -0600 | [diff] [blame] | 89 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 90 | #ifdef CONFIG_SYS_SCCR_SATACM /* SATA controller clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 91 | SCCR_SATACM | |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 92 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 93 | 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 Yanok | a4f3ed3 | 2010-09-17 23:41:47 +0200 | [diff] [blame] | 101 | #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 Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 107 | #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 Korsgaard | 2a483ee | 2009-12-08 22:20:34 +0100 | [diff] [blame] | 132 | __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 Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 154 | |
| 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.cc | 85df7b4 | 2017-01-17 08:33:48 +0100 | [diff] [blame] | 158 | /* global data region was cleared in start.S */ |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 159 | |
| 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 Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 166 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 167 | /* RSR - Reset Status Register - clear all status (4.6.1.3) */ |
Simon Glass | 4d6eaa3 | 2012-12-13 20:48:56 +0000 | [diff] [blame] | 168 | gd->arch.reset_status = __raw_readl(&im->reset.rsr); |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 169 | __raw_writel(~(RSR_RES), &im->reset.rsr); |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 170 | |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 171 | /* AER - Arbiter Event Register - store status */ |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 172 | gd->arch.arbiter_event_attributes = __raw_readl(&im->arbiter.aeatr); |
| 173 | gd->arch.arbiter_event_address = __raw_readl(&im->arbiter.aeadr); |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 174 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 175 | /* |
| 176 | * RMR - Reset Mode Register |
| 177 | * contains checkstop reset enable (4.6.1.4) |
| 178 | */ |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 179 | __raw_writel(RMR_CSRE & (1<<RMR_CSRE_SHIFT), &im->reset.rmr); |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 180 | |
Peter Korsgaard | 2a483ee | 2009-12-08 22:20:34 +0100 | [diff] [blame] | 181 | /* LCRR - Clock Ratio Register (10.3.1.16) |
| 182 | * write, read, and isync per MPC8379ERM rev.1 CLKDEV field description |
| 183 | */ |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 184 | clrsetbits_be32(&im->im_lbc.lcrr, lcrr_mask, lcrr_val); |
| 185 | __raw_readl(&im->im_lbc.lcrr); |
Peter Korsgaard | 2a483ee | 2009-12-08 22:20:34 +0100 | [diff] [blame] | 186 | isync(); |
| 187 | |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 188 | /* Enable Time Base & Decrementer ( so we will have udelay() )*/ |
| 189 | setbits_be32(&im->sysconf.spcr, SPCR_TBEN); |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 190 | |
| 191 | /* System General Purpose Register */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 192 | #ifdef CONFIG_SYS_SICRH |
Mario Six | 0344f5e | 2019-01-21 09:17:27 +0100 | [diff] [blame] | 193 | #if defined(CONFIG_ARCH_MPC834X) || defined(CONFIG_ARCH_MPC8313) |
Andre Schwarz | cea6648 | 2008-06-23 11:40:56 +0200 | [diff] [blame] | 194 | /* regarding to MPC34x manual rev.1 bits 28..29 must be preserved */ |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 195 | __raw_writel((im->sysconf.sicrh & 0x0000000C) | CONFIG_SYS_SICRH, |
| 196 | &im->sysconf.sicrh); |
Andre Schwarz | cea6648 | 2008-06-23 11:40:56 +0200 | [diff] [blame] | 197 | #else |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 198 | __raw_writel(CONFIG_SYS_SICRH, &im->sysconf.sicrh); |
Kumar Gala | e522143 | 2006-01-11 11:12:57 -0600 | [diff] [blame] | 199 | #endif |
Andre Schwarz | cea6648 | 2008-06-23 11:40:56 +0200 | [diff] [blame] | 200 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 201 | #ifdef CONFIG_SYS_SICRL |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 202 | __raw_writel(CONFIG_SYS_SICRL, &im->sysconf.sicrl); |
Kumar Gala | e522143 | 2006-01-11 11:12:57 -0600 | [diff] [blame] | 203 | #endif |
Gerlando Falauto | fe201cb | 2012-10-10 22:13:08 +0000 | [diff] [blame] | 204 | #ifdef CONFIG_SYS_GPR1 |
| 205 | __raw_writel(CONFIG_SYS_GPR1, &im->sysconf.gpr1); |
| 206 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 207 | #ifdef CONFIG_SYS_DDRCDR /* DDR control driver register */ |
| 208 | __raw_writel(CONFIG_SYS_DDRCDR, &im->sysconf.ddrcdr); |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 209 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 210 | #ifdef CONFIG_SYS_OBIR /* Output buffer impedance register */ |
| 211 | __raw_writel(CONFIG_SYS_OBIR, &im->sysconf.obir); |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 212 | #endif |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 213 | |
Dave Liu | e732e9c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 214 | #ifdef CONFIG_QE |
| 215 | /* Config QE ioports */ |
| 216 | config_qe_ioports(); |
| 217 | #endif |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 218 | /* Set up preliminary BR/OR regs */ |
| 219 | init_early_memctl_regs(); |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 220 | |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 221 | /* Local Access window setup */ |
| 222 | #if defined(CONFIG_SYS_LBLAWBAR0_PRELIM) && defined(CONFIG_SYS_LBLAWAR0_PRELIM) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 223 | im->sysconf.lblaw[0].bar = CONFIG_SYS_LBLAWBAR0_PRELIM; |
| 224 | im->sysconf.lblaw[0].ar = CONFIG_SYS_LBLAWAR0_PRELIM; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 225 | #else |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 226 | #error CONFIG_SYS_LBLAWBAR0_PRELIM & CONFIG_SYS_LBLAWAR0_PRELIM must be defined |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 227 | #endif |
| 228 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 229 | #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 Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 232 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 233 | #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 Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 236 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 237 | #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 Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 240 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 241 | #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 Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 244 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 245 | #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 Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 248 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 249 | #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 Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 252 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 253 | #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 Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 256 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 257 | #ifdef CONFIG_SYS_GPIO1_PRELIM |
| 258 | im->gpio[0].dat = CONFIG_SYS_GPIO1_DAT; |
| 259 | im->gpio[0].dir = CONFIG_SYS_GPIO1_DIR; |
Kumar Gala | ab7ec4f | 2006-01-11 11:21:14 -0600 | [diff] [blame] | 260 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 261 | #ifdef CONFIG_SYS_GPIO2_PRELIM |
| 262 | im->gpio[1].dat = CONFIG_SYS_GPIO2_DAT; |
| 263 | im->gpio[1].dir = CONFIG_SYS_GPIO2_DIR; |
Kumar Gala | ab7ec4f | 2006-01-11 11:21:14 -0600 | [diff] [blame] | 264 | #endif |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 265 | #if defined(CONFIG_USB_EHCI_FSL) && defined(CONFIG_ARCH_MPC831X) |
Vivek Mahajan | 288f7fb | 2009-05-25 17:23:16 +0530 | [diff] [blame] | 266 | uint32_t temp; |
ramneek mehresh | 16b0806 | 2013-09-12 16:35:49 +0530 | [diff] [blame] | 267 | struct usb_ehci *ehci = (struct usb_ehci *)CONFIG_SYS_FSL_USB1_ADDR; |
Vivek Mahajan | 288f7fb | 2009-05-25 17:23:16 +0530 | [diff] [blame] | 268 | |
| 269 | /* Configure interface. */ |
Vivek Mahajan | 2d421c1 | 2009-06-24 10:08:40 +0530 | [diff] [blame] | 270 | setbits_be32(&ehci->control, REFSEL_16MHZ | UTMI_PHY_EN); |
Vivek Mahajan | 288f7fb | 2009-05-25 17:23:16 +0530 | [diff] [blame] | 271 | |
| 272 | /* Wait for clock to stabilize */ |
| 273 | do { |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 274 | temp = __raw_readl(&ehci->control); |
Vivek Mahajan | 288f7fb | 2009-05-25 17:23:16 +0530 | [diff] [blame] | 275 | udelay(1000); |
| 276 | } while (!(temp & PHY_CLK_VALID)); |
| 277 | #endif |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 278 | } |
| 279 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 280 | int cpu_init_r (void) |
| 281 | { |
Dave Liu | e732e9c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 282 | #ifdef CONFIG_QE |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 283 | uint qe_base = CONFIG_SYS_IMMR + 0x00100000; /* QE immr base */ |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 284 | |
Dave Liu | e732e9c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 285 | qe_init(qe_base); |
| 286 | qe_reset(); |
| 287 | #endif |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 288 | return 0; |
| 289 | } |
Dave Liu | ebd35f8 | 2007-06-25 10:41:56 +0800 | [diff] [blame] | 290 | |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 291 | /* |
| 292 | * Print out the bus arbiter event |
| 293 | */ |
| 294 | #if defined(CONFIG_DISPLAY_AER_FULL) |
| 295 | static 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 Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 376 | int etype = (gd->arch.arbiter_event_attributes & AEATR_EVENT) |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 377 | >> AEATR_EVENT_SHIFT; |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 378 | int mstr_id = (gd->arch.arbiter_event_attributes & AEATR_MSTR_ID) |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 379 | >> AEATR_MSTR_ID_SHIFT; |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 380 | int tbst = (gd->arch.arbiter_event_attributes & AEATR_TBST) |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 381 | >> AEATR_TBST_SHIFT; |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 382 | int tsize = (gd->arch.arbiter_event_attributes & AEATR_TSIZE) |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 383 | >> AEATR_TSIZE_SHIFT; |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 384 | int ttype = (gd->arch.arbiter_event_attributes & AEATR_TTYPE) |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 385 | >> AEATR_TTYPE_SHIFT; |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 386 | |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 387 | if (!force && !gd->arch.arbiter_event_address) |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 388 | return 0; |
| 389 | |
| 390 | puts("Arbiter Event Status:\n"); |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 391 | printf(" Event Address: 0x%08lX\n", |
| 392 | gd->arch.arbiter_event_address); |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 393 | 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 Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 399 | return gd->arch.arbiter_event_address; |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | #elif defined(CONFIG_DISPLAY_AER_BRIEF) |
| 403 | |
| 404 | static int print_83xx_arb_event(int force) |
| 405 | { |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 406 | if (!force && !gd->arch.arbiter_event_address) |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 407 | return 0; |
| 408 | |
| 409 | printf("Arbiter Event Status: AEATR=0x%08lX, AEADR=0x%08lX\n", |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 410 | gd->arch.arbiter_event_attributes, |
| 411 | gd->arch.arbiter_event_address); |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 412 | |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 413 | return gd->arch.arbiter_event_address; |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 414 | } |
| 415 | #endif /* CONFIG_DISPLAY_AER_xxxx */ |
| 416 | |
Mario Six | 28fbefa | 2018-08-06 10:23:45 +0200 | [diff] [blame] | 417 | #ifndef CONFIG_CPU_MPC83XX |
Dave Liu | ebd35f8 | 2007-06-25 10:41:56 +0800 | [diff] [blame] | 418 | /* |
| 419 | * Figure out the cause of the reset |
| 420 | */ |
| 421 | int 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. Day | 0c91159 | 2016-05-23 06:49:21 -0400 | [diff] [blame] | 437 | static int n = ARRAY_SIZE(bits); |
Simon Glass | 4d6eaa3 | 2012-12-13 20:48:56 +0000 | [diff] [blame] | 438 | ulong rsr = gd->arch.reset_status; |
Dave Liu | ebd35f8 | 2007-06-25 10:41:56 +0800 | [diff] [blame] | 439 | 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 Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 450 | 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 Liu | ebd35f8 | 2007-06-25 10:41:56 +0800 | [diff] [blame] | 457 | return 0; |
| 458 | } |
Mario Six | 28fbefa | 2018-08-06 10:23:45 +0200 | [diff] [blame] | 459 | #endif |