xref: /netbsd-src/sys/arch/evbarm/lubbock/lubbock_machdep.c (revision d710132b4b8ce7f7cccaaf660cb16aa16b4077a0)
1 /*	$NetBSD: lubbock_machdep.c,v 1.1 2003/06/18 10:51:15 bsh Exp $ */
2 
3 /*
4  * Copyright (c) 2002, 2003  Genetec Corporation.  All rights reserved.
5  * Written by Hiroyuki Bessho for Genetec Corporation.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. The name of Genetec Corporation may not be used to endorse or
16  *    promote products derived from this software without specific prior
17  *    written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  *
31  * Machine dependant functions for kernel setup for
32  * Intel DBPXA250 evaluation board (a.k.a. Lubbock).
33  * Based on iq80310_machhdep.c
34  */
35 /*
36  * Copyright (c) 2001 Wasabi Systems, Inc.
37  * All rights reserved.
38  *
39  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
40  *
41  * Redistribution and use in source and binary forms, with or without
42  * modification, are permitted provided that the following conditions
43  * are met:
44  * 1. Redistributions of source code must retain the above copyright
45  *    notice, this list of conditions and the following disclaimer.
46  * 2. Redistributions in binary form must reproduce the above copyright
47  *    notice, this list of conditions and the following disclaimer in the
48  *    documentation and/or other materials provided with the distribution.
49  * 3. All advertising materials mentioning features or use of this software
50  *    must display the following acknowledgement:
51  *	This product includes software developed for the NetBSD Project by
52  *	Wasabi Systems, Inc.
53  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
54  *    or promote products derived from this software without specific prior
55  *    written permission.
56  *
57  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
58  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
59  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
61  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
62  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
63  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
64  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
65  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
67  * POSSIBILITY OF SUCH DAMAGE.
68  */
69 
70 /*
71  * Copyright (c) 1997,1998 Mark Brinicombe.
72  * Copyright (c) 1997,1998 Causality Limited.
73  * All rights reserved.
74  *
75  * Redistribution and use in source and binary forms, with or without
76  * modification, are permitted provided that the following conditions
77  * are met:
78  * 1. Redistributions of source code must retain the above copyright
79  *    notice, this list of conditions and the following disclaimer.
80  * 2. Redistributions in binary form must reproduce the above copyright
81  *    notice, this list of conditions and the following disclaimer in the
82  *    documentation and/or other materials provided with the distribution.
83  * 3. All advertising materials mentioning features or use of this software
84  *    must display the following acknowledgement:
85  *	This product includes software developed by Mark Brinicombe
86  *	for the NetBSD Project.
87  * 4. The name of the company nor the name of the author may be used to
88  *    endorse or promote products derived from this software without specific
89  *    prior written permission.
90  *
91  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
92  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
93  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
94  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
95  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
96  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
97  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
98  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
99  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
100  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
101  * SUCH DAMAGE.
102  *
103  * Machine dependant functions for kernel setup for Intel IQ80310 evaluation
104  * boards using RedBoot firmware.
105  */
106 
107 /*
108  * DIP switches:
109  *
110  * S19: no-dot: set RB_KDB.  enter kgdb session.
111  * S20: no-dot: set RB_SINGLE. don't go multi user mode.
112  */
113 #include "opt_ddb.h"
114 #include "opt_kgdb.h"
115 #include "opt_ipkdb.h"
116 #include "opt_pmap_debug.h"
117 #include "opt_md.h"
118 #include "opt_com.h"
119 #include "md.h"
120 #include "lcd.h"
121 
122 #include <sys/param.h>
123 #include <sys/device.h>
124 #include <sys/systm.h>
125 #include <sys/kernel.h>
126 #include <sys/exec.h>
127 #include <sys/proc.h>
128 #include <sys/msgbuf.h>
129 #include <sys/reboot.h>
130 #include <sys/termios.h>
131 #include <sys/ksyms.h>
132 
133 #include <uvm/uvm_extern.h>
134 
135 #include <sys/conf.h>
136 #include <dev/cons.h>
137 #include <dev/md.h>
138 #include <dev/ic/smc91cxxreg.h>
139 
140 #include <machine/db_machdep.h>
141 #include <ddb/db_sym.h>
142 #include <ddb/db_extern.h>
143 #ifdef KGDB
144 #include <sys/kgdb.h>
145 #endif
146 
147 #include <machine/bootconfig.h>
148 #include <machine/bus.h>
149 #include <machine/cpu.h>
150 #include <machine/frame.h>
151 #include <arm/undefined.h>
152 
153 #include <arm/arm32/machdep.h>
154 
155 #include <arm/xscale/pxa2x0reg.h>
156 #include <arm/xscale/pxa2x0var.h>
157 #include <arm/xscale/pxa2x0_gpio.h>
158 #include <arm/sa11x0/sa1111_reg.h>
159 #include <evbarm/lubbock/lubbock_reg.h>
160 #include <evbarm/lubbock/lubbock_var.h>
161 
162 /* Kernel text starts 2MB in from the bottom of the kernel address space. */
163 #define	KERNEL_TEXT_BASE	(KERNEL_BASE + 0x00200000)
164 #define	KERNEL_VM_BASE		(KERNEL_BASE + 0x01000000)
165 
166 /*
167  * The range 0xc1000000 - 0xccffffff is available for kernel VM space
168  * Core-logic registers and I/O mappings occupy 0xfd000000 - 0xffffffff
169  */
170 #define KERNEL_VM_SIZE		0x0C000000
171 
172 
173 /*
174  * Address to call from cpu_reset() to reset the machine.
175  * This is machine architecture dependant as it varies depending
176  * on where the ROM appears when you turn the MMU off.
177  */
178 
179 u_int cpu_reset_address = 0;
180 
181 /* Define various stack sizes in pages */
182 #define IRQ_STACK_SIZE	1
183 #define ABT_STACK_SIZE	1
184 #ifdef IPKDB
185 #define UND_STACK_SIZE	2
186 #else
187 #define UND_STACK_SIZE	1
188 #endif
189 
190 BootConfig bootconfig;		/* Boot config storage */
191 char *boot_args = NULL;
192 char *boot_file = NULL;
193 
194 vm_offset_t physical_start;
195 vm_offset_t physical_freestart;
196 vm_offset_t physical_freeend;
197 vm_offset_t physical_end;
198 u_int free_pages;
199 vm_offset_t pagetables_start;
200 int physmem = 0;
201 
202 /*int debug_flags;*/
203 #ifndef PMAP_STATIC_L1S
204 int max_processes = 64;			/* Default number */
205 #endif	/* !PMAP_STATIC_L1S */
206 
207 /* Physical and virtual addresses for some global pages */
208 pv_addr_t systempage;
209 pv_addr_t irqstack;
210 pv_addr_t undstack;
211 pv_addr_t abtstack;
212 pv_addr_t kernelstack;
213 pv_addr_t minidataclean;
214 
215 vm_offset_t msgbufphys;
216 
217 extern u_int data_abort_handler_address;
218 extern u_int prefetch_abort_handler_address;
219 extern u_int undefined_handler_address;
220 
221 #ifdef PMAP_DEBUG
222 extern int pmap_debug_level;
223 #endif
224 
225 #define KERNEL_PT_SYS		0	/* Page table for mapping proc0 zero page */
226 #define KERNEL_PT_KERNEL	1	/* Page table for mapping kernel */
227 #define	KERNEL_PT_KERNEL_NUM	4
228 #define KERNEL_PT_VMDATA	(KERNEL_PT_KERNEL+KERNEL_PT_KERNEL_NUM)
229 				        /* Page tables for mapping kernel VM */
230 #define	KERNEL_PT_VMDATA_NUM	4	/* start with 16MB of KVM */
231 #define NUM_KERNEL_PTS		(KERNEL_PT_VMDATA + KERNEL_PT_VMDATA_NUM)
232 
233 pv_addr_t kernel_pt_table[NUM_KERNEL_PTS];
234 
235 struct user *proc0paddr;
236 
237 /* Prototypes */
238 
239 #if 0
240 void	process_kernel_args(char *);
241 void	parse_mi_bootargs(char *args);
242 #endif
243 
244 void	consinit(void);
245 void	kgdb_port_init(void);
246 void	change_clock(uint32_t v);
247 
248 bs_protos(bs_notimpl);
249 
250 #include "com.h"
251 #if NCOM > 0
252 #include <dev/ic/comreg.h>
253 #include <dev/ic/comvar.h>
254 #endif
255 
256 #ifndef CONSPEED
257 #define CONSPEED B115200	/* What RedBoot uses */
258 #endif
259 #ifndef CONMODE
260 #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
261 #endif
262 
263 int comcnspeed = CONSPEED;
264 int comcnmode = CONMODE;
265 
266 /*
267  * void cpu_reboot(int howto, char *bootstr)
268  *
269  * Reboots the system
270  *
271  * Deal with any syncing, unmounting, dumping and shutdown hooks,
272  * then reset the CPU.
273  */
274 void
275 cpu_reboot(int howto, char *bootstr)
276 {
277 #ifdef DIAGNOSTIC
278 	/* info */
279 	printf("boot: howto=%08x curproc=%p\n", howto, curproc);
280 #endif
281 
282 	/*
283 	 * If we are still cold then hit the air brakes
284 	 * and crash to earth fast
285 	 */
286 	if (cold) {
287 		doshutdownhooks();
288 		printf("The operating system has halted.\n");
289 		printf("Please press any key to reboot.\n\n");
290 		cngetc();
291 		printf("rebooting...\n");
292 		cpu_reset();
293 		/*NOTREACHED*/
294 	}
295 
296 	/* Disable console buffering */
297 /*	cnpollc(1);*/
298 
299 	/*
300 	 * If RB_NOSYNC was not specified sync the discs.
301 	 * Note: Unless cold is set to 1 here, syslogd will die during the
302 	 * unmount.  It looks like syslogd is getting woken up only to find
303 	 * that it cannot page part of the binary in as the filesystem has
304 	 * been unmounted.
305 	 */
306 	if (!(howto & RB_NOSYNC))
307 		bootsync();
308 
309 	/* Say NO to interrupts */
310 	splhigh();
311 
312 	/* Do a dump if requested. */
313 	if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
314 		dumpsys();
315 
316 	/* Run any shutdown hooks */
317 	doshutdownhooks();
318 
319 	/* Make sure IRQ's are disabled */
320 	IRQdisable;
321 
322 	if (howto & RB_HALT) {
323 		printf("The operating system has halted.\n");
324 		printf("Please press any key to reboot.\n\n");
325 		cngetc();
326 	}
327 
328 	printf("rebooting...\n");
329 	cpu_reset();
330 	/*NOTREACHED*/
331 }
332 
333 static __inline
334 pd_entry_t *
335 read_ttb(void)
336 {
337   long ttb;
338 
339   __asm __volatile("mrc	p15, 0, %0, c2, c0, 0" : "=r" (ttb));
340 
341 
342   return (pd_entry_t *)(ttb & ~((1<<14)-1));
343 }
344 
345 /*
346  * Mapping table for core kernel memory. These areas are mapped in
347  * init time at fixed virtual address with section mappings.
348  */
349 struct l1_sec_map {
350 	vaddr_t	va;
351 	vaddr_t	pa;
352 	vsize_t	size;
353 	int flags;
354 } l1_sec_table[] = {
355     {
356 	    LUBBOCK_OBIO_VBASE,
357 	    LUBBOCK_OBIO_PBASE,
358 	    LUBBOCK_OBIO_SIZE,
359 	    PTE_NOCACHE,
360     },
361     {
362 	    LUBBOCK_GPIO_VBASE,
363 	    PXA2X0_GPIO_BASE,
364 	    PXA2X0_GPIO_SIZE,
365 	    PTE_NOCACHE,
366     },
367     {
368 	    LUBBOCK_CLKMAN_VBASE,
369 	    PXA2X0_CLKMAN_BASE,
370 	    PXA2X0_CLKMAN_SIZE,
371 	    PTE_NOCACHE,
372     },
373     {
374 	    LUBBOCK_INTCTL_VBASE,
375 	    PXA2X0_INTCTL_BASE,
376 	    PXA2X0_INTCTL_SIZE,
377 	    PTE_NOCACHE,
378     },
379     {0, 0, 0, 0,}
380 };
381 
382 static void
383 map_io_area(paddr_t pagedir)
384 {
385 	int loop;
386 
387 	/*
388 	 * Map devices we can map w/ section mappings.
389 	 */
390 	loop = 0;
391 	while (l1_sec_table[loop].size) {
392 		vm_size_t sz;
393 
394 #ifdef VERBOSE_INIT_ARM
395 		printf("%08lx -> %08lx @ %08lx\n", l1_sec_table[loop].pa,
396 		    l1_sec_table[loop].pa + l1_sec_table[loop].size - 1,
397 		    l1_sec_table[loop].va);
398 #endif
399 		for (sz = 0; sz < l1_sec_table[loop].size; sz += L1_S_SIZE)
400 			pmap_map_section(pagedir, l1_sec_table[loop].va + sz,
401 			    l1_sec_table[loop].pa + sz,
402 			    VM_PROT_READ|VM_PROT_WRITE,
403 			    l1_sec_table[loop].flags);
404 		++loop;
405 	}
406 }
407 
408 /*
409  * simple memory mapping function used in early bootstrap stage
410  * before pmap is initialized.
411  * size and cacheability are ignored and map one section with nocache.
412  */
413 static vaddr_t section_free = LUBBOCK_VBASE_FREE;
414 
415 static int
416 bootstrap_bs_map(void *t, bus_addr_t bpa, bus_size_t size,
417     int cacheable, bus_space_handle_t *bshp)
418 {
419 	u_long startpa;
420 	vaddr_t va;
421 	pd_entry_t *pagedir = read_ttb();
422 	/* This assumes PA==VA for page directory */
423 
424 	va = section_free;
425 	section_free += L1_S_SIZE;
426 
427 	startpa = trunc_page(bpa);
428 	pmap_map_section((vaddr_t)pagedir, va, startpa,
429 	    VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
430 	cpu_tlb_flushD();
431 
432 	*bshp = (bus_space_handle_t)(va + (bpa - startpa));
433 
434 	return(0);
435 }
436 
437 static void
438 copy_io_area_map(pd_entry_t *new_pd)
439 {
440 	pd_entry_t *cur_pd = read_ttb();
441 	vaddr_t va;
442 
443 	for (va = LUBBOCK_IO_AREA_VBASE;
444 	     (cur_pd[va>>L1_S_SHIFT] & L1_TYPE_MASK) == L1_TYPE_S;
445 	     va += L1_S_SIZE) {
446 
447 		new_pd[va>>L1_S_SHIFT] = cur_pd[va>>L1_S_SHIFT];
448 	}
449 }
450 
451 
452 
453 /*
454  * u_int initarm(...)
455  *
456  * Initial entry point on startup. This gets called before main() is
457  * entered.
458  * It should be responsible for setting up everything that must be
459  * in place when main is called.
460  * This includes
461  *   Taking a copy of the boot configuration structure.
462  *   Initialising the physical console so characters can be printed.
463  *   Setting up page tables for the kernel
464  *   Relocating the kernel to the bottom of physical memory
465  */
466 u_int
467 initarm(void *arg)
468 {
469 	extern vaddr_t xscale_cache_clean_addr;
470 	int loop;
471 	int loop1;
472 	u_int l1pagetable;
473 	pv_addr_t kernel_l1pt;
474 	paddr_t memstart;
475 	psize_t memsize;
476 	int led_data = 0;
477 #ifdef DIAGNOSTIC
478 	extern vsize_t xscale_minidata_clean_size; /* used in KASSERT */
479 #endif
480 	struct bus_space tmp_bs_tag;
481 	int	(*map_func_save)(void *, bus_addr_t, bus_size_t, int,
482 	    bus_space_handle_t *);
483 #define LEDSTEP_P() 	ioreg_write(LUBBOCK_OBIO_PBASE+LUBBOCK_HEXLED, led_data++)
484 #define LEDSTEP() hex_led(led_data++)
485 
486 	/* use physical address until pagetable is set */
487 	LEDSTEP_P();
488 
489 	/* start 32.768KHz OSC */
490 	ioreg_write(PXA2X0_CLKMAN_BASE + 0x08, 2);
491 
492 	/*
493 	 * Heads up ... Setup the CPU / MMU / TLB functions
494 	 */
495 	if (set_cpufuncs())
496 		panic("cpu not recognized!");
497 	LEDSTEP_P();
498 
499 	/* Get ready for splfoo() */
500 	pxa2x0_intr_bootstrap(PXA2X0_INTCTL_BASE);
501 
502 #if 0
503 	/* Calibrate the delay loop. */
504 #endif
505 
506 	/*
507 	 * Okay, RedBoot has provided us with the following memory map:
508 	 *
509 	 * Physical Address Range     Description
510 	 * -----------------------    ----------------------------------
511 	 * 0x00000000 - 0x01ffffff    flash Memory   (32MB)
512 	 * 0x04000000 - 0x05ffffff    Application flash Memory  (32MB)
513 	 * 0x08000000 - 0x080000ff    I/O baseboard registers
514 	 * 0x0a000000 - 0x0a0fffff    SRAM (1MB)
515 	 * 0x0c000000 - 0x0c0fffff    Ethernet Controller
516 	 * 0x0e000000 - 0x0e0fffff    Ethernet Controller (Attribute)
517 	 * 0x10000000 - 0x103fffff    SA-1111 Companion Chip
518 	 * 0x14000000 - 0x17ffffff    Expansion Card (64MB)
519 	 * 0x40000000 - 0x480fffff    Processor Registers
520 	 * 0xa0000000 - 0xa3ffffff    SDRAM Bank 0 (64MB)
521 	 *
522 	 *
523 	 * Virtual Address Range    X C B  Description
524 	 * -----------------------  - - -  ----------------------------------
525 	 * 0x00000000 - 0x00003fff  N Y Y  SDRAM
526 	 * 0x00004000 - 0x000fffff  N Y N  Boot ROM
527 	 * 0x00100000 - 0x01ffffff  N N N  Application Flash
528 	 * 0x04000000 - 0x05ffffff  N N N  Exp Application Flash
529 	 * 0x08000000 - 0x080fffff  N N N  I/O baseboard registers
530 	 * 0x0a000000 - 0x0a0fffff  N N N  SRAM
531 	 * 0x40000000 - 0x480fffff  N N N  Processor Registers
532 	 * 0xa0000000 - 0xa000ffff  N Y N  RedBoot SDRAM
533 	 * 0xa0017000 - 0xa3ffffff  Y Y Y  SDRAM
534 	 * 0xc0000000 - 0xcfffffff  Y Y Y  Cache Flush Region
535 	 * (done by this routine)
536 	 * 0xfd000000 - 0xfd0000ff  N N N  I/O baseboard registers
537 	 * 0xfd100000 - 0xfd2fffff  N N N  Processor Registers.
538 	 *
539 	 * The first level page table is at 0xa0004000.  There are also
540 	 * 2 second-level tables at 0xa0008000 and 0xa0008400.
541 	 *
542 	 */
543 
544 	{
545 		/*
546 		 * Tweak RedBoot's pagetable so that we can access to
547 		 * some registers at same VA before and after installing
548 		 * our page table.
549 		 */
550 		paddr_t ttb = (paddr_t)read_ttb();
551 
552 		map_io_area(ttb);
553 		cpu_tlb_flushD();
554 	}
555 
556 	/* setup GPIO for BTUART, in case bootloader doesn't take care of it */
557 	pxa2x0_gpio_bootstrap(LUBBOCK_GPIO_VBASE);
558 	pxa2x0_gpio_set_function(42, GPIO_ALT_FN_1_IN);
559 	pxa2x0_gpio_set_function(43, GPIO_ALT_FN_2_OUT);
560 	pxa2x0_gpio_set_function(44, GPIO_ALT_FN_1_IN);
561 	pxa2x0_gpio_set_function(45, GPIO_ALT_FN_2_OUT);
562 
563 	/* turn on clock to UART block.
564 	   XXX: this should not be done here. */
565 	ioreg_write(LUBBOCK_CLKMAN_VBASE+CLKMAN_CKEN, CKEN_FFUART|CKEN_BTUART |
566 	    ioreg_read(LUBBOCK_CLKMAN_VBASE+CLKMAN_CKEN));
567 
568 	LEDSTEP();
569 
570 	tmp_bs_tag = pxa2x0_bs_tag;
571 	tmp_bs_tag.bs_map = bootstrap_bs_map;
572 	map_func_save = pxa2x0_a4x_bs_tag.bs_map;
573 	pxa2x0_a4x_bs_tag.bs_map = bootstrap_bs_map;
574 
575 	LEDSTEP();
576 
577 
578 	consinit();
579 	LEDSTEP();
580 #ifdef KGDB
581 	kgdb_port_init();
582 	LEDSTEP();
583 #endif
584 
585 
586 	/* Talk to the user */
587 	printf("\nNetBSD/evbarm (lubbock) booting ...\n");
588 
589 	/* Tweak memory controller */
590 	{
591 		/* Modify access timing for CS3 (91c96) */
592 
593 		uint32_t tmp =
594 			ioreg_read(PXA2X0_MEMCTL_BASE+MEMCTL_MSC1);
595 		ioreg_write(PXA2X0_MEMCTL_BASE+MEMCTL_MSC1,
596 			     (tmp & 0xffff) | (0x3881<<16));
597 		/* RRR=3, RDN=8, RDF=8
598 		 * XXX: can be faster?
599 		 */
600 	}
601 
602 
603 	/* Initialize for PCMCIA/CF sockets */
604 	{
605 		uint32_t tmp;
606 
607 		/* Activate two sockets.
608 		   XXX: This code segment should be moved to
609 		        pcmcia MD attach routine.
610 		   XXX: These bits should be toggled based on
611 		        existene of PCMCIA/CF cards
612 		*/
613 		ioreg_write(PXA2X0_MEMCTL_BASE+MEMCTL_MECR,
614 			     MECR_NOS|MECR_CIT);
615 
616 		tmp = ioreg_read(LUBBOCK_SACC_PBASE+SACCSBI_SKCR);
617 		ioreg_write(LUBBOCK_SACC_PBASE+SACCSBI_SKCR,
618 			     (tmp & ~(1<<4)) | (1<<0));
619 	}
620 
621 #if 0
622 	/*
623 	 * Examine the boot args string for options we need to know about
624 	 * now.
625 	 */
626 	process_kernel_args((char *)nwbootinfo.bt_args);
627 #endif
628 
629 	{
630 		int processor_card_id;
631 
632 		processor_card_id = 0x000f &
633 			ioreg_read(LUBBOCK_OBIO_VBASE+LUBBOCK_MISCRD);
634 		switch(processor_card_id){
635 		case 0:
636 			/* Cotulla */
637 			memstart = 0xa0000000;
638 			memsize =  0x04000000; /* 64MB */
639 			break;
640 		case 1:
641 			/* XXX: Sabiani */
642 			memstart = 0xa0000000;
643 			memsize = 0x04000000; /* 64MB */
644 			break;
645 		default:
646 			/* XXX: Unknown  */
647 			memstart = 0xa0000000;
648 			memsize = 0x04000000; /* 64MB */
649 		}
650 	}
651 
652 	printf("initarm: Configuring system ...\n");
653 
654 	/* Fake bootconfig structure for the benefit of pmap.c */
655 	/* XXX must make the memory description h/w independant */
656 	bootconfig.dramblocks = 1;
657 	bootconfig.dram[0].address = memstart;
658 	bootconfig.dram[0].pages = memsize / PAGE_SIZE;
659 
660 	/*
661 	 * Set up the variables that define the availablilty of
662 	 * physical memory.  For now, we're going to set
663 	 * physical_freestart to 0xa0200000 (where the kernel
664 	 * was loaded), and allocate the memory we need downwards.
665 	 * If we get too close to the page tables that RedBoot
666 	 * set up, we will panic.  We will update physical_freestart
667 	 * and physical_freeend later to reflect what pmap_bootstrap()
668 	 * wants to see.
669 	 *
670 	 * XXX pmap_bootstrap() needs an enema.
671 	 */
672 	physical_start = bootconfig.dram[0].address;
673 	physical_end = physical_start + (bootconfig.dram[0].pages * PAGE_SIZE);
674 
675 	physical_freestart = 0xa0009000UL;
676 	physical_freeend = 0xa0200000UL;
677 
678 	physmem = (physical_end - physical_start) / PAGE_SIZE;
679 
680 #ifdef VERBOSE_INIT_ARM
681 	/* Tell the user about the memory */
682 	printf("physmemory: %d pages at 0x%08lx -> 0x%08lx\n", physmem,
683 	    physical_start, physical_end - 1);
684 #endif
685 
686 	/*
687 	 * Okay, the kernel starts 2MB in from the bottom of physical
688 	 * memory.  We are going to allocate our bootstrap pages downwards
689 	 * from there.
690 	 *
691 	 * We need to allocate some fixed page tables to get the kernel
692 	 * going.  We allocate one page directory and a number of page
693 	 * tables and store the physical addresses in the kernel_pt_table
694 	 * array.
695 	 *
696 	 * The kernel page directory must be on a 16K boundary.  The page
697 	 * tables must be on 4K bounaries.  What we do is allocate the
698 	 * page directory on the first 16K boundary that we encounter, and
699 	 * the page tables on 4K boundaries otherwise.  Since we allocate
700 	 * at least 3 L2 page tables, we are guaranteed to encounter at
701 	 * least one 16K aligned region.
702 	 */
703 
704 #ifdef VERBOSE_INIT_ARM
705 	printf("Allocating page tables\n");
706 #endif
707 
708 	free_pages = (physical_freeend - physical_freestart) / PAGE_SIZE;
709 
710 #ifdef VERBOSE_INIT_ARM
711 	printf("freestart = 0x%08lx, free_pages = %d (0x%08x)\n",
712 	       physical_freestart, free_pages, free_pages);
713 #endif
714 
715 	/* Define a macro to simplify memory allocation */
716 #define	valloc_pages(var, np)				\
717 	alloc_pages((var).pv_pa, (np));			\
718 	(var).pv_va = KERNEL_BASE + (var).pv_pa - physical_start;
719 
720 #define alloc_pages(var, np)				\
721 	physical_freeend -= ((np) * PAGE_SIZE);		\
722 	if (physical_freeend < physical_freestart)	\
723 		panic("initarm: out of memory");	\
724 	(var) = physical_freeend;			\
725 	free_pages -= (np);				\
726 	memset((char *)(var), 0, ((np) * PAGE_SIZE));
727 
728 	loop1 = 0;
729 	kernel_l1pt.pv_pa = 0;
730 	for (loop = 0; loop <= NUM_KERNEL_PTS; ++loop) {
731 		/* Are we 16KB aligned for an L1 ? */
732 		if (((physical_freeend - L1_TABLE_SIZE) & (L1_TABLE_SIZE - 1)) == 0
733 		    && kernel_l1pt.pv_pa == 0) {
734 			valloc_pages(kernel_l1pt, L1_TABLE_SIZE / PAGE_SIZE);
735 		} else {
736 			valloc_pages(kernel_pt_table[loop1],
737 			    L2_TABLE_SIZE / PAGE_SIZE);
738 			++loop1;
739 		}
740 	}
741 
742 	/* This should never be able to happen but better confirm that. */
743 	if (!kernel_l1pt.pv_pa || (kernel_l1pt.pv_pa & (L1_TABLE_SIZE-1)) != 0)
744 		panic("initarm: Failed to align the kernel page directory");
745 
746 	LEDSTEP();
747 
748 	/*
749 	 * Allocate a page for the system page mapped to V0x00000000
750 	 * This page will just contain the system vectors and can be
751 	 * shared by all processes.
752 	 */
753 	alloc_pages(systempage.pv_pa, 1);
754 
755 	/* Allocate stacks for all modes */
756 	valloc_pages(irqstack, IRQ_STACK_SIZE);
757 	valloc_pages(abtstack, ABT_STACK_SIZE);
758 	valloc_pages(undstack, UND_STACK_SIZE);
759 	valloc_pages(kernelstack, UPAGES);
760 
761 	/* Allocate enough pages for cleaning the Mini-Data cache. */
762 	KASSERT(xscale_minidata_clean_size <= PAGE_SIZE);
763 	valloc_pages(minidataclean, 1);
764 
765 #ifdef VERBOSE_INIT_ARM
766 	printf("IRQ stack: p0x%08lx v0x%08lx\n", irqstack.pv_pa,
767 	    irqstack.pv_va);
768 	printf("ABT stack: p0x%08lx v0x%08lx\n", abtstack.pv_pa,
769 	    abtstack.pv_va);
770 	printf("UND stack: p0x%08lx v0x%08lx\n", undstack.pv_pa,
771 	    undstack.pv_va);
772 	printf("SVC stack: p0x%08lx v0x%08lx\n", kernelstack.pv_pa,
773 	    kernelstack.pv_va);
774 #endif
775 
776 	/*
777 	 * XXX Defer this to later so that we can reclaim the memory
778 	 * XXX used by the RedBoot page tables.
779 	 */
780 	alloc_pages(msgbufphys, round_page(MSGBUFSIZE) / PAGE_SIZE);
781 
782 	/*
783 	 * Ok we have allocated physical pages for the primary kernel
784 	 * page tables
785 	 */
786 
787 #ifdef VERBOSE_INIT_ARM
788 	printf("Creating L1 page table at 0x%08lx\n", kernel_l1pt.pv_pa);
789 #endif
790 
791 	/*
792 	 * Now we start construction of the L1 page table
793 	 * We start by mapping the L2 page tables into the L1.
794 	 * This means that we can replace L1 mappings later on if necessary
795 	 */
796 	l1pagetable = kernel_l1pt.pv_pa;
797 
798 	/* Map the L2 pages tables in the L1 page table */
799 	pmap_link_l2pt(l1pagetable, 0x00000000,
800 	    &kernel_pt_table[KERNEL_PT_SYS]);
801 	for (loop = 0; loop < KERNEL_PT_KERNEL_NUM; loop++)
802 		pmap_link_l2pt(l1pagetable, KERNEL_BASE + loop * 0x00400000,
803 		    &kernel_pt_table[KERNEL_PT_KERNEL + loop]);
804 	for (loop = 0; loop < KERNEL_PT_VMDATA_NUM; loop++)
805 		pmap_link_l2pt(l1pagetable, KERNEL_VM_BASE + loop * 0x00400000,
806 		    &kernel_pt_table[KERNEL_PT_VMDATA + loop]);
807 
808 	/* update the top of the kernel VM */
809 	pmap_curmaxkvaddr =
810 	    KERNEL_VM_BASE + (KERNEL_PT_VMDATA_NUM * 0x00400000);
811 
812 #ifdef VERBOSE_INIT_ARM
813 	printf("Mapping kernel\n");
814 #endif
815 
816 	/* Now we fill in the L2 pagetable for the kernel static code/data */
817 	{
818 		extern char etext[], _end[];
819 		size_t textsize = (uintptr_t) etext - KERNEL_TEXT_BASE;
820 		size_t totalsize = (uintptr_t) _end - KERNEL_TEXT_BASE;
821 		u_int logical;
822 
823 		textsize = (textsize + PGOFSET) & ~PGOFSET;
824 		totalsize = (totalsize + PGOFSET) & ~PGOFSET;
825 
826 		logical = 0x00200000;	/* offset of kernel in RAM */
827 
828 		logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
829 		    physical_start + logical, textsize,
830 		    VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
831 		logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
832 		    physical_start + logical, totalsize - textsize,
833 		    VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
834 	}
835 
836 #ifdef VERBOSE_INIT_ARM
837 	printf("Constructing L2 page tables\n");
838 #endif
839 
840 	/* Map the stack pages */
841 	pmap_map_chunk(l1pagetable, irqstack.pv_va, irqstack.pv_pa,
842 	    IRQ_STACK_SIZE * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
843 	pmap_map_chunk(l1pagetable, abtstack.pv_va, abtstack.pv_pa,
844 	    ABT_STACK_SIZE * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
845 	pmap_map_chunk(l1pagetable, undstack.pv_va, undstack.pv_pa,
846 	    UND_STACK_SIZE * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
847 	pmap_map_chunk(l1pagetable, kernelstack.pv_va, kernelstack.pv_pa,
848 	    UPAGES * PAGE_SIZE, VM_PROT_READ | VM_PROT_WRITE, PTE_CACHE);
849 
850 	pmap_map_chunk(l1pagetable, kernel_l1pt.pv_va, kernel_l1pt.pv_pa,
851 	    L1_TABLE_SIZE, VM_PROT_READ | VM_PROT_WRITE, PTE_PAGETABLE);
852 
853 	for (loop = 0; loop < NUM_KERNEL_PTS; ++loop) {
854 		pmap_map_chunk(l1pagetable, kernel_pt_table[loop].pv_va,
855 		    kernel_pt_table[loop].pv_pa, L2_TABLE_SIZE,
856 		    VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
857 	}
858 
859 	/* Map the Mini-Data cache clean area. */
860 	xscale_setup_minidata(l1pagetable, minidataclean.pv_va,
861 	    minidataclean.pv_pa);
862 
863 	/* Map the vector page. */
864 #if 1
865 	/* MULTI-ICE requires that page 0 is NC/NB so that it can download the
866 	 * cache-clean code there.  */
867 	pmap_map_entry(l1pagetable, vector_page, systempage.pv_pa,
868 	    VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
869 #else
870 	pmap_map_entry(l1pagetable, vector_page, systempage.pv_pa,
871 	    VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
872 #endif
873 
874 	/*
875 	 * map integrated peripherals at same address in l1pagetable
876 	 * so that we can continue to use console.
877 	 */
878 	copy_io_area_map((pd_entry_t *)l1pagetable);
879 
880 	/*
881 	 * Give the XScale global cache clean code an appropriately
882 	 * sized chunk of unmapped VA space starting at 0xff000000
883 	 * (our device mappings end before this address).
884 	 */
885 	xscale_cache_clean_addr = 0xff000000U;
886 
887 	/*
888 	 * Now we have the real page tables in place so we can switch to them.
889 	 * Once this is done we will be running with the REAL kernel page
890 	 * tables.
891 	 */
892 
893 	/*
894 	 * Update the physical_freestart/physical_freeend/free_pages
895 	 * variables.
896 	 */
897 	{
898 		extern char _end[];
899 
900 		physical_freestart = physical_start +
901 		    (((((uintptr_t) _end) + PGOFSET) & ~PGOFSET) -
902 		     KERNEL_BASE);
903 		physical_freeend = physical_end;
904 		free_pages =
905 		    (physical_freeend - physical_freestart) / PAGE_SIZE;
906 	}
907 
908 	/* Switch tables */
909 #ifdef VERBOSE_INIT_ARM
910 	printf("freestart = 0x%08lx, free_pages = %d (0x%x)\n",
911 	       physical_freestart, free_pages, free_pages);
912 	printf("switching to new L1 page table  @%#lx...", kernel_l1pt.pv_pa);
913 #endif
914 
915 	LEDSTEP();
916 
917 	/* set new intc register address so that splfoo() doesn't
918 	   touch illegal address.  */
919 	pxa2x0_intr_bootstrap(LUBBOCK_INTCTL_VBASE);
920 
921 	LEDSTEP();
922 
923 	cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
924 	setttb(kernel_l1pt.pv_pa);
925 	cpu_tlb_flushID();
926 	cpu_domains(DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2));
927 	LEDSTEP();
928 
929 	/*
930 	 * Moved from cpu_startup() as data_abort_handler() references
931 	 * this during uvm init
932 	 */
933 	proc0paddr = (struct user *)kernelstack.pv_va;
934 	lwp0.l_addr = proc0paddr;
935 
936 #ifdef VERBOSE_INIT_ARM
937 	printf("bootstrap done.\n");
938 #endif
939 
940 	arm32_vector_init(ARM_VECTORS_LOW, ARM_VEC_ALL);
941 
942 	/*
943 	 * Pages were allocated during the secondary bootstrap for the
944 	 * stacks for different CPU modes.
945 	 * We must now set the r13 registers in the different CPU modes to
946 	 * point to these stacks.
947 	 * Since the ARM stacks use STMFD etc. we must set r13 to the top end
948 	 * of the stack memory.
949 	 */
950 	printf("init subsystems: stacks ");
951 
952 	set_stackptr(PSR_IRQ32_MODE, irqstack.pv_va + IRQ_STACK_SIZE * PAGE_SIZE);
953 	set_stackptr(PSR_ABT32_MODE, abtstack.pv_va + ABT_STACK_SIZE * PAGE_SIZE);
954 	set_stackptr(PSR_UND32_MODE, undstack.pv_va + UND_STACK_SIZE * PAGE_SIZE);
955 
956 	/*
957 	 * Well we should set a data abort handler.
958 	 * Once things get going this will change as we will need a proper
959 	 * handler.
960 	 * Until then we will use a handler that just panics but tells us
961 	 * why.
962 	 * Initialisation of the vectors will just panic on a data abort.
963 	 * This just fills in a slighly better one.
964 	 */
965 	printf("vectors ");
966 	data_abort_handler_address = (u_int)data_abort_handler;
967 	prefetch_abort_handler_address = (u_int)prefetch_abort_handler;
968 	undefined_handler_address = (u_int)undefinedinstruction_bounce;
969 
970 	/* Initialise the undefined instruction handlers */
971 	printf("undefined ");
972 	undefined_init();
973 
974 	/* Load memory into UVM. */
975 	printf("page ");
976 	uvm_setpagesize();        /* initialize PAGE_SIZE-dependent variables */
977 	uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
978 	    atop(physical_freestart), atop(physical_freeend),
979 	    VM_FREELIST_DEFAULT);
980 
981 	/* Boot strap pmap telling it where the kernel page table is */
982 	printf("pmap ");
983 	LEDSTEP();
984 	pmap_bootstrap((pd_entry_t *)kernel_l1pt.pv_va, KERNEL_VM_BASE,
985 	    KERNEL_VM_BASE + KERNEL_VM_SIZE);
986 	LEDSTEP();
987 
988 #ifdef __HAVE_MEMORY_DISK__
989 	md_root_setconf(memory_disk, sizeof memory_disk);
990 #endif
991 
992 	{
993 		uint16_t sw = ioreg16_read(LUBBOCK_OBIO_VBASE+LUBBOCK_USERSW);
994 
995 		if (0 == (sw & (1<<13))) /* check S19 */
996 			boothowto |= RB_KDB;
997 		if (0 == (sw & (1<<12))) /* S20 */
998 			boothowto |= RB_SINGLE;
999 	}
1000 
1001 	LEDSTEP();
1002 
1003 #ifdef IPKDB
1004 	/* Initialise ipkdb */
1005 	ipkdb_init();
1006 	if (boothowto & RB_KDB)
1007 		ipkdb_connect(0);
1008 #endif
1009 
1010 #ifdef KGDB
1011 	if (boothowto & RB_KDB) {
1012 		kgdb_debug_init = 1;
1013 		kgdb_connect(1);
1014 	}
1015 #endif
1016 
1017 #ifdef DDB
1018 	db_machine_init();
1019 
1020 	/* Firmware doesn't load symbols. */
1021 	ddb_init(0, NULL, NULL);
1022 
1023 	if (boothowto & RB_KDB)
1024 		Debugger();
1025 #endif
1026 
1027 	pxa2x0_a4x_bs_tag.bs_map = map_func_save ;
1028 
1029 	/* We return the new stack pointer address */
1030 	return(kernelstack.pv_va + USPACE_SVC_STACK_TOP);
1031 }
1032 
1033 #if 0
1034 void
1035 process_kernel_args(char *args)
1036 {
1037 
1038 	boothowto = 0;
1039 
1040 	/* Make a local copy of the bootargs */
1041 	strncpy(bootargs, args, MAX_BOOT_STRING);
1042 
1043 	args = bootargs;
1044 	boot_file = bootargs;
1045 
1046 	/* Skip the kernel image filename */
1047 	while (*args != ' ' && *args != 0)
1048 		++args;
1049 
1050 	if (*args != 0)
1051 		*args++ = 0;
1052 
1053 	while (*args == ' ')
1054 		++args;
1055 
1056 	boot_args = args;
1057 
1058 	printf("bootfile: %s\n", boot_file);
1059 	printf("bootargs: %s\n", boot_args);
1060 
1061 	parse_mi_bootargs(boot_args);
1062 }
1063 #endif
1064 
1065 #ifdef KGDB
1066 #ifndef KGDB_DEVNAME
1067 #define KGDB_DEVNAME "ffuart"
1068 #endif
1069 const char kgdb_devname[] = KGDB_DEVNAME;
1070 
1071 #if (NCOM > 0)
1072 #ifndef KGDB_DEVMODE
1073 #define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
1074 #endif
1075 int comkgdbmode = KGDB_DEVMODE;
1076 #endif /* NCOM */
1077 
1078 #endif /* KGDB */
1079 
1080 
1081 void
1082 consinit(void)
1083 {
1084 	static int consinit_called = 0;
1085 	uint32_t ckenreg = ioreg_read(LUBBOCK_CLKMAN_VBASE+CLKMAN_CKEN);
1086 #if 0
1087 	char *console = CONSDEVNAME;
1088 #endif
1089 
1090 	if (consinit_called != 0)
1091 		return;
1092 
1093 	consinit_called = 1;
1094 
1095 #if NCOM > 0
1096 
1097 #ifdef FFUARTCONSOLE
1098 	/* Check switch. */
1099 	if (0 == (ioreg_read(LUBBOCK_OBIO_VBASE+LUBBOCK_USERSW) & (1<<15))) {
1100 		/* We don't use FF serial when S17=no-dot position */
1101 	}
1102 #ifdef KGDB
1103 	else if (0 == strcmp(kgdb_devname, "ffuart")) {
1104 		/* port is reserved for kgdb */
1105 	}
1106 #endif
1107 	else if (0 == comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_FFUART_BASE,
1108 		     comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode)) {
1109 #if 0
1110 		/* XXX: can't call pxa2x0_clkman_config yet */
1111 		pxa2x0_clkman_config(CKEN_FFUART, 1);
1112 #else
1113 		ioreg_write(LUBBOCK_CLKMAN_VBASE+CLKMAN_CKEN,
1114 		    ckenreg|CKEN_FFUART);
1115 #endif
1116 
1117 		return;
1118 	}
1119 #endif /* FFUARTCONSOLE */
1120 
1121 #ifdef BTUARTCONSOLE
1122 #ifdef KGDB
1123 	if (0 == strcmp(kgdb_devname, "btuart")) {
1124 		/* port is reserved for kgdb */
1125 	} else
1126 #endif
1127 	if (0 == comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_BTUART_BASE,
1128 		comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode)) {
1129 		ioreg_write(LUBBOCK_CLKMAN_VBASE+CLKMAN_CKEN,
1130 		    ckenreg|CKEN_BTUART);
1131 		return;
1132 	}
1133 #endif /* BTUARTCONSOLE */
1134 
1135 
1136 #endif /* NCOM */
1137 
1138 }
1139 
1140 #ifdef KGDB
1141 void
1142 kgdb_port_init(void)
1143 {
1144 #if (NCOM > 0) && defined(COM_PXA2X0)
1145 	paddr_t paddr = 0;
1146 	enum pxa2x0_uart_id uart_id;
1147 	uint32_t ckenreg = ioreg_read(LUBBOCK_CLKMAN_VBASE+CLKMAN_CKEN);
1148 
1149 	if (0 == strcmp(kgdb_devname, "ffuart")) {
1150 		paddr = PXA2X0_FFUART_BASE;
1151 		clenreg |= CKEN_FFUART;
1152 	}
1153 	else if (0 == strcmp(kgdb_devname, "btuart")) {
1154 		paddr = PXA2X0_BTUART_BASE;
1155 		clenreg |= CKEN_BTUART;
1156 	}
1157 
1158 	if (paddr &&
1159 	    0 == com_kgdb_attach_pxa2x0(&pxa2x0_a4x_bs_tag, paddr,
1160 		kgdb_rate, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comkgdbmode)) {
1161 
1162 		ioreg_write(LUBBOCK_CLKMAN_VBASE+CLKMAN_CKEN, ckenreg);
1163 	}
1164 #endif
1165 }
1166 #endif
1167 
1168 #if 0
1169 /*
1170  * display a number in hex LED.
1171  * a digit is blank when the corresponding bit in arg blank is 1
1172  */
1173 unsigned short led_control_value = 0;
1174 
1175 void
1176 hex_led_blank(uint32_t value, int blank)
1177 {
1178 	int save = disable_interrupts(I32_bit);
1179 
1180 	ioreg_write(LUBBOCK_OBIO_VBASE+0x10, value);
1181 	led_control_value = (led_control_value & 0xff)
1182 		| ((blank & 0xff)<<8);
1183 	ioreg_write(LUBBOCK_OBIO_VBASE+0x40, led_control_value);
1184 	restore_interrupts(save);
1185 }
1186 #endif
1187