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