machdep.c revision 1.5.2.3 1 1.5.2.2 rmind /* $NetBSD: machdep.c,v 1.5.2.3 2011/05/31 03:04:01 rmind Exp $ */
2 1.5.2.2 rmind /*-
3 1.5.2.2 rmind * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
4 1.5.2.2 rmind * All rights reserved.
5 1.5.2.2 rmind *
6 1.5.2.2 rmind * This code is derived from software contributed to The NetBSD Foundation
7 1.5.2.2 rmind * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects
8 1.5.2.2 rmind * Agency and which was developed by Matt Thomas of 3am Software Foundry.
9 1.5.2.2 rmind *
10 1.5.2.2 rmind * This material is based upon work supported by the Defense Advanced Research
11 1.5.2.2 rmind * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under
12 1.5.2.2 rmind * Contract No. N66001-09-C-2073.
13 1.5.2.2 rmind * Approved for Public Release, Distribution Unlimited
14 1.5.2.2 rmind *
15 1.5.2.2 rmind * Redistribution and use in source and binary forms, with or without
16 1.5.2.2 rmind * modification, are permitted provided that the following conditions
17 1.5.2.2 rmind * are met:
18 1.5.2.2 rmind * 1. Redistributions of source code must retain the above copyright
19 1.5.2.2 rmind * notice, this list of conditions and the following disclaimer.
20 1.5.2.2 rmind * 2. Redistributions in binary form must reproduce the above copyright
21 1.5.2.2 rmind * notice, this list of conditions and the following disclaimer in the
22 1.5.2.2 rmind * documentation and/or other materials provided with the distribution.
23 1.5.2.2 rmind *
24 1.5.2.2 rmind * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
25 1.5.2.2 rmind * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 1.5.2.2 rmind * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 1.5.2.2 rmind * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
28 1.5.2.2 rmind * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 1.5.2.2 rmind * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 1.5.2.2 rmind * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 1.5.2.2 rmind * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 1.5.2.2 rmind * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 1.5.2.2 rmind * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 1.5.2.2 rmind * POSSIBILITY OF SUCH DAMAGE.
35 1.5.2.2 rmind */
36 1.5.2.2 rmind
37 1.5.2.2 rmind #include <sys/cdefs.h>
38 1.5.2.2 rmind
39 1.5.2.2 rmind __KERNEL_RCSID(0, "$NetSBD$");
40 1.5.2.2 rmind
41 1.5.2.2 rmind #include "opt_mpc85xx.h"
42 1.5.2.2 rmind #include "opt_altivec.h"
43 1.5.2.2 rmind #include "opt_pci.h"
44 1.5.2.2 rmind #include "opt_ddb.h"
45 1.5.2.2 rmind #include "gpio.h"
46 1.5.2.2 rmind #include "pci.h"
47 1.5.2.2 rmind
48 1.5.2.2 rmind #define DDRC_PRIVATE
49 1.5.2.2 rmind #define GLOBAL_PRIVATE
50 1.5.2.2 rmind #define L2CACHE_PRIVATE
51 1.5.2.2 rmind #define _POWERPC_BUS_DMA_PRIVATE
52 1.5.2.2 rmind
53 1.5.2.2 rmind #include <sys/param.h>
54 1.5.2.2 rmind #include <sys/cpu.h>
55 1.5.2.2 rmind #include <sys/intr.h>
56 1.5.2.2 rmind #include <sys/msgbuf.h>
57 1.5.2.2 rmind #include <sys/tty.h>
58 1.5.2.2 rmind #include <sys/kcore.h>
59 1.5.2.2 rmind #include <sys/bitops.h>
60 1.5.2.2 rmind #include <sys/bus.h>
61 1.5.2.2 rmind #include <sys/extent.h>
62 1.5.2.2 rmind #include <sys/malloc.h>
63 1.5.2.2 rmind
64 1.5.2.2 rmind #include <uvm/uvm_extern.h>
65 1.5.2.2 rmind
66 1.5.2.2 rmind #include <prop/proplib.h>
67 1.5.2.2 rmind
68 1.5.2.2 rmind #include <machine/stdarg.h>
69 1.5.2.2 rmind
70 1.5.2.2 rmind #include <dev/cons.h>
71 1.5.2.2 rmind
72 1.5.2.2 rmind #include <dev/ic/comreg.h>
73 1.5.2.2 rmind #include <dev/ic/comvar.h>
74 1.5.2.2 rmind
75 1.5.2.2 rmind #include <net/if.h>
76 1.5.2.2 rmind #include <net/if_media.h>
77 1.5.2.2 rmind #include <dev/mii/miivar.h>
78 1.5.2.2 rmind
79 1.5.2.2 rmind #include <powerpc/pcb.h>
80 1.5.2.2 rmind #include <powerpc/spr.h>
81 1.5.2.2 rmind #include <powerpc/booke/spr.h>
82 1.5.2.2 rmind
83 1.5.2.2 rmind #include <powerpc/booke/cpuvar.h>
84 1.5.2.2 rmind #include <powerpc/booke/e500reg.h>
85 1.5.2.2 rmind #include <powerpc/booke/e500var.h>
86 1.5.2.2 rmind #include <powerpc/booke/etsecreg.h>
87 1.5.2.2 rmind #include <powerpc/booke/openpicreg.h>
88 1.5.2.2 rmind #ifdef CADMUS
89 1.5.2.2 rmind #include <evbppc/mpc85xx/cadmusreg.h>
90 1.5.2.2 rmind #endif
91 1.5.2.2 rmind #ifdef PIXIS
92 1.5.2.2 rmind #include <evbppc/mpc85xx/pixisreg.h>
93 1.5.2.2 rmind #endif
94 1.5.2.2 rmind
95 1.5.2.2 rmind void initppc(vaddr_t, vaddr_t);
96 1.5.2.2 rmind
97 1.5.2.2 rmind #define MEMREGIONS 4
98 1.5.2.2 rmind phys_ram_seg_t physmemr[MEMREGIONS]; /* All memory */
99 1.5.2.2 rmind phys_ram_seg_t availmemr[MEMREGIONS]; /* Available memory */
100 1.5.2.2 rmind static u_int nmemr;
101 1.5.2.2 rmind
102 1.5.2.2 rmind #ifndef CONSFREQ
103 1.5.2.2 rmind # define CONSFREQ -1 /* inherit from firmware */
104 1.5.2.2 rmind #endif
105 1.5.2.2 rmind #ifndef CONSPEED
106 1.5.2.2 rmind # define CONSPEED 115200
107 1.5.2.2 rmind #endif
108 1.5.2.2 rmind #ifndef CONMODE
109 1.5.2.2 rmind # define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8)
110 1.5.2.2 rmind #endif
111 1.5.2.2 rmind #ifndef CONSADDR
112 1.5.2.2 rmind # define CONSADDR DUART2_BASE
113 1.5.2.2 rmind #endif
114 1.5.2.2 rmind
115 1.5.2.2 rmind int comcnfreq = CONSFREQ;
116 1.5.2.2 rmind int comcnspeed = CONSPEED;
117 1.5.2.2 rmind tcflag_t comcnmode = CONMODE;
118 1.5.2.2 rmind bus_addr_t comcnaddr = (bus_addr_t)CONSADDR;
119 1.5.2.2 rmind
120 1.5.2.2 rmind #if NPCI > 0
121 1.5.2.2 rmind struct extent *pcimem_ex;
122 1.5.2.2 rmind struct extent *pciio_ex;
123 1.5.2.2 rmind #endif
124 1.5.2.2 rmind
125 1.5.2.2 rmind struct powerpc_bus_space gur_bst = {
126 1.5.2.2 rmind .pbs_flags = _BUS_SPACE_BIG_ENDIAN|_BUS_SPACE_MEM_TYPE,
127 1.5.2.2 rmind .pbs_offset = GUR_BASE,
128 1.5.2.2 rmind .pbs_limit = GUR_SIZE,
129 1.5.2.2 rmind };
130 1.5.2.2 rmind
131 1.5.2.2 rmind struct powerpc_bus_space gur_le_bst = {
132 1.5.2.2 rmind .pbs_flags = _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
133 1.5.2.2 rmind .pbs_offset = GUR_BASE,
134 1.5.2.2 rmind .pbs_limit = GUR_SIZE,
135 1.5.2.2 rmind };
136 1.5.2.2 rmind
137 1.5.2.2 rmind const bus_space_handle_t gur_bsh = (bus_space_handle_t)(uintptr_t)(GUR_BASE);
138 1.5.2.2 rmind
139 1.5.2.3 rmind #if defined(SYS_CLK)
140 1.5.2.3 rmind static uint64_t e500_sys_clk = SYS_CLK;
141 1.5.2.3 rmind #endif
142 1.5.2.2 rmind #ifdef CADMUS
143 1.5.2.2 rmind static uint8_t cadmus_pci;
144 1.5.2.2 rmind static uint8_t cadmus_csr;
145 1.5.2.3 rmind #ifndef SYS_CLK
146 1.5.2.2 rmind static uint64_t e500_sys_clk = 33333333; /* 33.333333Mhz */
147 1.5.2.3 rmind #endif
148 1.5.2.2 rmind #elif defined(PIXIS)
149 1.5.2.2 rmind static const uint32_t pixis_spd_map[8] = {
150 1.5.2.2 rmind [PX_SPD_33MHZ] = 33333333,
151 1.5.2.2 rmind [PX_SPD_40MHZ] = 40000000,
152 1.5.2.2 rmind [PX_SPD_50MHZ] = 50000000,
153 1.5.2.2 rmind [PX_SPD_66MHZ] = 66666666,
154 1.5.2.2 rmind [PX_SPD_83MHZ] = 83333333,
155 1.5.2.3 rmind [PX_SPD_100MHZ] = 100000000,
156 1.5.2.2 rmind [PX_SPD_133MHZ] = 133333333,
157 1.5.2.2 rmind [PX_SPD_166MHZ] = 166666667,
158 1.5.2.2 rmind };
159 1.5.2.2 rmind static uint8_t pixis_spd;
160 1.5.2.3 rmind #ifndef SYS_CLK
161 1.5.2.2 rmind static uint64_t e500_sys_clk;
162 1.5.2.3 rmind #endif
163 1.5.2.3 rmind #elif !defined(SYS_CLK)
164 1.5.2.2 rmind static uint64_t e500_sys_clk = 66666667; /* 66.666667Mhz */
165 1.5.2.2 rmind #endif
166 1.5.2.2 rmind
167 1.5.2.2 rmind static int e500_cngetc(dev_t);
168 1.5.2.2 rmind static void e500_cnputc(dev_t, int);
169 1.5.2.2 rmind
170 1.5.2.2 rmind static struct consdev e500_earlycons = {
171 1.5.2.2 rmind .cn_getc = e500_cngetc,
172 1.5.2.2 rmind .cn_putc = e500_cnputc,
173 1.5.2.2 rmind .cn_pollc = nullcnpollc,
174 1.5.2.2 rmind };
175 1.5.2.2 rmind
176 1.5.2.2 rmind /*
177 1.5.2.2 rmind * List of port-specific devices to attach to the processor local bus.
178 1.5.2.2 rmind */
179 1.5.2.2 rmind static const struct cpunode_locators mpc8548_cpunode_locs[] = {
180 1.5.2.3 rmind { "cpu", 0, 0, 0, 0, { 0 }, 0, /* not a real device */
181 1.5.2.3 rmind { 0xffff, SVR_MPC8572v1 >> 16, SVR_P2020v2 >> 16 } },
182 1.5.2.3 rmind #if defined(MPC8572) || defined(P2020)
183 1.5.2.3 rmind { "cpu", 0, 0, 1, 0, { 0 }, 0, /* not a real device */
184 1.5.2.3 rmind { SVR_MPC8572v1 >> 16, SVR_P2020v2 >> 16 } },
185 1.5.2.3 rmind { "cpu", 0, 0, 2, 0, { 0 }, 0, /* not a real device */
186 1.5.2.3 rmind { SVR_MPC8572v1 >> 16, SVR_P2020v2 >> 16 } },
187 1.5.2.3 rmind #endif
188 1.5.2.2 rmind { "wdog" }, /* not a real device */
189 1.5.2.2 rmind { "duart", DUART1_BASE, 2*DUART_SIZE, 0,
190 1.5.2.2 rmind 1, { ISOURCE_DUART },
191 1.5.2.2 rmind 1 + ilog2(DEVDISR_DUART) },
192 1.5.2.2 rmind { "tsec", ETSEC1_BASE, ETSEC_SIZE, 1,
193 1.5.2.2 rmind 3, { ISOURCE_ETSEC1_TX, ISOURCE_ETSEC1_RX, ISOURCE_ETSEC1_ERR },
194 1.5.2.2 rmind 1 + ilog2(DEVDISR_TSEC1) },
195 1.5.2.2 rmind #if defined(MPC8548) || defined(MPC8555) || defined(MPC8572) || defined(P2020)
196 1.5.2.2 rmind { "tsec", ETSEC2_BASE, ETSEC_SIZE, 2,
197 1.5.2.2 rmind 3, { ISOURCE_ETSEC2_TX, ISOURCE_ETSEC2_RX, ISOURCE_ETSEC2_ERR },
198 1.5.2.2 rmind 1 + ilog2(DEVDISR_TSEC2),
199 1.5.2.2 rmind { SVR_MPC8548v1 >> 16, SVR_MPC8555v1 >> 16,
200 1.5.2.2 rmind SVR_MPC8572v1 >> 16, SVR_P2020v2 >> 16 } },
201 1.5.2.2 rmind #endif
202 1.5.2.2 rmind #if defined(MPC8544) || defined(MPC8536)
203 1.5.2.2 rmind { "tsec", ETSEC3_BASE, ETSEC_SIZE, 2,
204 1.5.2.2 rmind 3, { ISOURCE_ETSEC3_TX, ISOURCE_ETSEC3_RX, ISOURCE_ETSEC3_ERR },
205 1.5.2.2 rmind 1 + ilog2(DEVDISR_TSEC3),
206 1.5.2.2 rmind { SVR_MPC8536v1 >> 16, SVR_MPC8544v1 >> 16 } },
207 1.5.2.2 rmind #endif
208 1.5.2.2 rmind #if defined(MPC8548) || defined(MPC8572) || defined(P2020)
209 1.5.2.2 rmind { "tsec", ETSEC3_BASE, ETSEC_SIZE, 3,
210 1.5.2.2 rmind 3, { ISOURCE_ETSEC3_TX, ISOURCE_ETSEC3_RX, ISOURCE_ETSEC3_ERR },
211 1.5.2.2 rmind 1 + ilog2(DEVDISR_TSEC3),
212 1.5.2.2 rmind { SVR_MPC8548v1 >> 16, SVR_MPC8572v1 >> 16,
213 1.5.2.2 rmind SVR_P2020v2 >> 16 } },
214 1.5.2.2 rmind #endif
215 1.5.2.2 rmind #if defined(MPC8548) || defined(MPC8572)
216 1.5.2.2 rmind { "tsec", ETSEC4_BASE, ETSEC_SIZE, 4,
217 1.5.2.2 rmind 3, { ISOURCE_ETSEC4_TX, ISOURCE_ETSEC4_RX, ISOURCE_ETSEC4_ERR },
218 1.5.2.2 rmind 1 + ilog2(DEVDISR_TSEC4),
219 1.5.2.2 rmind { SVR_MPC8548v1 >> 16, SVR_MPC8572v1 >> 16 } },
220 1.5.2.2 rmind #endif
221 1.5.2.2 rmind { "diic", I2C1_BASE, 2*I2C_SIZE, 0,
222 1.5.2.2 rmind 1, { ISOURCE_I2C },
223 1.5.2.2 rmind 1 + ilog2(DEVDISR_I2C) },
224 1.5.2.2 rmind /* MPC8572 doesn't have any GPIO */
225 1.5.2.2 rmind { "gpio", GLOBAL_BASE, GLOBAL_SIZE, 0,
226 1.5.2.2 rmind 1, { ISOURCE_GPIO },
227 1.5.2.2 rmind 0,
228 1.5.2.2 rmind { 0xffff, SVR_MPC8572v1 >> 16 } },
229 1.5.2.2 rmind { "ddrc", DDRC1_BASE, DDRC_SIZE, 0,
230 1.5.2.2 rmind 1, { ISOURCE_DDR },
231 1.5.2.2 rmind 1 + ilog2(DEVDISR_DDR_15),
232 1.5.2.2 rmind { 0xffff, SVR_MPC8572v1 >> 16, SVR_MPC8536v1 >> 16 } },
233 1.5.2.2 rmind #if defined(MPC8536)
234 1.5.2.2 rmind { "ddrc", DDRC1_BASE, DDRC_SIZE, 0,
235 1.5.2.2 rmind 1, { ISOURCE_DDR },
236 1.5.2.2 rmind 1 + ilog2(DEVDISR_DDR_16),
237 1.5.2.2 rmind { SVR_MPC8536v1 >> 16 } },
238 1.5.2.2 rmind #endif
239 1.5.2.2 rmind #if defined(MPC8572)
240 1.5.2.2 rmind { "ddrc", DDRC1_BASE, DDRC_SIZE, 1,
241 1.5.2.2 rmind 1, { ISOURCE_DDR },
242 1.5.2.2 rmind 1 + ilog2(DEVDISR_DDR_15),
243 1.5.2.2 rmind { SVR_MPC8572v1 >> 16 } },
244 1.5.2.2 rmind { "ddrc", DDRC1_BASE, DDRC_SIZE, 2,
245 1.5.2.2 rmind 1, { ISOURCE_DDR },
246 1.5.2.2 rmind 1 + ilog2(DEVDISR_DDR2_14),
247 1.5.2.2 rmind { SVR_MPC8572v1 >> 16 } },
248 1.5.2.2 rmind #endif
249 1.5.2.3 rmind { "lbc", LBC_BASE, LBC_SIZE, 0,
250 1.5.2.3 rmind 1, { ISOURCE_LBC },
251 1.5.2.3 rmind 1 + ilog2(DEVDISR_LBC) },
252 1.5.2.2 rmind #if defined(MPC8544) || defined(MPC8536)
253 1.5.2.2 rmind { "pcie", PCIE1_BASE, PCI_SIZE, 1,
254 1.5.2.2 rmind 1, { ISOURCE_PCIEX },
255 1.5.2.2 rmind 1 + ilog2(DEVDISR_PCIE),
256 1.5.2.2 rmind { SVR_MPC8536v1 >> 16, SVR_MPC8544v1 >> 16 } },
257 1.5.2.2 rmind { "pcie", PCIE2_MPC8544_BASE, PCI_SIZE, 2,
258 1.5.2.2 rmind 1, { ISOURCE_PCIEX2 },
259 1.5.2.2 rmind 1 + ilog2(DEVDISR_PCIE2),
260 1.5.2.2 rmind { SVR_MPC8536v1 >> 16, SVR_MPC8544v1 >> 16 } },
261 1.5.2.2 rmind { "pcie", PCIE3_MPC8544_BASE, PCI_SIZE, 3,
262 1.5.2.2 rmind 1, { ISOURCE_PCIEX3 },
263 1.5.2.2 rmind 1 + ilog2(DEVDISR_PCIE3),
264 1.5.2.2 rmind { SVR_MPC8536v1 >> 16, SVR_MPC8544v1 >> 16 } },
265 1.5.2.2 rmind { "pci", PCIX1_MPC8544_BASE, PCI_SIZE, 0,
266 1.5.2.2 rmind 1, { ISOURCE_PCI1 },
267 1.5.2.2 rmind 1 + ilog2(DEVDISR_PCI1),
268 1.5.2.2 rmind { SVR_MPC8536v1 >> 16, SVR_MPC8544v1 >> 16 } },
269 1.5.2.2 rmind #endif
270 1.5.2.2 rmind #ifdef MPC8548
271 1.5.2.2 rmind { "pcie", PCIE1_BASE, PCI_SIZE, 0,
272 1.5.2.2 rmind 1, { ISOURCE_PCIEX },
273 1.5.2.2 rmind 1 + ilog2(DEVDISR_PCIE),
274 1.5.2.2 rmind { SVR_MPC8548v1 >> 16 }, },
275 1.5.2.2 rmind { "pci", PCIX1_MPC8548_BASE, PCI_SIZE, 1,
276 1.5.2.2 rmind 1, { ISOURCE_PCI1 },
277 1.5.2.2 rmind 1 + ilog2(DEVDISR_PCI1),
278 1.5.2.2 rmind { SVR_MPC8548v1 >> 16 }, },
279 1.5.2.2 rmind { "pci", PCIX2_MPC8548_BASE, PCI_SIZE, 2,
280 1.5.2.2 rmind 1, { ISOURCE_PCI2 },
281 1.5.2.2 rmind 1 + ilog2(DEVDISR_PCI2),
282 1.5.2.2 rmind { SVR_MPC8548v1 >> 16 }, },
283 1.5.2.2 rmind #endif
284 1.5.2.2 rmind #if defined(MPC8572) || defined(P2020)
285 1.5.2.2 rmind { "pcie", PCIE1_BASE, PCI_SIZE, 1,
286 1.5.2.2 rmind 1, { ISOURCE_PCIEX },
287 1.5.2.2 rmind 1 + ilog2(DEVDISR_PCIE),
288 1.5.2.2 rmind { SVR_MPC8572v1 >> 16, SVR_P2020v2 >> 16 } },
289 1.5.2.2 rmind { "pcie", PCIE2_MPC8572_BASE, PCI_SIZE, 2,
290 1.5.2.2 rmind 1, { ISOURCE_PCIEX2 },
291 1.5.2.2 rmind 1 + ilog2(DEVDISR_PCIE2),
292 1.5.2.2 rmind { SVR_MPC8572v1 >> 16, SVR_P2020v2 >> 16 } },
293 1.5.2.2 rmind { "pcie", PCIE3_MPC8572_BASE, PCI_SIZE, 3,
294 1.5.2.2 rmind 1, { ISOURCE_PCIEX3_MPC8572 },
295 1.5.2.2 rmind 1 + ilog2(DEVDISR_PCIE3),
296 1.5.2.2 rmind { SVR_MPC8572v1 >> 16, SVR_P2020v2 >> 16 } },
297 1.5.2.2 rmind #endif
298 1.5.2.2 rmind #if defined(MPC8536) || defined(P2020)
299 1.5.2.2 rmind { "ehci", USB1_BASE, USB_SIZE, 1,
300 1.5.2.2 rmind 1, { ISOURCE_USB1 },
301 1.5.2.2 rmind 1 + ilog2(DEVDISR_USB1),
302 1.5.2.2 rmind { SVR_MPC8536v1 >> 16, SVR_P2020v2 >> 16 } },
303 1.5.2.2 rmind #endif
304 1.5.2.2 rmind #ifdef MPC8536
305 1.5.2.2 rmind { "ehci", USB2_BASE, USB_SIZE, 2,
306 1.5.2.2 rmind 1, { ISOURCE_USB2 },
307 1.5.2.2 rmind 1 + ilog2(DEVDISR_USB2),
308 1.5.2.2 rmind { SVR_MPC8536v1 >> 16 }, },
309 1.5.2.2 rmind { "ehci", USB3_BASE, USB_SIZE, 3,
310 1.5.2.2 rmind 1, { ISOURCE_USB3 },
311 1.5.2.2 rmind 1 + ilog2(DEVDISR_USB3),
312 1.5.2.2 rmind { SVR_MPC8536v1 >> 16 }, },
313 1.5.2.2 rmind { "sata", SATA1_BASE, SATA_SIZE, 1,
314 1.5.2.2 rmind 1, { ISOURCE_SATA1 },
315 1.5.2.2 rmind 1 + ilog2(DEVDISR_SATA1),
316 1.5.2.2 rmind { SVR_MPC8536v1 >> 16 }, },
317 1.5.2.2 rmind { "sata", SATA2_BASE, SATA_SIZE, 2,
318 1.5.2.2 rmind 1, { ISOURCE_SATA2 },
319 1.5.2.2 rmind 1 + ilog2(DEVDISR_SATA2),
320 1.5.2.2 rmind { SVR_MPC8536v1 >> 16 }, },
321 1.5.2.2 rmind { "spi", SPI_BASE, SPI_SIZE, 0,
322 1.5.2.2 rmind 1, { ISOURCE_SPI },
323 1.5.2.2 rmind 1 + ilog2(DEVDISR_SPI_15),
324 1.5.2.2 rmind { SVR_MPC8536v1 >> 16 }, },
325 1.5.2.2 rmind { "sdhc", ESDHC_BASE, ESDHC_SIZE, 0,
326 1.5.2.2 rmind 1, { ISOURCE_ESDHC },
327 1.5.2.2 rmind 1 + ilog2(DEVDISR_ESDHC_12),
328 1.5.2.2 rmind { SVR_MPC8536v1 >> 16 }, },
329 1.5.2.2 rmind #endif
330 1.5.2.2 rmind #if defined(P2020)
331 1.5.2.2 rmind { "spi", SPI_BASE, SPI_SIZE, 0,
332 1.5.2.2 rmind 1, { ISOURCE_SPI },
333 1.5.2.2 rmind 1 + ilog2(DEVDISR_SPI_28),
334 1.5.2.2 rmind { SVR_P2020v2 >> 16 }, },
335 1.5.2.2 rmind { "sdhc", ESDHC_BASE, ESDHC_SIZE, 0,
336 1.5.2.2 rmind 1, { ISOURCE_ESDHC },
337 1.5.2.2 rmind 1 + ilog2(DEVDISR_ESDHC_10),
338 1.5.2.2 rmind { SVR_P2020v2 >> 16 }, },
339 1.5.2.2 rmind #endif
340 1.5.2.2 rmind //{ "sec", RNG_BASE, RNG_SIZE, 0, 0, },
341 1.5.2.2 rmind { NULL }
342 1.5.2.2 rmind };
343 1.5.2.2 rmind
344 1.5.2.2 rmind static int
345 1.5.2.2 rmind e500_cngetc(dev_t dv)
346 1.5.2.2 rmind {
347 1.5.2.2 rmind volatile uint8_t * const com0addr = (void *)(GUR_BASE+CONSADDR);
348 1.5.2.2 rmind
349 1.5.2.2 rmind if ((com0addr[com_lsr] & LSR_RXRDY) == 0)
350 1.5.2.2 rmind return -1;
351 1.5.2.2 rmind
352 1.5.2.2 rmind return com0addr[com_data] & 0xff;
353 1.5.2.2 rmind }
354 1.5.2.2 rmind
355 1.5.2.2 rmind static void
356 1.5.2.2 rmind e500_cnputc(dev_t dv, int c)
357 1.5.2.2 rmind {
358 1.5.2.2 rmind volatile uint8_t * const com0addr = (void *)(GUR_BASE+CONSADDR);
359 1.5.2.2 rmind int timo = 150000;
360 1.5.2.2 rmind
361 1.5.2.2 rmind while ((com0addr[com_lsr] & LSR_TXRDY) == 0 && --timo > 0)
362 1.5.2.2 rmind ;
363 1.5.2.2 rmind
364 1.5.2.2 rmind com0addr[com_data] = c;
365 1.5.2.2 rmind __asm("mbar");
366 1.5.2.2 rmind
367 1.5.2.2 rmind while ((com0addr[com_lsr] & LSR_TSRE) == 0 && --timo > 0)
368 1.5.2.2 rmind ;
369 1.5.2.2 rmind }
370 1.5.2.2 rmind
371 1.5.2.2 rmind static void *
372 1.5.2.2 rmind gur_tlb_mapiodev(paddr_t pa, psize_t len)
373 1.5.2.2 rmind {
374 1.5.2.2 rmind if (pa < gur_bst.pbs_offset)
375 1.5.2.2 rmind return NULL;
376 1.5.2.2 rmind if (pa + len > gur_bst.pbs_offset + gur_bst.pbs_limit)
377 1.5.2.2 rmind return NULL;
378 1.5.2.2 rmind return (void *)pa;
379 1.5.2.2 rmind }
380 1.5.2.2 rmind
381 1.5.2.2 rmind static void *(* const early_tlb_mapiodev)(paddr_t, psize_t) = gur_tlb_mapiodev;
382 1.5.2.2 rmind
383 1.5.2.2 rmind static void
384 1.5.2.2 rmind e500_cpu_reset(void)
385 1.5.2.2 rmind {
386 1.5.2.2 rmind __asm volatile("sync");
387 1.5.2.2 rmind cpu_write_4(GLOBAL_BASE + RSTCR, HRESET_REQ);
388 1.5.2.2 rmind __asm volatile("msync;isync");
389 1.5.2.2 rmind }
390 1.5.2.2 rmind
391 1.5.2.2 rmind static psize_t
392 1.5.2.2 rmind memprobe(vaddr_t endkernel)
393 1.5.2.2 rmind {
394 1.5.2.2 rmind phys_ram_seg_t *mr;
395 1.5.2.3 rmind paddr_t boot_page = cpu_read_4(GUR_BPTR);
396 1.5.2.3 rmind printf(" bptr=%"PRIxPADDR, boot_page);
397 1.5.2.3 rmind if (boot_page & BPTR_EN) {
398 1.5.2.3 rmind /*
399 1.5.2.3 rmind * shift it to an address
400 1.5.2.3 rmind */
401 1.5.2.3 rmind boot_page = (boot_page & BPTR_BOOT_PAGE) << PAGE_SHIFT;
402 1.5.2.3 rmind } else {
403 1.5.2.3 rmind boot_page = ~(paddr_t)0;
404 1.5.2.3 rmind }
405 1.5.2.2 rmind
406 1.5.2.2 rmind /*
407 1.5.2.2 rmind * First we need to find out how much physical memory we have.
408 1.5.2.2 rmind * We could let our bootloader tell us, but it's almost as easy
409 1.5.2.2 rmind * to ask the DDR memory controller.
410 1.5.2.2 rmind */
411 1.5.2.2 rmind mr = physmemr;
412 1.5.2.2 rmind #if 1
413 1.5.2.2 rmind for (u_int i = 0; i < 4; i++) {
414 1.5.2.2 rmind uint32_t v = cpu_read_4(DDRC1_BASE + CS_CONFIG(i));
415 1.5.2.2 rmind if (v & CS_CONFIG_EN) {
416 1.5.2.2 rmind v = cpu_read_4(DDRC1_BASE + CS_BNDS(i));
417 1.5.2.3 rmind if (v == 0)
418 1.5.2.3 rmind continue;
419 1.5.2.2 rmind mr->start = BNDS_SA_GET(v);
420 1.5.2.2 rmind mr->size = BNDS_SIZE_GET(v);
421 1.5.2.3 rmind #if 0
422 1.5.2.3 rmind printf(" [%zd]={%#"PRIx64"@%#"PRIx64"}",
423 1.5.2.3 rmind mr - physmemr, mr->size, mr->start);
424 1.5.2.3 rmind #endif
425 1.5.2.2 rmind mr++;
426 1.5.2.2 rmind }
427 1.5.2.2 rmind }
428 1.5.2.2 rmind
429 1.5.2.2 rmind if (mr == physmemr)
430 1.5.2.2 rmind panic("no memory configured!");
431 1.5.2.2 rmind #else
432 1.5.2.2 rmind mr->start = 0;
433 1.5.2.2 rmind mr->size = 32 << 20;
434 1.5.2.2 rmind mr++;
435 1.5.2.2 rmind #endif
436 1.5.2.2 rmind
437 1.5.2.2 rmind /*
438 1.5.2.2 rmind * Sort memory regions from low to high and coalesce adjacent regions
439 1.5.2.2 rmind */
440 1.5.2.2 rmind u_int cnt = mr - physmemr;
441 1.5.2.2 rmind if (cnt > 1) {
442 1.5.2.2 rmind for (u_int i = 0; i < cnt - 1; i++) {
443 1.5.2.2 rmind for (u_int j = i + 1; j < cnt; j++) {
444 1.5.2.2 rmind if (physmemr[j].start < physmemr[i].start) {
445 1.5.2.2 rmind phys_ram_seg_t tmp = physmemr[i];
446 1.5.2.2 rmind physmemr[i] = physmemr[j];
447 1.5.2.2 rmind physmemr[j] = tmp;
448 1.5.2.2 rmind }
449 1.5.2.2 rmind }
450 1.5.2.2 rmind }
451 1.5.2.2 rmind mr = physmemr;
452 1.5.2.2 rmind for (u_int i = 0; i < cnt; i++, mr++) {
453 1.5.2.2 rmind if (mr->start + mr->size == mr[1].start) {
454 1.5.2.2 rmind mr->size += mr[1].size;
455 1.5.2.2 rmind for (u_int j = 1; j < cnt - i; j++)
456 1.5.2.2 rmind mr[j] = mr[j+1];
457 1.5.2.2 rmind cnt--;
458 1.5.2.2 rmind }
459 1.5.2.2 rmind }
460 1.5.2.2 rmind }
461 1.5.2.2 rmind
462 1.5.2.2 rmind /*
463 1.5.2.2 rmind * Copy physical memory to available memory.
464 1.5.2.2 rmind */
465 1.5.2.2 rmind memcpy(availmemr, physmemr, cnt * sizeof(physmemr[0]));
466 1.5.2.2 rmind
467 1.5.2.2 rmind /*
468 1.5.2.2 rmind * Adjust available memory to skip kernel at start of memory.
469 1.5.2.2 rmind */
470 1.5.2.2 rmind availmemr[0].size -= endkernel - availmemr[0].start;
471 1.5.2.2 rmind availmemr[0].start = endkernel;
472 1.5.2.2 rmind
473 1.5.2.3 rmind mr = availmemr;
474 1.5.2.3 rmind for (u_int i = 0; i < cnt; i++, mr++) {
475 1.5.2.3 rmind /*
476 1.5.2.3 rmind * U-boot reserves a boot-page on multi-core chips.
477 1.5.2.3 rmind * We need to make sure that we never disturb it.
478 1.5.2.3 rmind */
479 1.5.2.3 rmind const paddr_t mr_end = mr->start + mr->size;
480 1.5.2.3 rmind if (mr_end > boot_page && boot_page >= mr->start) {
481 1.5.2.3 rmind /*
482 1.5.2.3 rmind * Normally u-boot will put in at the end
483 1.5.2.3 rmind * of memory. But in case it doesn't, deal
484 1.5.2.3 rmind * with all possibilities.
485 1.5.2.3 rmind */
486 1.5.2.3 rmind if (boot_page + PAGE_SIZE == mr_end) {
487 1.5.2.3 rmind mr->size -= PAGE_SIZE;
488 1.5.2.3 rmind } else if (boot_page == mr->start) {
489 1.5.2.3 rmind mr->start += PAGE_SIZE;
490 1.5.2.3 rmind mr->size -= PAGE_SIZE;
491 1.5.2.3 rmind } else {
492 1.5.2.3 rmind mr->size = boot_page - mr->start;
493 1.5.2.3 rmind mr++;
494 1.5.2.3 rmind for (u_int j = cnt; j > i + 1; j--) {
495 1.5.2.3 rmind availmemr[j] = availmemr[j-1];
496 1.5.2.3 rmind }
497 1.5.2.3 rmind cnt++;
498 1.5.2.3 rmind mr->start = boot_page + PAGE_SIZE;
499 1.5.2.3 rmind mr->size = mr_end - mr->start;
500 1.5.2.3 rmind }
501 1.5.2.3 rmind break;
502 1.5.2.3 rmind }
503 1.5.2.3 rmind }
504 1.5.2.3 rmind
505 1.5.2.2 rmind /*
506 1.5.2.2 rmind * Steal pages at the end of memory for the kernel message buffer.
507 1.5.2.2 rmind */
508 1.5.2.2 rmind availmemr[cnt-1].size -= round_page(MSGBUFSIZE);
509 1.5.2.2 rmind msgbuf_paddr =
510 1.5.2.2 rmind (uintptr_t)(availmemr[cnt-1].start + availmemr[cnt-1].size);
511 1.5.2.2 rmind
512 1.5.2.2 rmind /*
513 1.5.2.2 rmind * Calculate physmem.
514 1.5.2.2 rmind */
515 1.5.2.2 rmind for (u_int i = 0; i < cnt; i++)
516 1.5.2.2 rmind physmem += atop(physmemr[i].size);
517 1.5.2.2 rmind
518 1.5.2.2 rmind nmemr = cnt;
519 1.5.2.2 rmind return physmemr[cnt-1].start + physmemr[cnt-1].size;
520 1.5.2.2 rmind }
521 1.5.2.2 rmind
522 1.5.2.2 rmind void
523 1.5.2.2 rmind consinit(void)
524 1.5.2.2 rmind {
525 1.5.2.2 rmind static bool attached = false;
526 1.5.2.2 rmind
527 1.5.2.2 rmind if (attached)
528 1.5.2.2 rmind return;
529 1.5.2.2 rmind attached = true;
530 1.5.2.2 rmind
531 1.5.2.2 rmind if (comcnfreq == -1) {
532 1.5.2.2 rmind const uint32_t porpplsr = cpu_read_4(GLOBAL_BASE + PORPLLSR);
533 1.5.2.2 rmind const uint32_t plat_ratio = PLAT_RATIO_GET(porpplsr);
534 1.5.2.2 rmind comcnfreq = e500_sys_clk * plat_ratio;
535 1.5.2.2 rmind printf(" comcnfreq=%u", comcnfreq);
536 1.5.2.2 rmind }
537 1.5.2.2 rmind
538 1.5.2.2 rmind comcnattach(&gur_bst, comcnaddr, comcnspeed, comcnfreq,
539 1.5.2.2 rmind COM_TYPE_NORMAL, comcnmode);
540 1.5.2.2 rmind }
541 1.5.2.2 rmind
542 1.5.2.2 rmind void
543 1.5.2.2 rmind cpu_probe_cache(void)
544 1.5.2.2 rmind {
545 1.5.2.2 rmind struct cpu_info * const ci = curcpu();
546 1.5.2.2 rmind const uint32_t l1cfg0 = mfspr(SPR_L1CFG0);
547 1.5.2.2 rmind
548 1.5.2.2 rmind ci->ci_ci.dcache_size = L1CFG_CSIZE_GET(l1cfg0);
549 1.5.2.2 rmind ci->ci_ci.dcache_line_size = 32 << L1CFG_CBSIZE_GET(l1cfg0);
550 1.5.2.2 rmind
551 1.5.2.2 rmind if (L1CFG_CARCH_GET(l1cfg0) == L1CFG_CARCH_HARVARD) {
552 1.5.2.2 rmind const uint32_t l1cfg1 = mfspr(SPR_L1CFG1);
553 1.5.2.2 rmind
554 1.5.2.2 rmind ci->ci_ci.icache_size = L1CFG_CSIZE_GET(l1cfg1);
555 1.5.2.2 rmind ci->ci_ci.icache_line_size = 32 << L1CFG_CBSIZE_GET(l1cfg1);
556 1.5.2.2 rmind } else {
557 1.5.2.2 rmind ci->ci_ci.icache_size = ci->ci_ci.dcache_size;
558 1.5.2.2 rmind ci->ci_ci.icache_line_size = ci->ci_ci.dcache_line_size;
559 1.5.2.2 rmind }
560 1.5.2.2 rmind
561 1.5.2.2 rmind #ifdef DEBUG
562 1.5.2.2 rmind uint32_t l1csr0 = mfspr(SPR_L1CSR0);
563 1.5.2.2 rmind if ((L1CSR_CE & l1csr0) == 0)
564 1.5.2.2 rmind printf(" DC=off");
565 1.5.2.2 rmind
566 1.5.2.2 rmind uint32_t l1csr1 = mfspr(SPR_L1CSR1);
567 1.5.2.2 rmind if ((L1CSR_CE & l1csr1) == 0)
568 1.5.2.2 rmind printf(" IC=off");
569 1.5.2.2 rmind #endif
570 1.5.2.2 rmind }
571 1.5.2.2 rmind
572 1.5.2.2 rmind static uint16_t
573 1.5.2.2 rmind getsvr(void)
574 1.5.2.2 rmind {
575 1.5.2.2 rmind uint16_t svr = mfspr(SPR_SVR) >> 16;
576 1.5.2.2 rmind
577 1.5.2.2 rmind svr &= ~0x8; /* clear security bit */
578 1.5.2.2 rmind switch (svr) {
579 1.5.2.2 rmind case SVR_MPC8543v1 >> 16: return SVR_MPC8548v1 >> 16;
580 1.5.2.2 rmind case SVR_MPC8541v1 >> 16: return SVR_MPC8555v1 >> 16;
581 1.5.2.2 rmind case SVR_P2010v2 >> 16: return SVR_P2020v2 >> 16;
582 1.5.2.2 rmind default: return svr;
583 1.5.2.2 rmind }
584 1.5.2.2 rmind }
585 1.5.2.2 rmind
586 1.5.2.2 rmind static const char *
587 1.5.2.2 rmind socname(uint32_t svr)
588 1.5.2.2 rmind {
589 1.5.2.2 rmind svr &= ~0x80000; /* clear security bit */
590 1.5.2.2 rmind switch (svr >> 8) {
591 1.5.2.2 rmind case SVR_MPC8533 >> 8: return "MPC8533";
592 1.5.2.2 rmind case SVR_MPC8536v1 >> 8: return "MPC8536";
593 1.5.2.2 rmind case SVR_MPC8541v1 >> 8: return "MPC8541";
594 1.5.2.2 rmind case SVR_MPC8543v2 >> 8: return "MPC8543";
595 1.5.2.2 rmind case SVR_MPC8544v1 >> 8: return "MPC8544";
596 1.5.2.2 rmind case SVR_MPC8545v2 >> 8: return "MPC8545";
597 1.5.2.2 rmind case SVR_MPC8547v2 >> 8: return "MPC8547";
598 1.5.2.2 rmind case SVR_MPC8548v2 >> 8: return "MPC8548";
599 1.5.2.2 rmind case SVR_MPC8555v1 >> 8: return "MPC8555";
600 1.5.2.2 rmind case SVR_MPC8568v1 >> 8: return "MPC8568";
601 1.5.2.2 rmind case SVR_MPC8567v1 >> 8: return "MPC8567";
602 1.5.2.2 rmind case SVR_MPC8572v1 >> 8: return "MPC8572";
603 1.5.2.2 rmind case SVR_P2020v2 >> 8: return "P2020";
604 1.5.2.2 rmind case SVR_P2010v2 >> 8: return "P2010";
605 1.5.2.2 rmind default:
606 1.5.2.2 rmind panic("%s: unknown SVR %#x", __func__, svr);
607 1.5.2.2 rmind }
608 1.5.2.2 rmind }
609 1.5.2.2 rmind
610 1.5.2.2 rmind static void
611 1.5.2.2 rmind e500_tlb_print(device_t self, const char *name, uint32_t tlbcfg)
612 1.5.2.2 rmind {
613 1.5.2.2 rmind static const char units[16] = "KKKKKMMMMMGGGGGT";
614 1.5.2.2 rmind
615 1.5.2.2 rmind const uint32_t minsize = 1U << (2 * TLBCFG_MINSIZE(tlbcfg));
616 1.5.2.2 rmind const uint32_t assoc = TLBCFG_ASSOC(tlbcfg);
617 1.5.2.2 rmind const u_int maxsize_log4k = TLBCFG_MAXSIZE(tlbcfg);
618 1.5.2.2 rmind const uint64_t maxsize = 1ULL << (2 * maxsize_log4k % 10);
619 1.5.2.2 rmind const uint32_t nentries = TLBCFG_NENTRY(tlbcfg);
620 1.5.2.2 rmind
621 1.5.2.2 rmind aprint_normal_dev(self, "%s:", name);
622 1.5.2.2 rmind
623 1.5.2.2 rmind aprint_normal(" %u", nentries);
624 1.5.2.2 rmind if (TLBCFG_AVAIL_P(tlbcfg)) {
625 1.5.2.2 rmind aprint_normal(" variable-size (%uKB..%"PRIu64"%cB)",
626 1.5.2.2 rmind minsize, maxsize, units[maxsize_log4k]);
627 1.5.2.2 rmind } else {
628 1.5.2.2 rmind aprint_normal(" fixed-size (%uKB)", minsize);
629 1.5.2.2 rmind }
630 1.5.2.2 rmind if (assoc == 0 || assoc == nentries)
631 1.5.2.2 rmind aprint_normal(" fully");
632 1.5.2.2 rmind else
633 1.5.2.2 rmind aprint_normal(" %u-way set", assoc);
634 1.5.2.2 rmind aprint_normal(" associative entries\n");
635 1.5.2.2 rmind }
636 1.5.2.2 rmind
637 1.5.2.2 rmind static void
638 1.5.2.2 rmind e500_cpu_attach(device_t self, u_int instance)
639 1.5.2.2 rmind {
640 1.5.2.3 rmind struct cpu_info * const ci = &cpu_info[instance - (instance > 0)];
641 1.5.2.2 rmind
642 1.5.2.3 rmind if (instance > 1) {
643 1.5.2.3 rmind #ifdef MULTIPROCESSOR
644 1.5.2.3 rmind #error still needs to be written
645 1.5.2.2 rmind ci->ci_idepth = -1;
646 1.5.2.2 rmind cpu_probe_cache();
647 1.5.2.3 rmind #else
648 1.5.2.3 rmind aprint_error_dev(self, "disabled (uniprocessor kernel)\n");
649 1.5.2.3 rmind return;
650 1.5.2.3 rmind #endif
651 1.5.2.2 rmind }
652 1.5.2.2 rmind
653 1.5.2.3 rmind self->dv_private = ci;
654 1.5.2.3 rmind
655 1.5.2.3 rmind ci->ci_cpuid = instance - (instance > 0);
656 1.5.2.3 rmind ci->ci_dev = self;
657 1.5.2.3 rmind //ci->ci_idlespin = cpu_idlespin;
658 1.5.2.2 rmind uint64_t freq = board_info_get_number("processor-frequency");
659 1.5.2.3 rmind
660 1.5.2.2 rmind char freqbuf[10];
661 1.5.2.2 rmind if (freq >= 999500000) {
662 1.5.2.2 rmind const uint32_t freq32 = (freq + 500000) / 10000000;
663 1.5.2.2 rmind snprintf(freqbuf, sizeof(freqbuf), "%u.%02u GHz",
664 1.5.2.2 rmind freq32 / 100, freq32 % 100);
665 1.5.2.2 rmind } else {
666 1.5.2.2 rmind const uint32_t freq32 = (freq + 500000) / 1000000;
667 1.5.2.2 rmind snprintf(freqbuf, sizeof(freqbuf), "%u MHz", freq32);
668 1.5.2.2 rmind }
669 1.5.2.2 rmind
670 1.5.2.2 rmind const uint32_t pvr = mfpvr();
671 1.5.2.2 rmind const uint32_t svr = mfspr(SPR_SVR);
672 1.5.2.2 rmind const uint32_t pir = mfspr(SPR_PIR);
673 1.5.2.2 rmind
674 1.5.2.2 rmind aprint_normal_dev(self, "%s %s%s %u.%u with an e500%s %u.%u core, "
675 1.5.2.2 rmind "ID %u%s\n",
676 1.5.2.2 rmind freqbuf, socname(svr), (SVR_SECURITY_P(svr) ? "E" : ""),
677 1.5.2.2 rmind (svr >> 4) & 15, svr & 15,
678 1.5.2.2 rmind (pvr >> 16) == PVR_MPCe500v2 ? "v2" : "",
679 1.5.2.2 rmind (pvr >> 4) & 15, pvr & 15,
680 1.5.2.2 rmind pir, (pir == 0 ? " (Primary)" : ""));
681 1.5.2.2 rmind
682 1.5.2.2 rmind const uint32_t l1cfg0 = mfspr(SPR_L1CFG0);
683 1.5.2.2 rmind aprint_normal_dev(self,
684 1.5.2.2 rmind "%uKB/%uB %u-way L1 %s cache\n",
685 1.5.2.2 rmind L1CFG_CSIZE_GET(l1cfg0) >> 10,
686 1.5.2.2 rmind 32 << L1CFG_CBSIZE_GET(l1cfg0),
687 1.5.2.2 rmind L1CFG_CNWAY_GET(l1cfg0),
688 1.5.2.2 rmind L1CFG_CARCH_GET(l1cfg0) == L1CFG_CARCH_HARVARD
689 1.5.2.2 rmind ? "data" : "unified");
690 1.5.2.2 rmind
691 1.5.2.2 rmind if (L1CFG_CARCH_GET(l1cfg0) == L1CFG_CARCH_HARVARD) {
692 1.5.2.2 rmind const uint32_t l1cfg1 = mfspr(SPR_L1CFG1);
693 1.5.2.2 rmind aprint_normal_dev(self,
694 1.5.2.2 rmind "%uKB/%uB %u-way L1 %s cache\n",
695 1.5.2.2 rmind L1CFG_CSIZE_GET(l1cfg1) >> 10,
696 1.5.2.2 rmind 32 << L1CFG_CBSIZE_GET(l1cfg1),
697 1.5.2.2 rmind L1CFG_CNWAY_GET(l1cfg1),
698 1.5.2.2 rmind "instruction");
699 1.5.2.2 rmind }
700 1.5.2.2 rmind
701 1.5.2.2 rmind const uint32_t mmucfg = mfspr(SPR_MMUCFG);
702 1.5.2.2 rmind aprint_normal_dev(self,
703 1.5.2.2 rmind "%u TLBs, %u concurrent %u-bit PIDs (%u total)\n",
704 1.5.2.2 rmind MMUCFG_NTLBS_GET(mmucfg) + 1,
705 1.5.2.2 rmind MMUCFG_NPIDS_GET(mmucfg),
706 1.5.2.2 rmind MMUCFG_PIDSIZE_GET(mmucfg) + 1,
707 1.5.2.2 rmind 1 << (MMUCFG_PIDSIZE_GET(mmucfg) + 1));
708 1.5.2.2 rmind
709 1.5.2.2 rmind e500_tlb_print(self, "tlb0", mfspr(SPR_TLB0CFG));
710 1.5.2.2 rmind e500_tlb_print(self, "tlb1", mfspr(SPR_TLB1CFG));
711 1.5.2.2 rmind
712 1.5.2.2 rmind intr_cpu_init(ci);
713 1.5.2.2 rmind cpu_evcnt_attach(ci);
714 1.5.2.2 rmind }
715 1.5.2.2 rmind
716 1.5.2.2 rmind static void
717 1.5.2.2 rmind calltozero(void)
718 1.5.2.2 rmind {
719 1.5.2.2 rmind panic("call to 0 from %p", __builtin_return_address(0));
720 1.5.2.2 rmind }
721 1.5.2.2 rmind
722 1.5.2.2 rmind void
723 1.5.2.2 rmind initppc(vaddr_t startkernel, vaddr_t endkernel)
724 1.5.2.2 rmind {
725 1.5.2.2 rmind struct cpu_info * const ci = curcpu();
726 1.5.2.2 rmind struct cpu_softc * const cpu = ci->ci_softc;
727 1.5.2.2 rmind
728 1.5.2.2 rmind cn_tab = &e500_earlycons;
729 1.5.2.2 rmind printf(" initppc<enter>");
730 1.5.2.2 rmind
731 1.5.2.2 rmind const register_t hid0 = mfspr(SPR_HID0);
732 1.5.2.2 rmind mtspr(SPR_HID0, hid0 | HID0_TBEN | HID0_EMCP);
733 1.5.2.2 rmind #ifdef CADMUS
734 1.5.2.2 rmind /*
735 1.5.2.2 rmind * Need to cache this from cadmus since we need to unmap cadmus since
736 1.5.2.2 rmind * it falls in the middle of kernel address space.
737 1.5.2.2 rmind */
738 1.5.2.2 rmind cadmus_pci = ((uint8_t *)0xf8004000)[CM_PCI];
739 1.5.2.2 rmind cadmus_csr = ((uint8_t *)0xf8004000)[CM_CSR];
740 1.5.2.2 rmind ((uint8_t *)0xf8004000)[CM_CSR] |= CM_RST_PHYRST;
741 1.5.2.2 rmind printf(" cadmus_pci=%#x", cadmus_pci);
742 1.5.2.2 rmind printf(" cadmus_csr=%#x", cadmus_csr);
743 1.5.2.2 rmind ((uint8_t *)0xf8004000)[CM_CSR] = 0;
744 1.5.2.2 rmind if ((cadmus_pci & CM_PCI_PSPEED) == CM_PCI_PSPEED_66) {
745 1.5.2.2 rmind e500_sys_clk *= 2;
746 1.5.2.2 rmind }
747 1.5.2.2 rmind #endif
748 1.5.2.2 rmind #ifdef PIXIS
749 1.5.2.2 rmind pixis_spd = ((uint8_t *)PX_BASE)[PX_SPD];
750 1.5.2.3 rmind printf(" pixis_spd=%#x sysclk=%"PRIuMAX,
751 1.5.2.3 rmind pixis_spd, PX_SPD_SYSCLK_GET(pixis_spd));
752 1.5.2.3 rmind #ifndef SYS_CLK
753 1.5.2.2 rmind e500_sys_clk = pixis_spd_map[PX_SPD_SYSCLK_GET(pixis_spd)];
754 1.5.2.3 rmind #else
755 1.5.2.3 rmind printf(" pixis_sysclk=%u", pixis_spd_map[PX_SPD_SYSCLK_GET(pixis_spd)]);
756 1.5.2.3 rmind #endif
757 1.5.2.2 rmind #endif
758 1.5.2.2 rmind printf(" porpllsr=0x%08x",
759 1.5.2.2 rmind *(uint32_t *)(GUR_BASE + GLOBAL_BASE + PORPLLSR));
760 1.5.2.2 rmind printf(" sys_clk=%"PRIu64, e500_sys_clk);
761 1.5.2.2 rmind
762 1.5.2.2 rmind /*
763 1.5.2.2 rmind * Make sure arguments are page aligned.
764 1.5.2.2 rmind */
765 1.5.2.2 rmind startkernel = trunc_page(startkernel);
766 1.5.2.2 rmind endkernel = round_page(endkernel);
767 1.5.2.2 rmind
768 1.5.2.2 rmind /*
769 1.5.2.2 rmind * Initialize the bus space tag used to access the 85xx general
770 1.5.2.2 rmind * utility registers. It doesn't need to be extent protected.
771 1.5.2.2 rmind * We know the GUR is mapped via a TLB1 entry so we add a limited
772 1.5.2.2 rmind * mapiodev which allows mappings in GUR space.
773 1.5.2.2 rmind */
774 1.5.2.2 rmind CTASSERT(offsetof(struct tlb_md_ops, md_tlb_mapiodev) == 0);
775 1.5.2.2 rmind cpu_md_ops.md_tlb_ops = (const void *)&early_tlb_mapiodev;
776 1.5.2.2 rmind bus_space_init(&gur_bst, NULL, NULL, 0);
777 1.5.2.2 rmind bus_space_init(&gur_le_bst, NULL, NULL, 0);
778 1.5.2.2 rmind cpu->cpu_bst = &gur_bst;
779 1.5.2.2 rmind cpu->cpu_le_bst = &gur_le_bst;
780 1.5.2.2 rmind cpu->cpu_bsh = gur_bsh;
781 1.5.2.2 rmind
782 1.5.2.2 rmind /*
783 1.5.2.2 rmind * Attach the console early, really early.
784 1.5.2.2 rmind */
785 1.5.2.2 rmind consinit();
786 1.5.2.2 rmind
787 1.5.2.2 rmind /*
788 1.5.2.2 rmind * Reset the PIC to a known state.
789 1.5.2.2 rmind */
790 1.5.2.2 rmind cpu_write_4(OPENPIC_BASE + OPENPIC_GCR, GCR_RST);
791 1.5.2.2 rmind while (cpu_read_4(OPENPIC_BASE + OPENPIC_GCR) & GCR_RST)
792 1.5.2.2 rmind ;
793 1.5.2.2 rmind #if 0
794 1.5.2.2 rmind cpu_write_4(OPENPIC_BASE + OPENPIC_CTPR, 15); /* IPL_HIGH */
795 1.5.2.2 rmind #endif
796 1.5.2.2 rmind printf(" openpic-reset(ctpr=%u)",
797 1.5.2.2 rmind cpu_read_4(OPENPIC_BASE + OPENPIC_CTPR));
798 1.5.2.2 rmind
799 1.5.2.2 rmind /*
800 1.5.2.2 rmind * fill in with an absolute branch to a routine that will panic.
801 1.5.2.2 rmind */
802 1.5.2.2 rmind *(int *)0 = 0x48000002 | (int) calltozero;
803 1.5.2.2 rmind
804 1.5.2.2 rmind /*
805 1.5.2.2 rmind * Get the cache sizes.
806 1.5.2.2 rmind */
807 1.5.2.2 rmind cpu_probe_cache();
808 1.5.2.3 rmind printf(" cache(DC=%uKB/%u,IC=%uKB/%u)",
809 1.5.2.2 rmind ci->ci_ci.dcache_size >> 10,
810 1.5.2.2 rmind ci->ci_ci.dcache_line_size,
811 1.5.2.2 rmind ci->ci_ci.icache_size >> 10,
812 1.5.2.2 rmind ci->ci_ci.icache_line_size);
813 1.5.2.2 rmind
814 1.5.2.2 rmind /*
815 1.5.2.2 rmind * Now find out how much memory is attached
816 1.5.2.2 rmind */
817 1.5.2.2 rmind pmemsize = memprobe(endkernel);
818 1.5.2.2 rmind cpu->cpu_highmem = pmemsize;
819 1.5.2.2 rmind printf(" memprobe=%zuMB", (size_t) (pmemsize >> 20));
820 1.5.2.2 rmind
821 1.5.2.2 rmind /*
822 1.5.2.2 rmind * Now we need cleanout the TLB of stuff that we don't need.
823 1.5.2.2 rmind */
824 1.5.2.2 rmind e500_tlb_init(endkernel, pmemsize);
825 1.5.2.2 rmind printf(" e500_tlbinit(%#lx,%zuMB)",
826 1.5.2.2 rmind endkernel, (size_t) (pmemsize >> 20));
827 1.5.2.2 rmind
828 1.5.2.2 rmind /*
829 1.5.2.2 rmind *
830 1.5.2.2 rmind */
831 1.5.2.2 rmind printf(" hid0=%#lx/%#lx", hid0, mfspr(SPR_HID0));
832 1.5.2.2 rmind printf(" hid1=%#lx", mfspr(SPR_HID1));
833 1.5.2.2 rmind printf(" pordevsr=%#x", cpu_read_4(GLOBAL_BASE + PORDEVSR));
834 1.5.2.2 rmind printf(" devdisr=%#x", cpu_read_4(GLOBAL_BASE + DEVDISR));
835 1.5.2.2 rmind
836 1.5.2.2 rmind mtmsr(mfmsr() | PSL_CE | PSL_ME | PSL_DE);
837 1.5.2.2 rmind
838 1.5.2.2 rmind /*
839 1.5.2.2 rmind * Initialize the message buffer.
840 1.5.2.2 rmind */
841 1.5.2.2 rmind initmsgbuf((void *)msgbuf_paddr, round_page(MSGBUFSIZE));
842 1.5.2.2 rmind printf(" msgbuf=%p", (void *)msgbuf_paddr);
843 1.5.2.2 rmind
844 1.5.2.2 rmind /*
845 1.5.2.2 rmind * Initialize exception vectors and interrupts
846 1.5.2.2 rmind */
847 1.5.2.2 rmind exception_init(&e500_intrsw);
848 1.5.2.2 rmind printf(" exception_init=%p", &e500_intrsw);
849 1.5.2.2 rmind mtspr(SPR_TCR, TCR_WIE | mfspr(SPR_TCR));
850 1.5.2.2 rmind
851 1.5.2.2 rmind /*
852 1.5.2.2 rmind * Set the page size.
853 1.5.2.2 rmind */
854 1.5.2.2 rmind uvm_setpagesize();
855 1.5.2.2 rmind
856 1.5.2.2 rmind /*
857 1.5.2.2 rmind * Initialize the pmap.
858 1.5.2.2 rmind */
859 1.5.2.2 rmind pmap_bootstrap(startkernel, endkernel, availmemr, nmemr);
860 1.5.2.2 rmind
861 1.5.2.2 rmind /*
862 1.5.2.2 rmind * Let's take all the indirect calls via our stubs and patch
863 1.5.2.2 rmind * them to be direct calls.
864 1.5.2.2 rmind */
865 1.5.2.2 rmind booke_fixup_stubs();
866 1.5.2.2 rmind #if 0
867 1.5.2.2 rmind /*
868 1.5.2.2 rmind * As a debug measure we can change the TLB entry that maps all of
869 1.5.2.2 rmind * memory to one that encompasses the 64KB with the kernel vectors.
870 1.5.2.2 rmind * All other pages will be soft faulted into the TLB as needed.
871 1.5.2.2 rmind */
872 1.5.2.2 rmind const uint32_t saved_mas0 = mfspr(SPR_MAS0);
873 1.5.2.2 rmind mtspr(SPR_MAS6, 0);
874 1.5.2.2 rmind __asm volatile("tlbsx\t0, %0" :: "b"(startkernel));
875 1.5.2.2 rmind uint32_t mas0 = mfspr(SPR_MAS0);
876 1.5.2.2 rmind uint32_t mas1 = mfspr(SPR_MAS1);
877 1.5.2.2 rmind uint32_t mas2 = mfspr(SPR_MAS2);
878 1.5.2.2 rmind uint32_t mas3 = mfspr(SPR_MAS3);
879 1.5.2.2 rmind KASSERT(mas3 & MAS3_SW);
880 1.5.2.2 rmind KASSERT(mas3 & MAS3_SR);
881 1.5.2.2 rmind KASSERT(mas3 & MAS3_SX);
882 1.5.2.2 rmind mas1 = (mas1 & ~MAS1_TSIZE) | MASX_TSIZE_64KB;
883 1.5.2.2 rmind pt_entry_t xpn_mask = ~0 << (10 + 2 * MASX_TSIZE_GET(mas1));
884 1.5.2.2 rmind mas2 = (mas2 & ~(MAS2_EPN )) | (startkernel & xpn_mask);
885 1.5.2.2 rmind mas3 = (mas3 & ~(MAS3_RPN|MAS3_SW)) | (startkernel & xpn_mask);
886 1.5.2.2 rmind printf(" %#lx=<%#x,%#x,%#x,%#x>", startkernel, mas0, mas1, mas2, mas3);
887 1.5.2.2 rmind #if 1
888 1.5.2.2 rmind mtspr(SPR_MAS1, mas1);
889 1.5.2.2 rmind mtspr(SPR_MAS2, mas2);
890 1.5.2.2 rmind mtspr(SPR_MAS3, mas3);
891 1.5.2.2 rmind extern void tlbwe(void);
892 1.5.2.2 rmind tlbwe();
893 1.5.2.2 rmind mtspr(SPR_MAS0, saved_mas0);
894 1.5.2.2 rmind printf("(ok)");
895 1.5.2.2 rmind #endif
896 1.5.2.2 rmind #endif
897 1.5.2.2 rmind
898 1.5.2.2 rmind /*
899 1.5.2.2 rmind * Set some more MD helpers
900 1.5.2.2 rmind */
901 1.5.2.2 rmind cpu_md_ops.md_cpunode_locs = mpc8548_cpunode_locs;
902 1.5.2.2 rmind cpu_md_ops.md_device_register = e500_device_register;
903 1.5.2.2 rmind cpu_md_ops.md_cpu_attach = e500_cpu_attach;
904 1.5.2.2 rmind cpu_md_ops.md_cpu_reset = e500_cpu_reset;
905 1.5.2.2 rmind #if NGPIO > 0
906 1.5.2.2 rmind cpu_md_ops.md_cpunode_attach = pq3gpio_attach;
907 1.5.2.2 rmind #endif
908 1.5.2.2 rmind
909 1.5.2.2 rmind printf(" initppc done!\n");
910 1.5.2.2 rmind }
911 1.5.2.2 rmind
912 1.5.2.2 rmind #ifdef MPC8548
913 1.5.2.2 rmind static const char * const mpc8548cds_extirq_names[] = {
914 1.5.2.2 rmind [0] = "pci inta",
915 1.5.2.2 rmind [1] = "pci intb",
916 1.5.2.2 rmind [2] = "pci intc",
917 1.5.2.2 rmind [3] = "pci intd",
918 1.5.2.2 rmind [4] = "irq4",
919 1.5.2.2 rmind [5] = "gige phy",
920 1.5.2.2 rmind [6] = "atm phy",
921 1.5.2.2 rmind [7] = "cpld",
922 1.5.2.2 rmind [8] = "irq8",
923 1.5.2.2 rmind [9] = "nvram",
924 1.5.2.2 rmind [10] = "debug",
925 1.5.2.2 rmind [11] = "pci2 inta",
926 1.5.2.2 rmind };
927 1.5.2.2 rmind #endif
928 1.5.2.2 rmind
929 1.5.2.2 rmind static const char * const mpc85xx_extirq_names[] = {
930 1.5.2.2 rmind [0] = "extirq 0",
931 1.5.2.2 rmind [1] = "extirq 1",
932 1.5.2.2 rmind [2] = "extirq 2",
933 1.5.2.2 rmind [3] = "extirq 3",
934 1.5.2.2 rmind [4] = "extirq 4",
935 1.5.2.2 rmind [5] = "extirq 5",
936 1.5.2.2 rmind [6] = "extirq 6",
937 1.5.2.2 rmind [7] = "extirq 7",
938 1.5.2.2 rmind [8] = "extirq 8",
939 1.5.2.2 rmind [9] = "extirq 9",
940 1.5.2.2 rmind [10] = "extirq 10",
941 1.5.2.2 rmind [11] = "extirq 11",
942 1.5.2.2 rmind };
943 1.5.2.2 rmind
944 1.5.2.2 rmind static void
945 1.5.2.2 rmind mpc85xx_extirq_setup(void)
946 1.5.2.2 rmind {
947 1.5.2.2 rmind #ifdef MPC8548
948 1.5.2.2 rmind const char * const * names = mpc8548cds_extirq_names;
949 1.5.2.2 rmind const size_t n = __arraycount(mpc8548cds_extirq_names);
950 1.5.2.2 rmind #else
951 1.5.2.2 rmind const char * const * names = mpc85xx_extirq_names;
952 1.5.2.2 rmind const size_t n = __arraycount(mpc85xx_extirq_names);
953 1.5.2.2 rmind #endif
954 1.5.2.2 rmind prop_array_t extirqs = prop_array_create_with_capacity(n);
955 1.5.2.2 rmind for (u_int i = 0; i < n; i++) {
956 1.5.2.2 rmind prop_string_t ps = prop_string_create_cstring_nocopy(names[i]);
957 1.5.2.2 rmind prop_array_set(extirqs, i, ps);
958 1.5.2.2 rmind prop_object_release(ps);
959 1.5.2.2 rmind }
960 1.5.2.2 rmind board_info_add_object("external-irqs", extirqs);
961 1.5.2.2 rmind prop_object_release(extirqs);
962 1.5.2.2 rmind }
963 1.5.2.2 rmind
964 1.5.2.2 rmind static void
965 1.5.2.2 rmind mpc85xx_pci_setup(const char *name, uint32_t intmask, int ist, int inta, ...)
966 1.5.2.2 rmind {
967 1.5.2.2 rmind prop_dictionary_t pci_intmap = prop_dictionary_create();
968 1.5.2.2 rmind KASSERT(pci_intmap != NULL);
969 1.5.2.2 rmind prop_number_t mask = prop_number_create_unsigned_integer(intmask);
970 1.5.2.2 rmind KASSERT(mask != NULL);
971 1.5.2.2 rmind prop_dictionary_set(pci_intmap, "interrupt-mask", mask);
972 1.5.2.2 rmind prop_object_release(mask);
973 1.5.2.2 rmind prop_number_t pn_ist = prop_number_create_unsigned_integer(ist);
974 1.5.2.2 rmind KASSERT(pn_ist != NULL);
975 1.5.2.2 rmind prop_number_t pn_intr = prop_number_create_unsigned_integer(inta);
976 1.5.2.2 rmind KASSERT(pn_intr != NULL);
977 1.5.2.2 rmind prop_dictionary_t entry = prop_dictionary_create();
978 1.5.2.2 rmind KASSERT(entry != NULL);
979 1.5.2.2 rmind prop_dictionary_set(entry, "interrupt", pn_intr);
980 1.5.2.2 rmind prop_dictionary_set(entry, "type", pn_ist);
981 1.5.2.2 rmind prop_dictionary_set(pci_intmap, "000000", entry);
982 1.5.2.2 rmind prop_object_release(pn_intr);
983 1.5.2.2 rmind prop_object_release(entry);
984 1.5.2.2 rmind va_list ap;
985 1.5.2.2 rmind va_start(ap, inta);
986 1.5.2.2 rmind u_int intrinc = __LOWEST_SET_BIT(intmask);
987 1.5.2.2 rmind for (u_int i = 0; i < intmask; i += intrinc) {
988 1.5.2.2 rmind char prop_name[12];
989 1.5.2.2 rmind snprintf(prop_name, sizeof(prop_name), "%06x", i + intrinc);
990 1.5.2.2 rmind entry = prop_dictionary_create();
991 1.5.2.2 rmind KASSERT(entry != NULL);
992 1.5.2.2 rmind pn_intr = prop_number_create_unsigned_integer(va_arg(ap, u_int));
993 1.5.2.2 rmind KASSERT(pn_intr != NULL);
994 1.5.2.2 rmind prop_dictionary_set(entry, "interrupt", pn_intr);
995 1.5.2.2 rmind prop_dictionary_set(entry, "type", pn_ist);
996 1.5.2.2 rmind prop_dictionary_set(pci_intmap, prop_name, entry);
997 1.5.2.2 rmind prop_object_release(pn_intr);
998 1.5.2.2 rmind prop_object_release(entry);
999 1.5.2.2 rmind }
1000 1.5.2.2 rmind va_end(ap);
1001 1.5.2.2 rmind prop_object_release(pn_ist);
1002 1.5.2.2 rmind board_info_add_object(name, pci_intmap);
1003 1.5.2.2 rmind prop_object_release(pci_intmap);
1004 1.5.2.2 rmind }
1005 1.5.2.2 rmind
1006 1.5.2.2 rmind void
1007 1.5.2.2 rmind cpu_startup(void)
1008 1.5.2.2 rmind {
1009 1.5.2.2 rmind struct cpu_info * const ci = curcpu();
1010 1.5.2.2 rmind const uint16_t svr = getsvr();
1011 1.5.2.2 rmind
1012 1.5.2.2 rmind booke_cpu_startup(socname(mfspr(SPR_SVR)));
1013 1.5.2.2 rmind
1014 1.5.2.2 rmind uint32_t v = cpu_read_4(GLOBAL_BASE + PORPLLSR);
1015 1.5.2.2 rmind uint32_t plat_ratio = PLAT_RATIO_GET(v);
1016 1.5.2.2 rmind uint32_t e500_ratio = E500_RATIO_GET(v);
1017 1.5.2.2 rmind
1018 1.5.2.2 rmind uint64_t ccb_freq = e500_sys_clk * plat_ratio;
1019 1.5.2.2 rmind uint64_t cpu_freq = ccb_freq * e500_ratio / 2;
1020 1.5.2.2 rmind
1021 1.5.2.2 rmind ci->ci_khz = (cpu_freq + 500) / 1000;
1022 1.5.2.2 rmind cpu_timebase = ci->ci_data.cpu_cc_freq = ccb_freq / 8;
1023 1.5.2.2 rmind
1024 1.5.2.2 rmind board_info_add_number("my-id", svr);
1025 1.5.2.2 rmind board_info_add_bool("pq3");
1026 1.5.2.2 rmind board_info_add_number("mem-size", pmemsize);
1027 1.5.2.2 rmind const uint32_t l2ctl = cpu_read_4(L2CACHE_BASE + L2CTL);
1028 1.5.2.2 rmind uint32_t l2siz = L2CTL_L2SIZ_GET(l2ctl);
1029 1.5.2.2 rmind uint32_t l2banks = l2siz >> 16;
1030 1.5.2.2 rmind #ifdef MPC85555
1031 1.5.2.2 rmind if (svr == (MPC8555v1 >> 16)) {
1032 1.5.2.2 rmind l2siz >>= 1;
1033 1.5.2.2 rmind l2banks >>= 1;
1034 1.5.2.2 rmind }
1035 1.5.2.2 rmind #endif
1036 1.5.2.3 rmind paddr_t boot_page = cpu_read_4(GUR_BPTR);
1037 1.5.2.3 rmind if (boot_page & BPTR_EN) {
1038 1.5.2.3 rmind bool found = false;
1039 1.5.2.3 rmind boot_page = (boot_page & BPTR_BOOT_PAGE) << PAGE_SHIFT;
1040 1.5.2.3 rmind for (const uint32_t *dp = (void *)(boot_page + PAGE_SIZE - 4),
1041 1.5.2.3 rmind * const bp = (void *)boot_page;
1042 1.5.2.3 rmind bp <= dp; dp--) {
1043 1.5.2.3 rmind if (*dp == boot_page) {
1044 1.5.2.3 rmind uintptr_t spinup_table_addr = (uintptr_t)++dp;
1045 1.5.2.3 rmind spinup_table_addr =
1046 1.5.2.3 rmind roundup2(spinup_table_addr, 32);
1047 1.5.2.3 rmind board_info_add_number("mp-boot-page",
1048 1.5.2.3 rmind boot_page);
1049 1.5.2.3 rmind board_info_add_number("mp-spin-up-table",
1050 1.5.2.3 rmind spinup_table_addr);
1051 1.5.2.3 rmind printf("Found MP boot page @ %#"PRIxPADDR". "
1052 1.5.2.3 rmind "Spin-up table @ %#"PRIxPTR"\n",
1053 1.5.2.3 rmind boot_page, spinup_table_addr);
1054 1.5.2.3 rmind found = true;
1055 1.5.2.3 rmind break;
1056 1.5.2.3 rmind }
1057 1.5.2.3 rmind }
1058 1.5.2.3 rmind if (!found)
1059 1.5.2.3 rmind printf("Found MP boot page @ %#"PRIxPADDR
1060 1.5.2.3 rmind " with missing U-boot signature!\n", boot_page);
1061 1.5.2.3 rmind }
1062 1.5.2.2 rmind board_info_add_number("l2-cache-size", l2siz);
1063 1.5.2.2 rmind board_info_add_number("l2-cache-line-size", 32);
1064 1.5.2.2 rmind board_info_add_number("l2-cache-banks", l2banks);
1065 1.5.2.2 rmind board_info_add_number("l2-cache-ways", 8);
1066 1.5.2.2 rmind
1067 1.5.2.2 rmind board_info_add_number("processor-frequency", cpu_freq);
1068 1.5.2.2 rmind board_info_add_number("bus-frequency", ccb_freq);
1069 1.5.2.2 rmind board_info_add_number("pci-frequency", e500_sys_clk);
1070 1.5.2.2 rmind board_info_add_number("timebase-frequency", ccb_freq / 8);
1071 1.5.2.2 rmind
1072 1.5.2.2 rmind #ifdef CADMUS
1073 1.5.2.2 rmind const uint8_t phy_base = CM_CSR_EPHY_GET(cadmus_csr) << 2;
1074 1.5.2.2 rmind board_info_add_number("tsec1-phy-addr", phy_base + 0);
1075 1.5.2.2 rmind board_info_add_number("tsec2-phy-addr", phy_base + 1);
1076 1.5.2.2 rmind board_info_add_number("tsec3-phy-addr", phy_base + 2);
1077 1.5.2.2 rmind board_info_add_number("tsec4-phy-addr", phy_base + 3);
1078 1.5.2.2 rmind #else
1079 1.5.2.2 rmind board_info_add_number("tsec1-phy-addr", MII_PHY_ANY);
1080 1.5.2.2 rmind board_info_add_number("tsec2-phy-addr", MII_PHY_ANY);
1081 1.5.2.2 rmind board_info_add_number("tsec3-phy-addr", MII_PHY_ANY);
1082 1.5.2.2 rmind board_info_add_number("tsec4-phy-addr", MII_PHY_ANY);
1083 1.5.2.2 rmind #endif
1084 1.5.2.2 rmind
1085 1.5.2.2 rmind uint64_t macstnaddr =
1086 1.5.2.2 rmind ((uint64_t)le32toh(cpu_read_4(ETSEC1_BASE + MACSTNADDR1)) << 16)
1087 1.5.2.2 rmind | ((uint64_t)le32toh(cpu_read_4(ETSEC1_BASE + MACSTNADDR2)) << 48);
1088 1.5.2.2 rmind board_info_add_data("tsec-mac-addr-base", &macstnaddr, 6);
1089 1.5.2.2 rmind
1090 1.5.2.2 rmind #if NPCI > 0 && defined(PCI_MEMBASE)
1091 1.5.2.2 rmind pcimem_ex = extent_create("pcimem",
1092 1.5.2.2 rmind PCI_MEMBASE, PCI_MEMBASE + 4*PCI_MEMSIZE,
1093 1.5.2.2 rmind M_DEVBUF, NULL, 0, EX_WAITOK);
1094 1.5.2.2 rmind #endif
1095 1.5.2.2 rmind #if NPCI > 0 && defined(PCI_IOBASE)
1096 1.5.2.2 rmind pciio_ex = extent_create("pciio",
1097 1.5.2.2 rmind PCI_IOBASE, PCI_IOBASE + 4*PCI_IOSIZE,
1098 1.5.2.2 rmind M_DEVBUF, NULL, 0, EX_WAITOK);
1099 1.5.2.2 rmind #endif
1100 1.5.2.2 rmind mpc85xx_extirq_setup();
1101 1.5.2.2 rmind /*
1102 1.5.2.2 rmind * PCI-Express virtual wire interrupts on combined with
1103 1.5.2.2 rmind * External IRQ0/1/2/3.
1104 1.5.2.2 rmind */
1105 1.5.2.2 rmind switch (svr) {
1106 1.5.2.2 rmind #if defined(MPC8548)
1107 1.5.2.2 rmind case SVR_MPC8548v1 >> 16:
1108 1.5.2.2 rmind mpc85xx_pci_setup("pcie0-interrupt-map", 0x001800,
1109 1.5.2.2 rmind IST_LEVEL, 0, 1, 2, 3);
1110 1.5.2.2 rmind break;
1111 1.5.2.2 rmind #endif
1112 1.5.2.2 rmind #if defined(MPC8544) || defined(MPC8572) || defined(MPC8536) || defined(P2020)
1113 1.5.2.2 rmind case SVR_MPC8536v1 >> 16:
1114 1.5.2.2 rmind case SVR_MPC8544v1 >> 16:
1115 1.5.2.2 rmind case SVR_MPC8572v1 >> 16:
1116 1.5.2.2 rmind case SVR_P2010v2 >> 16:
1117 1.5.2.2 rmind case SVR_P2020v2 >> 16:
1118 1.5.2.2 rmind mpc85xx_pci_setup("pcie1-interrupt-map", 0x001800, IST_LEVEL,
1119 1.5.2.2 rmind 0, 1, 2, 3);
1120 1.5.2.2 rmind mpc85xx_pci_setup("pcie2-interrupt-map", 0x001800, IST_LEVEL,
1121 1.5.2.2 rmind 4, 5, 6, 7);
1122 1.5.2.2 rmind mpc85xx_pci_setup("pcie3-interrupt-map", 0x001800, IST_LEVEL,
1123 1.5.2.2 rmind 8, 9, 10, 11);
1124 1.5.2.2 rmind break;
1125 1.5.2.2 rmind #endif
1126 1.5.2.2 rmind }
1127 1.5.2.2 rmind switch (svr) {
1128 1.5.2.2 rmind #if defined(MPC8536)
1129 1.5.2.2 rmind case SVR_MPC8536v1 >> 16:
1130 1.5.2.2 rmind mpc85xx_pci_setup("pci0-interrupt-map", 0x001800, IST_LEVEL,
1131 1.5.2.2 rmind 1, 2, 3, 4);
1132 1.5.2.2 rmind break;
1133 1.5.2.2 rmind #endif
1134 1.5.2.2 rmind #if defined(MPC8544)
1135 1.5.2.2 rmind case SVR_MPC8544v1 >> 16:
1136 1.5.2.2 rmind mpc85xx_pci_setup("pci0-interrupt-map", 0x001800, IST_LEVEL,
1137 1.5.2.2 rmind 0, 1, 2, 3);
1138 1.5.2.2 rmind break;
1139 1.5.2.2 rmind #endif
1140 1.5.2.2 rmind #if defined(MPC8548)
1141 1.5.2.2 rmind case SVR_MPC8548v1 >> 16:
1142 1.5.2.2 rmind mpc85xx_pci_setup("pci1-interrupt-map", 0x001800, IST_LEVEL,
1143 1.5.2.2 rmind 0, 1, 2, 3);
1144 1.5.2.2 rmind mpc85xx_pci_setup("pci2-interrupt-map", 0x001800, IST_LEVEL,
1145 1.5.2.2 rmind 11, 1, 2, 3);
1146 1.5.2.2 rmind break;
1147 1.5.2.2 rmind #endif
1148 1.5.2.2 rmind }
1149 1.5.2.2 rmind }
1150