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 | b47839c | 2019-01-21 09:17:58 +0100 | [diff] [blame] | 17 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 18 | DECLARE_GLOBAL_DATA_PTR; |
| 19 | |
Dave Liu | e732e9c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 20 | #ifdef CONFIG_QE |
| 21 | extern qe_iop_conf_t qe_iop_conf_tab[]; |
| 22 | extern void qe_config_iopin(u8 port, u8 pin, int dir, |
| 23 | int open_drain, int assign); |
| 24 | extern void qe_init(uint qe_base); |
| 25 | extern void qe_reset(void); |
| 26 | |
| 27 | static void config_qe_ioports(void) |
| 28 | { |
| 29 | u8 port, pin; |
| 30 | int dir, open_drain, assign; |
| 31 | int i; |
| 32 | |
| 33 | for (i = 0; qe_iop_conf_tab[i].assign != QE_IOP_TAB_END; i++) { |
| 34 | port = qe_iop_conf_tab[i].port; |
| 35 | pin = qe_iop_conf_tab[i].pin; |
| 36 | dir = qe_iop_conf_tab[i].dir; |
| 37 | open_drain = qe_iop_conf_tab[i].open_drain; |
| 38 | assign = qe_iop_conf_tab[i].assign; |
| 39 | qe_config_iopin(port, pin, dir, open_drain, assign); |
| 40 | } |
| 41 | } |
| 42 | #endif |
| 43 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 44 | /* |
| 45 | * Breathe some life into the CPU... |
| 46 | * |
| 47 | * Set up the memory map, |
| 48 | * initialize a bunch of registers, |
| 49 | * initialize the UPM's |
| 50 | */ |
| 51 | void cpu_init_f (volatile immap_t * im) |
| 52 | { |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 53 | __be32 acr_mask = |
| 54 | #ifdef CONFIG_SYS_ACR_PIPE_DEP /* Arbiter pipeline depth */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 55 | ACR_PIPE_DEP | |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 56 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 57 | #ifdef CONFIG_SYS_ACR_RPTCNT /* Arbiter repeat count */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 58 | ACR_RPTCNT | |
Kim Phillips | 19a91de | 2008-01-16 12:06:16 -0600 | [diff] [blame] | 59 | #endif |
Heiko Schocher | 5318b08 | 2010-01-07 08:56:00 +0100 | [diff] [blame] | 60 | #ifdef CONFIG_SYS_ACR_APARK /* Arbiter address parking mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 61 | ACR_APARK | |
Heiko Schocher | 5318b08 | 2010-01-07 08:56:00 +0100 | [diff] [blame] | 62 | #endif |
| 63 | #ifdef CONFIG_SYS_ACR_PARKM /* Arbiter parking master */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 64 | ACR_PARKM | |
Heiko Schocher | 5318b08 | 2010-01-07 08:56:00 +0100 | [diff] [blame] | 65 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 66 | 0; |
| 67 | __be32 acr_val = |
| 68 | #ifdef CONFIG_SYS_ACR_PIPE_DEP /* Arbiter pipeline depth */ |
| 69 | (CONFIG_SYS_ACR_PIPE_DEP << ACR_PIPE_DEP_SHIFT) | |
| 70 | #endif |
| 71 | #ifdef CONFIG_SYS_ACR_RPTCNT /* Arbiter repeat count */ |
| 72 | (CONFIG_SYS_ACR_RPTCNT << ACR_RPTCNT_SHIFT) | |
| 73 | #endif |
Heiko Schocher | 5318b08 | 2010-01-07 08:56:00 +0100 | [diff] [blame] | 74 | #ifdef CONFIG_SYS_ACR_APARK /* Arbiter address parking mode */ |
| 75 | (CONFIG_SYS_ACR_APARK << ACR_APARK_SHIFT) | |
| 76 | #endif |
| 77 | #ifdef CONFIG_SYS_ACR_PARKM /* Arbiter parking master */ |
| 78 | (CONFIG_SYS_ACR_PARKM << ACR_PARKM_SHIFT) | |
| 79 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 80 | 0; |
| 81 | __be32 spcr_mask = |
| 82 | #ifdef CONFIG_SYS_SPCR_OPT /* Optimize transactions between CSB and other dev */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 83 | SPCR_OPT | |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 84 | #endif |
| 85 | #ifdef CONFIG_SYS_SPCR_TSECEP /* all eTSEC's Emergency priority */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 86 | SPCR_TSECEP | |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 87 | #endif |
| 88 | #ifdef CONFIG_SYS_SPCR_TSEC1EP /* TSEC1 Emergency priority */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 89 | SPCR_TSEC1EP | |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 90 | #endif |
| 91 | #ifdef CONFIG_SYS_SPCR_TSEC2EP /* TSEC2 Emergency priority */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 92 | SPCR_TSEC2EP | |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 93 | #endif |
| 94 | 0; |
| 95 | __be32 spcr_val = |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 96 | #ifdef CONFIG_SYS_SPCR_OPT |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 97 | (CONFIG_SYS_SPCR_OPT << SPCR_OPT_SHIFT) | |
Michael Barkowski | 06e2e19 | 2008-03-20 13:15:34 -0400 | [diff] [blame] | 98 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 99 | #ifdef CONFIG_SYS_SPCR_TSECEP /* all eTSEC's Emergency priority */ |
| 100 | (CONFIG_SYS_SPCR_TSECEP << SPCR_TSECEP_SHIFT) | |
Kim Phillips | 19a91de | 2008-01-16 12:06:16 -0600 | [diff] [blame] | 101 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 102 | #ifdef CONFIG_SYS_SPCR_TSEC1EP /* TSEC1 Emergency priority */ |
| 103 | (CONFIG_SYS_SPCR_TSEC1EP << SPCR_TSEC1EP_SHIFT) | |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 104 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 105 | #ifdef CONFIG_SYS_SPCR_TSEC2EP /* TSEC2 Emergency priority */ |
| 106 | (CONFIG_SYS_SPCR_TSEC2EP << SPCR_TSEC2EP_SHIFT) | |
Kim Phillips | 19a91de | 2008-01-16 12:06:16 -0600 | [diff] [blame] | 107 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 108 | 0; |
| 109 | __be32 sccr_mask = |
| 110 | #ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 111 | SCCR_ENCCM | |
Kim Phillips | 19a91de | 2008-01-16 12:06:16 -0600 | [diff] [blame] | 112 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 113 | #ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 114 | SCCR_PCICM | |
Kim Phillips | 19a91de | 2008-01-16 12:06:16 -0600 | [diff] [blame] | 115 | #endif |
Ilya Yanok | a4f3ed3 | 2010-09-17 23:41:47 +0200 | [diff] [blame] | 116 | #ifdef CONFIG_SYS_SCCR_PCIEXP1CM /* PCIE1 clock mode */ |
| 117 | SCCR_PCIEXP1CM | |
| 118 | #endif |
| 119 | #ifdef CONFIG_SYS_SCCR_PCIEXP2CM /* PCIE2 clock mode */ |
| 120 | SCCR_PCIEXP2CM | |
| 121 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 122 | #ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 123 | SCCR_TSECCM | |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 124 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 125 | #ifdef CONFIG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 126 | SCCR_TSEC1CM | |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 127 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 128 | #ifdef CONFIG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 129 | SCCR_TSEC2CM | |
Kumar Gala | 15c3f69 | 2007-02-27 23:51:42 -0600 | [diff] [blame] | 130 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 131 | #ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 132 | SCCR_TSEC1ON | |
Timur Tabi | 0b2deff | 2007-07-03 13:04:34 -0500 | [diff] [blame] | 133 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 134 | #ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 135 | SCCR_TSEC2ON | |
Timur Tabi | 0b2deff | 2007-07-03 13:04:34 -0500 | [diff] [blame] | 136 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 137 | #ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 138 | SCCR_USBMPHCM | |
Kumar Gala | 15c3f69 | 2007-02-27 23:51:42 -0600 | [diff] [blame] | 139 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 140 | #ifdef CONFIG_SYS_SCCR_USBDRCM /* USB DR clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 141 | SCCR_USBDRCM | |
Kumar Gala | 15c3f69 | 2007-02-27 23:51:42 -0600 | [diff] [blame] | 142 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 143 | #ifdef CONFIG_SYS_SCCR_SATACM /* SATA controller clock mode */ |
Kim Phillips | 8d5fa6a | 2010-05-19 17:06:46 -0500 | [diff] [blame] | 144 | SCCR_SATACM | |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 145 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 146 | 0; |
| 147 | __be32 sccr_val = |
| 148 | #ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */ |
| 149 | (CONFIG_SYS_SCCR_ENCCM << SCCR_ENCCM_SHIFT) | |
| 150 | #endif |
| 151 | #ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */ |
| 152 | (CONFIG_SYS_SCCR_PCICM << SCCR_PCICM_SHIFT) | |
| 153 | #endif |
Ilya Yanok | a4f3ed3 | 2010-09-17 23:41:47 +0200 | [diff] [blame] | 154 | #ifdef CONFIG_SYS_SCCR_PCIEXP1CM /* PCIE1 clock mode */ |
| 155 | (CONFIG_SYS_SCCR_PCIEXP1CM << SCCR_PCIEXP1CM_SHIFT) | |
| 156 | #endif |
| 157 | #ifdef CONFIG_SYS_SCCR_PCIEXP2CM /* PCIE2 clock mode */ |
| 158 | (CONFIG_SYS_SCCR_PCIEXP2CM << SCCR_PCIEXP2CM_SHIFT) | |
| 159 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 160 | #ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */ |
| 161 | (CONFIG_SYS_SCCR_TSECCM << SCCR_TSECCM_SHIFT) | |
| 162 | #endif |
| 163 | #ifdef CONFIG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */ |
| 164 | (CONFIG_SYS_SCCR_TSEC1CM << SCCR_TSEC1CM_SHIFT) | |
| 165 | #endif |
| 166 | #ifdef CONFIG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */ |
| 167 | (CONFIG_SYS_SCCR_TSEC2CM << SCCR_TSEC2CM_SHIFT) | |
| 168 | #endif |
| 169 | #ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */ |
| 170 | (CONFIG_SYS_SCCR_TSEC1ON << SCCR_TSEC1ON_SHIFT) | |
| 171 | #endif |
| 172 | #ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */ |
| 173 | (CONFIG_SYS_SCCR_TSEC2ON << SCCR_TSEC2ON_SHIFT) | |
| 174 | #endif |
| 175 | #ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */ |
| 176 | (CONFIG_SYS_SCCR_USBMPHCM << SCCR_USBMPHCM_SHIFT) | |
| 177 | #endif |
| 178 | #ifdef CONFIG_SYS_SCCR_USBDRCM /* USB DR clock mode */ |
| 179 | (CONFIG_SYS_SCCR_USBDRCM << SCCR_USBDRCM_SHIFT) | |
| 180 | #endif |
| 181 | #ifdef CONFIG_SYS_SCCR_SATACM /* SATA controller clock mode */ |
| 182 | (CONFIG_SYS_SCCR_SATACM << SCCR_SATACM_SHIFT) | |
| 183 | #endif |
| 184 | 0; |
Peter Korsgaard | 2a483ee | 2009-12-08 22:20:34 +0100 | [diff] [blame] | 185 | __be32 lcrr_mask = |
| 186 | #ifdef CONFIG_SYS_LCRR_DBYP /* PLL bypass */ |
| 187 | LCRR_DBYP | |
| 188 | #endif |
| 189 | #ifdef CONFIG_SYS_LCRR_EADC /* external address delay */ |
| 190 | LCRR_EADC | |
| 191 | #endif |
| 192 | #ifdef CONFIG_SYS_LCRR_CLKDIV /* system clock divider */ |
| 193 | LCRR_CLKDIV | |
| 194 | #endif |
| 195 | 0; |
| 196 | __be32 lcrr_val = |
| 197 | #ifdef CONFIG_SYS_LCRR_DBYP /* PLL bypass */ |
| 198 | CONFIG_SYS_LCRR_DBYP | |
| 199 | #endif |
| 200 | #ifdef CONFIG_SYS_LCRR_EADC |
| 201 | CONFIG_SYS_LCRR_EADC | |
| 202 | #endif |
| 203 | #ifdef CONFIG_SYS_LCRR_CLKDIV /* system clock divider */ |
| 204 | CONFIG_SYS_LCRR_CLKDIV | |
| 205 | #endif |
| 206 | 0; |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 207 | |
| 208 | /* Pointer is writable since we allocated a register for it */ |
| 209 | gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET); |
| 210 | |
mario.six@gdsys.cc | 85df7b4 | 2017-01-17 08:33:48 +0100 | [diff] [blame] | 211 | /* global data region was cleared in start.S */ |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 212 | |
| 213 | /* system performance tweaking */ |
| 214 | clrsetbits_be32(&im->arbiter.acr, acr_mask, acr_val); |
| 215 | |
| 216 | clrsetbits_be32(&im->sysconf.spcr, spcr_mask, spcr_val); |
| 217 | |
| 218 | clrsetbits_be32(&im->clk.sccr, sccr_mask, sccr_val); |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 219 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 220 | /* RSR - Reset Status Register - clear all status (4.6.1.3) */ |
Simon Glass | 4d6eaa3 | 2012-12-13 20:48:56 +0000 | [diff] [blame] | 221 | gd->arch.reset_status = __raw_readl(&im->reset.rsr); |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 222 | __raw_writel(~(RSR_RES), &im->reset.rsr); |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 223 | |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 224 | /* AER - Arbiter Event Register - store status */ |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 225 | gd->arch.arbiter_event_attributes = __raw_readl(&im->arbiter.aeatr); |
| 226 | gd->arch.arbiter_event_address = __raw_readl(&im->arbiter.aeadr); |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 227 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 228 | /* |
| 229 | * RMR - Reset Mode Register |
| 230 | * contains checkstop reset enable (4.6.1.4) |
| 231 | */ |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 232 | __raw_writel(RMR_CSRE & (1<<RMR_CSRE_SHIFT), &im->reset.rmr); |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 233 | |
Peter Korsgaard | 2a483ee | 2009-12-08 22:20:34 +0100 | [diff] [blame] | 234 | /* LCRR - Clock Ratio Register (10.3.1.16) |
| 235 | * write, read, and isync per MPC8379ERM rev.1 CLKDEV field description |
| 236 | */ |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 237 | clrsetbits_be32(&im->im_lbc.lcrr, lcrr_mask, lcrr_val); |
| 238 | __raw_readl(&im->im_lbc.lcrr); |
Peter Korsgaard | 2a483ee | 2009-12-08 22:20:34 +0100 | [diff] [blame] | 239 | isync(); |
| 240 | |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 241 | /* Enable Time Base & Decrementer ( so we will have udelay() )*/ |
| 242 | setbits_be32(&im->sysconf.spcr, SPCR_TBEN); |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 243 | |
| 244 | /* System General Purpose Register */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 245 | #ifdef CONFIG_SYS_SICRH |
Mario Six | 0344f5e | 2019-01-21 09:17:27 +0100 | [diff] [blame] | 246 | #if defined(CONFIG_ARCH_MPC834X) || defined(CONFIG_ARCH_MPC8313) |
Andre Schwarz | cea6648 | 2008-06-23 11:40:56 +0200 | [diff] [blame] | 247 | /* regarding to MPC34x manual rev.1 bits 28..29 must be preserved */ |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 248 | __raw_writel((im->sysconf.sicrh & 0x0000000C) | CONFIG_SYS_SICRH, |
| 249 | &im->sysconf.sicrh); |
Andre Schwarz | cea6648 | 2008-06-23 11:40:56 +0200 | [diff] [blame] | 250 | #else |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 251 | __raw_writel(CONFIG_SYS_SICRH, &im->sysconf.sicrh); |
Kumar Gala | e522143 | 2006-01-11 11:12:57 -0600 | [diff] [blame] | 252 | #endif |
Andre Schwarz | cea6648 | 2008-06-23 11:40:56 +0200 | [diff] [blame] | 253 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 254 | #ifdef CONFIG_SYS_SICRL |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 255 | __raw_writel(CONFIG_SYS_SICRL, &im->sysconf.sicrl); |
Kumar Gala | e522143 | 2006-01-11 11:12:57 -0600 | [diff] [blame] | 256 | #endif |
Gerlando Falauto | fe201cb | 2012-10-10 22:13:08 +0000 | [diff] [blame] | 257 | #ifdef CONFIG_SYS_GPR1 |
| 258 | __raw_writel(CONFIG_SYS_GPR1, &im->sysconf.gpr1); |
| 259 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 260 | #ifdef CONFIG_SYS_DDRCDR /* DDR control driver register */ |
| 261 | __raw_writel(CONFIG_SYS_DDRCDR, &im->sysconf.ddrcdr); |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 262 | #endif |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 263 | #ifdef CONFIG_SYS_OBIR /* Output buffer impedance register */ |
| 264 | __raw_writel(CONFIG_SYS_OBIR, &im->sysconf.obir); |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 265 | #endif |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 266 | |
Dave Liu | e732e9c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 267 | #ifdef CONFIG_QE |
| 268 | /* Config QE ioports */ |
| 269 | config_qe_ioports(); |
| 270 | #endif |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 271 | /* Set up preliminary BR/OR regs */ |
| 272 | init_early_memctl_regs(); |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 273 | |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 274 | /* Local Access window setup */ |
| 275 | #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] | 276 | im->sysconf.lblaw[0].bar = CONFIG_SYS_LBLAWBAR0_PRELIM; |
| 277 | im->sysconf.lblaw[0].ar = CONFIG_SYS_LBLAWAR0_PRELIM; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 278 | #else |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 279 | #error CONFIG_SYS_LBLAWBAR0_PRELIM & CONFIG_SYS_LBLAWAR0_PRELIM must be defined |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 280 | #endif |
| 281 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 282 | #if defined(CONFIG_SYS_LBLAWBAR1_PRELIM) && defined(CONFIG_SYS_LBLAWAR1_PRELIM) |
| 283 | im->sysconf.lblaw[1].bar = CONFIG_SYS_LBLAWBAR1_PRELIM; |
| 284 | im->sysconf.lblaw[1].ar = CONFIG_SYS_LBLAWAR1_PRELIM; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 285 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 286 | #if defined(CONFIG_SYS_LBLAWBAR2_PRELIM) && defined(CONFIG_SYS_LBLAWAR2_PRELIM) |
| 287 | im->sysconf.lblaw[2].bar = CONFIG_SYS_LBLAWBAR2_PRELIM; |
| 288 | im->sysconf.lblaw[2].ar = CONFIG_SYS_LBLAWAR2_PRELIM; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 289 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 290 | #if defined(CONFIG_SYS_LBLAWBAR3_PRELIM) && defined(CONFIG_SYS_LBLAWAR3_PRELIM) |
| 291 | im->sysconf.lblaw[3].bar = CONFIG_SYS_LBLAWBAR3_PRELIM; |
| 292 | im->sysconf.lblaw[3].ar = CONFIG_SYS_LBLAWAR3_PRELIM; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 293 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 294 | #if defined(CONFIG_SYS_LBLAWBAR4_PRELIM) && defined(CONFIG_SYS_LBLAWAR4_PRELIM) |
| 295 | im->sysconf.lblaw[4].bar = CONFIG_SYS_LBLAWBAR4_PRELIM; |
| 296 | im->sysconf.lblaw[4].ar = CONFIG_SYS_LBLAWAR4_PRELIM; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 297 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 298 | #if defined(CONFIG_SYS_LBLAWBAR5_PRELIM) && defined(CONFIG_SYS_LBLAWAR5_PRELIM) |
| 299 | im->sysconf.lblaw[5].bar = CONFIG_SYS_LBLAWBAR5_PRELIM; |
| 300 | im->sysconf.lblaw[5].ar = CONFIG_SYS_LBLAWAR5_PRELIM; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 301 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 302 | #if defined(CONFIG_SYS_LBLAWBAR6_PRELIM) && defined(CONFIG_SYS_LBLAWAR6_PRELIM) |
| 303 | im->sysconf.lblaw[6].bar = CONFIG_SYS_LBLAWBAR6_PRELIM; |
| 304 | im->sysconf.lblaw[6].ar = CONFIG_SYS_LBLAWAR6_PRELIM; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 305 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 306 | #if defined(CONFIG_SYS_LBLAWBAR7_PRELIM) && defined(CONFIG_SYS_LBLAWAR7_PRELIM) |
| 307 | im->sysconf.lblaw[7].bar = CONFIG_SYS_LBLAWBAR7_PRELIM; |
| 308 | im->sysconf.lblaw[7].ar = CONFIG_SYS_LBLAWAR7_PRELIM; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 309 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 310 | #ifdef CONFIG_SYS_GPIO1_PRELIM |
| 311 | im->gpio[0].dat = CONFIG_SYS_GPIO1_DAT; |
| 312 | im->gpio[0].dir = CONFIG_SYS_GPIO1_DIR; |
Kumar Gala | ab7ec4f | 2006-01-11 11:21:14 -0600 | [diff] [blame] | 313 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 314 | #ifdef CONFIG_SYS_GPIO2_PRELIM |
| 315 | im->gpio[1].dat = CONFIG_SYS_GPIO2_DAT; |
| 316 | im->gpio[1].dir = CONFIG_SYS_GPIO2_DIR; |
Kumar Gala | ab7ec4f | 2006-01-11 11:21:14 -0600 | [diff] [blame] | 317 | #endif |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 318 | #if defined(CONFIG_USB_EHCI_FSL) && defined(CONFIG_ARCH_MPC831X) |
Vivek Mahajan | 288f7fb | 2009-05-25 17:23:16 +0530 | [diff] [blame] | 319 | uint32_t temp; |
ramneek mehresh | 16b0806 | 2013-09-12 16:35:49 +0530 | [diff] [blame] | 320 | struct usb_ehci *ehci = (struct usb_ehci *)CONFIG_SYS_FSL_USB1_ADDR; |
Vivek Mahajan | 288f7fb | 2009-05-25 17:23:16 +0530 | [diff] [blame] | 321 | |
| 322 | /* Configure interface. */ |
Vivek Mahajan | 2d421c1 | 2009-06-24 10:08:40 +0530 | [diff] [blame] | 323 | setbits_be32(&ehci->control, REFSEL_16MHZ | UTMI_PHY_EN); |
Vivek Mahajan | 288f7fb | 2009-05-25 17:23:16 +0530 | [diff] [blame] | 324 | |
| 325 | /* Wait for clock to stabilize */ |
| 326 | do { |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 327 | temp = __raw_readl(&ehci->control); |
Vivek Mahajan | 288f7fb | 2009-05-25 17:23:16 +0530 | [diff] [blame] | 328 | udelay(1000); |
| 329 | } while (!(temp & PHY_CLK_VALID)); |
| 330 | #endif |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 331 | } |
| 332 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 333 | int cpu_init_r (void) |
| 334 | { |
Dave Liu | e732e9c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 335 | #ifdef CONFIG_QE |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 336 | uint qe_base = CONFIG_SYS_IMMR + 0x00100000; /* QE immr base */ |
Kim Phillips | 328040a | 2009-09-25 18:19:44 -0500 | [diff] [blame] | 337 | |
Dave Liu | e732e9c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 338 | qe_init(qe_base); |
| 339 | qe_reset(); |
| 340 | #endif |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 341 | return 0; |
| 342 | } |
Dave Liu | ebd35f8 | 2007-06-25 10:41:56 +0800 | [diff] [blame] | 343 | |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 344 | /* |
| 345 | * Print out the bus arbiter event |
| 346 | */ |
| 347 | #if defined(CONFIG_DISPLAY_AER_FULL) |
| 348 | static int print_83xx_arb_event(int force) |
| 349 | { |
| 350 | static char* event[] = { |
| 351 | "Address Time Out", |
| 352 | "Data Time Out", |
| 353 | "Address Only Transfer Type", |
| 354 | "External Control Word Transfer Type", |
| 355 | "Reserved Transfer Type", |
| 356 | "Transfer Error", |
| 357 | "reserved", |
| 358 | "reserved" |
| 359 | }; |
| 360 | static char* master[] = { |
| 361 | "e300 Core Data Transaction", |
| 362 | "reserved", |
| 363 | "e300 Core Instruction Fetch", |
| 364 | "reserved", |
| 365 | "TSEC1", |
| 366 | "TSEC2", |
| 367 | "USB MPH", |
| 368 | "USB DR", |
| 369 | "Encryption Core", |
| 370 | "I2C Boot Sequencer", |
| 371 | "JTAG", |
| 372 | "reserved", |
| 373 | "eSDHC", |
| 374 | "PCI1", |
| 375 | "PCI2", |
| 376 | "DMA", |
| 377 | "QUICC Engine 00", |
| 378 | "QUICC Engine 01", |
| 379 | "QUICC Engine 10", |
| 380 | "QUICC Engine 11", |
| 381 | "reserved", |
| 382 | "reserved", |
| 383 | "reserved", |
| 384 | "reserved", |
| 385 | "SATA1", |
| 386 | "SATA2", |
| 387 | "SATA3", |
| 388 | "SATA4", |
| 389 | "reserved", |
| 390 | "PCI Express 1", |
| 391 | "PCI Express 2", |
| 392 | "TDM-DMAC" |
| 393 | }; |
| 394 | static char *transfer[] = { |
| 395 | "Address-only, Clean Block", |
| 396 | "Address-only, lwarx reservation set", |
| 397 | "Single-beat or Burst write", |
| 398 | "reserved", |
| 399 | "Address-only, Flush Block", |
| 400 | "reserved", |
| 401 | "Burst write", |
| 402 | "reserved", |
| 403 | "Address-only, sync", |
| 404 | "Address-only, tlbsync", |
| 405 | "Single-beat or Burst read", |
| 406 | "Single-beat or Burst read", |
| 407 | "Address-only, Kill Block", |
| 408 | "Address-only, icbi", |
| 409 | "Burst read", |
| 410 | "reserved", |
| 411 | "Address-only, eieio", |
| 412 | "reserved", |
| 413 | "Single-beat write", |
| 414 | "reserved", |
| 415 | "ecowx - Illegal single-beat write", |
| 416 | "reserved", |
| 417 | "reserved", |
| 418 | "reserved", |
| 419 | "Address-only, TLB Invalidate", |
| 420 | "reserved", |
| 421 | "Single-beat or Burst read", |
| 422 | "reserved", |
| 423 | "eciwx - Illegal single-beat read", |
| 424 | "reserved", |
| 425 | "Burst read", |
| 426 | "reserved" |
| 427 | }; |
| 428 | |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 429 | int etype = (gd->arch.arbiter_event_attributes & AEATR_EVENT) |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 430 | >> AEATR_EVENT_SHIFT; |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 431 | int mstr_id = (gd->arch.arbiter_event_attributes & AEATR_MSTR_ID) |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 432 | >> AEATR_MSTR_ID_SHIFT; |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 433 | int tbst = (gd->arch.arbiter_event_attributes & AEATR_TBST) |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 434 | >> AEATR_TBST_SHIFT; |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 435 | int tsize = (gd->arch.arbiter_event_attributes & AEATR_TSIZE) |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 436 | >> AEATR_TSIZE_SHIFT; |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 437 | int ttype = (gd->arch.arbiter_event_attributes & AEATR_TTYPE) |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 438 | >> AEATR_TTYPE_SHIFT; |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 439 | |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 440 | if (!force && !gd->arch.arbiter_event_address) |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 441 | return 0; |
| 442 | |
| 443 | puts("Arbiter Event Status:\n"); |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 444 | printf(" Event Address: 0x%08lX\n", |
| 445 | gd->arch.arbiter_event_address); |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 446 | printf(" Event Type: 0x%1x = %s\n", etype, event[etype]); |
| 447 | printf(" Master ID: 0x%02x = %s\n", mstr_id, master[mstr_id]); |
| 448 | printf(" Transfer Size: 0x%1x = %d bytes\n", (tbst<<3) | tsize, |
| 449 | tbst ? (tsize ? tsize : 8) : 16 + 8 * tsize); |
| 450 | printf(" Transfer Type: 0x%02x = %s\n", ttype, transfer[ttype]); |
| 451 | |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 452 | return gd->arch.arbiter_event_address; |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | #elif defined(CONFIG_DISPLAY_AER_BRIEF) |
| 456 | |
| 457 | static int print_83xx_arb_event(int force) |
| 458 | { |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 459 | if (!force && !gd->arch.arbiter_event_address) |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 460 | return 0; |
| 461 | |
| 462 | printf("Arbiter Event Status: AEATR=0x%08lX, AEADR=0x%08lX\n", |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 463 | gd->arch.arbiter_event_attributes, |
| 464 | gd->arch.arbiter_event_address); |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 465 | |
Simon Glass | 387a1f2 | 2012-12-13 20:48:57 +0000 | [diff] [blame] | 466 | return gd->arch.arbiter_event_address; |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 467 | } |
| 468 | #endif /* CONFIG_DISPLAY_AER_xxxx */ |
| 469 | |
Mario Six | 28fbefa | 2018-08-06 10:23:45 +0200 | [diff] [blame] | 470 | #ifndef CONFIG_CPU_MPC83XX |
Dave Liu | ebd35f8 | 2007-06-25 10:41:56 +0800 | [diff] [blame] | 471 | /* |
| 472 | * Figure out the cause of the reset |
| 473 | */ |
| 474 | int prt_83xx_rsr(void) |
| 475 | { |
| 476 | static struct { |
| 477 | ulong mask; |
| 478 | char *desc; |
| 479 | } bits[] = { |
| 480 | { |
| 481 | RSR_SWSR, "Software Soft"}, { |
| 482 | RSR_SWHR, "Software Hard"}, { |
| 483 | RSR_JSRS, "JTAG Soft"}, { |
| 484 | RSR_CSHR, "Check Stop"}, { |
| 485 | RSR_SWRS, "Software Watchdog"}, { |
| 486 | RSR_BMRS, "Bus Monitor"}, { |
| 487 | RSR_SRS, "External/Internal Soft"}, { |
| 488 | RSR_HRS, "External/Internal Hard"} |
| 489 | }; |
Robert P. J. Day | 0c91159 | 2016-05-23 06:49:21 -0400 | [diff] [blame] | 490 | static int n = ARRAY_SIZE(bits); |
Simon Glass | 4d6eaa3 | 2012-12-13 20:48:56 +0000 | [diff] [blame] | 491 | ulong rsr = gd->arch.reset_status; |
Dave Liu | ebd35f8 | 2007-06-25 10:41:56 +0800 | [diff] [blame] | 492 | int i; |
| 493 | char *sep; |
| 494 | |
| 495 | puts("Reset Status:"); |
| 496 | |
| 497 | sep = " "; |
| 498 | for (i = 0; i < n; i++) |
| 499 | if (rsr & bits[i].mask) { |
| 500 | printf("%s%s", sep, bits[i].desc); |
| 501 | sep = ", "; |
| 502 | } |
Nick Spence | 56fd3c2 | 2008-08-28 14:09:19 -0700 | [diff] [blame] | 503 | puts("\n"); |
| 504 | |
| 505 | #if defined(CONFIG_DISPLAY_AER_FULL) || defined(CONFIG_DISPLAY_AER_BRIEF) |
| 506 | print_83xx_arb_event(rsr & RSR_BMRS); |
| 507 | #endif |
| 508 | puts("\n"); |
| 509 | |
Dave Liu | ebd35f8 | 2007-06-25 10:41:56 +0800 | [diff] [blame] | 510 | return 0; |
| 511 | } |
Mario Six | 28fbefa | 2018-08-06 10:23:45 +0200 | [diff] [blame] | 512 | #endif |