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