Home | History | Annotate | Line # | Download | only in gumstix
gumstix_machdep.c revision 1.42.2.3
      1  1.42.2.3       tls /*	$NetBSD: gumstix_machdep.c,v 1.42.2.3 2014/08/20 00:02:54 tls Exp $ */
      2       1.1  kiyohara /*
      3       1.3  kiyohara  * Copyright (C) 2005, 2006, 2007  WIDE Project and SOUM Corporation.
      4       1.1  kiyohara  * All rights reserved.
      5       1.1  kiyohara  *
      6       1.1  kiyohara  * Written by Takashi Kiyohara and Susumu Miki for WIDE Project and SOUM
      7       1.1  kiyohara  * Corporation.
      8       1.1  kiyohara  *
      9       1.1  kiyohara  * Redistribution and use in source and binary forms, with or without
     10       1.1  kiyohara  * modification, are permitted provided that the following conditions
     11       1.1  kiyohara  * are met:
     12       1.1  kiyohara  * 1. Redistributions of source code must retain the above copyright
     13       1.1  kiyohara  *    notice, this list of conditions and the following disclaimer.
     14       1.1  kiyohara  * 2. Redistributions in binary form must reproduce the above copyright
     15       1.1  kiyohara  *    notice, this list of conditions and the following disclaimer in the
     16       1.1  kiyohara  *    documentation and/or other materials provided with the distribution.
     17       1.1  kiyohara  * 3. Neither the name of the project nor the name of SOUM Corporation
     18       1.1  kiyohara  *    may be used to endorse or promote products derived from this software
     19       1.1  kiyohara  *    without specific prior written permission.
     20       1.1  kiyohara  *
     21       1.1  kiyohara  * THIS SOFTWARE IS PROVIDED BY THE PROJECT and SOUM CORPORATION ``AS IS''
     22       1.1  kiyohara  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     23       1.1  kiyohara  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     24       1.1  kiyohara  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT AND SOUM CORPORATION
     25       1.1  kiyohara  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26       1.1  kiyohara  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27       1.1  kiyohara  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28       1.1  kiyohara  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29       1.1  kiyohara  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30       1.1  kiyohara  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     31       1.1  kiyohara  * POSSIBILITY OF SUCH DAMAGE.
     32       1.1  kiyohara  */
     33       1.1  kiyohara /*
     34      1.17  kiyohara  * Copyright (c) 2002, 2003, 2004, 2005  Genetec Corporation.
     35       1.1  kiyohara  * All rights reserved.
     36       1.1  kiyohara  *
     37       1.1  kiyohara  * Written by Hiroyuki Bessho for Genetec Corporation.
     38       1.1  kiyohara  *
     39       1.1  kiyohara  * Redistribution and use in source and binary forms, with or without
     40       1.1  kiyohara  * modification, are permitted provided that the following conditions
     41       1.1  kiyohara  * are met:
     42       1.1  kiyohara  * 1. Redistributions of source code must retain the above copyright
     43       1.1  kiyohara  *    notice, this list of conditions and the following disclaimer.
     44       1.1  kiyohara  * 2. Redistributions in binary form must reproduce the above copyright
     45       1.1  kiyohara  *    notice, this list of conditions and the following disclaimer in the
     46       1.1  kiyohara  *    documentation and/or other materials provided with the distribution.
     47      1.17  kiyohara  * 3. The name of Genetec Corporation may not be used to endorse or
     48       1.1  kiyohara  *    promote products derived from this software without specific prior
     49       1.1  kiyohara  *    written permission.
     50       1.1  kiyohara  *
     51       1.1  kiyohara  * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
     52       1.1  kiyohara  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     53       1.1  kiyohara  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     54       1.1  kiyohara  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
     55       1.1  kiyohara  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     56       1.1  kiyohara  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     57       1.1  kiyohara  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     58       1.1  kiyohara  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     59       1.1  kiyohara  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     60       1.1  kiyohara  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     61       1.1  kiyohara  * POSSIBILITY OF SUCH DAMAGE.
     62       1.1  kiyohara  *
     63      1.36       wiz  * Machine dependent functions for kernel setup for Genetec G4250EBX
     64       1.1  kiyohara  * evaluation board.
     65      1.17  kiyohara  *
     66       1.1  kiyohara  * Based on iq80310_machhdep.c
     67       1.1  kiyohara  */
     68       1.1  kiyohara /*
     69       1.1  kiyohara  * Copyright (c) 2001 Wasabi Systems, Inc.
     70       1.1  kiyohara  * All rights reserved.
     71       1.1  kiyohara  *
     72       1.1  kiyohara  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
     73       1.1  kiyohara  *
     74       1.1  kiyohara  * Redistribution and use in source and binary forms, with or without
     75       1.1  kiyohara  * modification, are permitted provided that the following conditions
     76       1.1  kiyohara  * are met:
     77       1.1  kiyohara  * 1. Redistributions of source code must retain the above copyright
     78       1.1  kiyohara  *    notice, this list of conditions and the following disclaimer.
     79       1.1  kiyohara  * 2. Redistributions in binary form must reproduce the above copyright
     80       1.1  kiyohara  *    notice, this list of conditions and the following disclaimer in the
     81       1.1  kiyohara  *    documentation and/or other materials provided with the distribution.
     82       1.1  kiyohara  * 3. All advertising materials mentioning features or use of this software
     83       1.1  kiyohara  *    must display the following acknowledgement:
     84       1.1  kiyohara  *	This product includes software developed for the NetBSD Project by
     85       1.1  kiyohara  *	Wasabi Systems, Inc.
     86       1.1  kiyohara  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     87       1.1  kiyohara  *    or promote products derived from this software without specific prior
     88       1.1  kiyohara  *    written permission.
     89       1.1  kiyohara  *
     90       1.1  kiyohara  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     91       1.1  kiyohara  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     92       1.1  kiyohara  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     93       1.1  kiyohara  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     94       1.1  kiyohara  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     95       1.1  kiyohara  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     96       1.1  kiyohara  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     97       1.1  kiyohara  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     98       1.1  kiyohara  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     99       1.1  kiyohara  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    100       1.1  kiyohara  * POSSIBILITY OF SUCH DAMAGE.
    101       1.1  kiyohara  */
    102       1.1  kiyohara 
    103       1.1  kiyohara /*
    104       1.1  kiyohara  * Copyright (c) 1997,1998 Mark Brinicombe.
    105       1.1  kiyohara  * Copyright (c) 1997,1998 Causality Limited.
    106       1.1  kiyohara  * All rights reserved.
    107       1.1  kiyohara  *
    108       1.1  kiyohara  * Redistribution and use in source and binary forms, with or without
    109       1.1  kiyohara  * modification, are permitted provided that the following conditions
    110       1.1  kiyohara  * are met:
    111       1.1  kiyohara  * 1. Redistributions of source code must retain the above copyright
    112       1.1  kiyohara  *    notice, this list of conditions and the following disclaimer.
    113       1.1  kiyohara  * 2. Redistributions in binary form must reproduce the above copyright
    114       1.1  kiyohara  *    notice, this list of conditions and the following disclaimer in the
    115       1.1  kiyohara  *    documentation and/or other materials provided with the distribution.
    116       1.1  kiyohara  * 3. All advertising materials mentioning features or use of this software
    117       1.1  kiyohara  *    must display the following acknowledgement:
    118       1.1  kiyohara  *	This product includes software developed by Mark Brinicombe
    119       1.1  kiyohara  *	for the NetBSD Project.
    120       1.1  kiyohara  * 4. The name of the company nor the name of the author may be used to
    121       1.1  kiyohara  *    endorse or promote products derived from this software without specific
    122       1.1  kiyohara  *    prior written permission.
    123       1.1  kiyohara  *
    124       1.1  kiyohara  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
    125       1.1  kiyohara  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    126       1.1  kiyohara  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    127       1.1  kiyohara  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
    128       1.1  kiyohara  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    129       1.1  kiyohara  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    130       1.1  kiyohara  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    131       1.1  kiyohara  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    132       1.1  kiyohara  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    133       1.1  kiyohara  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    134       1.1  kiyohara  * SUCH DAMAGE.
    135       1.1  kiyohara  *
    136      1.36       wiz  * Machine dependent functions for kernel setup for Intel IQ80310 evaluation
    137       1.1  kiyohara  * boards using RedBoot firmware.
    138       1.1  kiyohara  */
    139       1.1  kiyohara 
    140      1.29  kiyohara #include "opt_evbarm_boardtype.h"
    141      1.27  kiyohara #include "opt_cputypes.h"
    142      1.31  kiyohara #include "opt_gumstix.h"
    143      1.31  kiyohara #ifdef OVERO
    144      1.30  kiyohara #include "opt_omap.h"
    145      1.32  kiyohara #include "prcm.h"
    146      1.31  kiyohara #endif
    147       1.1  kiyohara #include "opt_kgdb.h"
    148       1.1  kiyohara #include "opt_pmap_debug.h"
    149       1.1  kiyohara #include "opt_com.h"
    150       1.1  kiyohara 
    151       1.1  kiyohara #include <sys/param.h>
    152      1.26  kiyohara #include <sys/conf.h>
    153       1.1  kiyohara #include <sys/device.h>
    154      1.26  kiyohara #include <sys/exec.h>
    155       1.1  kiyohara #include <sys/kernel.h>
    156       1.1  kiyohara #include <sys/proc.h>
    157       1.1  kiyohara #include <sys/reboot.h>
    158      1.26  kiyohara #include <sys/systm.h>
    159       1.1  kiyohara #include <sys/termios.h>
    160  1.42.2.3       tls #include <sys/bus.h>
    161  1.42.2.3       tls #include <sys/cpu.h>
    162  1.42.2.3       tls 
    163  1.42.2.3       tls #include <uvm/uvm_extern.h>
    164       1.1  kiyohara 
    165      1.27  kiyohara #include <machine/autoconf.h>
    166       1.1  kiyohara #include <machine/bootconfig.h>
    167  1.42.2.3       tls #include <arm/locore.h>
    168       1.1  kiyohara 
    169       1.1  kiyohara #include <arm/arm32/machdep.h>
    170  1.42.2.2       tls #ifdef OVERO
    171      1.30  kiyohara #include <arm/omap/omap2_gpmcreg.h>
    172      1.32  kiyohara #include <arm/omap/omap2_prcm.h>
    173      1.27  kiyohara #include <arm/omap/omap2_reg.h>
    174      1.27  kiyohara #include <arm/omap/omap_var.h>
    175      1.27  kiyohara #include <arm/omap/omap_com.h>
    176  1.42.2.2       tls #endif
    177       1.1  kiyohara #include <arm/xscale/pxa2x0reg.h>
    178       1.1  kiyohara #include <arm/xscale/pxa2x0var.h>
    179       1.1  kiyohara #include <arm/xscale/pxa2x0_gpio.h>
    180       1.1  kiyohara #include <evbarm/gumstix/gumstixreg.h>
    181       1.1  kiyohara #include <evbarm/gumstix/gumstixvar.h>
    182       1.1  kiyohara 
    183      1.26  kiyohara #include <dev/cons.h>
    184      1.26  kiyohara 
    185      1.26  kiyohara #ifdef KGDB
    186      1.26  kiyohara #include <sys/kgdb.h>
    187      1.26  kiyohara #endif
    188      1.26  kiyohara 
    189       1.1  kiyohara /*
    190  1.42.2.3       tls  * The range 0xc1000000 - 0xcfffffff is available for kernel VM space
    191       1.1  kiyohara  * Core-logic registers and I/O mappings occupy 0xfd000000 - 0xffffffff
    192       1.1  kiyohara  */
    193  1.42.2.3       tls #ifndef KERNEL_VM_BASE
    194  1.42.2.3       tls #define	KERNEL_VM_BASE		0xc1000000
    195  1.42.2.3       tls #endif
    196  1.42.2.3       tls #define KERNEL_VM_SIZE		0x0f000000
    197       1.1  kiyohara 
    198       1.1  kiyohara BootConfig bootconfig;		/* Boot config storage */
    199       1.1  kiyohara static char bootargs[MAX_BOOT_STRING];
    200      1.38       mrg const size_t bootargs_len = sizeof(bootargs) - 1;	/* without nul */
    201       1.1  kiyohara char *boot_args = NULL;
    202       1.1  kiyohara 
    203       1.1  kiyohara uint32_t system_serial_high;
    204       1.1  kiyohara uint32_t system_serial_low;
    205       1.1  kiyohara 
    206       1.1  kiyohara /* Prototypes */
    207      1.27  kiyohara #if defined(GUMSTIX)
    208       1.3  kiyohara static void	read_system_serial(void);
    209  1.42.2.3       tls #elif defined(OVERO)
    210  1.42.2.3       tls static void	overo_reset(void);
    211  1.42.2.3       tls static void	find_cpu_clock(void);
    212      1.27  kiyohara #endif
    213       1.3  kiyohara static void	process_kernel_args(int, char *[]);
    214      1.25  kiyohara static void	process_kernel_args_liner(char *);
    215       1.3  kiyohara #ifdef KGDB
    216       1.3  kiyohara static void	kgdb_port_init(void);
    217       1.3  kiyohara #endif
    218      1.28  kiyohara static void	gumstix_device_register(device_t, void *);
    219       1.1  kiyohara 
    220       1.1  kiyohara bs_protos(bs_notimpl);
    221       1.1  kiyohara 
    222       1.1  kiyohara #include "com.h"
    223       1.1  kiyohara #if NCOM > 0
    224       1.1  kiyohara #include <dev/ic/comreg.h>
    225       1.1  kiyohara #include <dev/ic/comvar.h>
    226       1.1  kiyohara #endif
    227       1.1  kiyohara 
    228      1.27  kiyohara #if defined(CPU_XSCALE_PXA250) || defined(CPU_XSCALE_PXA270)
    229      1.15  kiyohara #include "lcd.h"
    230      1.27  kiyohara #endif
    231      1.15  kiyohara 
    232       1.1  kiyohara #ifndef CONSPEED
    233       1.1  kiyohara #define CONSPEED B115200	/* It's a setting of the default of u-boot */
    234       1.1  kiyohara #endif
    235       1.1  kiyohara #ifndef CONMODE
    236       1.1  kiyohara #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
    237       1.1  kiyohara #endif
    238       1.1  kiyohara 
    239       1.1  kiyohara int comcnspeed = CONSPEED;
    240       1.1  kiyohara int comcnmode = CONMODE;
    241       1.1  kiyohara 
    242      1.25  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_CONSOLE
    243      1.25  kiyohara static char console[16];
    244      1.25  kiyohara #endif
    245      1.25  kiyohara 
    246       1.3  kiyohara extern void gxio_config_pin(void);
    247       1.5  kiyohara extern void gxio_config_expansion(char *);
    248       1.3  kiyohara 
    249       1.1  kiyohara 
    250      1.25  kiyohara static inline pd_entry_t *
    251       1.1  kiyohara read_ttb(void)
    252       1.1  kiyohara {
    253      1.27  kiyohara 	long ttb;
    254       1.1  kiyohara 
    255      1.27  kiyohara 	__asm volatile("mrc	p15, 0, %0, c2, c0, 0" : "=r" (ttb));
    256       1.1  kiyohara 
    257      1.27  kiyohara 	return (pd_entry_t *)(ttb & ~((1<<14)-1));
    258       1.1  kiyohara }
    259       1.1  kiyohara 
    260       1.1  kiyohara /*
    261       1.1  kiyohara  * Static device mappings. These peripheral registers are mapped at
    262       1.1  kiyohara  * fixed virtual addresses very early in initarm() so that we can use
    263       1.1  kiyohara  * them while booting the kernel, and stay at the same address
    264       1.1  kiyohara  * throughout whole kernel's life time.
    265       1.1  kiyohara  *
    266       1.1  kiyohara  * We use this table twice; once with bootstrap page table, and once
    267       1.1  kiyohara  * with kernel's page table which we build up in initarm().
    268       1.1  kiyohara  *
    269       1.1  kiyohara  * Since we map these registers into the bootstrap page table using
    270       1.1  kiyohara  * pmap_devmap_bootstrap() which calls pmap_map_chunk(), we map
    271       1.1  kiyohara  * registers segment-aligned and segment-rounded in order to avoid
    272       1.1  kiyohara  * using the 2nd page tables.
    273       1.1  kiyohara  */
    274       1.1  kiyohara 
    275       1.1  kiyohara #define	_A(a)	((a) & ~L1_S_OFFSET)
    276       1.1  kiyohara #define	_S(s)	(((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1))
    277       1.1  kiyohara 
    278       1.1  kiyohara static const struct pmap_devmap gumstix_devmap[] = {
    279      1.27  kiyohara #if defined(GUMSTIX)
    280       1.1  kiyohara 	{
    281       1.1  kiyohara 		GUMSTIX_GPIO_VBASE,
    282       1.1  kiyohara 		_A(PXA2X0_GPIO_BASE),
    283       1.1  kiyohara 		_S(PXA250_GPIO_SIZE),
    284      1.27  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    285      1.27  kiyohara 		PTE_NOCACHE,
    286       1.1  kiyohara 	},
    287       1.1  kiyohara 	{
    288      1.12     cliff 		GUMSTIX_CLKMAN_VBASE,
    289      1.12     cliff 		_A(PXA2X0_CLKMAN_BASE),
    290      1.12     cliff 		_S(PXA2X0_CLKMAN_SIZE),
    291      1.27  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    292      1.27  kiyohara 		PTE_NOCACHE,
    293       1.1  kiyohara 	},
    294       1.1  kiyohara 	{
    295       1.1  kiyohara 		GUMSTIX_INTCTL_VBASE,
    296       1.1  kiyohara 		_A(PXA2X0_INTCTL_BASE),
    297       1.1  kiyohara 		_S(PXA2X0_INTCTL_SIZE),
    298      1.27  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    299      1.27  kiyohara 		PTE_NOCACHE,
    300       1.1  kiyohara 	},
    301       1.1  kiyohara 	{
    302       1.1  kiyohara 		GUMSTIX_FFUART_VBASE,
    303       1.1  kiyohara 		_A(PXA2X0_FFUART_BASE),
    304       1.1  kiyohara 		_S(4 * COM_NPORTS),
    305      1.27  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    306      1.27  kiyohara 		PTE_NOCACHE,
    307       1.1  kiyohara 	},
    308       1.1  kiyohara 	{
    309       1.3  kiyohara 		GUMSTIX_STUART_VBASE,
    310       1.3  kiyohara 		_A(PXA2X0_STUART_BASE),
    311       1.3  kiyohara 		_S(4 * COM_NPORTS),
    312      1.27  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    313      1.27  kiyohara 		PTE_NOCACHE,
    314       1.3  kiyohara 	},
    315       1.3  kiyohara 	{
    316       1.1  kiyohara 		GUMSTIX_BTUART_VBASE,
    317       1.1  kiyohara 		_A(PXA2X0_BTUART_BASE),
    318       1.1  kiyohara 		_S(4 * COM_NPORTS),
    319      1.27  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    320      1.27  kiyohara 		PTE_NOCACHE,
    321       1.1  kiyohara 	},
    322       1.3  kiyohara 	{
    323       1.3  kiyohara 		GUMSTIX_HWUART_VBASE,
    324       1.3  kiyohara 		_A(PXA2X0_HWUART_BASE),
    325       1.3  kiyohara 		_S(4 * COM_NPORTS),
    326      1.27  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    327      1.27  kiyohara 		PTE_NOCACHE,
    328       1.3  kiyohara 	},
    329      1.15  kiyohara 	{
    330      1.15  kiyohara 		GUMSTIX_LCDC_VBASE,
    331      1.15  kiyohara 		_A(PXA2X0_LCDC_BASE),
    332      1.15  kiyohara 		_S(4 * COM_NPORTS),
    333      1.27  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    334      1.27  kiyohara 		PTE_NOCACHE,
    335      1.27  kiyohara 	},
    336      1.27  kiyohara #elif defined(OVERO)
    337      1.27  kiyohara 	{
    338      1.27  kiyohara 		OVERO_L4_PERIPHERAL_VBASE,
    339      1.27  kiyohara 		_A(OMAP3530_L4_PERIPHERAL_BASE),
    340      1.27  kiyohara 		_S(OMAP3530_L4_PERIPHERAL_SIZE),
    341      1.27  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    342      1.27  kiyohara 		PTE_NOCACHE
    343      1.15  kiyohara 	},
    344      1.30  kiyohara 	{
    345      1.30  kiyohara 		OVERO_GPMC_VBASE,
    346      1.30  kiyohara 		_A(GPMC_BASE),
    347      1.30  kiyohara 		_S(GPMC_SIZE),
    348      1.30  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    349      1.30  kiyohara 		PTE_NOCACHE
    350      1.30  kiyohara 	},
    351      1.27  kiyohara #endif
    352      1.27  kiyohara 	{ 0, 0, 0, 0, 0 }
    353       1.1  kiyohara };
    354       1.1  kiyohara 
    355       1.1  kiyohara #undef	_A
    356       1.1  kiyohara #undef	_S
    357       1.1  kiyohara 
    358       1.1  kiyohara 
    359       1.1  kiyohara /*
    360       1.1  kiyohara  * u_int initarm(...)
    361       1.1  kiyohara  *
    362       1.1  kiyohara  * Initial entry point on startup. This gets called before main() is
    363       1.1  kiyohara  * entered.
    364       1.1  kiyohara  * It should be responsible for setting up everything that must be
    365       1.1  kiyohara  * in place when main is called.
    366       1.1  kiyohara  * This includes
    367       1.1  kiyohara  *   Taking a copy of the boot configuration structure.
    368       1.1  kiyohara  *   Initialising the physical console so characters can be printed.
    369       1.1  kiyohara  *   Setting up page tables for the kernel
    370       1.1  kiyohara  *   Relocating the kernel to the bottom of physical memory
    371       1.1  kiyohara  */
    372       1.1  kiyohara u_int
    373       1.1  kiyohara initarm(void *arg)
    374       1.1  kiyohara {
    375  1.42.2.3       tls 	extern char KERNEL_BASE_phys[];
    376       1.1  kiyohara 	extern uint32_t *u_boot_args[];
    377      1.15  kiyohara 	extern uint32_t ram_size;
    378      1.15  kiyohara 	enum { r0 = 0, r1 = 1, r2 = 2, r3 = 3 }; /* args from u-boot */
    379      1.27  kiyohara 
    380      1.27  kiyohara 	/*
    381  1.42.2.3       tls 	 * We mapped PA == VA in gumstix_start.S.
    382  1.42.2.3       tls 	 * Also mapped SDRAM to KERNEL_BASE first 64Mbyte only with cachable.
    383      1.27  kiyohara 	 *
    384      1.27  kiyohara 	 * Gumstix (basix, connex, verdex, verdex-pro):
    385      1.27  kiyohara 	 * Physical Address Range     Description
    386      1.27  kiyohara 	 * -----------------------    ----------------------------------
    387      1.27  kiyohara 	 * 0x00000000 - 0x00ffffff    flash Memory   (16MB or 4MB)
    388      1.27  kiyohara 	 * 0x40000000 - 0x480fffff    Processor Registers
    389      1.27  kiyohara 	 * 0xa0000000 - 0xa3ffffff    SDRAM Bank 0 (64MB or 128MB)
    390  1.42.2.3       tls 	 * 0xc0000000 - 0xc3ffffff    KERNEL_BASE
    391      1.27  kiyohara 	 *
    392      1.27  kiyohara 	 * Overo:
    393      1.27  kiyohara 	 * Physical Address Range     Description
    394      1.27  kiyohara 	 * -----------------------    ----------------------------------
    395  1.42.2.3       tls 	 * 0x80000000 - 0x8fffffff    SDRAM Bank 0 (256MB or 512MB)
    396  1.42.2.3       tls 	 * 0x80000000 - 0x83ffffff    KERNEL_BASE
    397      1.27  kiyohara 	 */
    398      1.27  kiyohara 
    399  1.42.2.3       tls #if defined(GUMSTIX)
    400  1.42.2.3       tls 	cpu_reset_address = NULL;
    401  1.42.2.3       tls #elif defined(OVERO)
    402  1.42.2.3       tls 	cpu_reset_address = overo_reset;
    403  1.42.2.3       tls 
    404  1.42.2.3       tls 	find_cpu_clock();	// find our CPU speed.
    405  1.42.2.3       tls #endif
    406  1.42.2.3       tls 
    407      1.27  kiyohara 	/*
    408      1.27  kiyohara 	 * Heads up ... Setup the CPU / MMU / TLB functions
    409      1.27  kiyohara 	 */
    410      1.27  kiyohara 	if (set_cpufuncs())
    411      1.27  kiyohara 		panic("cpu not recognized!");
    412       1.1  kiyohara 
    413       1.1  kiyohara 	/* map some peripheral registers at static I/O area */
    414       1.1  kiyohara 	pmap_devmap_bootstrap((vaddr_t)read_ttb(), gumstix_devmap);
    415       1.1  kiyohara 
    416      1.27  kiyohara #if defined(CPU_XSCALE_PXA250) || defined(CPU_XSCALE_PXA270)
    417       1.1  kiyohara 	/* start 32.768kHz OSC */
    418      1.12     cliff 	ioreg_write(GUMSTIX_CLKMAN_VBASE + CLKMAN_OSCC, OSCC_OON);
    419       1.1  kiyohara 
    420       1.1  kiyohara 	/* Get ready for splfoo() */
    421       1.1  kiyohara 	pxa2x0_intr_bootstrap(GUMSTIX_INTCTL_VBASE);
    422       1.1  kiyohara 
    423      1.27  kiyohara 	/* setup GPIO for {FF,ST,HW}UART. */
    424      1.27  kiyohara 	pxa2x0_gpio_bootstrap(GUMSTIX_GPIO_VBASE);
    425      1.27  kiyohara 
    426      1.27  kiyohara 	pxa2x0_clkman_bootstrap(GUMSTIX_CLKMAN_VBASE);
    427      1.42      matt #elif defined(CPU_CORTEX)
    428      1.42      matt 	cortex_pmc_ccnt_init();
    429      1.27  kiyohara #endif
    430       1.1  kiyohara 
    431       1.1  kiyohara 	cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
    432       1.1  kiyohara 
    433       1.3  kiyohara 	/* configure GPIOs. */
    434       1.3  kiyohara 	gxio_config_pin();
    435       1.1  kiyohara 
    436      1.21  kiyohara 
    437      1.25  kiyohara #ifndef GUMSTIX_NETBSD_ARGS_CONSOLE
    438       1.1  kiyohara 	consinit();
    439      1.25  kiyohara #endif
    440       1.1  kiyohara #ifdef KGDB
    441       1.1  kiyohara 	kgdb_port_init();
    442       1.1  kiyohara #endif
    443       1.1  kiyohara 
    444  1.42.2.2       tls 	/*
    445       1.1  kiyohara 	 * Examine the boot args string for options we need to know about
    446       1.1  kiyohara 	 * now.
    447       1.1  kiyohara 	 */
    448      1.27  kiyohara #if defined(GUMSTIX)
    449      1.15  kiyohara #define SDRAM_START	0xa0000000UL
    450      1.27  kiyohara #elif defined(OVERO)
    451      1.27  kiyohara #define SDRAM_START	0x80000000UL
    452      1.27  kiyohara #endif
    453      1.15  kiyohara 	if (((uint32_t)u_boot_args[r0] & 0xf0000000) != SDRAM_START)
    454      1.15  kiyohara 		/* Maybe r0 is 'argc'.  We are booted by command 'go'. */
    455      1.15  kiyohara 		process_kernel_args((int)u_boot_args[r0],
    456      1.15  kiyohara 		    (char **)u_boot_args[r1]);
    457      1.15  kiyohara 	else
    458      1.15  kiyohara 		/*
    459      1.15  kiyohara 		 * Maybe r3 is 'boot args string' of 'bootm'.  This string is
    460      1.15  kiyohara 		 * linely.
    461      1.15  kiyohara 		 */
    462      1.25  kiyohara 		process_kernel_args_liner((char *)u_boot_args[r3]);
    463      1.25  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_CONSOLE
    464      1.25  kiyohara 	consinit();
    465      1.25  kiyohara #endif
    466      1.25  kiyohara 
    467      1.25  kiyohara 	/* Talk to the user */
    468      1.29  kiyohara #define BDSTR(s)	_BDSTR(s)
    469      1.29  kiyohara #define _BDSTR(s)	#s
    470      1.29  kiyohara 	printf("\nNetBSD/evbarm (" BDSTR(EVBARM_BOARDTYPE) ") booting ...\n");
    471      1.25  kiyohara 
    472      1.25  kiyohara 	/* Read system serial */
    473      1.27  kiyohara #if defined(GUMSTIX)
    474      1.25  kiyohara 	read_system_serial();
    475      1.27  kiyohara #endif
    476       1.1  kiyohara 
    477       1.6  kiyohara #ifdef VERBOSE_INIT_ARM
    478       1.1  kiyohara 	printf("initarm: Configuring system ...\n");
    479       1.6  kiyohara #endif
    480       1.1  kiyohara 
    481       1.1  kiyohara 	/* Fake bootconfig structure for the benefit of pmap.c */
    482       1.2       wiz 	/* XXX must make the memory description h/w independent */
    483       1.1  kiyohara 	bootconfig.dramblocks = 1;
    484  1.42.2.3       tls 	bootconfig.dram[0].address = SDRAM_START;
    485  1.42.2.3       tls 	bootconfig.dram[0].pages = ram_size / PAGE_SIZE;
    486       1.1  kiyohara 
    487  1.42.2.3       tls 	KASSERT(ram_size <= KERNEL_VM_BASE - KERNEL_BASE);
    488       1.1  kiyohara 
    489  1.42.2.3       tls 	arm32_bootmem_init(bootconfig.dram[0].address, ram_size,
    490  1.42.2.3       tls 	    (uintptr_t) KERNEL_BASE_phys);
    491  1.42.2.3       tls 	arm32_kernel_vm_init(KERNEL_VM_BASE,
    492      1.27  kiyohara #if defined(CPU_XSCALE_PXA250) || defined(CPU_XSCALE_PXA270)
    493  1.42.2.3       tls 	    ARM_VECTORS_LOW,
    494      1.27  kiyohara #elif defined(CPU_CORTEXA8)
    495  1.42.2.3       tls 	    ARM_VECTORS_HIGH,
    496       1.1  kiyohara #endif
    497  1.42.2.3       tls 	    0, gumstix_devmap, true);
    498       1.1  kiyohara 
    499      1.28  kiyohara 	evbarm_device_register = gumstix_device_register;
    500      1.28  kiyohara 
    501  1.42.2.3       tls 	return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0);
    502       1.1  kiyohara }
    503       1.1  kiyohara 
    504      1.27  kiyohara #if defined(GUMSTIX)
    505       1.3  kiyohara static void
    506      1.14    cegger read_system_serial(void)
    507       1.1  kiyohara {
    508       1.1  kiyohara #define GUMSTIX_SYSTEM_SERIAL_ADDR	0
    509       1.1  kiyohara #define GUMSTIX_SYSTEM_SERIAL_SIZE	8
    510       1.1  kiyohara #define FLASH_OFFSET_INTEL_PROTECTION	0x81
    511       1.1  kiyohara #define FLASH_OFFSET_USER_PROTECTION	0x85
    512       1.1  kiyohara #define FLASH_CMD_READ_ID		0x90
    513       1.1  kiyohara #define FLASH_CMD_RESET			0xff
    514       1.1  kiyohara 	int i;
    515       1.1  kiyohara 	char system_serial[GUMSTIX_SYSTEM_SERIAL_SIZE], *src;
    516       1.1  kiyohara 	char x;
    517       1.1  kiyohara 
    518       1.1  kiyohara 	src = (char *)(FLASH_OFFSET_USER_PROTECTION * 2 /*word*/);
    519       1.1  kiyohara 	*(volatile uint16_t *)0 = FLASH_CMD_READ_ID;
    520       1.1  kiyohara 	memcpy(system_serial,
    521       1.1  kiyohara 	    src + GUMSTIX_SYSTEM_SERIAL_ADDR, sizeof (system_serial));
    522       1.1  kiyohara 	*(volatile uint16_t *)0 = FLASH_CMD_RESET;
    523       1.1  kiyohara 
    524       1.1  kiyohara 	for (i = 1, x = system_serial[0]; i < sizeof (system_serial); i++)
    525       1.1  kiyohara 		x &= system_serial[i];
    526       1.1  kiyohara 	if (x == 0xff) {
    527       1.1  kiyohara 		src = (char *)(FLASH_OFFSET_INTEL_PROTECTION * 2 /*word*/);
    528       1.1  kiyohara 		*(volatile uint16_t *)0 = FLASH_CMD_READ_ID;
    529       1.1  kiyohara 		memcpy(system_serial,
    530       1.1  kiyohara 		    src + GUMSTIX_SYSTEM_SERIAL_ADDR, sizeof (system_serial));
    531       1.1  kiyohara 		*(volatile uint16_t *)0 = FLASH_CMD_RESET;
    532       1.1  kiyohara 
    533       1.1  kiyohara 		/*
    534       1.1  kiyohara 		 * XXXX: Don't need ???
    535       1.1  kiyohara 		 * gumstix_serial_hash(system_serial);
    536       1.1  kiyohara 		 */
    537       1.1  kiyohara 	}
    538       1.1  kiyohara 	system_serial_high = system_serial[0] << 24 | system_serial[1] << 16 |
    539       1.1  kiyohara 	    system_serial[2] << 8 | system_serial[3];
    540       1.1  kiyohara 	system_serial_low = system_serial[4] << 24 | system_serial[5] << 16 |
    541       1.1  kiyohara 	    system_serial[6] << 8 | system_serial[7];
    542       1.1  kiyohara 
    543       1.1  kiyohara 	printf("system serial: 0x");
    544       1.1  kiyohara 	for (i = 0; i < sizeof (system_serial); i++)
    545       1.1  kiyohara 		printf("%02x", system_serial[i]);
    546       1.1  kiyohara 	printf("\n");
    547       1.1  kiyohara }
    548  1.42.2.3       tls 
    549  1.42.2.3       tls #elif defined(OVERO)
    550  1.42.2.3       tls 
    551  1.42.2.3       tls static void
    552  1.42.2.3       tls overo_reset(void)
    553  1.42.2.3       tls {
    554  1.42.2.3       tls 
    555  1.42.2.3       tls #if NPRCM > 0
    556  1.42.2.3       tls 	prcm_cold_reset();
    557  1.42.2.3       tls #endif
    558  1.42.2.3       tls }
    559  1.42.2.3       tls 
    560  1.42.2.3       tls static void
    561  1.42.2.3       tls find_cpu_clock(void)
    562  1.42.2.3       tls {
    563  1.42.2.3       tls 	const vaddr_t prm_base = OMAP2_PRM_BASE;
    564  1.42.2.3       tls 	const vaddr_t cm_base = OMAP2_CM_BASE;
    565  1.42.2.3       tls 	const uint32_t prm_clksel =
    566  1.42.2.3       tls 	    *(volatile uint32_t *)(prm_base + PLL_MOD + OMAP3_PRM_CLKSEL);
    567  1.42.2.3       tls 	static const uint32_t prm_clksel_freqs[] = OMAP3_PRM_CLKSEL_FREQS;
    568  1.42.2.3       tls 	const uint32_t sys_clk =
    569  1.42.2.3       tls 	    prm_clksel_freqs[__SHIFTOUT(prm_clksel, OMAP3_PRM_CLKSEL_CLKIN)];
    570  1.42.2.3       tls 	const uint32_t dpll1 =
    571  1.42.2.3       tls 	    *(volatile uint32_t *)(cm_base + OMAP3_CM_CLKSEL1_PLL_MPU);
    572  1.42.2.3       tls 	const uint32_t dpll2 =
    573  1.42.2.3       tls 	    *(volatile uint32_t *)(cm_base + OMAP3_CM_CLKSEL2_PLL_MPU);
    574  1.42.2.3       tls 	const uint32_t m =
    575  1.42.2.3       tls 	    __SHIFTOUT(dpll1, OMAP3_CM_CLKSEL1_PLL_MPU_DPLL_MULT);
    576  1.42.2.3       tls 	const uint32_t n = __SHIFTOUT(dpll1, OMAP3_CM_CLKSEL1_PLL_MPU_DPLL_DIV);
    577  1.42.2.3       tls 	const uint32_t m2 =
    578  1.42.2.3       tls 	    __SHIFTOUT(dpll2, OMAP3_CM_CLKSEL2_PLL_MPU_DPLL_CLKOUT_DIV);
    579  1.42.2.3       tls 
    580  1.42.2.3       tls 	/*
    581  1.42.2.3       tls 	 * MPU_CLK supplies ARM_FCLK which is twice the CPU frequency.
    582  1.42.2.3       tls 	 */
    583  1.42.2.3       tls 	curcpu()->ci_data.cpu_cc_freq =
    584  1.42.2.3       tls 	    ((sys_clk * m) / ((n + 1) * m2 * 2)) * OMAP3_PRM_CLKSEL_MULT;
    585  1.42.2.3       tls 	omap_sys_clk = sys_clk * OMAP3_PRM_CLKSEL_MULT;
    586  1.42.2.3       tls }
    587      1.27  kiyohara #endif
    588       1.1  kiyohara 
    589      1.25  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_BUSHEADER
    590      1.15  kiyohara static const char busheader_name[] = "busheader=";
    591      1.25  kiyohara #endif
    592      1.30  kiyohara #if defined(GUMSTIX_NETBSD_ARGS_BUSHEADER) || \
    593      1.30  kiyohara     defined(GUMSTIX_NETBSD_ARGS_EXPANSION)
    594      1.30  kiyohara static const char expansion_name[] = "expansion=";
    595      1.30  kiyohara #endif
    596      1.25  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_CONSOLE
    597      1.25  kiyohara static const char console_name[] = "console=";
    598      1.25  kiyohara #endif
    599       1.3  kiyohara static void
    600       1.1  kiyohara process_kernel_args(int argc, char *argv[])
    601       1.1  kiyohara {
    602       1.5  kiyohara 	int gxio_configured = 0, i, j;
    603       1.1  kiyohara 
    604       1.1  kiyohara 	boothowto = 0;
    605       1.1  kiyohara 
    606       1.1  kiyohara 	for (i = 1, j = 0; i < argc; i++) {
    607      1.25  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_BUSHEADER
    608       1.1  kiyohara 		if (!strncmp(argv[i], busheader_name, strlen(busheader_name))) {
    609      1.30  kiyohara 			/* Configure for GPIOs of busheader side */
    610       1.5  kiyohara 			gxio_config_expansion(argv[i] + strlen(busheader_name));
    611       1.5  kiyohara 			gxio_configured = 1;
    612       1.1  kiyohara 			continue;
    613       1.1  kiyohara 		}
    614      1.25  kiyohara #endif
    615      1.30  kiyohara #if defined(GUMSTIX_NETBSD_ARGS_BUSHEADER) || \
    616      1.30  kiyohara     defined(GUMSTIX_NETBSD_ARGS_EXPANSION)
    617      1.30  kiyohara 		if (!strncmp(argv[i], expansion_name, strlen(expansion_name))) {
    618      1.30  kiyohara 			/* Configure expansion */
    619      1.30  kiyohara 			gxio_config_expansion(argv[i] + strlen(expansion_name));
    620      1.30  kiyohara 			gxio_configured = 1;
    621      1.30  kiyohara 			continue;
    622      1.30  kiyohara 		}
    623      1.30  kiyohara #endif
    624      1.25  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_CONSOLE
    625      1.25  kiyohara 		if (!strncmp(argv[i], console_name, strlen(console_name))) {
    626      1.25  kiyohara 			strncpy(console, argv[i] + strlen(console_name),
    627      1.25  kiyohara 			    sizeof(console));
    628      1.25  kiyohara 			consinit();
    629      1.25  kiyohara 		}
    630      1.25  kiyohara #endif
    631      1.38       mrg 		if (j == bootargs_len) {
    632       1.1  kiyohara 			*(bootargs + j) = '\0';
    633       1.1  kiyohara 			continue;
    634       1.1  kiyohara 		}
    635       1.1  kiyohara 		if (j != 0)
    636       1.1  kiyohara 			*(bootargs + j++) = ' ';
    637      1.38       mrg 		strncpy(bootargs + j, argv[i], bootargs_len - j);
    638      1.38       mrg 		bootargs[bootargs_len] = '\0';
    639       1.1  kiyohara 		j += strlen(argv[i]);
    640       1.1  kiyohara 	}
    641       1.1  kiyohara 	boot_args = bootargs;
    642       1.1  kiyohara 
    643       1.1  kiyohara 	parse_mi_bootargs(boot_args);
    644       1.5  kiyohara 
    645       1.5  kiyohara 	if (!gxio_configured)
    646       1.5  kiyohara 		gxio_config_expansion(NULL);
    647       1.1  kiyohara }
    648       1.1  kiyohara 
    649      1.15  kiyohara static void
    650      1.25  kiyohara process_kernel_args_liner(char *args)
    651      1.15  kiyohara {
    652      1.30  kiyohara 	int i = 0;
    653      1.25  kiyohara 	char *p = NULL;
    654      1.15  kiyohara 
    655      1.15  kiyohara 	boothowto = 0;
    656      1.15  kiyohara 
    657      1.15  kiyohara 	strncpy(bootargs, args, sizeof(bootargs));
    658      1.30  kiyohara #if defined(GUMSTIX_NETBSD_ARGS_BUSHEADER) || \
    659      1.30  kiyohara     defined(GUMSTIX_NETBSD_ARGS_EXPANSION)
    660      1.30  kiyohara 	{
    661      1.30  kiyohara 		char *q;
    662      1.30  kiyohara 
    663      1.30  kiyohara 		if ((p = strstr(bootargs, expansion_name)))
    664      1.30  kiyohara 			q = p + strlen(expansion_name);
    665      1.25  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_BUSHEADER
    666      1.31  kiyohara 		else if ((p = strstr(bootargs, busheader_name)))
    667      1.30  kiyohara 			q = p + strlen(busheader_name);
    668      1.30  kiyohara #endif
    669      1.30  kiyohara 		if (p) {
    670      1.30  kiyohara 			char expansion[256], c;
    671      1.25  kiyohara 
    672      1.30  kiyohara 			i = 0;
    673      1.30  kiyohara 			do {
    674      1.30  kiyohara 				c = *(q + i);
    675      1.30  kiyohara 				if (c == ' ')
    676      1.30  kiyohara 					c = '\0';
    677      1.30  kiyohara 				expansion[i++] = c;
    678      1.30  kiyohara 			} while (c != '\0' && i < sizeof(expansion));
    679      1.30  kiyohara 			gxio_config_expansion(expansion);
    680      1.30  kiyohara 			strcpy(p, q + i);
    681      1.30  kiyohara 		}
    682      1.15  kiyohara 	}
    683      1.25  kiyohara #endif
    684      1.27  kiyohara 	if (p == NULL)
    685      1.25  kiyohara 		gxio_config_expansion(NULL);
    686      1.25  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_CONSOLE
    687      1.25  kiyohara 	p = strstr(bootargs, console_name);
    688      1.25  kiyohara 	if (p != NULL) {
    689      1.25  kiyohara 		char c;
    690      1.25  kiyohara 
    691      1.30  kiyohara 		i = 0;
    692      1.25  kiyohara 		do {
    693      1.25  kiyohara 			c = *(p + strlen(console_name) + i);
    694      1.25  kiyohara 			if (c == ' ')
    695      1.25  kiyohara 				c = '\0';
    696      1.25  kiyohara 			console[i++] = c;
    697      1.25  kiyohara 		} while (c != '\0' && i < sizeof(console));
    698      1.25  kiyohara 		consinit();
    699      1.30  kiyohara 		strcpy(p, p + strlen(console_name) + i);
    700      1.25  kiyohara 	}
    701      1.25  kiyohara #endif
    702      1.15  kiyohara 	boot_args = bootargs;
    703      1.15  kiyohara 
    704      1.15  kiyohara 	parse_mi_bootargs(boot_args);
    705      1.15  kiyohara }
    706      1.15  kiyohara 
    707       1.1  kiyohara #ifdef KGDB
    708       1.1  kiyohara #ifndef KGDB_DEVNAME
    709       1.6  kiyohara #define KGDB_DEVNAME	"ffuart"
    710       1.1  kiyohara #endif
    711       1.1  kiyohara const char kgdb_devname[] = KGDB_DEVNAME;
    712       1.1  kiyohara 
    713       1.6  kiyohara #ifndef KGDB_DEVRATE
    714       1.6  kiyohara #define KGDB_DEVRATE	CONSPEED
    715       1.6  kiyohara #endif
    716       1.6  kiyohara int kgdb_devrate = KGDB_DEVRATE;
    717       1.6  kiyohara 
    718       1.1  kiyohara #if (NCOM > 0)
    719       1.1  kiyohara #ifndef KGDB_DEVMODE
    720       1.6  kiyohara #define KGDB_DEVMODE	CONMODE
    721       1.1  kiyohara #endif
    722       1.1  kiyohara int comkgdbmode = KGDB_DEVMODE;
    723       1.1  kiyohara #endif /* NCOM */
    724       1.1  kiyohara 
    725       1.1  kiyohara #endif /* KGDB */
    726       1.1  kiyohara 
    727       1.1  kiyohara 
    728       1.1  kiyohara void
    729       1.1  kiyohara consinit(void)
    730       1.1  kiyohara {
    731       1.1  kiyohara 	static int consinit_called = 0;
    732       1.1  kiyohara 
    733       1.1  kiyohara 	if (consinit_called != 0)
    734       1.1  kiyohara 		return;
    735       1.1  kiyohara 
    736       1.1  kiyohara 	consinit_called = 1;
    737       1.1  kiyohara 
    738       1.1  kiyohara #if NCOM > 0
    739       1.1  kiyohara 
    740      1.33  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_CONSOLE
    741      1.33  kiyohara 	/* Maybe passed Linux's bootargs 'console=ttyS?,<speed>...' */
    742      1.33  kiyohara 	if (strncmp(console, "ttyS", 4) == 0 && console[5] == ',') {
    743      1.33  kiyohara 		int i;
    744      1.33  kiyohara 
    745      1.33  kiyohara 		comcnspeed = 0;
    746      1.33  kiyohara 		for (i = 6; i < strlen(console) && isdigit(console[i]); i++)
    747      1.33  kiyohara 			comcnspeed = comcnspeed * 10 + (console[i] - '0');
    748      1.33  kiyohara 	}
    749      1.33  kiyohara #endif
    750      1.33  kiyohara 
    751      1.27  kiyohara #if defined(GUMSTIX)
    752      1.27  kiyohara 
    753       1.1  kiyohara #ifdef FFUARTCONSOLE
    754       1.1  kiyohara #ifdef KGDB
    755      1.25  kiyohara 	if (strcmp(kgdb_devname, "ffuart") == 0){
    756       1.1  kiyohara 		/* port is reserved for kgdb */
    757      1.17  kiyohara 	} else
    758       1.1  kiyohara #endif
    759      1.25  kiyohara #if defined(GUMSTIX_NETBSD_ARGS_CONSOLE)
    760      1.33  kiyohara 	if (console[0] == '\0' || strcasecmp(console, "ffuart") == 0 ||
    761      1.33  kiyohara 	    strncmp(console, "ttyS0,", 6) == 0)
    762      1.25  kiyohara #endif
    763       1.3  kiyohara 	{
    764      1.27  kiyohara 		int rv;
    765      1.27  kiyohara 
    766      1.25  kiyohara 		rv = comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_FFUART_BASE,
    767      1.25  kiyohara 		    comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode);
    768      1.25  kiyohara 		if (rv == 0) {
    769      1.21  kiyohara 			pxa2x0_clkman_config(CKEN_FFUART, 1);
    770       1.3  kiyohara 			return;
    771       1.3  kiyohara 		}
    772       1.1  kiyohara 	}
    773       1.1  kiyohara #endif /* FFUARTCONSOLE */
    774       1.1  kiyohara 
    775       1.3  kiyohara #ifdef STUARTCONSOLE
    776       1.3  kiyohara #ifdef KGDB
    777      1.25  kiyohara 	if (strcmp(kgdb_devname, "stuart") == 0) {
    778       1.3  kiyohara 		/* port is reserved for kgdb */
    779       1.3  kiyohara 	} else
    780       1.3  kiyohara #endif
    781      1.25  kiyohara #if defined(GUMSTIX_NETBSD_ARGS_CONSOLE)
    782      1.25  kiyohara 	if (console[0] == '\0' || strcasecmp(console, "stuart") == 0)
    783      1.25  kiyohara #endif
    784       1.3  kiyohara 	{
    785      1.27  kiyohara 		int rv;
    786      1.27  kiyohara 
    787      1.25  kiyohara 		rv = comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_STUART_BASE,
    788      1.25  kiyohara 		    comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode);
    789      1.25  kiyohara 		if (rv == 0) {
    790      1.21  kiyohara 			pxa2x0_clkman_config(CKEN_STUART, 1);
    791       1.3  kiyohara 			return;
    792       1.3  kiyohara 		}
    793       1.3  kiyohara 	}
    794       1.3  kiyohara #endif /* STUARTCONSOLE */
    795       1.3  kiyohara 
    796       1.1  kiyohara #ifdef BTUARTCONSOLE
    797       1.1  kiyohara #ifdef KGDB
    798      1.25  kiyohara 	if (strcmp(kgdb_devname, "btuart") == 0) {
    799       1.1  kiyohara 		/* port is reserved for kgdb */
    800       1.1  kiyohara 	} else
    801       1.1  kiyohara #endif
    802      1.25  kiyohara #if defined(GUMSTIX_NETBSD_ARGS_CONSOLE)
    803      1.25  kiyohara 	if (console[0] == '\0' || strcasecmp(console, "btuart") == 0)
    804      1.25  kiyohara #endif
    805       1.3  kiyohara 	{
    806      1.27  kiyohara 		int rv;
    807      1.27  kiyohara 
    808      1.25  kiyohara 		rv = comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_BTUART_BASE,
    809      1.25  kiyohara 		    comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode);
    810      1.25  kiyohara 		if (rv == 0) {
    811      1.21  kiyohara 			pxa2x0_clkman_config(CKEN_BTUART, 1);
    812       1.3  kiyohara 			return;
    813       1.3  kiyohara 		}
    814       1.1  kiyohara 	}
    815       1.1  kiyohara #endif /* BTUARTCONSOLE */
    816       1.1  kiyohara 
    817       1.3  kiyohara #ifdef HWUARTCONSOLE
    818       1.3  kiyohara #ifdef KGDB
    819      1.25  kiyohara 	if (strcmp(kgdb_devname, "hwuart") == 0) {
    820       1.3  kiyohara 		/* port is reserved for kgdb */
    821       1.3  kiyohara 	} else
    822       1.3  kiyohara #endif
    823      1.25  kiyohara #if defined(GUMSTIX_NETBSD_ARGS_CONSOLE)
    824      1.25  kiyohara 	if (console[0] == '\0' || strcasecmp(console, "hwuart") == 0)
    825      1.25  kiyohara #endif
    826       1.3  kiyohara 	{
    827      1.25  kiyohara 		rv = comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_HWUART_BASE,
    828      1.25  kiyohara 		    comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode);
    829      1.25  kiyohara 		if (rv == 0) {
    830      1.21  kiyohara 			pxa2x0_clkman_config(CKEN_HWUART, 1);
    831       1.3  kiyohara 			return;
    832       1.3  kiyohara 		}
    833       1.3  kiyohara 	}
    834       1.3  kiyohara #endif /* HWUARTCONSOLE */
    835       1.1  kiyohara 
    836      1.27  kiyohara #elif defined(OVERO)
    837      1.27  kiyohara 
    838      1.27  kiyohara 	if (comcnattach(&omap_a4x_bs_tag, 0x49020000, comcnspeed,
    839      1.27  kiyohara 	    OMAP_COM_FREQ, COM_TYPE_NORMAL, comcnmode) == 0)
    840      1.27  kiyohara 		return;
    841      1.27  kiyohara 
    842      1.27  kiyohara #endif /* GUMSTIX or OVERO */
    843      1.27  kiyohara 
    844       1.1  kiyohara #endif /* NCOM */
    845       1.1  kiyohara 
    846      1.15  kiyohara #if NLCD > 0
    847      1.25  kiyohara #if defined(GUMSTIX_NETBSD_ARGS_CONSOLE)
    848      1.25  kiyohara 	if (console[0] == '\0' || strcasecmp(console, "lcd") == 0)
    849      1.25  kiyohara #endif
    850      1.25  kiyohara 	{
    851      1.25  kiyohara 		gxlcd_cnattach();
    852      1.25  kiyohara 	}
    853      1.15  kiyohara #endif
    854       1.1  kiyohara }
    855       1.1  kiyohara 
    856       1.1  kiyohara #ifdef KGDB
    857       1.3  kiyohara static void
    858       1.1  kiyohara kgdb_port_init(void)
    859       1.1  kiyohara {
    860       1.1  kiyohara #if (NCOM > 0) && defined(COM_PXA2X0)
    861       1.1  kiyohara 	paddr_t paddr = 0;
    862      1.21  kiyohara 	int cken = 0;
    863       1.1  kiyohara 
    864       1.1  kiyohara 	if (0 == strcmp(kgdb_devname, "ffuart")) {
    865       1.1  kiyohara 		paddr = PXA2X0_FFUART_BASE;
    866      1.21  kiyohara 		cken = CKEN_FFUART;
    867       1.3  kiyohara 	} else if (0 == strcmp(kgdb_devname, "stuart")) {
    868       1.3  kiyohara 		paddr = PXA2X0_STUART_BASE;
    869      1.21  kiyohara 		cken = CKEN_STUART;
    870       1.3  kiyohara 	} else if (0 == strcmp(kgdb_devname, "btuart")) {
    871       1.1  kiyohara 		paddr = PXA2X0_BTUART_BASE;
    872      1.21  kiyohara 		cken = CKEN_BTUART;
    873       1.3  kiyohara 	} else if (0 == strcmp(kgdb_devname, "hwuart")) {
    874       1.3  kiyohara 		paddr = PXA2X0_HWUART_BASE;
    875      1.21  kiyohara 		cken = CKEN_HWUART;
    876       1.1  kiyohara 	}
    877       1.1  kiyohara 
    878       1.1  kiyohara 	if (paddr &&
    879       1.1  kiyohara 	    0 == com_kgdb_attach(&pxa2x0_a4x_bs_tag, paddr,
    880       1.6  kiyohara 		kgdb_devrate, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comkgdbmode)) {
    881       1.1  kiyohara 
    882      1.21  kiyohara 		pxa2x0_clkman_config(cken, 1);
    883       1.1  kiyohara 	}
    884       1.1  kiyohara 
    885       1.1  kiyohara #endif
    886       1.1  kiyohara }
    887       1.1  kiyohara #endif
    888      1.28  kiyohara 
    889      1.28  kiyohara static void
    890      1.28  kiyohara gumstix_device_register(device_t dev, void *aux)
    891      1.28  kiyohara {
    892  1.42.2.2       tls 	prop_dictionary_t dict = device_properties(dev);
    893      1.28  kiyohara 
    894  1.42.2.2       tls 	if (device_is_a(dev, "ehci")) {
    895  1.42.2.3       tls 		prop_dictionary_set_uint16(dict, "nports", 2);
    896  1.42.2.2       tls 		prop_dictionary_set_bool(dict, "phy-reset", true);
    897  1.42.2.3       tls 		prop_dictionary_set_cstring(dict, "port0-mode", "none");
    898  1.42.2.2       tls 		prop_dictionary_set_int16(dict, "port0-gpio", -1);
    899  1.42.2.3       tls 		prop_dictionary_set_cstring(dict, "port1-mode", "phy");
    900  1.42.2.2       tls 		prop_dictionary_set_int16(dict, "port1-gpio", 183);
    901  1.42.2.3       tls 		prop_dictionary_set_bool(dict, "port1-gpioval", true);
    902  1.42.2.3       tls 		prop_dictionary_set_uint16(dict, "dpll5-m", 443);
    903  1.42.2.3       tls 		prop_dictionary_set_uint16(dict, "dpll5-n", 11);
    904  1.42.2.3       tls 		prop_dictionary_set_uint16(dict, "dpll5-m2", 4);
    905  1.42.2.2       tls 	}
    906      1.28  kiyohara 	if (device_is_a(dev, "ohci")) {
    907  1.42.2.2       tls 		if (prop_dictionary_set_bool(dict,
    908      1.28  kiyohara 		    "Ganged-power-mask-on-port1", 1) == false) {
    909      1.28  kiyohara 			printf("WARNING: unable to set power-mask for port1"
    910  1.42.2.1       tls 			    " property for %s\n", device_xname(dev));
    911      1.28  kiyohara 		}
    912  1.42.2.2       tls 		if (prop_dictionary_set_bool(dict,
    913      1.28  kiyohara 		    "Ganged-power-mask-on-port2", 1) == false) {
    914      1.28  kiyohara 			printf("WARNING: unable to set power-mask for port2"
    915  1.42.2.1       tls 			    " property for %s\n", device_xname(dev));
    916      1.28  kiyohara 		}
    917  1.42.2.2       tls 		if (prop_dictionary_set_bool(dict,
    918      1.28  kiyohara 		    "Ganged-power-mask-on-port3", 1) == false) {
    919      1.28  kiyohara 			printf("WARNING: unable to set power-mask for port3"
    920  1.42.2.1       tls 			    " property for %s\n", device_xname(dev));
    921      1.28  kiyohara 		}
    922      1.28  kiyohara 	}
    923      1.28  kiyohara }
    924