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