xref: /netbsd-src/sys/arch/evbarm/kobo/kobo_machdep.c (revision d90047b5d07facf36e6c01dcc0bded8997ce9cc2)
1 /*	$NetBSD: kobo_machdep.c,v 1.8 2019/07/24 12:33:18 hkenken 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.8 2019/07/24 12:33:18 hkenken Exp $");
106 
107 #include "opt_evbarm_boardtype.h"
108 #include "opt_arm_debug.h"
109 #include "opt_console.h"
110 #include "opt_cputypes.h"
111 #include "opt_ddb.h"
112 #include "opt_kgdb.h"
113 #include "opt_md.h"
114 #include "opt_com.h"
115 #include "imxuart.h"
116 #include "opt_imxuart.h"
117 #include "opt_imx.h"
118 #include "opt_machdep.h"
119 
120 #include <sys/param.h>
121 #include <sys/device.h>
122 #include <sys/reboot.h>
123 #include <sys/termios.h>
124 #include <sys/bus.h>
125 
126 #include <machine/db_machdep.h>
127 #ifdef KGDB
128 #include <sys/kgdb.h>
129 #endif
130 
131 #include <machine/bootconfig.h>
132 
133 #include <arm/arm32/machdep.h>
134 
135 #include <arm/imx/imx51reg.h>
136 #include <arm/imx/imx51var.h>
137 #include <arm/imx/imxuartreg.h>
138 #include <arm/imx/imxuartvar.h>
139 #include <arm/imx/imx50_iomuxreg.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 /* filled in before cleaning bss. keep in .data */
154 u_int uboot_args[4] __attribute__((__section__(".data")));
155 
156 /*
157  * Macros to translate between physical and virtual for a subset of the
158  * kernel address space.  *Not* for general use.
159  */
160 #define KERNEL_BASE_PHYS ((paddr_t)KERNEL_BASE_phys)
161 
162 void consinit(void);
163 
164 #ifdef KGDB
165 void	kgdb_port_init(void);
166 #endif
167 
168 static void init_clocks(void);
169 static void setup_ioports(void);
170 
171 #ifndef CONSPEED
172 #define CONSPEED B115200	/* What RedBoot uses */
173 #endif
174 #ifndef CONMODE
175 #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
176 #endif
177 
178 int comcnspeed = CONSPEED;
179 int comcnmode = CONMODE;
180 
181 /*
182  * Static device mappings. These peripheral registers are mapped at
183  * fixed virtual addresses very early in initarm() so that we can use
184  * them while booting the kernel, and stay at the same address
185  * throughout whole kernel's life time.
186  *
187  * We use this table twice; once with bootstrap page table, and once
188  * with kernel's page table which we build up in initarm().
189  *
190  * Since we map these registers into the bootstrap page table using
191  * pmap_devmap_bootstrap() which calls pmap_map_chunk(), we map
192  * registers segment-aligned and segment-rounded in order to avoid
193  * using the 2nd page tables.
194  */
195 
196 #define _A(a)   ((a) & ~L1_S_OFFSET)
197 #define _S(s)   (((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1))
198 
199 const struct pmap_devmap kobo_devmap[] = {
200 	{
201 		/* for UART2, IOMUXC */
202 		.pd_va = _A(KOBO_IO_VBASE0),
203 		.pd_pa = _A(KOBO_IO_PBASE0),
204 		.pd_size = _S(L1_S_SIZE * 4),
205 		.pd_prot = VM_PROT_READ|VM_PROT_WRITE,
206 		.pd_cache = PTE_NOCACHE
207 	},
208 	{0}
209 };
210 
211 #undef	_A
212 #undef	_S
213 
214 #ifndef MEMSTART
215 #define MEMSTART	0x70000000
216 #endif
217 #ifndef MEMSIZE
218 #define MEMSIZE		256
219 #endif
220 
221 static void
222 init_clocks(void)
223 {
224 	cortex_pmc_ccnt_init();
225 }
226 
227 struct iomux_setup {
228 	/* iomux registers are 32-bit wide, but upper 16 bits are not
229 	 * used. */
230 	uint16_t	reg;
231 	uint16_t	val;
232 };
233 
234 #define	IOMUX_M(padname, mux)		\
235 	IOMUX_DATA(__CONCAT(IOMUXC_SW_MUX_CTL_PAD_,padname), mux)
236 
237 #define	IOMUX_P(padname, pad)		\
238 	IOMUX_DATA(__CONCAT(IOMUXC_SW_PAD_CTL_PAD_,padname), pad)
239 
240 #define	IOMUX_MP(padname, mux, pad)	\
241 	IOMUX_M(padname, mux), \
242 	IOMUX_P(padname, pad)
243 
244 #define	IOMUX_DATA(offset, value)	\
245 	{				\
246 		.reg = (offset),	\
247 		.val = (value),		\
248 	}
249 
250 const struct iomux_setup iomux_setup_data[] = {
251 #define	HYS	PAD_CTL_HYS
252 #define	ODE	PAD_CTL_ODE
253 #define	DSEHIGH	PAD_CTL_DSE_HIGH
254 #define	DSEMID	PAD_CTL_DSE_MID
255 #define	DSELOW	PAD_CTL_DSE_LOW
256 #define	DSEMAX	PAD_CTL_DSE_MAX
257 #define	SRE	PAD_CTL_SRE
258 #define	KEEPER	PAD_CTL_KEEPER
259 #define	PULL	PAD_CTL_PULL
260 #define	PU_22K	PAD_CTL_PUS_22K_PU
261 #define	PU_47K	PAD_CTL_PUS_47K_PU
262 #define	PU_100K	PAD_CTL_PUS_100K_PU
263 #define	PD_100K	PAD_CTL_PUS_100K_PD
264 #define	HVE	PAD_CTL_HVE	/* Low output voltage */
265 
266 #define	ALT0	IOMUX_CONFIG_ALT0
267 #define	ALT1	IOMUX_CONFIG_ALT1
268 #define	ALT2	IOMUX_CONFIG_ALT2
269 #define	ALT3	IOMUX_CONFIG_ALT3
270 #define	ALT4	IOMUX_CONFIG_ALT4
271 #define	ALT5	IOMUX_CONFIG_ALT5
272 #define	ALT6	IOMUX_CONFIG_ALT6
273 #define	ALT7	IOMUX_CONFIG_ALT7
274 #define	SION	IOMUX_CONFIG_SION
275 
276 	/* I2C1 */
277 	IOMUX_MP(I2C1_SCL, ALT0 | SION, PULL | PU_100K | HYS | ODE | DSEHIGH),
278 	IOMUX_MP(I2C1_SDA, ALT0 | SION, PULL | PU_100K | HYS | ODE | DSEHIGH),
279 
280 	/* I2C2 */
281 	IOMUX_MP(I2C2_SCL, ALT0 | SION, PULL | PU_100K | HYS | ODE | DSEHIGH),
282 	IOMUX_MP(I2C2_SDA, ALT0 | SION, PULL | PU_100K | HYS | ODE | DSEHIGH),
283 
284 	/* I2C3 */
285 	IOMUX_MP(I2C3_SCL, ALT0 | SION, PULL | PU_100K | HYS | ODE | DSEHIGH),
286 	IOMUX_MP(I2C3_SDA, ALT0 | SION, PULL | PU_100K | HYS | ODE | DSEHIGH),
287 
288 	/* UART2 */
289 	IOMUX_MP(UART2_RXD, ALT0, HYS | PULL | DSEHIGH | SRE),
290 	IOMUX_MP(UART2_TXD, ALT0, HYS | PULL | DSEHIGH | SRE),
291 
292 	/* SD1 */
293 	IOMUX_MP(SD1_CMD, ALT0, HVE | PU_22K | DSEMAX | SRE),
294 	IOMUX_MP(SD1_CLK, ALT0, HVE | PU_22K | DSEMAX | SRE),
295 	IOMUX_MP(SD1_D0, ALT0, HVE | PU_22K | DSEMAX | SRE),
296 	IOMUX_MP(SD1_D1, ALT0, HVE | PU_22K | DSEMAX | SRE),
297 	IOMUX_MP(SD1_D2, ALT0, HVE | PU_22K | DSEMAX | SRE),
298 	IOMUX_MP(SD1_D3, ALT0, HVE | PU_22K | DSEMAX | SRE),
299 //	IOMUX_MP(SD1_CD, ALT0, HVE | PU_22K | DSEMAX | SRE),
300 
301 	/* SD2 */
302 	IOMUX_MP(SD2_CMD, ALT0, HVE | PU_22K | DSEMAX | SRE),
303 	IOMUX_MP(SD2_CLK, ALT0, HVE | PU_22K | DSEMAX | SRE),
304 	IOMUX_MP(SD2_D0, ALT0, HVE | PU_22K | DSEMAX | SRE),
305 	IOMUX_MP(SD2_D1, ALT0, HVE | PU_22K | DSEMAX | SRE),
306 	IOMUX_MP(SD2_D2, ALT0, HVE | PU_22K | DSEMAX | SRE),
307 	IOMUX_MP(SD2_D3, ALT0, HVE | PU_22K | DSEMAX | SRE),
308 	IOMUX_MP(SD2_CD, ALT0, HVE | PU_22K | DSEMAX | SRE),
309 
310 	IOMUX_DATA(IOMUXC_ESDHC2_IPP_CARD_DET_SELECT_INPUT, INPUT_DAISY_1),
311 
312 	/* SD3 */
313 	IOMUX_MP(SD3_CMD, ALT0, HVE | PU_22K | DSEMAX | SRE),
314 	IOMUX_MP(SD3_CLK, ALT0, HVE | PU_22K | DSEMAX | SRE),
315 	IOMUX_MP(SD3_D0, ALT0, HVE | PU_22K | DSEMAX | SRE),
316 	IOMUX_MP(SD3_D1, ALT0, HVE | PU_22K | DSEMAX | SRE),
317 	IOMUX_MP(SD3_D2, ALT0, HVE | PU_22K | DSEMAX | SRE),
318 	IOMUX_MP(SD3_D3, ALT0, HVE | PU_22K | DSEMAX | SRE),
319 //	IOMUX_MP(SD3_CD, ALT0, HVE | PU_22K | DSEMAX | SRE),
320 
321 	/* OTG */
322 	IOMUX_M(PWM2, ALT2),
323 //	IOMUX_MP(PWM1, ALT2, HYS | KEEPER | DSEHIGH),
324 
325 	/* EPDC */
326 	IOMUX_M(EPDC_D0, ALT0),
327 	IOMUX_M(EPDC_D1, ALT0),
328 	IOMUX_M(EPDC_D2, ALT0),
329 	IOMUX_M(EPDC_D3, ALT0),
330 	IOMUX_M(EPDC_D4, ALT0),
331 	IOMUX_M(EPDC_D5, ALT0),
332 	IOMUX_M(EPDC_D6, ALT0),
333 	IOMUX_M(EPDC_D7, ALT0),
334 	IOMUX_M(EPDC_GDCLK, ALT0),
335 	IOMUX_M(EPDC_GDSP, ALT0),
336 	IOMUX_M(EPDC_GDOE, ALT0),
337 	IOMUX_M(EPDC_GDRL, ALT0),
338 	IOMUX_M(EPDC_SDCLK, ALT0),
339 	IOMUX_M(EPDC_SDOE, ALT0),
340 	IOMUX_M(EPDC_SDLE, ALT0),
341 	IOMUX_M(EPDC_BDR0, ALT0),
342 	IOMUX_M(EPDC_BDR1, ALT0),
343 	IOMUX_M(EPDC_SDCE0, ALT0),
344 
345 	IOMUX_M(EPDC_PWRSTAT, ALT1),	/* GPIO3[28] */
346 	IOMUX_M(EPDC_PWRCTRL0, ALT1),	/* GPIO3[29] */
347 	IOMUX_M(EPDC_VCOM0, ALT1),	/* GPIO4[21] */
348 	IOMUX_M(UART4_TXD, ALT1),	/* GPIO6[16] */
349 	IOMUX_M(UART4_RXD, ALT1),	/* GPIO6[17] */
350 
351 //	IOMUX_M(PWM2, ALT1),		/* GPIO6[25] */
352 
353 #undef	ODE
354 #undef	HYS
355 #undef	SRE
356 #undef	PULL
357 #undef	KEEPER
358 #undef	PU_22K
359 #undef	PU_47K
360 #undef	PU_100K
361 #undef	PD_100K
362 #undef	HVE
363 #undef	DSEMAX
364 #undef	DSEHIGH
365 #undef	DSEMID
366 #undef	DSELOW
367 
368 #undef	ALT0
369 #undef	ALT1
370 #undef	ALT2
371 #undef	ALT3
372 #undef	ALT4
373 #undef	ALT5
374 #undef	ALT6
375 #undef	ALT7
376 #undef	SION
377 };
378 
379 static void
380 setup_ioports(void)
381 {
382 	int i;
383 	const struct iomux_setup *p;
384 
385 	for (i=0; i < __arraycount(iomux_setup_data); ++i) {
386 		p = iomux_setup_data + i;
387 
388 		ioreg_write(KOBO_IOMUXC_VBASE + p->reg,
389 			    p->val);
390 	}
391 }
392 
393 #ifdef	CONSDEVNAME
394 const char consdevname[] = CONSDEVNAME;
395 
396 #ifndef	CONMODE
397 #define	CONMODE	((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
398 #endif
399 #ifndef	CONSPEED
400 #define	CONSPEED	115200
401 #endif
402 
403 int consmode = CONMODE;
404 int consrate = CONSPEED;
405 
406 #endif	/* CONSDEVNAME */
407 
408 #ifndef	IMXUART_FREQ
409 #define	IMXUART_FREQ	24000000
410 #endif
411 
412 /*
413  * vaddr_t initarm(...)
414  *
415  * Initial entry point on startup. This gets called before main() is
416  * entered.
417  * It should be responsible for setting up everything that must be
418  * in place when main is called.
419  * This includes
420  *   Taking a copy of the boot configuration structure.
421  *   Initialising the physical console so characters can be printed.
422  *   Setting up page tables for the kernel
423  */
424 vaddr_t
425 initarm(void *arg)
426 {
427 	/*
428 	 * Heads up ... Setup the CPU / MMU / TLB functions
429 	 */
430 	if (set_cpufuncs())		// starts PMC counter
431 		panic("cpu not recognized!");
432 
433 	extern char ARM_BOOTSTRAP_LxPT[];
434 	pmap_devmap_bootstrap((vaddr_t)ARM_BOOTSTRAP_LxPT, kobo_devmap);
435 
436 	cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
437 
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_cnattach(&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