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