Home | History | Annotate | Line # | Download | only in kobo
kobo_machdep.c revision 1.2.8.1
      1 /*	$NetBSD: kobo_machdep.c,v 1.2.8.1 2015/06/06 14:39:58 skrll Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2002, 2003, 2005, 2010  Genetec Corporation.
      5  * All rights reserved.
      6  * Written by Hiroyuki Bessho for Genetec Corporation.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  *
     17  * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
     18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     20  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
     21  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27  * POSSIBILITY OF SUCH DAMAGE.
     28  *
     29  * Machine dependent functions for kernel setup for RAKUTEN Kobo.
     30  * Based on iq80310_machhdep.c
     31  */
     32 /*
     33  * Copyright (c) 2001 Wasabi Systems, Inc.
     34  * All rights reserved.
     35  *
     36  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
     37  *
     38  * Redistribution and use in source and binary forms, with or without
     39  * modification, are permitted provided that the following conditions
     40  * are met:
     41  * 1. Redistributions of source code must retain the above copyright
     42  *    notice, this list of conditions and the following disclaimer.
     43  * 2. Redistributions in binary form must reproduce the above copyright
     44  *    notice, this list of conditions and the following disclaimer in the
     45  *    documentation and/or other materials provided with the distribution.
     46  * 3. All advertising materials mentioning features or use of this software
     47  *    must display the following acknowledgement:
     48  *	This product includes software developed for the NetBSD Project by
     49  *	Wasabi Systems, Inc.
     50  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     51  *    or promote products derived from this software without specific prior
     52  *    written permission.
     53  *
     54  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     55  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     56  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     57  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     58  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     59  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     60  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     61  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     62  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     63  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     64  * POSSIBILITY OF SUCH DAMAGE.
     65  */
     66 
     67 /*
     68  * Copyright (c) 1997,1998 Mark Brinicombe.
     69  * Copyright (c) 1997,1998 Causality Limited.
     70  * All rights reserved.
     71  *
     72  * Redistribution and use in source and binary forms, with or without
     73  * modification, are permitted provided that the following conditions
     74  * are met:
     75  * 1. Redistributions of source code must retain the above copyright
     76  *    notice, this list of conditions and the following disclaimer.
     77  * 2. Redistributions in binary form must reproduce the above copyright
     78  *    notice, this list of conditions and the following disclaimer in the
     79  *    documentation and/or other materials provided with the distribution.
     80  * 3. All advertising materials mentioning features or use of this software
     81  *    must display the following acknowledgement:
     82  *	This product includes software developed by Mark Brinicombe
     83  *	for the NetBSD Project.
     84  * 4. The name of the company nor the name of the author may be used to
     85  *    endorse or promote products derived from this software without specific
     86  *    prior written permission.
     87  *
     88  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
     89  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     90  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     91  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     92  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     93  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     94  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     95  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     96  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     97  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     98  * SUCH DAMAGE.
     99  *
    100  * Machine dependent functions for kernel setup for Intel IQ80310 evaluation
    101  * boards using RedBoot firmware.
    102  */
    103 
    104 #include <sys/cdefs.h>
    105 __KERNEL_RCSID(0, "$NetBSD: kobo_machdep.c,v 1.2.8.1 2015/06/06 14:39:58 skrll Exp $");
    106 
    107 #include "opt_evbarm_boardtype.h"
    108 #include "opt_arm_debug.h"
    109 #include "opt_cputypes.h"
    110 #include "opt_ddb.h"
    111 #include "opt_kgdb.h"
    112 #include "opt_md.h"
    113 #include "opt_com.h"
    114 #include "imxuart.h"
    115 #include "opt_imxuart.h"
    116 #include "opt_imx.h"
    117 #include "opt_machdep.h"
    118 
    119 #include <sys/param.h>
    120 #include <sys/device.h>
    121 #include <sys/reboot.h>
    122 #include <sys/termios.h>
    123 #include <sys/bus.h>
    124 
    125 #include <machine/db_machdep.h>
    126 #ifdef KGDB
    127 #include <sys/kgdb.h>
    128 #endif
    129 
    130 #include <machine/bootconfig.h>
    131 
    132 #include <arm/arm32/machdep.h>
    133 
    134 #include <arm/imx/imx51reg.h>
    135 #include <arm/imx/imx51var.h>
    136 #include <arm/imx/imxuartreg.h>
    137 #include <arm/imx/imxuartvar.h>
    138 #include <arm/imx/imx50_iomuxreg.h>
    139 #include <arm/imx/imxgpiovar.h>
    140 
    141 #include <evbarm/kobo/kobo.h>
    142 #include <evbarm/kobo/kobo_reg.h>
    143 
    144 /* Kernel text starts 1MB in from the bottom of the kernel address space. */
    145 #define	KERNEL_TEXT_BASE	(KERNEL_BASE + 0x00100000)
    146 
    147 BootConfig bootconfig;		/* Boot config storage */
    148 static char bootargs[MAX_BOOT_STRING];
    149 char *boot_args = NULL;
    150 
    151 extern char KERNEL_BASE_phys[];
    152 
    153 /*
    154  * Macros to translate between physical and virtual for a subset of the
    155  * kernel address space.  *Not* for general use.
    156  */
    157 #define KERNEL_BASE_PHYS ((paddr_t)KERNEL_BASE_phys)
    158 
    159 void consinit(void);
    160 
    161 #ifdef KGDB
    162 void	kgdb_port_init(void);
    163 #endif
    164 
    165 static void init_clocks(void);
    166 static void setup_ioports(void);
    167 
    168 #ifndef CONSPEED
    169 #define CONSPEED B115200	/* What RedBoot uses */
    170 #endif
    171 #ifndef CONMODE
    172 #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
    173 #endif
    174 
    175 int comcnspeed = CONSPEED;
    176 int comcnmode = CONMODE;
    177 
    178 /*
    179  * Static device mappings. These peripheral registers are mapped at
    180  * fixed virtual addresses very early in initarm() so that we can use
    181  * them while booting the kernel, and stay at the same address
    182  * throughout whole kernel's life time.
    183  *
    184  * We use this table twice; once with bootstrap page table, and once
    185  * with kernel's page table which we build up in initarm().
    186  *
    187  * Since we map these registers into the bootstrap page table using
    188  * pmap_devmap_bootstrap() which calls pmap_map_chunk(), we map
    189  * registers segment-aligned and segment-rounded in order to avoid
    190  * using the 2nd page tables.
    191  */
    192 
    193 #define _A(a)   ((a) & ~L1_S_OFFSET)
    194 #define _S(s)   (((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1))
    195 
    196 const struct pmap_devmap kobo_devmap[] = {
    197 	{
    198 		/* for UART2, IOMUXC */
    199 		.pd_va = _A(KOBO_IO_VBASE0),
    200 		.pd_pa = _A(KOBO_IO_PBASE0),
    201 		.pd_size = _S(L1_S_SIZE * 4),
    202 		.pd_prot = VM_PROT_READ|VM_PROT_WRITE,
    203 		.pd_cache = PTE_NOCACHE
    204 	},
    205 	{0}
    206 };
    207 
    208 #undef	_A
    209 #undef	_S
    210 
    211 #ifndef MEMSTART
    212 #define MEMSTART	0x70000000
    213 #endif
    214 #ifndef MEMSIZE
    215 #define MEMSIZE		256
    216 #endif
    217 
    218 static void
    219 init_clocks(void)
    220 {
    221 	cortex_pmc_ccnt_init();
    222 }
    223 
    224 struct iomux_setup {
    225 	/* iomux registers are 32-bit wide, but upper 16 bits are not
    226 	 * used. */
    227 	uint16_t	reg;
    228 	uint16_t	val;
    229 };
    230 
    231 #define	IOMUX_M(padname, mux)		\
    232 	IOMUX_DATA(__CONCAT(IOMUXC_SW_MUX_CTL_PAD_,padname), mux)
    233 
    234 #define	IOMUX_P(padname, pad)		\
    235 	IOMUX_DATA(__CONCAT(IOMUXC_SW_PAD_CTL_PAD_,padname), pad)
    236 
    237 #define	IOMUX_MP(padname, mux, pad)	\
    238 	IOMUX_M(padname, mux), \
    239 	IOMUX_P(padname, pad)
    240 
    241 #define	IOMUX_DATA(offset, value)	\
    242 	{				\
    243 		.reg = (offset),	\
    244 		.val = (value),		\
    245 	}
    246 
    247 const struct iomux_setup iomux_setup_data[] = {
    248 #define	HYS	PAD_CTL_HYS
    249 #define	ODE	PAD_CTL_ODE
    250 #define	DSEHIGH	PAD_CTL_DSE_HIGH
    251 #define	DSEMID	PAD_CTL_DSE_MID
    252 #define	DSELOW	PAD_CTL_DSE_LOW
    253 #define	DSEMAX	PAD_CTL_DSE_MAX
    254 #define	SRE	PAD_CTL_SRE
    255 #define	KEEPER	PAD_CTL_KEEPER
    256 #define	PULL	PAD_CTL_PULL
    257 #define	PU_22K	PAD_CTL_PUS_22K_PU
    258 #define	PU_47K	PAD_CTL_PUS_47K_PU
    259 #define	PU_100K	PAD_CTL_PUS_100K_PU
    260 #define	PD_100K	PAD_CTL_PUS_100K_PD
    261 #define	HVE	PAD_CTL_HVE	/* Low output voltage */
    262 
    263 #define	ALT0	IOMUX_CONFIG_ALT0
    264 #define	ALT1	IOMUX_CONFIG_ALT1
    265 #define	ALT2	IOMUX_CONFIG_ALT2
    266 #define	ALT3	IOMUX_CONFIG_ALT3
    267 #define	ALT4	IOMUX_CONFIG_ALT4
    268 #define	ALT5	IOMUX_CONFIG_ALT5
    269 #define	ALT6	IOMUX_CONFIG_ALT6
    270 #define	ALT7	IOMUX_CONFIG_ALT7
    271 #define	SION	IOMUX_CONFIG_SION
    272 
    273 	/* I2C1 */
    274 	IOMUX_MP(I2C1_SCL, ALT0 | SION, PULL | PU_100K | HYS | ODE | DSEHIGH),
    275 	IOMUX_MP(I2C1_SDA, ALT0 | SION, PULL | PU_100K | HYS | ODE | DSEHIGH),
    276 
    277 	/* I2C2 */
    278 	IOMUX_MP(I2C2_SCL, ALT0 | SION, PULL | PU_100K | HYS | ODE | DSEHIGH),
    279 	IOMUX_MP(I2C2_SDA, ALT0 | SION, PULL | PU_100K | HYS | ODE | DSEHIGH),
    280 
    281 	/* I2C3 */
    282 	IOMUX_MP(I2C3_SCL, ALT0 | SION, PULL | PU_100K | HYS | ODE | DSEHIGH),
    283 	IOMUX_MP(I2C3_SDA, ALT0 | SION, PULL | PU_100K | HYS | ODE | DSEHIGH),
    284 
    285 	/* UART2 */
    286 	IOMUX_MP(UART2_RXD, ALT0, HYS | PULL | DSEHIGH | SRE),
    287 	IOMUX_MP(UART2_TXD, ALT0, HYS | PULL | DSEHIGH | SRE),
    288 
    289 	/* SD1 */
    290 	IOMUX_MP(SD1_CMD, ALT0, HVE | PU_22K | DSEMAX | SRE),
    291 	IOMUX_MP(SD1_CLK, ALT0, HVE | PU_22K | DSEMAX | SRE),
    292 	IOMUX_MP(SD1_D0, ALT0, HVE | PU_22K | DSEMAX | SRE),
    293 	IOMUX_MP(SD1_D1, ALT0, HVE | PU_22K | DSEMAX | SRE),
    294 	IOMUX_MP(SD1_D2, ALT0, HVE | PU_22K | DSEMAX | SRE),
    295 	IOMUX_MP(SD1_D3, ALT0, HVE | PU_22K | DSEMAX | SRE),
    296 //	IOMUX_MP(SD1_CD, ALT0, HVE | PU_22K | DSEMAX | SRE),
    297 
    298 	/* SD2 */
    299 	IOMUX_MP(SD2_CMD, ALT0, HVE | PU_22K | DSEMAX | SRE),
    300 	IOMUX_MP(SD2_CLK, ALT0, HVE | PU_22K | DSEMAX | SRE),
    301 	IOMUX_MP(SD2_D0, ALT0, HVE | PU_22K | DSEMAX | SRE),
    302 	IOMUX_MP(SD2_D1, ALT0, HVE | PU_22K | DSEMAX | SRE),
    303 	IOMUX_MP(SD2_D2, ALT0, HVE | PU_22K | DSEMAX | SRE),
    304 	IOMUX_MP(SD2_D3, ALT0, HVE | PU_22K | DSEMAX | SRE),
    305 	IOMUX_MP(SD2_CD, ALT0, HVE | PU_22K | DSEMAX | SRE),
    306 
    307 	IOMUX_DATA(IOMUXC_ESDHC2_IPP_CARD_DET_SELECT_INPUT, INPUT_DAISY_1),
    308 
    309 	/* SD3 */
    310 	IOMUX_MP(SD3_CMD, ALT0, HVE | PU_22K | DSEMAX | SRE),
    311 	IOMUX_MP(SD3_CLK, ALT0, HVE | PU_22K | DSEMAX | SRE),
    312 	IOMUX_MP(SD3_D0, ALT0, HVE | PU_22K | DSEMAX | SRE),
    313 	IOMUX_MP(SD3_D1, ALT0, HVE | PU_22K | DSEMAX | SRE),
    314 	IOMUX_MP(SD3_D2, ALT0, HVE | PU_22K | DSEMAX | SRE),
    315 	IOMUX_MP(SD3_D3, ALT0, HVE | PU_22K | DSEMAX | SRE),
    316 //	IOMUX_MP(SD3_CD, ALT0, HVE | PU_22K | DSEMAX | SRE),
    317 
    318 	/* OTG */
    319 	IOMUX_M(PWM2, ALT2),
    320 //	IOMUX_MP(PWM1, ALT2, HYS | KEEPER | DSEHIGH),
    321 
    322 	/* EPDC */
    323 	IOMUX_M(EPDC_D0, ALT0),
    324 	IOMUX_M(EPDC_D1, ALT0),
    325 	IOMUX_M(EPDC_D2, ALT0),
    326 	IOMUX_M(EPDC_D3, ALT0),
    327 	IOMUX_M(EPDC_D4, ALT0),
    328 	IOMUX_M(EPDC_D5, ALT0),
    329 	IOMUX_M(EPDC_D6, ALT0),
    330 	IOMUX_M(EPDC_D7, ALT0),
    331 	IOMUX_M(EPDC_GDCLK, ALT0),
    332 	IOMUX_M(EPDC_GDSP, ALT0),
    333 	IOMUX_M(EPDC_GDOE, ALT0),
    334 	IOMUX_M(EPDC_GDRL, ALT0),
    335 	IOMUX_M(EPDC_SDCLK, ALT0),
    336 	IOMUX_M(EPDC_SDOE, ALT0),
    337 	IOMUX_M(EPDC_SDLE, ALT0),
    338 	IOMUX_M(EPDC_BDR0, ALT0),
    339 	IOMUX_M(EPDC_BDR1, ALT0),
    340 	IOMUX_M(EPDC_SDCE0, ALT0),
    341 
    342 	IOMUX_M(EPDC_PWRSTAT, ALT1),	/* GPIO3[28] */
    343 	IOMUX_M(EPDC_PWRCTRL0, ALT1),	/* GPIO3[29] */
    344 	IOMUX_M(EPDC_VCOM0, ALT1),	/* GPIO4[21] */
    345 	IOMUX_M(UART4_TXD, ALT1),	/* GPIO6[16] */
    346 	IOMUX_M(UART4_RXD, ALT1),	/* GPIO6[17] */
    347 
    348 //	IOMUX_M(PWM2, ALT1),		/* GPIO6[25] */
    349 
    350 #undef	ODE
    351 #undef	HYS
    352 #undef	SRE
    353 #undef	PULL
    354 #undef	KEEPER
    355 #undef	PU_22K
    356 #undef	PU_47K
    357 #undef	PU_100K
    358 #undef	PD_100K
    359 #undef	HVE
    360 #undef	DSEMAX
    361 #undef	DSEHIGH
    362 #undef	DSEMID
    363 #undef	DSELOW
    364 
    365 #undef	ALT0
    366 #undef	ALT1
    367 #undef	ALT2
    368 #undef	ALT3
    369 #undef	ALT4
    370 #undef	ALT5
    371 #undef	ALT6
    372 #undef	ALT7
    373 #undef	SION
    374 };
    375 
    376 static void
    377 setup_ioports(void)
    378 {
    379 	int i;
    380 	const struct iomux_setup *p;
    381 
    382 	for (i=0; i < __arraycount(iomux_setup_data); ++i) {
    383 		p = iomux_setup_data + i;
    384 
    385 		ioreg_write(KOBO_IOMUXC_VBASE + p->reg,
    386 			    p->val);
    387 	}
    388 }
    389 
    390 #ifdef	CONSDEVNAME
    391 const char consdevname[] = CONSDEVNAME;
    392 
    393 #ifndef	CONMODE
    394 #define	CONMODE	((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
    395 #endif
    396 #ifndef	CONSPEED
    397 #define	CONSPEED	115200
    398 #endif
    399 
    400 int consmode = CONMODE;
    401 int consrate = CONSPEED;
    402 
    403 #endif	/* CONSDEVNAME */
    404 
    405 #ifndef	IMXUART_FREQ
    406 #define	IMXUART_FREQ	24000000
    407 #endif
    408 
    409 /*
    410  * u_int initarm(...)
    411  *
    412  * Initial entry point on startup. This gets called before main() is
    413  * entered.
    414  * It should be responsible for setting up everything that must be
    415  * in place when main is called.
    416  * This includes
    417  *   Taking a copy of the boot configuration structure.
    418  *   Initialising the physical console so characters can be printed.
    419  *   Setting up page tables for the kernel
    420  */
    421 u_int
    422 initarm(void *arg)
    423 {
    424 	/*
    425 	 * Heads up ... Setup the CPU / MMU / TLB functions
    426 	 */
    427 	if (set_cpufuncs())		// starts PMC counter
    428 		panic("cpu not recognized!");
    429 
    430 	/* map some peripheral registers */
    431 	pmap_devmap_bootstrap((vaddr_t)armreg_ttbr_read() & -L1_TABLE_SIZE,
    432 	    kobo_devmap);
    433 
    434 	cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
    435 
    436 	/* Register devmap for devices we mapped in start */
    437 	pmap_devmap_register(kobo_devmap);
    438 	setup_ioports();
    439 
    440 	consinit();
    441 
    442 	init_clocks();
    443 
    444 #ifdef KGDB
    445 	kgdb_port_init();
    446 #endif
    447 
    448 	/* Talk to the user */
    449 	printf("\nNetBSD/evbarm (" ___STRING(EVBARM_BOARDTYPE) ") booting ...\n");
    450 
    451 #ifdef BOOT_ARGS
    452 	char mi_bootargs[] = BOOT_ARGS;
    453 	parse_mi_bootargs(mi_bootargs);
    454 #endif
    455 	bootargs[0] = '\0';
    456 
    457 #ifdef VERBOSE_INIT_ARM
    458 	printf("initarm: Configuring system");
    459 	printf(", CLIDR=%010o CTR=%#x",
    460 	    armreg_clidr_read(), armreg_ctr_read());
    461 	printf("\n");
    462 #endif
    463 
    464 #ifdef VERBOSE_INIT_ARM
    465 	printf("initarm: Configuring system ...\n");
    466 #endif
    467 	/*
    468 	 * Set up the variables that define the availability of physical
    469 	 * memory.
    470 	 */
    471 
    472 	/* Fake bootconfig structure for the benefit of pmap.c. */
    473 	bootconfig.dramblocks = 1;
    474 	bootconfig.dram[0].address = MEMSTART;
    475 	bootconfig.dram[0].pages = (MEMSIZE * 1024 * 1024) / PAGE_SIZE;
    476 
    477 	psize_t ram_size = bootconfig.dram[0].pages * PAGE_SIZE;
    478 
    479 #ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
    480 	const bool mapallmem_p = true;
    481 	if (ram_size > (KERNEL_VM_BASE - KERNEL_BASE)) {
    482 		printf("%s: dropping RAM size from %luMB to %uMB\n",
    483 		    __func__, (unsigned long) (ram_size >> 20),
    484 		    (KERNEL_VM_BASE - KERNEL_BASE) >> 20);
    485 		ram_size = KERNEL_VM_BASE - KERNEL_BASE;
    486 	}
    487 	KASSERT(ram_size <= KERNEL_VM_BASE - KERNEL_BASE);
    488 #else
    489 	const bool mapallmem_p = false;
    490 #endif
    491 
    492 	arm32_bootmem_init(bootconfig.dram[0].address, ram_size,
    493 	    KERNEL_BASE_PHYS);
    494 	arm32_kernel_vm_init(KERNEL_VM_BASE, ARM_VECTORS_HIGH, 0,
    495 	    kobo_devmap, mapallmem_p);
    496 
    497 #ifdef BOOTHOWTO
    498 	boothowto |= BOOTHOWTO;
    499 #endif
    500 
    501 	return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0);
    502 }
    503 
    504 void
    505 consinit(void)
    506 {
    507 	static int consinit_called = 0;
    508 
    509 	if (consinit_called)
    510 		return;
    511 
    512 	consinit_called = 1;
    513 
    514 #ifdef	CONSDEVNAME
    515 
    516 #if NIMXUART > 0
    517 	imxuart_set_frequency(IMXUART_FREQ, 2);
    518 #endif
    519 
    520 #if (NIMXUART > 0) && defined(IMXUARTCONSOLE)
    521 	if (strcmp(consdevname, "imxuart") == 0) {
    522 		paddr_t consaddr;
    523 #ifdef	CONADDR
    524 		consaddr = CONADDR;
    525 #else
    526 		consaddr = IMX51_UART2_BASE;
    527 #endif
    528 		imxuart_cons_attach(&armv7_generic_bs_tag, consaddr, consrate, consmode);
    529 		return;
    530 	}
    531 #endif
    532 
    533 #endif
    534 
    535 #if (NWSDISPLAY > 0) && defined(IMXEPDCCONSOLE)
    536 #if NUKBD > 0
    537 	ukbd_cnattach();
    538 #endif
    539 	{
    540 		extern void kobo_cnattach(void);
    541 		kobo_cnattach();
    542 	}
    543 #endif
    544 }
    545 
    546 #ifdef KGDB
    547 #ifndef KGDB_DEVNAME
    548 #define KGDB_DEVNAME "imxuart"
    549 #endif
    550 #ifndef KGDB_DEVMODE
    551 #define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
    552 #endif
    553 
    554 const char kgdb_devname[20] = KGDB_DEVNAME;
    555 int kgdb_mode = KGDB_DEVMODE;
    556 int kgdb_addr = KGDB_DEVADDR;
    557 extern int kgdb_rate;	/* defined in kgdb_stub.c */
    558 
    559 void
    560 kgdb_port_init(void)
    561 {
    562 #if (NIMXUART > 0)
    563 	if (strcmp(kgdb_devname, "imxuart") == 0) {
    564 		imxuart_kgdb_attach(&armv7_generic_bs_tag, kgdb_addr,
    565 		kgdb_rate, kgdb_mode);
    566 	    return;
    567 	}
    568 
    569 #endif
    570 }
    571 #endif
    572