viper_machdep.c revision 1.24 1 1.24 matt /* $NetBSD: viper_machdep.c,v 1.24 2014/09/13 18:08:39 matt Exp $ */
2 1.1 pooka
3 1.1 pooka /*
4 1.1 pooka * Startup routines for the Arcom Viper. Below you can trace the
5 1.1 pooka * impressive lineage ;)
6 1.1 pooka *
7 1.1 pooka * Modified for the Viper by Antti Kantee <pooka (at) netbsd.org>
8 1.1 pooka */
9 1.1 pooka
10 1.1 pooka /*
11 1.1 pooka * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved.
12 1.1 pooka * Written by Hiroyuki Bessho for Genetec Corporation.
13 1.1 pooka *
14 1.1 pooka * Redistribution and use in source and binary forms, with or without
15 1.1 pooka * modification, are permitted provided that the following conditions
16 1.1 pooka * are met:
17 1.1 pooka * 1. Redistributions of source code must retain the above copyright
18 1.1 pooka * notice, this list of conditions and the following disclaimer.
19 1.1 pooka * 2. Redistributions in binary form must reproduce the above copyright
20 1.1 pooka * notice, this list of conditions and the following disclaimer in the
21 1.1 pooka * documentation and/or other materials provided with the distribution.
22 1.1 pooka * 3. The name of Genetec Corporation may not be used to endorse or
23 1.1 pooka * promote products derived from this software without specific prior
24 1.1 pooka * written permission.
25 1.1 pooka *
26 1.1 pooka * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
27 1.1 pooka * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 pooka * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 pooka * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
30 1.1 pooka * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 pooka * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 pooka * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 pooka * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 pooka * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 pooka * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 pooka * POSSIBILITY OF SUCH DAMAGE.
37 1.1 pooka *
38 1.18 wiz * Machine dependent functions for kernel setup for
39 1.1 pooka * Intel DBPXA250 evaluation board (a.k.a. Lubbock).
40 1.1 pooka * Based on iq80310_machhdep.c
41 1.1 pooka */
42 1.1 pooka /*
43 1.1 pooka * Copyright (c) 2001 Wasabi Systems, Inc.
44 1.1 pooka * All rights reserved.
45 1.1 pooka *
46 1.1 pooka * Written by Jason R. Thorpe for Wasabi Systems, Inc.
47 1.1 pooka *
48 1.1 pooka * Redistribution and use in source and binary forms, with or without
49 1.1 pooka * modification, are permitted provided that the following conditions
50 1.1 pooka * are met:
51 1.1 pooka * 1. Redistributions of source code must retain the above copyright
52 1.1 pooka * notice, this list of conditions and the following disclaimer.
53 1.1 pooka * 2. Redistributions in binary form must reproduce the above copyright
54 1.1 pooka * notice, this list of conditions and the following disclaimer in the
55 1.1 pooka * documentation and/or other materials provided with the distribution.
56 1.1 pooka * 3. All advertising materials mentioning features or use of this software
57 1.1 pooka * must display the following acknowledgement:
58 1.1 pooka * This product includes software developed for the NetBSD Project by
59 1.1 pooka * Wasabi Systems, Inc.
60 1.1 pooka * 4. The name of Wasabi Systems, Inc. may not be used to endorse
61 1.1 pooka * or promote products derived from this software without specific prior
62 1.1 pooka * written permission.
63 1.1 pooka *
64 1.1 pooka * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
65 1.1 pooka * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
66 1.1 pooka * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
67 1.1 pooka * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
68 1.1 pooka * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
69 1.1 pooka * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
70 1.1 pooka * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
71 1.1 pooka * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
72 1.1 pooka * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
73 1.1 pooka * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
74 1.1 pooka * POSSIBILITY OF SUCH DAMAGE.
75 1.1 pooka */
76 1.1 pooka
77 1.1 pooka /*
78 1.1 pooka * Copyright (c) 1997,1998 Mark Brinicombe.
79 1.1 pooka * Copyright (c) 1997,1998 Causality Limited.
80 1.1 pooka * All rights reserved.
81 1.1 pooka *
82 1.1 pooka * Redistribution and use in source and binary forms, with or without
83 1.1 pooka * modification, are permitted provided that the following conditions
84 1.1 pooka * are met:
85 1.1 pooka * 1. Redistributions of source code must retain the above copyright
86 1.1 pooka * notice, this list of conditions and the following disclaimer.
87 1.1 pooka * 2. Redistributions in binary form must reproduce the above copyright
88 1.1 pooka * notice, this list of conditions and the following disclaimer in the
89 1.1 pooka * documentation and/or other materials provided with the distribution.
90 1.1 pooka * 3. All advertising materials mentioning features or use of this software
91 1.1 pooka * must display the following acknowledgement:
92 1.1 pooka * This product includes software developed by Mark Brinicombe
93 1.1 pooka * for the NetBSD Project.
94 1.1 pooka * 4. The name of the company nor the name of the author may be used to
95 1.1 pooka * endorse or promote products derived from this software without specific
96 1.1 pooka * prior written permission.
97 1.1 pooka *
98 1.1 pooka * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
99 1.1 pooka * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
100 1.1 pooka * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
101 1.1 pooka * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
102 1.1 pooka * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
103 1.1 pooka * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
104 1.1 pooka * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
105 1.1 pooka * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
106 1.1 pooka * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
107 1.1 pooka * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
108 1.1 pooka * SUCH DAMAGE.
109 1.1 pooka *
110 1.18 wiz * Machine dependent functions for kernel setup for Intel IQ80310 evaluation
111 1.1 pooka * boards using RedBoot firmware.
112 1.1 pooka */
113 1.1 pooka
114 1.1 pooka #include <sys/cdefs.h>
115 1.24 matt __KERNEL_RCSID(0, "$NetBSD: viper_machdep.c,v 1.24 2014/09/13 18:08:39 matt Exp $");
116 1.1 pooka
117 1.1 pooka #include "opt_ddb.h"
118 1.1 pooka #include "opt_kgdb.h"
119 1.1 pooka #include "opt_pmap_debug.h"
120 1.1 pooka #include "opt_md.h"
121 1.1 pooka #include "opt_com.h"
122 1.1 pooka #include "lcd.h"
123 1.1 pooka
124 1.1 pooka #include <sys/param.h>
125 1.1 pooka #include <sys/device.h>
126 1.1 pooka #include <sys/systm.h>
127 1.1 pooka #include <sys/kernel.h>
128 1.1 pooka #include <sys/exec.h>
129 1.1 pooka #include <sys/proc.h>
130 1.1 pooka #include <sys/msgbuf.h>
131 1.1 pooka #include <sys/reboot.h>
132 1.1 pooka #include <sys/termios.h>
133 1.1 pooka #include <sys/ksyms.h>
134 1.23 matt #include <sys/bus.h>
135 1.23 matt #include <sys/cpu.h>
136 1.1 pooka
137 1.1 pooka #include <uvm/uvm_extern.h>
138 1.1 pooka
139 1.1 pooka #include <sys/conf.h>
140 1.1 pooka #include <dev/cons.h>
141 1.1 pooka #include <dev/md.h>
142 1.1 pooka #include <dev/ic/smc91cxxreg.h>
143 1.1 pooka
144 1.1 pooka #include <machine/db_machdep.h>
145 1.1 pooka #include <ddb/db_sym.h>
146 1.1 pooka #include <ddb/db_extern.h>
147 1.1 pooka #ifdef KGDB
148 1.1 pooka #include <sys/kgdb.h>
149 1.1 pooka #endif
150 1.1 pooka
151 1.1 pooka #include <machine/bootconfig.h>
152 1.23 matt #include <arm/locore.h>
153 1.1 pooka #include <arm/undefined.h>
154 1.1 pooka
155 1.1 pooka #include <arm/arm32/machdep.h>
156 1.1 pooka
157 1.1 pooka #include <arm/xscale/pxa2x0reg.h>
158 1.1 pooka #include <arm/xscale/pxa2x0var.h>
159 1.1 pooka #include <arm/xscale/pxa2x0_gpio.h>
160 1.1 pooka #include <arm/sa11x0/sa1111_reg.h>
161 1.1 pooka #include <evbarm/viper/viper_reg.h>
162 1.1 pooka
163 1.1 pooka /* Kernel text starts 2MB in from the bottom of the kernel address space. */
164 1.1 pooka #define KERNEL_TEXT_BASE (KERNEL_BASE + 0x00200000)
165 1.1 pooka #define KERNEL_VM_BASE (KERNEL_BASE + 0x01000000)
166 1.1 pooka
167 1.1 pooka /*
168 1.1 pooka * The range 0xc1000000 - 0xccffffff is available for kernel VM space
169 1.1 pooka * Core-logic registers and I/O mappings occupy 0xfd000000 - 0xffffffff
170 1.1 pooka */
171 1.1 pooka #define KERNEL_VM_SIZE 0x0C000000
172 1.1 pooka
173 1.1 pooka BootConfig bootconfig; /* Boot config storage */
174 1.1 pooka char *boot_args = NULL;
175 1.1 pooka char *boot_file = NULL;
176 1.1 pooka
177 1.24 matt vaddr_t physical_start;
178 1.24 matt vaddr_t physical_freestart;
179 1.24 matt vaddr_t physical_freeend;
180 1.24 matt vaddr_t physical_end;
181 1.1 pooka u_int free_pages;
182 1.1 pooka
183 1.1 pooka /*int debug_flags;*/
184 1.1 pooka #ifndef PMAP_STATIC_L1S
185 1.1 pooka int max_processes = 64; /* Default number */
186 1.1 pooka #endif /* !PMAP_STATIC_L1S */
187 1.1 pooka
188 1.1 pooka /* Physical and virtual addresses for some global pages */
189 1.1 pooka pv_addr_t minidataclean;
190 1.1 pooka
191 1.24 matt paddr_t msgbufphys;
192 1.1 pooka
193 1.1 pooka #ifdef PMAP_DEBUG
194 1.1 pooka extern int pmap_debug_level;
195 1.1 pooka #endif
196 1.1 pooka
197 1.1 pooka #define KERNEL_PT_SYS 0 /* Page table for mapping proc0 zero page */
198 1.1 pooka #define KERNEL_PT_KERNEL 1 /* Page table for mapping kernel */
199 1.1 pooka #define KERNEL_PT_KERNEL_NUM 4
200 1.1 pooka #define KERNEL_PT_VMDATA (KERNEL_PT_KERNEL+KERNEL_PT_KERNEL_NUM)
201 1.1 pooka /* Page tables for mapping kernel VM */
202 1.1 pooka #define KERNEL_PT_VMDATA_NUM 4 /* start with 16MB of KVM */
203 1.1 pooka #define NUM_KERNEL_PTS (KERNEL_PT_VMDATA + KERNEL_PT_VMDATA_NUM)
204 1.1 pooka
205 1.1 pooka pv_addr_t kernel_pt_table[NUM_KERNEL_PTS];
206 1.1 pooka
207 1.1 pooka /* Prototypes */
208 1.1 pooka
209 1.1 pooka #if 0
210 1.1 pooka void process_kernel_args(char *);
211 1.1 pooka #endif
212 1.1 pooka
213 1.1 pooka void consinit(void);
214 1.1 pooka void kgdb_port_init(void);
215 1.1 pooka void change_clock(uint32_t v);
216 1.1 pooka
217 1.1 pooka bs_protos(bs_notimpl);
218 1.1 pooka
219 1.1 pooka #include "com.h"
220 1.1 pooka #if NCOM > 0
221 1.1 pooka #include <dev/ic/comreg.h>
222 1.1 pooka #include <dev/ic/comvar.h>
223 1.1 pooka #endif
224 1.1 pooka
225 1.1 pooka #ifndef CONSPEED
226 1.1 pooka #define CONSPEED B115200 /* What RedBoot uses */
227 1.1 pooka #endif
228 1.1 pooka #ifndef CONMODE
229 1.1 pooka #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
230 1.1 pooka #endif
231 1.1 pooka
232 1.1 pooka int comcnspeed = CONSPEED;
233 1.1 pooka int comcnmode = CONMODE;
234 1.1 pooka
235 1.7 kiyohara static struct pxa2x0_gpioconf boarddep_gpioconf[] = {
236 1.7 kiyohara { 44, GPIO_ALT_FN_1_IN }, /* BTCST */
237 1.7 kiyohara { 45, GPIO_ALT_FN_2_OUT }, /* BTRST */
238 1.7 kiyohara
239 1.7 kiyohara { -1 }
240 1.7 kiyohara };
241 1.7 kiyohara static struct pxa2x0_gpioconf *viper_gpioconf[] = {
242 1.7 kiyohara pxa25x_com_btuart_gpioconf,
243 1.7 kiyohara pxa25x_com_ffuart_gpioconf,
244 1.7 kiyohara pxa25x_com_stuart_gpioconf,
245 1.7 kiyohara boarddep_gpioconf,
246 1.7 kiyohara NULL
247 1.7 kiyohara };
248 1.7 kiyohara
249 1.1 pooka /*
250 1.1 pooka * void cpu_reboot(int howto, char *bootstr)
251 1.1 pooka *
252 1.1 pooka * Reboots the system
253 1.1 pooka *
254 1.1 pooka * Deal with any syncing, unmounting, dumping and shutdown hooks,
255 1.1 pooka * then reset the CPU.
256 1.1 pooka */
257 1.1 pooka void
258 1.1 pooka cpu_reboot(int howto, char *bootstr)
259 1.1 pooka {
260 1.1 pooka #ifdef DIAGNOSTIC
261 1.1 pooka /* info */
262 1.1 pooka printf("boot: howto=%08x curproc=%p\n", howto, curproc);
263 1.1 pooka #endif
264 1.1 pooka
265 1.1 pooka /*
266 1.1 pooka * If we are still cold then hit the air brakes
267 1.1 pooka * and crash to earth fast
268 1.1 pooka */
269 1.1 pooka if (cold) {
270 1.1 pooka doshutdownhooks();
271 1.11 dyoung pmf_system_shutdown(boothowto);
272 1.1 pooka printf("The operating system has halted.\n");
273 1.1 pooka printf("Please press any key to reboot.\n\n");
274 1.1 pooka cngetc();
275 1.1 pooka printf("rebooting...\n");
276 1.1 pooka cpu_reset();
277 1.1 pooka /*NOTREACHED*/
278 1.1 pooka }
279 1.1 pooka
280 1.1 pooka /* Disable console buffering */
281 1.1 pooka /* cnpollc(1);*/
282 1.1 pooka
283 1.1 pooka /*
284 1.1 pooka * If RB_NOSYNC was not specified sync the discs.
285 1.1 pooka * Note: Unless cold is set to 1 here, syslogd will die during the
286 1.1 pooka * unmount. It looks like syslogd is getting woken up only to find
287 1.1 pooka * that it cannot page part of the binary in as the filesystem has
288 1.1 pooka * been unmounted.
289 1.1 pooka */
290 1.1 pooka if (!(howto & RB_NOSYNC))
291 1.1 pooka bootsync();
292 1.1 pooka
293 1.1 pooka /* Say NO to interrupts */
294 1.1 pooka splhigh();
295 1.1 pooka
296 1.1 pooka /* Do a dump if requested. */
297 1.1 pooka if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
298 1.1 pooka dumpsys();
299 1.1 pooka
300 1.1 pooka /* Run any shutdown hooks */
301 1.1 pooka doshutdownhooks();
302 1.1 pooka
303 1.11 dyoung pmf_system_shutdown(boothowto);
304 1.11 dyoung
305 1.1 pooka /* Make sure IRQ's are disabled */
306 1.1 pooka IRQdisable;
307 1.1 pooka
308 1.1 pooka if (howto & RB_HALT) {
309 1.1 pooka printf("The operating system has halted.\n");
310 1.1 pooka printf("Please press any key to reboot.\n\n");
311 1.1 pooka cngetc();
312 1.1 pooka }
313 1.1 pooka
314 1.1 pooka printf("rebooting...\n");
315 1.1 pooka cpu_reset();
316 1.1 pooka /*NOTREACHED*/
317 1.1 pooka }
318 1.1 pooka
319 1.1 pooka /*
320 1.1 pooka * Static device mappings. These peripheral registers are mapped at
321 1.1 pooka * fixed virtual addresses very early in viper_start() so that we
322 1.1 pooka * can use them while booting the kernel, and stay at the same address
323 1.1 pooka * throughout whole kernel's life time.
324 1.1 pooka *
325 1.1 pooka * We use this table twice; once with bootstrap page table, and once
326 1.1 pooka * with kernel's page table which we build up in initarm().
327 1.1 pooka */
328 1.1 pooka
329 1.1 pooka static const struct pmap_devmap viper_devmap[] = {
330 1.1 pooka {
331 1.1 pooka VIPER_GPIO_VBASE,
332 1.1 pooka PXA2X0_GPIO_BASE,
333 1.1 pooka L1_S_SIZE,
334 1.1 pooka VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE,
335 1.1 pooka },
336 1.1 pooka {
337 1.1 pooka VIPER_CLKMAN_VBASE,
338 1.1 pooka PXA2X0_CLKMAN_BASE,
339 1.1 pooka L1_S_SIZE,
340 1.1 pooka VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE,
341 1.1 pooka },
342 1.1 pooka {
343 1.1 pooka VIPER_INTCTL_VBASE,
344 1.1 pooka PXA2X0_INTCTL_BASE,
345 1.1 pooka L1_S_SIZE,
346 1.1 pooka VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE,
347 1.1 pooka },
348 1.1 pooka {
349 1.1 pooka VIPER_FFUART_VBASE,
350 1.1 pooka PXA2X0_FFUART_BASE,
351 1.1 pooka L1_S_SIZE,
352 1.1 pooka VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE,
353 1.1 pooka },
354 1.1 pooka {
355 1.1 pooka VIPER_BTUART_VBASE,
356 1.1 pooka PXA2X0_BTUART_BASE,
357 1.1 pooka L1_S_SIZE,
358 1.1 pooka VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE,
359 1.1 pooka },
360 1.1 pooka
361 1.1 pooka {0, 0, 0, 0,}
362 1.1 pooka };
363 1.1 pooka
364 1.1 pooka #ifndef MEMSTART
365 1.1 pooka #define MEMSTART 0xa0000000
366 1.1 pooka #endif
367 1.1 pooka #ifndef MEMSIZE
368 1.1 pooka #define MEMSIZE 0x4000000
369 1.1 pooka #endif
370 1.1 pooka
371 1.1 pooka /*
372 1.1 pooka * u_int initarm(...)
373 1.1 pooka *
374 1.1 pooka * Initial entry point on startup. This gets called before main() is
375 1.1 pooka * entered.
376 1.1 pooka * It should be responsible for setting up everything that must be
377 1.1 pooka * in place when main is called.
378 1.1 pooka * This includes
379 1.1 pooka * Taking a copy of the boot configuration structure.
380 1.1 pooka * Initialising the physical console so characters can be printed.
381 1.1 pooka * Setting up page tables for the kernel
382 1.1 pooka * Relocating the kernel to the bottom of physical memory
383 1.1 pooka */
384 1.1 pooka u_int
385 1.1 pooka initarm(void *arg)
386 1.1 pooka {
387 1.1 pooka extern vaddr_t xscale_cache_clean_addr;
388 1.1 pooka int loop;
389 1.1 pooka int loop1;
390 1.1 pooka u_int l1pagetable;
391 1.1 pooka #ifdef DIAGNOSTIC
392 1.1 pooka extern vsize_t xscale_minidata_clean_size; /* used in KASSERT */
393 1.1 pooka #endif
394 1.1 pooka
395 1.1 pooka /* Register devmap for devices we mapped in start */
396 1.1 pooka pmap_devmap_register(viper_devmap);
397 1.1 pooka
398 1.3 lukem /* start 32.768 kHz OSC */
399 1.1 pooka ioreg_write(VIPER_CLKMAN_VBASE + 0x08, 2);
400 1.1 pooka /* Get ready for splfoo() */
401 1.1 pooka pxa2x0_intr_bootstrap(VIPER_INTCTL_VBASE);
402 1.1 pooka
403 1.1 pooka /*
404 1.1 pooka * Heads up ... Setup the CPU / MMU / TLB functions
405 1.1 pooka */
406 1.1 pooka if (set_cpufuncs())
407 1.1 pooka panic("cpu not recognized!");
408 1.1 pooka
409 1.1 pooka #if 0
410 1.1 pooka /* Calibrate the delay loop. */
411 1.1 pooka #endif
412 1.1 pooka
413 1.1 pooka /* setup GPIO for BTUART, in case bootloader doesn't take care of it */
414 1.1 pooka pxa2x0_gpio_bootstrap(VIPER_GPIO_VBASE);
415 1.7 kiyohara pxa2x0_gpio_config(viper_gpioconf);
416 1.1 pooka
417 1.1 pooka /* turn on clock to UART block.
418 1.1 pooka XXX: this should not be done here. */
419 1.1 pooka ioreg_write(VIPER_CLKMAN_VBASE+CLKMAN_CKEN, CKEN_FFUART|CKEN_BTUART |
420 1.1 pooka ioreg_read(VIPER_CLKMAN_VBASE+CLKMAN_CKEN));
421 1.1 pooka
422 1.1 pooka consinit();
423 1.1 pooka #ifdef KGDB
424 1.1 pooka kgdb_port_init();
425 1.1 pooka #endif
426 1.1 pooka /* Talk to the user */
427 1.1 pooka printf("\nNetBSD/evbarm (viper) booting ...\n");
428 1.1 pooka
429 1.1 pooka #if 0
430 1.1 pooka /*
431 1.1 pooka * Examine the boot args string for options we need to know about
432 1.1 pooka * now.
433 1.1 pooka */
434 1.1 pooka process_kernel_args((char *)nwbootinfo.bt_args);
435 1.1 pooka #endif
436 1.1 pooka
437 1.1 pooka printf("initarm: Configuring system ...\n");
438 1.1 pooka
439 1.1 pooka /* Fake bootconfig structure for the benefit of pmap.c */
440 1.6 wiz /* XXX must make the memory description h/w independent */
441 1.1 pooka bootconfig.dramblocks = 1;
442 1.1 pooka bootconfig.dram[0].address = MEMSTART;
443 1.1 pooka bootconfig.dram[0].pages = MEMSIZE / PAGE_SIZE;
444 1.1 pooka
445 1.1 pooka /*
446 1.1 pooka * Set up the variables that define the availablilty of
447 1.1 pooka * physical memory. For now, we're going to set
448 1.1 pooka * physical_freestart to 0xa0200000 (where the kernel
449 1.1 pooka * was loaded), and allocate the memory we need downwards.
450 1.1 pooka * If we get too close to the page tables that RedBoot
451 1.1 pooka * set up, we will panic. We will update physical_freestart
452 1.1 pooka * and physical_freeend later to reflect what pmap_bootstrap()
453 1.1 pooka * wants to see.
454 1.1 pooka *
455 1.1 pooka * XXX pmap_bootstrap() needs an enema.
456 1.1 pooka * (now that would be truly hardcore XXX)
457 1.1 pooka */
458 1.1 pooka physical_start = bootconfig.dram[0].address;
459 1.1 pooka physical_end = physical_start + (bootconfig.dram[0].pages * PAGE_SIZE);
460 1.1 pooka
461 1.1 pooka physical_freestart = 0xa0009000UL;
462 1.1 pooka physical_freeend = 0xa0200000UL;
463 1.1 pooka
464 1.1 pooka physmem = (physical_end - physical_start) / PAGE_SIZE;
465 1.1 pooka
466 1.1 pooka #ifdef VERBOSE_INIT_ARM
467 1.1 pooka /* Tell the user about the memory */
468 1.1 pooka printf("physmemory: %d pages at 0x%08lx -> 0x%08lx\n", physmem,
469 1.1 pooka physical_start, physical_end - 1);
470 1.1 pooka #endif
471 1.1 pooka
472 1.1 pooka /*
473 1.1 pooka * Okay, the kernel starts 2MB in from the bottom of physical
474 1.1 pooka * memory. We are going to allocate our bootstrap pages downwards
475 1.1 pooka * from there.
476 1.1 pooka *
477 1.1 pooka * We need to allocate some fixed page tables to get the kernel
478 1.1 pooka * going. We allocate one page directory and a number of page
479 1.1 pooka * tables and store the physical addresses in the kernel_pt_table
480 1.1 pooka * array.
481 1.1 pooka *
482 1.1 pooka * The kernel page directory must be on a 16K boundary. The page
483 1.1 pooka * tables must be on 4K boundaries. What we do is allocate the
484 1.1 pooka * page directory on the first 16K boundary that we encounter, and
485 1.1 pooka * the page tables on 4K boundaries otherwise. Since we allocate
486 1.1 pooka * at least 3 L2 page tables, we are guaranteed to encounter at
487 1.1 pooka * least one 16K aligned region.
488 1.1 pooka */
489 1.1 pooka
490 1.1 pooka #ifdef VERBOSE_INIT_ARM
491 1.1 pooka printf("Allocating page tables\n");
492 1.1 pooka #endif
493 1.1 pooka
494 1.1 pooka free_pages = (physical_freeend - physical_freestart) / PAGE_SIZE;
495 1.1 pooka
496 1.1 pooka #ifdef VERBOSE_INIT_ARM
497 1.1 pooka printf("freestart = 0x%08lx, free_pages = %d (0x%08x)\n",
498 1.1 pooka physical_freestart, free_pages, free_pages);
499 1.1 pooka #endif
500 1.1 pooka
501 1.1 pooka /* Define a macro to simplify memory allocation */
502 1.1 pooka #define valloc_pages(var, np) \
503 1.1 pooka alloc_pages((var).pv_pa, (np)); \
504 1.1 pooka (var).pv_va = KERNEL_BASE + (var).pv_pa - physical_start;
505 1.1 pooka
506 1.1 pooka #define alloc_pages(var, np) \
507 1.1 pooka physical_freeend -= ((np) * PAGE_SIZE); \
508 1.1 pooka if (physical_freeend < physical_freestart) \
509 1.1 pooka panic("initarm: out of memory"); \
510 1.1 pooka (var) = physical_freeend; \
511 1.1 pooka free_pages -= (np); \
512 1.1 pooka memset((char *)(var), 0, ((np) * PAGE_SIZE));
513 1.1 pooka
514 1.1 pooka loop1 = 0;
515 1.1 pooka for (loop = 0; loop <= NUM_KERNEL_PTS; ++loop) {
516 1.1 pooka /* Are we 16KB aligned for an L1 ? */
517 1.1 pooka if (((physical_freeend - L1_TABLE_SIZE) & (L1_TABLE_SIZE - 1)) == 0
518 1.1 pooka && kernel_l1pt.pv_pa == 0) {
519 1.1 pooka valloc_pages(kernel_l1pt, L1_TABLE_SIZE / PAGE_SIZE);
520 1.1 pooka } else {
521 1.1 pooka valloc_pages(kernel_pt_table[loop1],
522 1.1 pooka L2_TABLE_SIZE / PAGE_SIZE);
523 1.1 pooka ++loop1;
524 1.1 pooka }
525 1.1 pooka }
526 1.1 pooka
527 1.1 pooka /* This should never be able to happen but better confirm that. */
528 1.1 pooka if (!kernel_l1pt.pv_pa || (kernel_l1pt.pv_pa & (L1_TABLE_SIZE-1)) != 0)
529 1.1 pooka panic("initarm: Failed to align the kernel page directory");
530 1.1 pooka
531 1.1 pooka /*
532 1.1 pooka * Allocate a page for the system page mapped to V0x00000000
533 1.1 pooka * This page will just contain the system vectors and can be
534 1.1 pooka * shared by all processes.
535 1.1 pooka */
536 1.1 pooka alloc_pages(systempage.pv_pa, 1);
537 1.1 pooka
538 1.1 pooka /* Allocate stacks for all modes */
539 1.1 pooka valloc_pages(irqstack, IRQ_STACK_SIZE);
540 1.1 pooka valloc_pages(abtstack, ABT_STACK_SIZE);
541 1.1 pooka valloc_pages(undstack, UND_STACK_SIZE);
542 1.1 pooka valloc_pages(kernelstack, UPAGES);
543 1.1 pooka
544 1.1 pooka /* Allocate enough pages for cleaning the Mini-Data cache. */
545 1.1 pooka KASSERT(xscale_minidata_clean_size <= PAGE_SIZE);
546 1.1 pooka valloc_pages(minidataclean, 1);
547 1.1 pooka
548 1.1 pooka #ifdef VERBOSE_INIT_ARM
549 1.1 pooka printf("IRQ stack: p0x%08lx v0x%08lx\n", irqstack.pv_pa,
550 1.1 pooka irqstack.pv_va);
551 1.1 pooka printf("ABT stack: p0x%08lx v0x%08lx\n", abtstack.pv_pa,
552 1.1 pooka abtstack.pv_va);
553 1.1 pooka printf("UND stack: p0x%08lx v0x%08lx\n", undstack.pv_pa,
554 1.1 pooka undstack.pv_va);
555 1.1 pooka printf("SVC stack: p0x%08lx v0x%08lx\n", kernelstack.pv_pa,
556 1.1 pooka kernelstack.pv_va);
557 1.1 pooka #endif
558 1.1 pooka
559 1.1 pooka /*
560 1.1 pooka * XXX Defer this to later so that we can reclaim the memory
561 1.1 pooka * XXX used by the RedBoot page tables.
562 1.1 pooka */
563 1.1 pooka alloc_pages(msgbufphys, round_page(MSGBUFSIZE) / PAGE_SIZE);
564 1.1 pooka
565 1.1 pooka /*
566 1.1 pooka * Ok we have allocated physical pages for the primary kernel
567 1.1 pooka * page tables
568 1.1 pooka */
569 1.1 pooka
570 1.1 pooka #ifdef VERBOSE_INIT_ARM
571 1.1 pooka printf("Creating L1 page table at 0x%08lx\n", kernel_l1pt.pv_pa);
572 1.1 pooka #endif
573 1.1 pooka
574 1.1 pooka /*
575 1.1 pooka * Now we start construction of the L1 page table
576 1.1 pooka * We start by mapping the L2 page tables into the L1.
577 1.1 pooka * This means that we can replace L1 mappings later on if necessary
578 1.1 pooka */
579 1.1 pooka l1pagetable = kernel_l1pt.pv_pa;
580 1.1 pooka
581 1.1 pooka /* Map the L2 pages tables in the L1 page table */
582 1.1 pooka pmap_link_l2pt(l1pagetable, 0x00000000,
583 1.1 pooka &kernel_pt_table[KERNEL_PT_SYS]);
584 1.1 pooka for (loop = 0; loop < KERNEL_PT_KERNEL_NUM; loop++)
585 1.1 pooka pmap_link_l2pt(l1pagetable, KERNEL_BASE + loop * 0x00400000,
586 1.1 pooka &kernel_pt_table[KERNEL_PT_KERNEL + loop]);
587 1.1 pooka for (loop = 0; loop < KERNEL_PT_VMDATA_NUM; loop++)
588 1.1 pooka pmap_link_l2pt(l1pagetable, KERNEL_VM_BASE + loop * 0x00400000,
589 1.1 pooka &kernel_pt_table[KERNEL_PT_VMDATA + loop]);
590 1.1 pooka
591 1.1 pooka /* update the top of the kernel VM */
592 1.1 pooka pmap_curmaxkvaddr =
593 1.1 pooka KERNEL_VM_BASE + (KERNEL_PT_VMDATA_NUM * 0x00400000);
594 1.1 pooka
595 1.1 pooka #ifdef VERBOSE_INIT_ARM
596 1.1 pooka printf("Mapping kernel\n");
597 1.1 pooka #endif
598 1.1 pooka
599 1.1 pooka /* Now we fill in the L2 pagetable for the kernel static code/data */
600 1.1 pooka {
601 1.1 pooka extern char etext[], _end[];
602 1.1 pooka size_t textsize = (uintptr_t) etext - KERNEL_TEXT_BASE;
603 1.1 pooka size_t totalsize = (uintptr_t) _end - KERNEL_TEXT_BASE;
604 1.1 pooka u_int logical;
605 1.1 pooka
606 1.1 pooka textsize = (textsize + PGOFSET) & ~PGOFSET;
607 1.1 pooka totalsize = (totalsize + PGOFSET) & ~PGOFSET;
608 1.1 pooka
609 1.1 pooka logical = 0x00200000; /* offset of kernel in RAM */
610 1.1 pooka
611 1.1 pooka logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
612 1.1 pooka physical_start + logical, textsize,
613 1.1 pooka VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
614 1.1 pooka logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
615 1.1 pooka physical_start + logical, totalsize - textsize,
616 1.1 pooka VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
617 1.1 pooka }
618 1.1 pooka
619 1.1 pooka #ifdef VERBOSE_INIT_ARM
620 1.1 pooka printf("Constructing L2 page tables\n");
621 1.1 pooka #endif
622 1.1 pooka
623 1.1 pooka /* Map the stack pages */
624 1.1 pooka pmap_map_chunk(l1pagetable, irqstack.pv_va, irqstack.pv_pa,
625 1.1 pooka IRQ_STACK_SIZE * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
626 1.1 pooka pmap_map_chunk(l1pagetable, abtstack.pv_va, abtstack.pv_pa,
627 1.1 pooka ABT_STACK_SIZE * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
628 1.1 pooka pmap_map_chunk(l1pagetable, undstack.pv_va, undstack.pv_pa,
629 1.1 pooka UND_STACK_SIZE * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
630 1.1 pooka pmap_map_chunk(l1pagetable, kernelstack.pv_va, kernelstack.pv_pa,
631 1.1 pooka UPAGES * PAGE_SIZE, VM_PROT_READ | VM_PROT_WRITE, PTE_CACHE);
632 1.1 pooka
633 1.1 pooka pmap_map_chunk(l1pagetable, kernel_l1pt.pv_va, kernel_l1pt.pv_pa,
634 1.1 pooka L1_TABLE_SIZE, VM_PROT_READ | VM_PROT_WRITE, PTE_PAGETABLE);
635 1.1 pooka
636 1.1 pooka for (loop = 0; loop < NUM_KERNEL_PTS; ++loop) {
637 1.1 pooka pmap_map_chunk(l1pagetable, kernel_pt_table[loop].pv_va,
638 1.1 pooka kernel_pt_table[loop].pv_pa, L2_TABLE_SIZE,
639 1.1 pooka VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
640 1.1 pooka }
641 1.1 pooka
642 1.1 pooka /* Map the Mini-Data cache clean area. */
643 1.1 pooka xscale_setup_minidata(l1pagetable, minidataclean.pv_va,
644 1.1 pooka minidataclean.pv_pa);
645 1.1 pooka
646 1.1 pooka /* Map the vector page. */
647 1.1 pooka #if 1
648 1.1 pooka /* MULTI-ICE requires that page 0 is NC/NB so that it can download the
649 1.1 pooka * cache-clean code there. */
650 1.1 pooka pmap_map_entry(l1pagetable, vector_page, systempage.pv_pa,
651 1.1 pooka VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
652 1.1 pooka #else
653 1.1 pooka pmap_map_entry(l1pagetable, vector_page, systempage.pv_pa,
654 1.1 pooka VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
655 1.1 pooka #endif
656 1.1 pooka
657 1.1 pooka /*
658 1.1 pooka * map integrated peripherals at same address in l1pagetable
659 1.1 pooka * so that we can continue to use console.
660 1.1 pooka */
661 1.1 pooka pmap_devmap_bootstrap(l1pagetable, viper_devmap);
662 1.1 pooka
663 1.1 pooka /*
664 1.1 pooka * Give the XScale global cache clean code an appropriately
665 1.1 pooka * sized chunk of unmapped VA space starting at 0xff000000
666 1.1 pooka * (our device mappings end before this address).
667 1.1 pooka */
668 1.1 pooka xscale_cache_clean_addr = 0xff000000U;
669 1.1 pooka
670 1.1 pooka /*
671 1.1 pooka * Now we have the real page tables in place so we can switch to them.
672 1.1 pooka * Once this is done we will be running with the REAL kernel page
673 1.1 pooka * tables.
674 1.1 pooka */
675 1.1 pooka
676 1.1 pooka /*
677 1.1 pooka * Update the physical_freestart/physical_freeend/free_pages
678 1.1 pooka * variables.
679 1.1 pooka */
680 1.1 pooka {
681 1.1 pooka extern char _end[];
682 1.1 pooka
683 1.1 pooka physical_freestart = physical_start +
684 1.1 pooka (((((uintptr_t) _end) + PGOFSET) & ~PGOFSET) -
685 1.1 pooka KERNEL_BASE);
686 1.1 pooka physical_freeend = physical_end;
687 1.1 pooka free_pages =
688 1.1 pooka (physical_freeend - physical_freestart) / PAGE_SIZE;
689 1.1 pooka }
690 1.1 pooka
691 1.1 pooka /* Switch tables */
692 1.1 pooka #ifdef VERBOSE_INIT_ARM
693 1.1 pooka printf("freestart = 0x%08lx, free_pages = %d (0x%x)\n",
694 1.1 pooka physical_freestart, free_pages, free_pages);
695 1.1 pooka printf("switching to new L1 page table @%#lx...", kernel_l1pt.pv_pa);
696 1.1 pooka #endif
697 1.1 pooka
698 1.1 pooka cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
699 1.22 matt cpu_setttb(kernel_l1pt.pv_pa, true);
700 1.1 pooka cpu_tlb_flushID();
701 1.1 pooka cpu_domains(DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2));
702 1.1 pooka
703 1.1 pooka /*
704 1.1 pooka * Moved from cpu_startup() as data_abort_handler() references
705 1.1 pooka * this during uvm init
706 1.1 pooka */
707 1.14 rmind uvm_lwp_setuarea(&lwp0, kernelstack.pv_va);
708 1.1 pooka
709 1.1 pooka #ifdef VERBOSE_INIT_ARM
710 1.1 pooka printf("bootstrap done.\n");
711 1.1 pooka #endif
712 1.1 pooka
713 1.1 pooka arm32_vector_init(ARM_VECTORS_LOW, ARM_VEC_ALL);
714 1.1 pooka
715 1.1 pooka /*
716 1.1 pooka * Pages were allocated during the secondary bootstrap for the
717 1.1 pooka * stacks for different CPU modes.
718 1.1 pooka * We must now set the r13 registers in the different CPU modes to
719 1.1 pooka * point to these stacks.
720 1.1 pooka * Since the ARM stacks use STMFD etc. we must set r13 to the top end
721 1.1 pooka * of the stack memory.
722 1.1 pooka */
723 1.1 pooka printf("init subsystems: stacks ");
724 1.1 pooka
725 1.1 pooka set_stackptr(PSR_IRQ32_MODE, irqstack.pv_va + IRQ_STACK_SIZE * PAGE_SIZE);
726 1.1 pooka set_stackptr(PSR_ABT32_MODE, abtstack.pv_va + ABT_STACK_SIZE * PAGE_SIZE);
727 1.1 pooka set_stackptr(PSR_UND32_MODE, undstack.pv_va + UND_STACK_SIZE * PAGE_SIZE);
728 1.1 pooka
729 1.1 pooka /*
730 1.1 pooka * Well we should set a data abort handler.
731 1.1 pooka * Once things get going this will change as we will need a proper
732 1.1 pooka * handler.
733 1.1 pooka * Until then we will use a handler that just panics but tells us
734 1.1 pooka * why.
735 1.1 pooka * Initialisation of the vectors will just panic on a data abort.
736 1.1 pooka * This just fills in a slightly better one.
737 1.1 pooka */
738 1.1 pooka printf("vectors ");
739 1.1 pooka data_abort_handler_address = (u_int)data_abort_handler;
740 1.1 pooka prefetch_abort_handler_address = (u_int)prefetch_abort_handler;
741 1.1 pooka undefined_handler_address = (u_int)undefinedinstruction_bounce;
742 1.1 pooka
743 1.1 pooka /* Initialise the undefined instruction handlers */
744 1.1 pooka printf("undefined ");
745 1.1 pooka undefined_init();
746 1.1 pooka
747 1.1 pooka /* Load memory into UVM. */
748 1.1 pooka printf("page ");
749 1.1 pooka uvm_setpagesize(); /* initialize PAGE_SIZE-dependent variables */
750 1.1 pooka uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
751 1.1 pooka atop(physical_freestart), atop(physical_freeend),
752 1.1 pooka VM_FREELIST_DEFAULT);
753 1.1 pooka
754 1.1 pooka /* Boot strap pmap telling it where the kernel page table is */
755 1.1 pooka printf("pmap ");
756 1.10 matt pmap_bootstrap(KERNEL_VM_BASE, KERNEL_VM_BASE + KERNEL_VM_SIZE);
757 1.1 pooka
758 1.1 pooka #ifdef __HAVE_MEMORY_DISK__
759 1.1 pooka md_root_setconf(memory_disk, sizeof memory_disk);
760 1.1 pooka #endif
761 1.1 pooka
762 1.1 pooka #ifdef KGDB
763 1.1 pooka if (boothowto & RB_KDB) {
764 1.1 pooka kgdb_debug_init = 1;
765 1.1 pooka kgdb_connect(1);
766 1.1 pooka }
767 1.1 pooka #endif
768 1.1 pooka
769 1.1 pooka #ifdef DDB
770 1.1 pooka db_machine_init();
771 1.1 pooka
772 1.1 pooka /* Firmware doesn't load symbols. */
773 1.1 pooka ddb_init(0, NULL, NULL);
774 1.1 pooka
775 1.1 pooka if (boothowto & RB_KDB)
776 1.1 pooka Debugger();
777 1.1 pooka #endif
778 1.1 pooka
779 1.1 pooka /* We return the new stack pointer address */
780 1.1 pooka return(kernelstack.pv_va + USPACE_SVC_STACK_TOP);
781 1.1 pooka }
782 1.1 pooka
783 1.1 pooka #if 0
784 1.1 pooka void
785 1.1 pooka process_kernel_args(char *args)
786 1.1 pooka {
787 1.1 pooka
788 1.1 pooka boothowto = 0;
789 1.1 pooka
790 1.1 pooka /* Make a local copy of the bootargs */
791 1.1 pooka strncpy(bootargs, args, MAX_BOOT_STRING);
792 1.1 pooka
793 1.1 pooka args = bootargs;
794 1.1 pooka boot_file = bootargs;
795 1.1 pooka
796 1.1 pooka /* Skip the kernel image filename */
797 1.1 pooka while (*args != ' ' && *args != 0)
798 1.1 pooka ++args;
799 1.1 pooka
800 1.1 pooka if (*args != 0)
801 1.1 pooka *args++ = 0;
802 1.1 pooka
803 1.1 pooka while (*args == ' ')
804 1.1 pooka ++args;
805 1.1 pooka
806 1.1 pooka boot_args = args;
807 1.1 pooka
808 1.1 pooka printf("bootfile: %s\n", boot_file);
809 1.1 pooka printf("bootargs: %s\n", boot_args);
810 1.1 pooka
811 1.1 pooka parse_mi_bootargs(boot_args);
812 1.1 pooka }
813 1.1 pooka #endif
814 1.1 pooka
815 1.1 pooka #ifdef KGDB
816 1.1 pooka #ifndef KGDB_DEVNAME
817 1.1 pooka #define KGDB_DEVNAME "ffuart"
818 1.1 pooka #endif
819 1.1 pooka const char kgdb_devname[] = KGDB_DEVNAME;
820 1.1 pooka
821 1.1 pooka #if (NCOM > 0)
822 1.1 pooka #ifndef KGDB_DEVMODE
823 1.1 pooka #define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
824 1.1 pooka #endif
825 1.1 pooka int comkgdbmode = KGDB_DEVMODE;
826 1.1 pooka #endif /* NCOM */
827 1.1 pooka
828 1.1 pooka #endif /* KGDB */
829 1.1 pooka
830 1.1 pooka
831 1.1 pooka void
832 1.1 pooka consinit(void)
833 1.1 pooka {
834 1.1 pooka static int consinit_called = 0;
835 1.1 pooka uint32_t ckenreg = ioreg_read(VIPER_CLKMAN_VBASE+CLKMAN_CKEN);
836 1.1 pooka #if 0
837 1.1 pooka char *console = CONSDEVNAME;
838 1.1 pooka #endif
839 1.1 pooka
840 1.1 pooka if (consinit_called != 0)
841 1.1 pooka return;
842 1.1 pooka consinit_called = 1;
843 1.1 pooka
844 1.1 pooka #if NCOM > 0
845 1.1 pooka
846 1.1 pooka #ifdef FFUARTCONSOLE
847 1.1 pooka #ifdef KGDB
848 1.1 pooka if (0 == strcmp(kgdb_devname, "ffuart")) {
849 1.1 pooka /* port is reserved for kgdb */
850 1.1 pooka } else
851 1.1 pooka #endif
852 1.1 pooka if (0 == comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_FFUART_BASE,
853 1.1 pooka comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode)) {
854 1.1 pooka
855 1.1 pooka #if 0
856 1.1 pooka /* XXX: can't call pxa2x0_clkman_config yet */
857 1.1 pooka pxa2x0_clkman_config(CKEN_FFUART, 1);
858 1.1 pooka #else
859 1.1 pooka ioreg_write(VIPER_CLKMAN_VBASE+CLKMAN_CKEN,
860 1.1 pooka ckenreg|CKEN_FFUART);
861 1.1 pooka #endif
862 1.1 pooka
863 1.1 pooka return;
864 1.1 pooka }
865 1.1 pooka
866 1.1 pooka #endif /* FFUARTCONSOLE */
867 1.1 pooka
868 1.1 pooka #ifdef BTUARTCONSOLE
869 1.1 pooka #ifdef KGDB
870 1.1 pooka if (0 == strcmp(kgdb_devname, "btuart")) {
871 1.1 pooka /* port is reserved for kgdb */
872 1.1 pooka } else
873 1.1 pooka #endif
874 1.1 pooka if (0 == comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_BTUART_BASE,
875 1.1 pooka comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode)) {
876 1.1 pooka ioreg_write(VIPER_CLKMAN_VBASE+CLKMAN_CKEN,
877 1.1 pooka ckenreg|CKEN_BTUART);
878 1.1 pooka return;
879 1.1 pooka }
880 1.1 pooka #endif /* BTUARTCONSOLE */
881 1.1 pooka
882 1.1 pooka /* no console, guess we're flying blind */
883 1.1 pooka
884 1.1 pooka #endif /* NCOM */
885 1.1 pooka
886 1.1 pooka }
887 1.1 pooka
888 1.1 pooka #ifdef KGDB
889 1.1 pooka void
890 1.1 pooka kgdb_port_init(void)
891 1.1 pooka {
892 1.1 pooka #if (NCOM > 0) && defined(COM_PXA2X0)
893 1.1 pooka paddr_t paddr = 0;
894 1.1 pooka uint32_t ckenreg = ioreg_read(VIPER_CLKMAN_VBASE+CLKMAN_CKEN);
895 1.1 pooka
896 1.1 pooka if (0 == strcmp(kgdb_devname, "ffuart")) {
897 1.1 pooka paddr = PXA2X0_FFUART_BASE;
898 1.1 pooka ckenreg |= CKEN_FFUART;
899 1.1 pooka }
900 1.1 pooka else if (0 == strcmp(kgdb_devname, "btuart")) {
901 1.1 pooka paddr = PXA2X0_BTUART_BASE;
902 1.1 pooka ckenreg |= CKEN_BTUART;
903 1.1 pooka }
904 1.1 pooka
905 1.1 pooka if (paddr &&
906 1.1 pooka 0 == com_kgdb_attach(&pxa2x0_a4x_bs_tag, paddr,
907 1.1 pooka kgdb_rate, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comkgdbmode)) {
908 1.1 pooka
909 1.1 pooka ioreg_write(VIPER_CLKMAN_VBASE+CLKMAN_CKEN, ckenreg);
910 1.1 pooka }
911 1.1 pooka #endif
912 1.1 pooka }
913 1.1 pooka #endif
914