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