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