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