integrator_machdep.c revision 1.77 1 1.77 skrll /* $NetBSD: integrator_machdep.c,v 1.77 2019/07/16 14:41:46 skrll Exp $ */
2 1.1 rearnsha
3 1.1 rearnsha /*
4 1.23 rearnsha * Copyright (c) 2001,2002 ARM Ltd
5 1.1 rearnsha * All rights reserved.
6 1.1 rearnsha *
7 1.1 rearnsha * Redistribution and use in source and binary forms, with or without
8 1.1 rearnsha * modification, are permitted provided that the following conditions
9 1.1 rearnsha * are met:
10 1.1 rearnsha * 1. Redistributions of source code must retain the above copyright
11 1.1 rearnsha * notice, this list of conditions and the following disclaimer.
12 1.1 rearnsha * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 rearnsha * notice, this list of conditions and the following disclaimer in the
14 1.1 rearnsha * documentation and/or other materials provided with the distribution.
15 1.1 rearnsha * 3. The name of the company may not be used to endorse or promote
16 1.1 rearnsha * products derived from this software without specific prior written
17 1.1 rearnsha * permission.
18 1.1 rearnsha *
19 1.23 rearnsha * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND
20 1.23 rearnsha * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.23 rearnsha * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.23 rearnsha * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARM LTD
23 1.23 rearnsha * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.23 rearnsha * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.23 rearnsha * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.23 rearnsha * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.23 rearnsha * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.23 rearnsha * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.23 rearnsha * POSSIBILITY OF SUCH DAMAGE.
30 1.23 rearnsha */
31 1.23 rearnsha
32 1.23 rearnsha /*
33 1.1 rearnsha * Copyright (c) 1997,1998 Mark Brinicombe.
34 1.1 rearnsha * Copyright (c) 1997,1998 Causality Limited.
35 1.1 rearnsha * All rights reserved.
36 1.1 rearnsha *
37 1.1 rearnsha * Redistribution and use in source and binary forms, with or without
38 1.1 rearnsha * modification, are permitted provided that the following conditions
39 1.1 rearnsha * are met:
40 1.1 rearnsha * 1. Redistributions of source code must retain the above copyright
41 1.1 rearnsha * notice, this list of conditions and the following disclaimer.
42 1.1 rearnsha * 2. Redistributions in binary form must reproduce the above copyright
43 1.1 rearnsha * notice, this list of conditions and the following disclaimer in the
44 1.1 rearnsha * documentation and/or other materials provided with the distribution.
45 1.1 rearnsha * 3. All advertising materials mentioning features or use of this software
46 1.1 rearnsha * must display the following acknowledgement:
47 1.1 rearnsha * This product includes software developed by Mark Brinicombe
48 1.1 rearnsha * for the NetBSD Project.
49 1.1 rearnsha * 4. The name of the company nor the name of the author may be used to
50 1.1 rearnsha * endorse or promote products derived from this software without specific
51 1.1 rearnsha * prior written permission.
52 1.1 rearnsha *
53 1.1 rearnsha * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
54 1.1 rearnsha * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
55 1.1 rearnsha * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
56 1.1 rearnsha * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
57 1.1 rearnsha * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
58 1.1 rearnsha * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
59 1.1 rearnsha * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 1.1 rearnsha * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 1.1 rearnsha * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 1.1 rearnsha * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 1.1 rearnsha * SUCH DAMAGE.
64 1.1 rearnsha *
65 1.67 wiz * Machine dependent functions for kernel setup for integrator board
66 1.1 rearnsha *
67 1.1 rearnsha * Created : 24/11/97
68 1.1 rearnsha */
69 1.43 lukem
70 1.43 lukem #include <sys/cdefs.h>
71 1.77 skrll __KERNEL_RCSID(0, "$NetBSD: integrator_machdep.c,v 1.77 2019/07/16 14:41:46 skrll Exp $");
72 1.1 rearnsha
73 1.75 skrll #include "opt_arm_debug.h"
74 1.76 skrll #include "opt_console.h"
75 1.1 rearnsha #include "opt_ddb.h"
76 1.1 rearnsha #include "opt_pmap_debug.h"
77 1.1 rearnsha
78 1.1 rearnsha #include <sys/param.h>
79 1.1 rearnsha #include <sys/device.h>
80 1.1 rearnsha #include <sys/systm.h>
81 1.1 rearnsha #include <sys/kernel.h>
82 1.1 rearnsha #include <sys/exec.h>
83 1.1 rearnsha #include <sys/proc.h>
84 1.1 rearnsha #include <sys/msgbuf.h>
85 1.1 rearnsha #include <sys/reboot.h>
86 1.1 rearnsha #include <sys/termios.h>
87 1.32 ragge #include <sys/ksyms.h>
88 1.74 matt #include <sys/bus.h>
89 1.74 matt #include <sys/cpu.h>
90 1.74 matt #include <sys/intr.h>
91 1.1 rearnsha
92 1.31 thorpej #include <uvm/uvm_extern.h>
93 1.31 thorpej
94 1.1 rearnsha #include <dev/cons.h>
95 1.1 rearnsha
96 1.1 rearnsha #include <machine/db_machdep.h>
97 1.1 rearnsha #include <ddb/db_sym.h>
98 1.1 rearnsha #include <ddb/db_extern.h>
99 1.1 rearnsha
100 1.1 rearnsha #include <machine/bootconfig.h>
101 1.74 matt #include <arm/locore.h>
102 1.6 thorpej #include <arm/undefined.h>
103 1.1 rearnsha
104 1.23 rearnsha #include <arm/arm32/machdep.h>
105 1.23 rearnsha
106 1.1 rearnsha #include <evbarm/integrator/integrator_boot.h>
107 1.1 rearnsha
108 1.1 rearnsha #include "pci.h"
109 1.32 ragge #include "ksyms.h"
110 1.1 rearnsha
111 1.1 rearnsha void ifpga_reset(void) __attribute__((noreturn));
112 1.36 thorpej
113 1.40 thorpej /*
114 1.40 thorpej * The range 0xc1000000 - 0xccffffff is available for kernel VM space
115 1.40 thorpej * Core-logic registers and I/O mappings occupy 0xfd000000 - 0xffffffff
116 1.40 thorpej */
117 1.73 skrll #define KERNEL_VM_BASE (KERNEL_BASE + 0x01000000)
118 1.40 thorpej #define KERNEL_VM_SIZE 0x0C000000
119 1.36 thorpej
120 1.1 rearnsha BootConfig bootconfig; /* Boot config storage */
121 1.1 rearnsha char *boot_args = NULL;
122 1.1 rearnsha char *boot_file = NULL;
123 1.1 rearnsha
124 1.1 rearnsha /* Prototypes */
125 1.1 rearnsha
126 1.23 rearnsha static void integrator_sdram_bounds (paddr_t *, psize_t *);
127 1.1 rearnsha
128 1.23 rearnsha void consinit(void);
129 1.1 rearnsha
130 1.1 rearnsha /* A load of console goo. */
131 1.1 rearnsha #include "vga.h"
132 1.23 rearnsha #if NVGA > 0
133 1.1 rearnsha #include <dev/ic/mc6845reg.h>
134 1.1 rearnsha #include <dev/ic/pcdisplayvar.h>
135 1.1 rearnsha #include <dev/ic/vgareg.h>
136 1.1 rearnsha #include <dev/ic/vgavar.h>
137 1.1 rearnsha #endif
138 1.1 rearnsha
139 1.1 rearnsha #include "pckbc.h"
140 1.23 rearnsha #if NPCKBC > 0
141 1.1 rearnsha #include <dev/ic/i8042reg.h>
142 1.1 rearnsha #include <dev/ic/pckbcvar.h>
143 1.1 rearnsha #endif
144 1.1 rearnsha
145 1.1 rearnsha #include "com.h"
146 1.23 rearnsha #if NCOM > 0
147 1.1 rearnsha #include <dev/ic/comreg.h>
148 1.1 rearnsha #include <dev/ic/comvar.h>
149 1.1 rearnsha #ifndef CONCOMADDR
150 1.1 rearnsha #define CONCOMADDR 0x3f8
151 1.1 rearnsha #endif
152 1.1 rearnsha #endif
153 1.1 rearnsha
154 1.23 rearnsha /*
155 1.23 rearnsha * Define the default console speed for the board. This is generally
156 1.23 rearnsha * what the firmware provided with the board defaults to.
157 1.23 rearnsha */
158 1.30 mycroft #ifndef CONSPEED
159 1.1 rearnsha #define CONSPEED B115200
160 1.1 rearnsha #endif
161 1.1 rearnsha #ifndef CONMODE
162 1.1 rearnsha #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
163 1.1 rearnsha #endif
164 1.1 rearnsha
165 1.1 rearnsha int comcnspeed = CONSPEED;
166 1.1 rearnsha int comcnmode = CONMODE;
167 1.1 rearnsha
168 1.1 rearnsha #include "plcom.h"
169 1.1 rearnsha #if (NPLCOM > 0)
170 1.1 rearnsha #include <evbarm/dev/plcomreg.h>
171 1.1 rearnsha #include <evbarm/dev/plcomvar.h>
172 1.1 rearnsha
173 1.1 rearnsha #include <evbarm/ifpga/ifpgamem.h>
174 1.1 rearnsha #include <evbarm/ifpga/ifpgareg.h>
175 1.1 rearnsha #include <evbarm/ifpga/ifpgavar.h>
176 1.1 rearnsha #endif
177 1.1 rearnsha
178 1.1 rearnsha #ifndef CONSDEVNAME
179 1.1 rearnsha #define CONSDEVNAME "plcom"
180 1.1 rearnsha #endif
181 1.1 rearnsha
182 1.1 rearnsha #ifndef PLCONSPEED
183 1.1 rearnsha #define PLCONSPEED B38400
184 1.1 rearnsha #endif
185 1.1 rearnsha #ifndef PLCONMODE
186 1.1 rearnsha #define PLCONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
187 1.1 rearnsha #endif
188 1.1 rearnsha #ifndef PLCOMCNUNIT
189 1.1 rearnsha #define PLCOMCNUNIT -1
190 1.1 rearnsha #endif
191 1.1 rearnsha
192 1.1 rearnsha int plcomcnspeed = PLCONSPEED;
193 1.1 rearnsha int plcomcnmode = PLCONMODE;
194 1.1 rearnsha
195 1.1 rearnsha #if 0
196 1.1 rearnsha extern struct consdev kcomcons;
197 1.1 rearnsha static void kcomcnputc(dev_t, int);
198 1.1 rearnsha #endif
199 1.1 rearnsha
200 1.1 rearnsha /*
201 1.1 rearnsha * void cpu_reboot(int howto, char *bootstr)
202 1.1 rearnsha *
203 1.1 rearnsha * Reboots the system
204 1.1 rearnsha *
205 1.1 rearnsha * Deal with any syncing, unmounting, dumping and shutdown hooks,
206 1.1 rearnsha * then reset the CPU.
207 1.1 rearnsha */
208 1.1 rearnsha void
209 1.23 rearnsha cpu_reboot(int howto, char *bootstr)
210 1.1 rearnsha {
211 1.1 rearnsha
212 1.1 rearnsha /*
213 1.1 rearnsha * If we are still cold then hit the air brakes
214 1.1 rearnsha * and crash to earth fast
215 1.1 rearnsha */
216 1.1 rearnsha if (cold) {
217 1.1 rearnsha doshutdownhooks();
218 1.59 dyoung pmf_system_shutdown(boothowto);
219 1.1 rearnsha printf("The operating system has halted.\n");
220 1.1 rearnsha printf("Please press any key to reboot.\n\n");
221 1.1 rearnsha cngetc();
222 1.1 rearnsha printf("rebooting...\n");
223 1.1 rearnsha ifpga_reset();
224 1.1 rearnsha /*NOTREACHED*/
225 1.1 rearnsha }
226 1.1 rearnsha
227 1.1 rearnsha /* Disable console buffering */
228 1.1 rearnsha
229 1.1 rearnsha /*
230 1.1 rearnsha * If RB_NOSYNC was not specified sync the discs.
231 1.23 rearnsha * Note: Unless cold is set to 1 here, syslogd will die during the
232 1.23 rearnsha * unmount. It looks like syslogd is getting woken up only to find
233 1.23 rearnsha * that it cannot page part of the binary in as the filesystem has
234 1.23 rearnsha * been unmounted.
235 1.1 rearnsha */
236 1.1 rearnsha if (!(howto & RB_NOSYNC))
237 1.1 rearnsha bootsync();
238 1.1 rearnsha
239 1.1 rearnsha /* Say NO to interrupts */
240 1.1 rearnsha splhigh();
241 1.1 rearnsha
242 1.1 rearnsha /* Do a dump if requested. */
243 1.1 rearnsha if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
244 1.1 rearnsha dumpsys();
245 1.1 rearnsha
246 1.1 rearnsha /* Run any shutdown hooks */
247 1.1 rearnsha doshutdownhooks();
248 1.1 rearnsha
249 1.59 dyoung pmf_system_shutdown(boothowto);
250 1.59 dyoung
251 1.1 rearnsha /* Make sure IRQ's are disabled */
252 1.1 rearnsha IRQdisable;
253 1.1 rearnsha
254 1.1 rearnsha if (howto & RB_HALT) {
255 1.1 rearnsha printf("The operating system has halted.\n");
256 1.1 rearnsha printf("Please press any key to reboot.\n\n");
257 1.1 rearnsha cngetc();
258 1.1 rearnsha }
259 1.1 rearnsha
260 1.1 rearnsha printf("rebooting...\n");
261 1.1 rearnsha ifpga_reset();
262 1.1 rearnsha /*NOTREACHED*/
263 1.1 rearnsha }
264 1.1 rearnsha
265 1.42 thorpej /* Statically mapped devices. */
266 1.42 thorpej static const struct pmap_devmap integrator_devmap[] = {
267 1.1 rearnsha #if NPLCOM > 0 && defined(PLCONSOLE)
268 1.23 rearnsha {
269 1.23 rearnsha UART0_BOOT_BASE,
270 1.23 rearnsha IFPGA_IO_BASE + IFPGA_UART0,
271 1.23 rearnsha 1024 * 1024,
272 1.23 rearnsha VM_PROT_READ|VM_PROT_WRITE,
273 1.23 rearnsha PTE_NOCACHE
274 1.23 rearnsha },
275 1.23 rearnsha
276 1.23 rearnsha {
277 1.23 rearnsha UART1_BOOT_BASE,
278 1.23 rearnsha IFPGA_IO_BASE + IFPGA_UART1,
279 1.23 rearnsha 1024 * 1024,
280 1.23 rearnsha VM_PROT_READ|VM_PROT_WRITE,
281 1.23 rearnsha PTE_NOCACHE
282 1.23 rearnsha },
283 1.1 rearnsha #endif
284 1.1 rearnsha #if NPCI > 0
285 1.23 rearnsha {
286 1.23 rearnsha IFPGA_PCI_IO_VBASE,
287 1.23 rearnsha IFPGA_PCI_IO_BASE,
288 1.23 rearnsha IFPGA_PCI_IO_VSIZE,
289 1.23 rearnsha VM_PROT_READ|VM_PROT_WRITE,
290 1.23 rearnsha PTE_NOCACHE
291 1.23 rearnsha },
292 1.23 rearnsha
293 1.23 rearnsha {
294 1.23 rearnsha IFPGA_PCI_CONF_VBASE,
295 1.23 rearnsha IFPGA_PCI_CONF_BASE,
296 1.23 rearnsha IFPGA_PCI_CONF_VSIZE,
297 1.23 rearnsha VM_PROT_READ|VM_PROT_WRITE,
298 1.42 thorpej PTE_NOCACHE
299 1.42 thorpej },
300 1.1 rearnsha #endif
301 1.1 rearnsha
302 1.23 rearnsha {
303 1.23 rearnsha 0,
304 1.23 rearnsha 0,
305 1.23 rearnsha 0,
306 1.23 rearnsha 0,
307 1.23 rearnsha 0
308 1.23 rearnsha }
309 1.1 rearnsha };
310 1.1 rearnsha
311 1.1 rearnsha /*
312 1.77 skrll * vaddr_t initarm(...)
313 1.1 rearnsha *
314 1.1 rearnsha * Initial entry point on startup. This gets called before main() is
315 1.1 rearnsha * entered.
316 1.1 rearnsha * It should be responsible for setting up everything that must be
317 1.1 rearnsha * in place when main is called.
318 1.1 rearnsha * This includes
319 1.1 rearnsha * Taking a copy of the boot configuration structure.
320 1.1 rearnsha * Initialising the physical console so characters can be printed.
321 1.1 rearnsha * Setting up page tables for the kernel
322 1.1 rearnsha * Relocating the kernel to the bottom of physical memory
323 1.1 rearnsha */
324 1.1 rearnsha
325 1.77 skrll vaddr_t
326 1.23 rearnsha initarm(void *arg)
327 1.1 rearnsha {
328 1.73 skrll extern int KERNEL_BASE_phys[];
329 1.23 rearnsha paddr_t memstart;
330 1.23 rearnsha psize_t memsize;
331 1.71 matt
332 1.1 rearnsha /*
333 1.1 rearnsha * Heads up ... Setup the CPU / MMU / TLB functions
334 1.1 rearnsha */
335 1.1 rearnsha if (set_cpufuncs())
336 1.73 skrll panic("cpu not recognized!");
337 1.1 rearnsha
338 1.73 skrll /* map some peripheral registers */
339 1.1 rearnsha
340 1.73 skrll pmap_devmap_bootstrap((vaddr_t)armreg_ttbr_read() & -L1_TABLE_SIZE,
341 1.73 skrll integrator_devmap);
342 1.69 skrll
343 1.73 skrll cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
344 1.69 skrll
345 1.73 skrll consinit();
346 1.1 rearnsha
347 1.1 rearnsha /* Talk to the user */
348 1.73 skrll #define BDSTR(s) _BDSTR(s)
349 1.73 skrll #define _BDSTR(s) #s
350 1.73 skrll printf("\nNetBSD/evbarm (" BDSTR(EVBARM_BOARDTYPE) ") booting ...\n");
351 1.1 rearnsha
352 1.1 rearnsha /*
353 1.23 rearnsha * Fetch the SDRAM start/size from the CM configuration registers.
354 1.1 rearnsha */
355 1.23 rearnsha integrator_sdram_bounds(&memstart, &memsize);
356 1.1 rearnsha
357 1.73 skrll #if defined(INTEGRATOR_CP)
358 1.73 skrll /*
359 1.73 skrll * XXX QEMU reports SDRAM starting at 0x100000, but presents a flat
360 1.73 skrll * physical memory model. Set memstart to 0x0, so arm32_bootmem_init
361 1.73 skrll * doesn't get fooled later.
362 1.73 skrll */
363 1.73 skrll memstart = 0;
364 1.73 skrll #endif
365 1.73 skrll
366 1.38 thorpej #ifdef VERBOSE_INIT_ARM
367 1.1 rearnsha printf("initarm: Configuring system ...\n");
368 1.38 thorpej #endif
369 1.1 rearnsha
370 1.23 rearnsha /* Fake bootconfig structure for the benefit of pmap.c */
371 1.23 rearnsha /* XXX must make the memory description h/w independent */
372 1.23 rearnsha bootconfig.dramblocks = 1;
373 1.23 rearnsha bootconfig.dram[0].address = memstart;
374 1.31 thorpej bootconfig.dram[0].pages = memsize / PAGE_SIZE;
375 1.47 rearnsha bootconfig.dram[0].flags = BOOT_DRAM_CAN_DMA | BOOT_DRAM_PREFER;
376 1.23 rearnsha
377 1.73 skrll arm32_bootmem_init(bootconfig.dram[0].address,
378 1.73 skrll bootconfig.dram[0].pages * PAGE_SIZE, (unsigned int) KERNEL_BASE_phys);
379 1.1 rearnsha
380 1.73 skrll arm32_kernel_vm_init(KERNEL_VM_BASE, ARM_VECTORS_LOW, 0, integrator_devmap,
381 1.73 skrll false);
382 1.1 rearnsha
383 1.38 thorpej #ifdef VERBOSE_INIT_ARM
384 1.1 rearnsha printf("done.\n");
385 1.38 thorpej #endif
386 1.1 rearnsha
387 1.73 skrll return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0);
388 1.1 rearnsha }
389 1.1 rearnsha
390 1.1 rearnsha void
391 1.1 rearnsha consinit(void)
392 1.1 rearnsha {
393 1.1 rearnsha static int consinit_called = 0;
394 1.1 rearnsha #if 0
395 1.1 rearnsha char *console = CONSDEVNAME;
396 1.1 rearnsha #endif
397 1.1 rearnsha
398 1.1 rearnsha if (consinit_called != 0)
399 1.1 rearnsha return;
400 1.1 rearnsha
401 1.1 rearnsha consinit_called = 1;
402 1.1 rearnsha
403 1.1 rearnsha #if NPLCOM > 0 && defined(PLCONSOLE)
404 1.1 rearnsha if (PLCOMCNUNIT == 0) {
405 1.73 skrll extern struct bus_space ifpga_common_bs_tag;
406 1.69 skrll static struct plcom_instance ifpga_pi1 = {
407 1.73 skrll #if defined(INTEGRATOR_CP)
408 1.73 skrll .pi_type = PLCOM_TYPE_PL011,
409 1.73 skrll #else
410 1.69 skrll .pi_type = PLCOM_TYPE_PL010,
411 1.73 skrll #endif
412 1.73 skrll .pi_iot = &ifpga_common_bs_tag,
413 1.69 skrll .pi_size = IFPGA_UART_SIZE,
414 1.73 skrll .pi_iobase = IFPGA_UART0
415 1.69 skrll };
416 1.69 skrll
417 1.69 skrll if (plcomcnattach(&ifpga_pi1, plcomcnspeed, IFPGA_UART_CLK,
418 1.69 skrll plcomcnmode, PLCOMCNUNIT))
419 1.1 rearnsha panic("can't init serial console");
420 1.1 rearnsha return;
421 1.1 rearnsha } else if (PLCOMCNUNIT == 1) {
422 1.73 skrll extern struct bus_space ifpga_common_bs_tag;
423 1.69 skrll static struct plcom_instance ifpga_pi1 = {
424 1.73 skrll #if defined(INTEGRATOR_CP)
425 1.73 skrll .pi_type = PLCOM_TYPE_PL011,
426 1.73 skrll #else
427 1.69 skrll .pi_type = PLCOM_TYPE_PL010,
428 1.73 skrll #endif
429 1.73 skrll .pi_iot = &ifpga_common_bs_tag,
430 1.69 skrll .pi_size = IFPGA_UART_SIZE,
431 1.73 skrll .pi_iobase = IFPGA_UART1
432 1.69 skrll };
433 1.69 skrll
434 1.69 skrll if (plcomcnattach(&ifpga_pi1, plcomcnspeed, IFPGA_UART_CLK,
435 1.69 skrll plcomcnmode, PLCOMCNUNIT))
436 1.1 rearnsha panic("can't init serial console");
437 1.1 rearnsha return;
438 1.1 rearnsha }
439 1.1 rearnsha #endif
440 1.1 rearnsha #if (NCOM > 0)
441 1.1 rearnsha if (comcnattach(&isa_io_bs_tag, CONCOMADDR, comcnspeed,
442 1.41 thorpej COM_FREQ, COM_TYPE_NORMAL, comcnmode))
443 1.1 rearnsha panic("can't init serial console @%x", CONCOMADDR);
444 1.1 rearnsha return;
445 1.1 rearnsha #endif
446 1.1 rearnsha panic("No serial console configured");
447 1.23 rearnsha }
448 1.23 rearnsha
449 1.23 rearnsha static void
450 1.23 rearnsha integrator_sdram_bounds(paddr_t *memstart, psize_t *memsize)
451 1.23 rearnsha {
452 1.23 rearnsha volatile unsigned long *cm_sdram
453 1.23 rearnsha = (volatile unsigned long *)0x10000020;
454 1.46 rearnsha volatile unsigned long *cm_stat
455 1.46 rearnsha = (volatile unsigned long *)0x10000010;
456 1.23 rearnsha
457 1.46 rearnsha *memstart = *cm_stat & 0x00ff0000;
458 1.23 rearnsha
459 1.46 rearnsha /*
460 1.46 rearnsha * Although the SSRAM overlaps the SDRAM, we can use the wrap-around
461 1.46 rearnsha * to access the entire bank.
462 1.46 rearnsha */
463 1.23 rearnsha switch ((*cm_sdram >> 2) & 0x7)
464 1.23 rearnsha {
465 1.23 rearnsha case 0:
466 1.23 rearnsha *memsize = 16 * 1024 * 1024;
467 1.23 rearnsha break;
468 1.23 rearnsha case 1:
469 1.23 rearnsha *memsize = 32 * 1024 * 1024;
470 1.23 rearnsha break;
471 1.23 rearnsha case 2:
472 1.23 rearnsha *memsize = 64 * 1024 * 1024;
473 1.23 rearnsha break;
474 1.23 rearnsha case 3:
475 1.23 rearnsha *memsize = 128 * 1024 * 1024;
476 1.23 rearnsha break;
477 1.23 rearnsha case 4:
478 1.46 rearnsha /* With 256M of memory there is no wrap-around. */
479 1.46 rearnsha *memsize = 256 * 1024 * 1024 - *memstart;
480 1.23 rearnsha break;
481 1.23 rearnsha default:
482 1.23 rearnsha printf("CM_SDRAM retuns unknown value, using 16M\n");
483 1.23 rearnsha *memsize = 16 * 1024 * 1024;
484 1.23 rearnsha break;
485 1.23 rearnsha }
486 1.1 rearnsha }
487