Home | History | Annotate | Line # | Download | only in netwalker
netwalker_machdep.c revision 1.5.2.3
      1  1.5.2.3  yamt /*	$NetBSD: netwalker_machdep.c,v 1.5.2.3 2014/05/22 11:39:42 yamt Exp $	*/
      2      1.1   bsh 
      3      1.1   bsh /*
      4  1.5.2.3  yamt  * Copyright (c) 2002, 2003, 2005, 2010  Genetec Corporation.
      5      1.1   bsh  * All rights reserved.
      6      1.1   bsh  * Written by Hiroyuki Bessho for Genetec Corporation.
      7      1.1   bsh  *
      8      1.1   bsh  * Redistribution and use in source and binary forms, with or without
      9      1.1   bsh  * modification, are permitted provided that the following conditions
     10      1.1   bsh  * are met:
     11      1.1   bsh  * 1. Redistributions of source code must retain the above copyright
     12      1.1   bsh  *    notice, this list of conditions and the following disclaimer.
     13      1.1   bsh  * 2. Redistributions in binary form must reproduce the above copyright
     14      1.1   bsh  *    notice, this list of conditions and the following disclaimer in the
     15      1.1   bsh  *    documentation and/or other materials provided with the distribution.
     16      1.1   bsh  *
     17      1.1   bsh  * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
     18      1.1   bsh  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     19      1.1   bsh  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     20      1.1   bsh  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
     21      1.1   bsh  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22      1.1   bsh  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23      1.1   bsh  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24      1.1   bsh  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25      1.1   bsh  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26      1.1   bsh  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27      1.1   bsh  * POSSIBILITY OF SUCH DAMAGE.
     28      1.1   bsh  *
     29      1.4   wiz  * Machine dependent functions for kernel setup for Sharp Netwalker.
     30      1.1   bsh  * Based on iq80310_machhdep.c
     31      1.1   bsh  */
     32      1.1   bsh /*
     33      1.1   bsh  * Copyright (c) 2001 Wasabi Systems, Inc.
     34      1.1   bsh  * All rights reserved.
     35      1.1   bsh  *
     36      1.1   bsh  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
     37      1.1   bsh  *
     38      1.1   bsh  * Redistribution and use in source and binary forms, with or without
     39      1.1   bsh  * modification, are permitted provided that the following conditions
     40      1.1   bsh  * are met:
     41      1.1   bsh  * 1. Redistributions of source code must retain the above copyright
     42      1.1   bsh  *    notice, this list of conditions and the following disclaimer.
     43      1.1   bsh  * 2. Redistributions in binary form must reproduce the above copyright
     44      1.1   bsh  *    notice, this list of conditions and the following disclaimer in the
     45      1.1   bsh  *    documentation and/or other materials provided with the distribution.
     46      1.1   bsh  * 3. All advertising materials mentioning features or use of this software
     47      1.1   bsh  *    must display the following acknowledgement:
     48      1.1   bsh  *	This product includes software developed for the NetBSD Project by
     49      1.1   bsh  *	Wasabi Systems, Inc.
     50      1.1   bsh  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     51      1.1   bsh  *    or promote products derived from this software without specific prior
     52      1.1   bsh  *    written permission.
     53      1.1   bsh  *
     54      1.1   bsh  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     55      1.1   bsh  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     56      1.1   bsh  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     57      1.1   bsh  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     58      1.1   bsh  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     59      1.1   bsh  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     60      1.1   bsh  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     61      1.1   bsh  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     62      1.1   bsh  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     63      1.1   bsh  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     64      1.1   bsh  * POSSIBILITY OF SUCH DAMAGE.
     65      1.1   bsh  */
     66      1.1   bsh 
     67      1.1   bsh /*
     68      1.1   bsh  * Copyright (c) 1997,1998 Mark Brinicombe.
     69      1.1   bsh  * Copyright (c) 1997,1998 Causality Limited.
     70      1.1   bsh  * All rights reserved.
     71      1.1   bsh  *
     72      1.1   bsh  * Redistribution and use in source and binary forms, with or without
     73      1.1   bsh  * modification, are permitted provided that the following conditions
     74      1.1   bsh  * are met:
     75      1.1   bsh  * 1. Redistributions of source code must retain the above copyright
     76      1.1   bsh  *    notice, this list of conditions and the following disclaimer.
     77      1.1   bsh  * 2. Redistributions in binary form must reproduce the above copyright
     78      1.1   bsh  *    notice, this list of conditions and the following disclaimer in the
     79      1.1   bsh  *    documentation and/or other materials provided with the distribution.
     80      1.1   bsh  * 3. All advertising materials mentioning features or use of this software
     81      1.1   bsh  *    must display the following acknowledgement:
     82      1.1   bsh  *	This product includes software developed by Mark Brinicombe
     83      1.1   bsh  *	for the NetBSD Project.
     84      1.1   bsh  * 4. The name of the company nor the name of the author may be used to
     85      1.1   bsh  *    endorse or promote products derived from this software without specific
     86      1.1   bsh  *    prior written permission.
     87      1.1   bsh  *
     88      1.1   bsh  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
     89      1.1   bsh  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     90      1.1   bsh  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     91      1.1   bsh  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     92      1.1   bsh  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     93      1.1   bsh  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     94      1.1   bsh  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     95      1.1   bsh  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     96      1.1   bsh  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     97      1.1   bsh  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     98      1.1   bsh  * SUCH DAMAGE.
     99      1.1   bsh  *
    100      1.4   wiz  * Machine dependent functions for kernel setup for Intel IQ80310 evaluation
    101      1.1   bsh  * boards using RedBoot firmware.
    102      1.1   bsh  */
    103      1.1   bsh 
    104      1.1   bsh #include <sys/cdefs.h>
    105  1.5.2.3  yamt __KERNEL_RCSID(0, "$NetBSD: netwalker_machdep.c,v 1.5.2.3 2014/05/22 11:39:42 yamt Exp $");
    106      1.1   bsh 
    107  1.5.2.3  yamt #include "opt_evbarm_boardtype.h"
    108  1.5.2.3  yamt #include "opt_cputypes.h"
    109      1.1   bsh #include "opt_ddb.h"
    110      1.1   bsh #include "opt_kgdb.h"
    111      1.1   bsh #include "opt_md.h"
    112      1.1   bsh #include "opt_com.h"
    113      1.1   bsh #include "imxuart.h"
    114      1.1   bsh #include "opt_imxuart.h"
    115      1.1   bsh #include "opt_imx.h"
    116  1.5.2.3  yamt #include "opt_imx51_ipuv3.h"
    117  1.5.2.3  yamt #include "wsdisplay.h"
    118  1.5.2.3  yamt #include "opt_machdep.h"
    119      1.1   bsh 
    120      1.1   bsh #include <sys/param.h>
    121      1.1   bsh #include <sys/device.h>
    122      1.1   bsh #include <sys/termios.h>
    123  1.5.2.3  yamt #include <sys/bus.h>
    124      1.1   bsh 
    125      1.1   bsh #include <machine/db_machdep.h>
    126      1.1   bsh #ifdef KGDB
    127      1.1   bsh #include <sys/kgdb.h>
    128      1.1   bsh #endif
    129      1.1   bsh 
    130      1.1   bsh #include <machine/bootconfig.h>
    131      1.1   bsh 
    132      1.1   bsh #include <arm/arm32/machdep.h>
    133      1.1   bsh 
    134      1.1   bsh #include <arm/imx/imx51reg.h>
    135      1.1   bsh #include <arm/imx/imx51var.h>
    136      1.1   bsh #include <arm/imx/imxgpioreg.h>
    137      1.1   bsh #include <arm/imx/imxwdogreg.h>
    138      1.1   bsh #include <arm/imx/imxuartreg.h>
    139      1.1   bsh #include <arm/imx/imxuartvar.h>
    140      1.1   bsh #include <arm/imx/imx51_iomuxreg.h>
    141  1.5.2.3  yamt 
    142      1.1   bsh #include <evbarm/netwalker/netwalker_reg.h>
    143  1.5.2.3  yamt #include <evbarm/netwalker/netwalker.h>
    144  1.5.2.3  yamt 
    145  1.5.2.3  yamt #include "ukbd.h"
    146  1.5.2.3  yamt #if (NUKBD > 0)
    147  1.5.2.3  yamt #include <dev/usb/ukbdvar.h>
    148  1.5.2.3  yamt #endif
    149      1.1   bsh 
    150      1.1   bsh /* Kernel text starts 1MB in from the bottom of the kernel address space. */
    151      1.1   bsh #define	KERNEL_TEXT_BASE	(KERNEL_BASE + 0x00100000)
    152      1.1   bsh 
    153      1.1   bsh BootConfig bootconfig;		/* Boot config storage */
    154  1.5.2.3  yamt static char bootargs[MAX_BOOT_STRING];
    155      1.1   bsh char *boot_args = NULL;
    156      1.1   bsh 
    157      1.1   bsh extern char KERNEL_BASE_phys[];
    158      1.1   bsh 
    159  1.5.2.3  yamt extern int cpu_do_powersave;
    160      1.1   bsh 
    161      1.1   bsh /*
    162      1.1   bsh  * Macros to translate between physical and virtual for a subset of the
    163      1.1   bsh  * kernel address space.  *Not* for general use.
    164      1.1   bsh  */
    165  1.5.2.3  yamt #define KERNEL_BASE_PHYS ((paddr_t)KERNEL_BASE_phys)
    166      1.1   bsh 
    167      1.1   bsh 
    168      1.1   bsh /* Prototypes */
    169      1.1   bsh 
    170      1.1   bsh void consinit(void);
    171      1.1   bsh 
    172      1.1   bsh #ifdef KGDB
    173      1.1   bsh void	kgdb_port_init(void);
    174      1.1   bsh #endif
    175      1.1   bsh 
    176      1.1   bsh static void init_clocks(void);
    177      1.1   bsh static void setup_ioports(void);
    178      1.1   bsh 
    179      1.1   bsh #ifndef CONSPEED
    180      1.1   bsh #define CONSPEED B115200	/* What RedBoot uses */
    181      1.1   bsh #endif
    182      1.1   bsh #ifndef CONMODE
    183      1.1   bsh #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
    184      1.1   bsh #endif
    185      1.1   bsh 
    186      1.1   bsh int comcnspeed = CONSPEED;
    187      1.1   bsh int comcnmode = CONMODE;
    188      1.1   bsh 
    189      1.1   bsh /*
    190      1.1   bsh  * Static device mappings. These peripheral registers are mapped at
    191      1.1   bsh  * fixed virtual addresses very early in netwalker_start() so that we
    192      1.1   bsh  * can use them while booting the kernel, and stay at the same address
    193      1.1   bsh  * throughout whole kernel's life time.
    194      1.1   bsh  *
    195      1.1   bsh  * We use this table twice; once with bootstrap page table, and once
    196      1.1   bsh  * with kernel's page table which we build up in initarm().
    197      1.1   bsh  */
    198      1.1   bsh 
    199      1.1   bsh #define _A(a)   ((a) & ~L1_S_OFFSET)
    200      1.1   bsh #define _S(s)   (((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1))
    201      1.1   bsh 
    202      1.1   bsh static const struct pmap_devmap netwalker_devmap[] = {
    203      1.1   bsh 	{
    204      1.1   bsh 		/* for UART1, IOMUXC */
    205  1.5.2.3  yamt 		.pd_va = _A(NETWALKER_IO_VBASE0),
    206  1.5.2.3  yamt 		.pd_pa = _A(NETWALKER_IO_PBASE0),
    207  1.5.2.3  yamt 		.pd_size = _S(L1_S_SIZE * 4),
    208  1.5.2.3  yamt 		.pd_prot = VM_PROT_READ|VM_PROT_WRITE,
    209  1.5.2.3  yamt 		.pd_cache = PTE_NOCACHE
    210      1.1   bsh 	},
    211  1.5.2.3  yamt 	{0}
    212      1.1   bsh };
    213      1.1   bsh 
    214  1.5.2.3  yamt #undef	_A
    215  1.5.2.3  yamt #undef	_S
    216  1.5.2.3  yamt 
    217      1.1   bsh #ifndef MEMSTART
    218      1.1   bsh #define MEMSTART	0x90000000
    219      1.1   bsh #endif
    220      1.1   bsh #ifndef MEMSIZE
    221      1.1   bsh #define MEMSIZE		512
    222      1.1   bsh #endif
    223      1.1   bsh 
    224      1.1   bsh /*
    225      1.1   bsh  * u_int initarm(...)
    226      1.1   bsh  *
    227      1.1   bsh  * Initial entry point on startup. This gets called before main() is
    228      1.1   bsh  * entered.
    229      1.1   bsh  * It should be responsible for setting up everything that must be
    230      1.1   bsh  * in place when main is called.
    231      1.1   bsh  * This includes
    232      1.1   bsh  *   Taking a copy of the boot configuration structure.
    233      1.1   bsh  *   Initialising the physical console so characters can be printed.
    234      1.1   bsh  *   Setting up page tables for the kernel
    235      1.1   bsh  *   Relocating the kernel to the bottom of physical memory
    236      1.1   bsh  */
    237      1.1   bsh u_int
    238      1.1   bsh initarm(void *arg)
    239      1.1   bsh {
    240  1.5.2.3  yamt 	/*
    241  1.5.2.3  yamt 	 * Heads up ... Setup the CPU / MMU / TLB functions
    242  1.5.2.3  yamt 	 */
    243  1.5.2.3  yamt 	if (set_cpufuncs())
    244  1.5.2.3  yamt 		panic("cpu not recognized!");
    245      1.1   bsh 
    246  1.5.2.3  yamt 	/* map some peripheral registers */
    247  1.5.2.3  yamt 	pmap_devmap_bootstrap((vaddr_t)armreg_ttbr_read() & -L1_TABLE_SIZE,
    248  1.5.2.3  yamt 	    netwalker_devmap);
    249      1.1   bsh 
    250  1.5.2.3  yamt 	cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
    251      1.1   bsh 
    252      1.1   bsh 	/* Register devmap for devices we mapped in start */
    253      1.1   bsh 	pmap_devmap_register(netwalker_devmap);
    254      1.1   bsh 	setup_ioports();
    255      1.1   bsh 
    256      1.1   bsh 	consinit();
    257      1.1   bsh 
    258      1.1   bsh #ifdef	NO_POWERSAVE
    259      1.1   bsh 	cpu_do_powersave=0;
    260      1.1   bsh #endif
    261      1.1   bsh 
    262      1.1   bsh 	init_clocks();
    263      1.1   bsh 
    264      1.1   bsh #ifdef KGDB
    265      1.1   bsh 	kgdb_port_init();
    266      1.1   bsh #endif
    267      1.1   bsh 
    268      1.1   bsh 	/* Talk to the user */
    269  1.5.2.3  yamt 	printf("\nNetBSD/evbarm (" ___STRING(EVBARM_BOARDTYPE) ") booting ...\n");
    270      1.1   bsh 
    271  1.5.2.3  yamt #ifdef BOOT_ARGS
    272  1.5.2.3  yamt 	char mi_bootargs[] = BOOT_ARGS;
    273  1.5.2.3  yamt 	parse_mi_bootargs(mi_bootargs);
    274  1.5.2.3  yamt #endif
    275  1.5.2.3  yamt 	bootargs[0] = '\0';
    276  1.5.2.3  yamt 
    277  1.5.2.3  yamt #if defined(VERBOSE_INIT_ARM) || 1
    278  1.5.2.3  yamt 	printf("initarm: Configuring system");
    279  1.5.2.3  yamt 	printf(", CLIDR=%010o CTR=%#x",
    280  1.5.2.3  yamt 	    armreg_clidr_read(), armreg_ctr_read());
    281  1.5.2.3  yamt 	printf("\n");
    282  1.5.2.3  yamt #endif
    283      1.1   bsh 	/*
    284      1.1   bsh 	 * Ok we have the following memory map
    285      1.1   bsh 	 *
    286      1.1   bsh 	 * Physical Address Range     Description
    287      1.1   bsh 	 * -----------------------    ----------------------------------
    288      1.1   bsh 	 *
    289  1.5.2.3  yamt 	 * 0x90000000 - 0xAFFFFFFF    DDR SDRAM (512MByte)
    290      1.1   bsh 	 *
    291      1.1   bsh 	 * The initarm() has the responsibility for creating the kernel
    292      1.1   bsh 	 * page tables.
    293      1.1   bsh 	 * It must also set up various memory pointers that are used
    294      1.1   bsh 	 * by pmap etc.
    295      1.1   bsh 	 */
    296      1.1   bsh 
    297      1.1   bsh #ifdef VERBOSE_INIT_ARM
    298      1.1   bsh 	printf("initarm: Configuring system ...\n");
    299      1.1   bsh #endif
    300      1.1   bsh 	/* Fake bootconfig structure for the benefit of pmap.c */
    301      1.1   bsh 	/* XXX must make the memory description h/w independent */
    302      1.1   bsh 	bootconfig.dramblocks = 1;
    303      1.1   bsh 	bootconfig.dram[0].address = MEMSTART;
    304  1.5.2.3  yamt 	bootconfig.dram[0].pages = (MEMSIZE * 1024 * 1024) / PAGE_SIZE;
    305      1.1   bsh 
    306  1.5.2.3  yamt 	psize_t ram_size = bootconfig.dram[0].pages * PAGE_SIZE;
    307      1.1   bsh 
    308  1.5.2.3  yamt #ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
    309  1.5.2.3  yamt 	if (ram_size > KERNEL_VM_BASE - KERNEL_BASE) {
    310  1.5.2.3  yamt 		printf("%s: dropping RAM size from %luMB to %uMB\n",
    311  1.5.2.3  yamt 		    __func__, (unsigned long) (ram_size >> 20),
    312  1.5.2.3  yamt 		    (KERNEL_VM_BASE - KERNEL_BASE) >> 20);
    313  1.5.2.3  yamt 		ram_size = KERNEL_VM_BASE - KERNEL_BASE;
    314      1.1   bsh 	}
    315      1.1   bsh #endif
    316      1.1   bsh 
    317  1.5.2.3  yamt 	arm32_bootmem_init(bootconfig.dram[0].address, ram_size,
    318  1.5.2.3  yamt 	    KERNEL_BASE_PHYS);
    319      1.1   bsh 
    320  1.5.2.3  yamt #ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
    321  1.5.2.3  yamt 	const bool mapallmem_p = true;
    322  1.5.2.3  yamt 	KASSERT(ram_size <= KERNEL_VM_BASE - KERNEL_BASE);
    323      1.1   bsh #else
    324  1.5.2.3  yamt 	const bool mapallmem_p = false;
    325      1.1   bsh #endif
    326      1.1   bsh 
    327  1.5.2.3  yamt 	arm32_kernel_vm_init(KERNEL_VM_BASE, ARM_VECTORS_HIGH, 0,
    328  1.5.2.3  yamt 	    netwalker_devmap, mapallmem_p);
    329      1.1   bsh 
    330      1.1   bsh 	/* disable power down counter in watch dog,
    331      1.1   bsh 	   This must be done within 16 seconds of start-up. */
    332      1.1   bsh 	ioreg16_write(NETWALKER_WDOG_VBASE + IMX_WDOG_WMCR, 0);
    333      1.1   bsh 
    334  1.5.2.3  yamt #ifdef BOOTHOWTO
    335  1.5.2.3  yamt 	boothowto |= BOOTHOWTO;
    336      1.1   bsh #endif
    337      1.1   bsh 
    338      1.1   bsh #ifdef VERBOSE_INIT_ARM
    339      1.1   bsh 	printf("initarm done.\n");
    340  1.5.2.3  yamt #endif
    341  1.5.2.3  yamt 	return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0);
    342      1.1   bsh }
    343      1.1   bsh 
    344      1.1   bsh 
    345      1.1   bsh static void
    346      1.1   bsh init_clocks(void)
    347      1.1   bsh {
    348  1.5.2.2  yamt 	cortex_pmc_ccnt_init();
    349      1.1   bsh }
    350      1.1   bsh 
    351      1.1   bsh struct iomux_setup {
    352  1.5.2.1  yamt 	/* iomux registers are 32-bit wide, but upper 16 bits are not
    353  1.5.2.1  yamt 	 * used. */
    354  1.5.2.1  yamt 	uint16_t	reg;
    355  1.5.2.1  yamt 	uint16_t	val;
    356      1.1   bsh };
    357      1.1   bsh 
    358  1.5.2.1  yamt #define	IOMUX_M(padname, mux)		\
    359  1.5.2.1  yamt 	IOMUX_DATA(__CONCAT(IOMUXC_SW_MUX_CTL_PAD_,padname), mux)
    360  1.5.2.1  yamt 
    361  1.5.2.1  yamt #define	IOMUX_P(padname, pad)		\
    362  1.5.2.1  yamt 	IOMUX_DATA(__CONCAT(IOMUXC_SW_PAD_CTL_PAD_,padname), pad)
    363  1.5.2.1  yamt 
    364  1.5.2.1  yamt #define	IOMUX_MP(padname, mux, pad)	\
    365  1.5.2.1  yamt 	IOMUX_M(padname, mux), \
    366  1.5.2.1  yamt 	IOMUX_P(padname, pad)
    367  1.5.2.1  yamt 
    368  1.5.2.1  yamt 
    369  1.5.2.1  yamt #define	IOMUX_DATA(offset, value)	\
    370  1.5.2.1  yamt 	{				\
    371  1.5.2.1  yamt 		.reg = (offset),	\
    372  1.5.2.1  yamt 		.val = (value),		\
    373      1.1   bsh 	}
    374      1.1   bsh 
    375      1.1   bsh 
    376  1.5.2.3  yamt /*
    377  1.5.2.3  yamt  * set same values to IOMUX registers as linux kernel does
    378  1.5.2.1  yamt  */
    379      1.1   bsh const struct iomux_setup iomux_setup_data[] = {
    380  1.5.2.1  yamt #define	HYS	PAD_CTL_HYS
    381  1.5.2.1  yamt #define	ODE	PAD_CTL_ODE
    382  1.5.2.1  yamt #define	DSEHIGH	PAD_CTL_DSE_HIGH
    383  1.5.2.1  yamt #define	DSEMID	PAD_CTL_DSE_MID
    384  1.5.2.1  yamt #define	DSELOW	PAD_CTL_DSE_LOW
    385  1.5.2.1  yamt #define	DSEMAX	PAD_CTL_DSE_MAX
    386  1.5.2.1  yamt #define	SRE	PAD_CTL_SRE
    387  1.5.2.1  yamt #define	KEEPER	PAD_CTL_KEEPER
    388  1.5.2.1  yamt #define	PULL	PAD_CTL_PULL
    389  1.5.2.1  yamt #define	PU_22K	PAD_CTL_PUS_22K_PU
    390  1.5.2.1  yamt #define	PU_47K	PAD_CTL_PUS_47K_PU
    391  1.5.2.1  yamt #define	PU_100K	PAD_CTL_PUS_100K_PU
    392  1.5.2.1  yamt #define	PD_100K	PAD_CTL_PUS_100K_PD
    393  1.5.2.1  yamt #define	HVE	PAD_CTL_HVE	/* Low output voltage */
    394  1.5.2.1  yamt 
    395  1.5.2.1  yamt #define	ALT0	IOMUX_CONFIG_ALT0
    396  1.5.2.1  yamt #define	ALT1	IOMUX_CONFIG_ALT1
    397  1.5.2.1  yamt #define	ALT2	IOMUX_CONFIG_ALT2
    398  1.5.2.1  yamt #define	ALT3	IOMUX_CONFIG_ALT3
    399  1.5.2.1  yamt #define	ALT4	IOMUX_CONFIG_ALT4
    400  1.5.2.1  yamt #define	ALT5	IOMUX_CONFIG_ALT5
    401  1.5.2.1  yamt #define	ALT6	IOMUX_CONFIG_ALT6
    402  1.5.2.1  yamt #define	ALT7	IOMUX_CONFIG_ALT7
    403  1.5.2.1  yamt #define	SION	IOMUX_CONFIG_SION
    404  1.5.2.1  yamt 
    405  1.5.2.1  yamt 	/* left button */
    406  1.5.2.1  yamt 	IOMUX_MP(EIM_EB2, ALT1, HYS),
    407  1.5.2.1  yamt 	/* right button */
    408  1.5.2.1  yamt 	IOMUX_MP(EIM_EB3, ALT1, HYS),
    409      1.1   bsh 
    410      1.1   bsh 	/* UART1 */
    411  1.5.2.1  yamt 	IOMUX_MP(UART1_RXD, ALT0, HYS | PULL | DSEHIGH | SRE),
    412  1.5.2.1  yamt 	IOMUX_MP(UART1_TXD, ALT0, HYS | PULL | DSEHIGH | SRE),
    413  1.5.2.1  yamt 	IOMUX_MP(UART1_RTS, ALT0, HYS | PULL | DSEHIGH),
    414  1.5.2.1  yamt 	IOMUX_MP(UART1_CTS, ALT0, HYS | PULL | DSEHIGH),
    415  1.5.2.1  yamt 
    416  1.5.2.1  yamt 	/* LCD Display */
    417  1.5.2.1  yamt 	IOMUX_M(DI1_PIN2, ALT0),
    418  1.5.2.1  yamt 	IOMUX_M(DI1_PIN3, ALT0),
    419  1.5.2.1  yamt 
    420  1.5.2.1  yamt 	IOMUX_DATA(IOMUXC_SW_PAD_CTL_GRP_DISP1_PKE0, PAD_CTL_PKE),
    421  1.5.2.1  yamt #if 0
    422  1.5.2.1  yamt 	IOMUX_MP(DISP1_DAT0, ALT0, SRE | DSEMAX | PULL),
    423  1.5.2.1  yamt 	IOMUX_MP(DISP1_DAT1, ALT0, SRE | DSEMAX | PULL),
    424  1.5.2.1  yamt 	IOMUX_MP(DISP1_DAT2, ALT0, SRE | DSEMAX | PULL),
    425  1.5.2.1  yamt 	IOMUX_MP(DISP1_DAT3, ALT0, SRE | DSEMAX | PULL),
    426  1.5.2.1  yamt 	IOMUX_MP(DISP1_DAT4, ALT0, SRE | DSEMAX | PULL),
    427  1.5.2.1  yamt 	IOMUX_MP(DISP1_DAT5, ALT0, SRE | DSEMAX | PULL),
    428  1.5.2.1  yamt #endif
    429  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT6, ALT0),
    430  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT7, ALT0),
    431  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT8, ALT0),
    432  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT9, ALT0),
    433  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT10, ALT0),
    434  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT11, ALT0),
    435  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT12, ALT0),
    436  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT13, ALT0),
    437  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT14, ALT0),
    438  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT15, ALT0),
    439  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT16, ALT0),
    440  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT17, ALT0),
    441  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT18, ALT0),
    442  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT19, ALT0),
    443  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT20, ALT0),
    444  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT21, ALT0),
    445  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT22, ALT0),
    446  1.5.2.1  yamt 	IOMUX_M(DISP1_DAT23, ALT0),
    447  1.5.2.1  yamt 
    448  1.5.2.1  yamt 	IOMUX_MP(DI1_D0_CS, ALT4, KEEPER | DSEHIGH | SRE), /* GPIO3_3 */
    449  1.5.2.1  yamt 	IOMUX_DATA(IOMUXC_GPIO3_IPP_IND_G_IN_3_SELECT_INPUT, INPUT_DAISY_0),
    450  1.5.2.1  yamt 	IOMUX_MP(CSI2_D12, ALT3, KEEPER | DSEHIGH | SRE), /* GPIO4_9 */
    451  1.5.2.1  yamt 	IOMUX_MP(CSI2_D13, ALT3, KEEPER | DSEHIGH | SRE),
    452  1.5.2.3  yamt #if 1
    453  1.5.2.3  yamt 	IOMUX_MP(GPIO1_2, ALT1, DSEHIGH | ODE),	/* LCD backlight by PWM */
    454  1.5.2.3  yamt #else
    455  1.5.2.3  yamt 	IOMUX_MP(GPIO1_2, ALT0, DSEHIGH | ODE),	/* LCD backlight by GPIO */
    456  1.5.2.3  yamt #endif
    457  1.5.2.1  yamt 	IOMUX_MP(EIM_A19, ALT1, SRE | DSEHIGH),
    458  1.5.2.1  yamt 	/* XXX VGA pins */
    459  1.5.2.1  yamt 	IOMUX_M(DI_GP4, ALT4),
    460  1.5.2.1  yamt 	IOMUX_M(GPIO1_8, SION | ALT0),
    461  1.5.2.1  yamt 
    462  1.5.2.1  yamt 	IOMUX_MP(GPIO1_8, SION | ALT0, HYS | DSEMID | PU_100K),
    463  1.5.2.1  yamt 	/* I2C1 */
    464  1.5.2.1  yamt 	IOMUX_MP(EIM_D16, SION | ALT4, HYS | ODE | DSEHIGH | SRE),
    465  1.5.2.1  yamt 	IOMUX_MP(EIM_D19, SION | ALT4, SRE),	/* SCL */
    466  1.5.2.1  yamt 	IOMUX_MP(EIM_A19, ALT1, SRE | DSEHIGH), /* GPIO2_13 */
    467  1.5.2.1  yamt 
    468  1.5.2.1  yamt #if 0
    469  1.5.2.1  yamt 	IOMUX_MP(EIM_A23, ALT1, 0),
    470  1.5.2.1  yamt #else
    471  1.5.2.1  yamt 	IOMUX_M(EIM_A23, ALT1),	/* GPIO2_17 */
    472  1.5.2.1  yamt #endif
    473  1.5.2.1  yamt 
    474  1.5.2.1  yamt 	/* BT */
    475  1.5.2.1  yamt 	IOMUX_M(EIM_D20, ALT1),	/* GPIO2_4 BT host wakeup */
    476  1.5.2.1  yamt 	IOMUX_M(EIM_D22, ALT1),	/* GPIO2_6 BT RESET */
    477  1.5.2.1  yamt 	IOMUX_M(EIM_D23, ALT1),	/* GPIO2_7 BT wakeup */
    478  1.5.2.1  yamt 
    479  1.5.2.1  yamt 	/* UART3 */
    480  1.5.2.1  yamt 	IOMUX_MP(EIM_D24, ALT3, KEEPER | PU_100K | DSEHIGH | SRE),
    481  1.5.2.1  yamt 	IOMUX_MP(EIM_D25, ALT3, KEEPER | PU_100K | DSEHIGH | SRE), /* CTS */
    482  1.5.2.1  yamt 	IOMUX_MP(EIM_D26, ALT3, KEEPER | PU_100K | DSEHIGH | SRE), /* TXD */
    483  1.5.2.1  yamt 	IOMUX_MP(EIM_D27, ALT3, KEEPER | PU_100K | DSEHIGH | SRE), /* RTS */
    484  1.5.2.1  yamt 	IOMUX_M(NANDF_D15, ALT3),	/* GPIO3_25 */
    485  1.5.2.1  yamt 	IOMUX_MP(NANDF_D14, ALT3, HYS | PULL | PU_100K ),	/* GPIO3_26 */
    486  1.5.2.3  yamt 
    487  1.5.2.3  yamt 	/* OJ6SH-T25 */
    488  1.5.2.1  yamt 	IOMUX_M(CSI1_D9, ALT3),			/* GPIO3_13 */
    489  1.5.2.1  yamt 	IOMUX_M(CSI1_VSYNC, ALT3),		/* GPIO3_14 */
    490  1.5.2.1  yamt 	IOMUX_M(CSI1_HSYNC, ALT3),		/* GPIO3_15 */
    491  1.5.2.1  yamt 
    492  1.5.2.1  yamt 	/* audio pins */
    493  1.5.2.1  yamt 	IOMUX_MP(AUD3_BB_TXD, ALT0, DSEHIGH | PU_100K | SRE),
    494  1.5.2.1  yamt 		/* XXX: linux code:
    495  1.5.2.1  yamt 		   (PAD_CTL_SRE_FAST	     | PAD_CTL_DRV_HIGH |
    496  1.5.2.1  yamt 		   PAD_CTL_100K_PU	     | PAD_CTL_HYS_NONE |
    497  1.5.2.1  yamt 		   PAD_CTL_DDR_INPUT_CMOS | PAD_CTL_DRV_VOT_LOW), */
    498  1.5.2.1  yamt 
    499  1.5.2.1  yamt 	IOMUX_MP(AUD3_BB_RXD, ALT0, KEEPER | DSEHIGH | SRE),
    500  1.5.2.1  yamt 	IOMUX_MP(AUD3_BB_CK, ALT0, KEEPER | DSEHIGH | SRE),
    501  1.5.2.1  yamt 	IOMUX_MP(AUD3_BB_FS, ALT0, KEEPER | DSEHIGH | SRE),
    502  1.5.2.1  yamt 
    503  1.5.2.1  yamt 	/* headphone detect */
    504  1.5.2.1  yamt 	IOMUX_MP(NANDF_D14, ALT3, HYS | PULL | PU_100K),
    505  1.5.2.1  yamt 	IOMUX_MP(CSPI1_RDY, ALT3, SRE | DSEHIGH),
    506  1.5.2.1  yamt 	/* XXX more audio pins ? */
    507  1.5.2.1  yamt 
    508  1.5.2.1  yamt 	/* CSPI */
    509  1.5.2.3  yamt 	IOMUX_MP(CSPI1_MOSI, ALT0, HYS | PULL | PD_100K | DSEHIGH | SRE),
    510  1.5.2.3  yamt 	IOMUX_MP(CSPI1_MISO, ALT0, HYS | PULL | PD_100K | DSEHIGH | SRE),
    511  1.5.2.3  yamt 	IOMUX_MP(CSPI1_SCLK, ALT0, HYS | PULL | PD_100K | DSEHIGH | SRE),
    512  1.5.2.3  yamt 
    513  1.5.2.3  yamt 	/* SPI CS */
    514  1.5.2.3  yamt 	IOMUX_MP(CSPI1_SS0, ALT3, HYS | KEEPER | DSEHIGH | SRE), /* GPIO4[24] */
    515  1.5.2.3  yamt 	IOMUX_MP(CSPI1_SS1, ALT3, HYS | KEEPER | DSEHIGH | SRE), /* GPIO4[25] */
    516  1.5.2.3  yamt 	IOMUX_MP(DI1_PIN11, ALT4, HYS | PULL | DSEHIGH | SRE),   /* GPIO3[0] */
    517  1.5.2.3  yamt 
    518  1.5.2.1  yamt 	/* 26M Osc */
    519  1.5.2.1  yamt 	IOMUX_MP(DI1_PIN12, ALT4, KEEPER | DSEHIGH | SRE), /* GPIO3_1 */
    520  1.5.2.1  yamt 
    521  1.5.2.1  yamt 	/* I2C */
    522  1.5.2.1  yamt 	IOMUX_MP(KEY_COL4, SION | ALT3, SRE),
    523  1.5.2.1  yamt 	IOMUX_DATA(IOMUXC_I2C2_IPP_SCL_IN_SELECT_INPUT, INPUT_DAISY_1),
    524  1.5.2.1  yamt 	IOMUX_MP(KEY_COL5, SION | ALT3, HYS | ODE | DSEHIGH | SRE),
    525  1.5.2.1  yamt 	IOMUX_DATA(IOMUXC_I2C2_IPP_SDA_IN_SELECT_INPUT, INPUT_DAISY_1),
    526  1.5.2.1  yamt 	IOMUX_DATA(IOMUXC_UART3_IPP_UART_RTS_B_SELECT_INPUT, INPUT_DAISY_3),
    527  1.5.2.3  yamt 
    528  1.5.2.1  yamt 	/* NAND */
    529  1.5.2.1  yamt 	IOMUX_MP(NANDF_WE_B, ALT0, HVE | DSEHIGH | PULL | PU_47K),
    530  1.5.2.1  yamt 	IOMUX_MP(NANDF_RE_B, ALT0, HVE | DSEHIGH | PULL | PU_47K),
    531  1.5.2.1  yamt 	IOMUX_MP(NANDF_ALE, ALT0, HVE | DSEHIGH | KEEPER),
    532  1.5.2.1  yamt 	IOMUX_MP(NANDF_CLE, ALT0, HVE | DSEHIGH | KEEPER),
    533  1.5.2.1  yamt 	IOMUX_MP(NANDF_WP_B, ALT0, HVE | DSEHIGH | PULL | PU_100K),
    534  1.5.2.1  yamt 	IOMUX_MP(NANDF_RB0, ALT0, HVE | DSELOW | PULL | PU_100K),
    535  1.5.2.1  yamt 	IOMUX_MP(NANDF_RB1, ALT0, HVE | DSELOW | PULL | PU_100K),
    536  1.5.2.1  yamt 	IOMUX_MP(NANDF_D7, ALT0, HVE | DSEHIGH | KEEPER | PU_100K),
    537  1.5.2.1  yamt 	IOMUX_MP(NANDF_D6, ALT0, HVE | DSEHIGH | KEEPER | PU_100K),
    538  1.5.2.1  yamt 	IOMUX_MP(NANDF_D5, ALT0, HVE | DSEHIGH | KEEPER | PU_100K),
    539  1.5.2.1  yamt 	IOMUX_MP(NANDF_D4, ALT0, HVE | DSEHIGH | KEEPER | PU_100K),
    540  1.5.2.1  yamt 	IOMUX_MP(NANDF_D3, ALT0, HVE | DSEHIGH | KEEPER | PU_100K),
    541  1.5.2.1  yamt 	IOMUX_MP(NANDF_D2, ALT0, HVE | DSEHIGH | KEEPER | PU_100K),
    542  1.5.2.1  yamt 	IOMUX_MP(NANDF_D1, ALT0, HVE | DSEHIGH | KEEPER | PU_100K),
    543  1.5.2.1  yamt 	IOMUX_MP(NANDF_D0, ALT0, HVE | DSEHIGH | KEEPER | PU_100K),
    544  1.5.2.1  yamt 
    545  1.5.2.1  yamt 	/* Batttery pins */
    546  1.5.2.1  yamt 	IOMUX_MP(NANDF_D13, ALT3, HYS | DSEHIGH),
    547  1.5.2.1  yamt 	IOMUX_MP(NANDF_D12, ALT3, HYS | DSEHIGH),
    548  1.5.2.1  yamt #if 0
    549  1.5.2.1  yamt 	IOMUX_MP(NANDF_D11, ALT3, HYS | DSEHIGH),
    550  1.5.2.1  yamt #endif
    551  1.5.2.1  yamt 	IOMUX_MP(NANDF_D10, ALT3, HYS | DSEHIGH),
    552  1.5.2.1  yamt 
    553  1.5.2.1  yamt 	/* SD1 */
    554  1.5.2.1  yamt 	IOMUX_MP(SD1_CMD, SION | ALT0, DSEHIGH | SRE),
    555  1.5.2.1  yamt 	IOMUX_MP(SD1_CLK, SION | ALT0, KEEPER | PU_47K | DSEHIGH),
    556  1.5.2.1  yamt 	IOMUX_MP(SD1_DATA0, ALT0, DSEHIGH | SRE),
    557  1.5.2.1  yamt 	IOMUX_MP(SD1_DATA1, ALT0, DSEHIGH | SRE),
    558  1.5.2.1  yamt 	IOMUX_MP(SD1_DATA2, ALT0, DSEHIGH | SRE),
    559  1.5.2.1  yamt 	IOMUX_MP(SD1_DATA3, ALT0, DSEHIGH | SRE),
    560  1.5.2.1  yamt 	IOMUX_MP(GPIO1_0, SION | ALT0, HYS | PU_100K),
    561  1.5.2.1  yamt 
    562  1.5.2.1  yamt 	/* SD2 */
    563  1.5.2.1  yamt 	IOMUX_P(SD2_CMD, HVE | PU_22K | DSEMAX | SRE),
    564  1.5.2.1  yamt 	IOMUX_P(SD2_CLK, HVE | PU_22K | DSEMAX | SRE),
    565  1.5.2.1  yamt 	IOMUX_P(SD2_DATA0, HVE | PU_22K | DSEMAX | SRE),
    566  1.5.2.1  yamt 	IOMUX_P(SD2_DATA1, HVE | PU_22K | DSEMAX | SRE),
    567  1.5.2.1  yamt 	IOMUX_P(SD2_DATA2, HVE | PU_22K | DSEMAX | SRE),
    568  1.5.2.1  yamt 	IOMUX_P(SD2_DATA3, HVE | PU_22K | DSEMAX | SRE),
    569  1.5.2.1  yamt 
    570  1.5.2.1  yamt 	/* USB */
    571  1.5.2.1  yamt 	IOMUX_MP(USBH1_CLK, ALT0, HYS | KEEPER | DSEHIGH | SRE),
    572  1.5.2.1  yamt 	IOMUX_MP(USBH1_DIR, ALT0, HYS | KEEPER | DSEHIGH | SRE),
    573  1.5.2.1  yamt 	IOMUX_MP(USBH1_STP, ALT0, HYS | KEEPER | DSEHIGH | SRE),
    574  1.5.2.1  yamt 	IOMUX_MP(USBH1_NXT, ALT0, HYS | KEEPER | PU_100K | DSEHIGH | SRE),
    575  1.5.2.1  yamt 	IOMUX_MP(USBH1_DATA0, ALT0, HYS | KEEPER | DSEHIGH | SRE),
    576  1.5.2.1  yamt 	IOMUX_MP(USBH1_DATA1, ALT0, HYS | KEEPER | DSEHIGH | SRE),
    577  1.5.2.1  yamt 	IOMUX_MP(USBH1_DATA2, ALT0, HYS | KEEPER | DSEHIGH | SRE),
    578  1.5.2.1  yamt 	IOMUX_MP(USBH1_DATA3, ALT0, HYS | KEEPER | DSEHIGH | SRE),
    579  1.5.2.1  yamt 	IOMUX_MP(USBH1_DATA4, ALT0, HYS | KEEPER | DSEHIGH | SRE),
    580  1.5.2.1  yamt 	IOMUX_MP(USBH1_DATA5, ALT0, HYS | KEEPER | DSEHIGH | SRE),
    581  1.5.2.1  yamt 	IOMUX_MP(USBH1_DATA6, ALT0, HYS | KEEPER | DSEHIGH | SRE),
    582  1.5.2.1  yamt 	IOMUX_MP(USBH1_DATA7, ALT0, HYS | KEEPER | DSEHIGH | SRE),
    583  1.5.2.1  yamt 	IOMUX_MP(EIM_D17, ALT1, KEEPER | DSEHIGH | SRE),
    584  1.5.2.1  yamt 	IOMUX_MP(EIM_D21, ALT1, KEEPER | DSEHIGH | SRE),
    585  1.5.2.1  yamt 	IOMUX_P(GPIO1_7, /*ALT0,*/ DSEHIGH | SRE),	/* USB Hub reset */
    586  1.5.2.1  yamt 
    587  1.5.2.1  yamt #undef	ODE
    588  1.5.2.1  yamt #undef	HYS
    589  1.5.2.1  yamt #undef	SRE
    590  1.5.2.1  yamt #undef	PULL
    591  1.5.2.1  yamt #undef	KEEPER
    592  1.5.2.1  yamt #undef	PU_22K
    593  1.5.2.1  yamt #undef	PU_47K
    594  1.5.2.1  yamt #undef	PU_100K
    595  1.5.2.1  yamt #undef	PD_100K
    596  1.5.2.1  yamt #undef	HVE
    597  1.5.2.1  yamt #undef	DSEMAX
    598  1.5.2.1  yamt #undef	DSEHIGH
    599  1.5.2.1  yamt #undef	DSEMID
    600  1.5.2.1  yamt #undef	DSELOW
    601  1.5.2.1  yamt 
    602  1.5.2.1  yamt #undef	ALT0
    603  1.5.2.1  yamt #undef	ALT1
    604  1.5.2.1  yamt #undef	ALT2
    605  1.5.2.1  yamt #undef	ALT3
    606  1.5.2.1  yamt #undef	ALT4
    607  1.5.2.1  yamt #undef	ALT5
    608  1.5.2.1  yamt #undef	ALT6
    609  1.5.2.1  yamt #undef	ALT7
    610  1.5.2.1  yamt #undef	SION
    611      1.1   bsh };
    612      1.1   bsh 
    613      1.1   bsh static void
    614      1.1   bsh setup_ioports(void)
    615      1.1   bsh {
    616      1.1   bsh 	int i;
    617      1.1   bsh 	const struct iomux_setup *p;
    618      1.1   bsh 
    619  1.5.2.1  yamt 	/* Initialize all IOMUX registers */
    620      1.1   bsh 	for (i=0; i < __arraycount(iomux_setup_data); ++i) {
    621      1.1   bsh 		p = iomux_setup_data + i;
    622      1.1   bsh 
    623  1.5.2.1  yamt 		ioreg_write(NETWALKER_IOMUXC_VBASE + p->reg,
    624  1.5.2.1  yamt 			    p->val);
    625      1.1   bsh 	}
    626      1.1   bsh }
    627      1.1   bsh 
    628      1.1   bsh 
    629      1.1   bsh #ifdef	CONSDEVNAME
    630      1.1   bsh const char consdevname[] = CONSDEVNAME;
    631      1.1   bsh 
    632      1.1   bsh #ifndef	CONMODE
    633      1.1   bsh #define	CONMODE	((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
    634      1.1   bsh #endif
    635      1.1   bsh #ifndef	CONSPEED
    636      1.1   bsh #define	CONSPEED	115200
    637      1.1   bsh #endif
    638      1.1   bsh 
    639      1.1   bsh int consmode = CONMODE;
    640      1.1   bsh int consrate = CONSPEED;
    641      1.1   bsh 
    642      1.1   bsh #endif	/* CONSDEVNAME */
    643      1.1   bsh 
    644      1.1   bsh #ifndef	IMXUART_FREQ
    645  1.5.2.1  yamt #define	IMXUART_FREQ	66500000
    646      1.1   bsh #endif
    647      1.1   bsh 
    648      1.1   bsh void
    649      1.1   bsh consinit(void)
    650      1.1   bsh {
    651      1.1   bsh 	static int consinit_called = 0;
    652      1.1   bsh 
    653      1.1   bsh 	if (consinit_called)
    654      1.1   bsh 		return;
    655      1.1   bsh 
    656      1.1   bsh 	consinit_called = 1;
    657      1.1   bsh 
    658      1.1   bsh #ifdef	CONSDEVNAME
    659      1.1   bsh 
    660      1.1   bsh #if NIMXUART > 0
    661      1.1   bsh 	imxuart_set_frequency(IMXUART_FREQ, 2);
    662      1.1   bsh #endif
    663      1.1   bsh 
    664      1.1   bsh #if (NIMXUART > 0) && defined(IMXUARTCONSOLE)
    665      1.1   bsh 	if (strcmp(consdevname, "imxuart") == 0) {
    666      1.1   bsh 		paddr_t consaddr;
    667      1.1   bsh #ifdef	CONADDR
    668      1.1   bsh 		consaddr = CONADDR;
    669      1.1   bsh #else
    670      1.1   bsh 		consaddr = IMX51_UART1_BASE;
    671      1.1   bsh #endif
    672      1.1   bsh 		imxuart_cons_attach(&imx_bs_tag, consaddr, consrate, consmode);
    673      1.1   bsh 	    return;
    674      1.1   bsh 	}
    675      1.1   bsh #endif
    676      1.1   bsh 
    677      1.1   bsh #endif
    678      1.1   bsh 
    679  1.5.2.3  yamt #if (NWSDISPLAY > 0) && defined(IMXIPUCONSOLE)
    680  1.5.2.3  yamt #if NUKBD > 0
    681  1.5.2.3  yamt 	ukbd_cnattach();
    682  1.5.2.3  yamt #endif
    683      1.1   bsh 	{
    684      1.1   bsh 		extern void netwalker_cnattach(void);
    685      1.1   bsh 		netwalker_cnattach();
    686      1.1   bsh 	}
    687      1.1   bsh #endif
    688      1.1   bsh }
    689      1.1   bsh 
    690      1.1   bsh #ifdef KGDB
    691      1.1   bsh #ifndef KGDB_DEVNAME
    692      1.1   bsh #define KGDB_DEVNAME "imxuart"
    693      1.1   bsh #endif
    694      1.1   bsh #ifndef KGDB_DEVMODE
    695      1.1   bsh #define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
    696      1.1   bsh #endif
    697      1.1   bsh 
    698      1.1   bsh const char kgdb_devname[20] = KGDB_DEVNAME;
    699      1.1   bsh int kgdb_mode = KGDB_DEVMODE;
    700      1.1   bsh int kgdb_addr = KGDB_DEVADDR;
    701      1.1   bsh extern int kgdb_rate;	/* defined in kgdb_stub.c */
    702      1.1   bsh 
    703      1.1   bsh void
    704      1.1   bsh kgdb_port_init(void)
    705      1.1   bsh {
    706      1.1   bsh #if (NIMXUART > 0)
    707      1.1   bsh 	if (strcmp(kgdb_devname, "imxuart") == 0) {
    708      1.1   bsh 		imxuart_kgdb_attach(&imx_bs_tag, kgdb_addr,
    709      1.1   bsh 		kgdb_rate, kgdb_mode);
    710      1.1   bsh 	    return;
    711      1.1   bsh 	}
    712      1.1   bsh 
    713      1.1   bsh #endif
    714      1.1   bsh }
    715      1.1   bsh #endif
    716      1.1   bsh 
    717      1.1   bsh 
    718