Home | History | Annotate | Line # | Download | only in gumstix
gumstix_machdep.c revision 1.72
      1  1.72  jmcneill /*	$NetBSD: gumstix_machdep.c,v 1.72 2022/10/29 13:10:25 jmcneill 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.60     skrll #include "opt_arm_debug.h"
    141  1.52  kiyohara #include "opt_com.h"
    142  1.61     skrll #include "opt_console.h"
    143  1.52  kiyohara #include "opt_cputypes.h"
    144  1.29  kiyohara #include "opt_evbarm_boardtype.h"
    145  1.31  kiyohara #include "opt_gumstix.h"
    146  1.52  kiyohara #include "opt_kgdb.h"
    147  1.67  jmcneill 
    148   1.1  kiyohara #include <sys/param.h>
    149  1.26  kiyohara #include <sys/conf.h>
    150   1.1  kiyohara #include <sys/device.h>
    151  1.26  kiyohara #include <sys/exec.h>
    152   1.1  kiyohara #include <sys/kernel.h>
    153   1.1  kiyohara #include <sys/proc.h>
    154   1.1  kiyohara #include <sys/reboot.h>
    155  1.26  kiyohara #include <sys/systm.h>
    156   1.1  kiyohara #include <sys/termios.h>
    157  1.47      matt #include <sys/bus.h>
    158  1.47      matt #include <sys/cpu.h>
    159  1.52  kiyohara #include <sys/gpio.h>
    160  1.52  kiyohara 
    161  1.52  kiyohara #include <prop/proplib.h>
    162   1.1  kiyohara 
    163  1.49  kiyohara #include <uvm/uvm_extern.h>
    164  1.49  kiyohara 
    165  1.52  kiyohara #include <arm/mainbus/mainbus.h>	/* don't reorder */
    166  1.52  kiyohara 
    167  1.52  kiyohara #include <machine/autoconf.h>		/* don't reorder */
    168   1.1  kiyohara #include <machine/bootconfig.h>
    169  1.47      matt #include <arm/locore.h>
    170   1.1  kiyohara 
    171   1.1  kiyohara #include <arm/arm32/machdep.h>
    172  1.62     skrll 
    173   1.1  kiyohara #include <arm/xscale/pxa2x0reg.h>
    174   1.1  kiyohara #include <arm/xscale/pxa2x0var.h>
    175   1.1  kiyohara #include <arm/xscale/pxa2x0_gpio.h>
    176   1.1  kiyohara #include <evbarm/gumstix/gumstixreg.h>
    177   1.1  kiyohara #include <evbarm/gumstix/gumstixvar.h>
    178   1.1  kiyohara 
    179  1.26  kiyohara #include <dev/cons.h>
    180  1.26  kiyohara 
    181  1.26  kiyohara #ifdef KGDB
    182  1.26  kiyohara #include <sys/kgdb.h>
    183  1.26  kiyohara #endif
    184  1.26  kiyohara 
    185  1.62     skrll #ifdef VERBOSE_INIT_ARM
    186  1.62     skrll #define VPRINTF(...)	printf(__VA_ARGS__)
    187  1.62     skrll #else
    188  1.62     skrll #define VPRINTF(...)	__nothing
    189  1.62     skrll #endif
    190  1.62     skrll 
    191   1.1  kiyohara /*
    192  1.58     skrll  * The range 0xc1000000 - 0xfd000000 is available for kernel VM space
    193  1.58     skrll  * Core-logic registers and I/O mappings occupy
    194  1.58     skrll  *
    195  1.58     skrll  *    0xfd000000 - 0xfd800000	on gumstix
    196   1.1  kiyohara  */
    197  1.49  kiyohara #ifndef KERNEL_VM_BASE
    198  1.58     skrll #define	KERNEL_VM_BASE		0xc8000000
    199  1.49  kiyohara #endif
    200  1.58     skrll #define KERNEL_VM_SIZE		0x35000000
    201   1.1  kiyohara 
    202   1.1  kiyohara BootConfig bootconfig;		/* Boot config storage */
    203   1.1  kiyohara static char bootargs[MAX_BOOT_STRING];
    204  1.38       mrg const size_t bootargs_len = sizeof(bootargs) - 1;	/* without nul */
    205   1.1  kiyohara char *boot_args = NULL;
    206   1.1  kiyohara 
    207   1.1  kiyohara uint32_t system_serial_high;
    208   1.1  kiyohara uint32_t system_serial_low;
    209   1.1  kiyohara 
    210   1.1  kiyohara /* Prototypes */
    211  1.27  kiyohara #if defined(GUMSTIX)
    212   1.3  kiyohara static void	read_system_serial(void);
    213  1.52  kiyohara #endif
    214   1.3  kiyohara static void	process_kernel_args(int, char *[]);
    215  1.25  kiyohara static void	process_kernel_args_liner(char *);
    216   1.3  kiyohara #ifdef KGDB
    217   1.3  kiyohara static void	kgdb_port_init(void);
    218   1.3  kiyohara #endif
    219  1.28  kiyohara static void	gumstix_device_register(device_t, void *);
    220   1.1  kiyohara 
    221   1.1  kiyohara bs_protos(bs_notimpl);
    222   1.1  kiyohara 
    223   1.1  kiyohara #include "com.h"
    224   1.1  kiyohara #if NCOM > 0
    225   1.1  kiyohara #include <dev/ic/comreg.h>
    226   1.1  kiyohara #include <dev/ic/comvar.h>
    227   1.1  kiyohara #endif
    228   1.1  kiyohara 
    229  1.52  kiyohara #if defined(CPU_XSCALE)
    230  1.15  kiyohara #include "lcd.h"
    231  1.27  kiyohara #endif
    232  1.15  kiyohara 
    233   1.1  kiyohara #ifndef CONSPEED
    234   1.1  kiyohara #define CONSPEED B115200	/* It's a setting of the default of u-boot */
    235   1.1  kiyohara #endif
    236   1.1  kiyohara #ifndef CONMODE
    237   1.1  kiyohara #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
    238   1.1  kiyohara #endif
    239   1.1  kiyohara 
    240   1.1  kiyohara int comcnspeed = CONSPEED;
    241   1.1  kiyohara int comcnmode = CONMODE;
    242   1.1  kiyohara 
    243  1.25  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_CONSOLE
    244  1.25  kiyohara static char console[16];
    245  1.25  kiyohara #endif
    246  1.25  kiyohara 
    247  1.55  kiyohara const struct tifb_panel_info *tifb_panel_info = NULL;
    248  1.52  kiyohara /* Use TPS65217 White LED Driver */
    249  1.52  kiyohara bool use_tps65217_wled = false;
    250  1.52  kiyohara 
    251  1.52  kiyohara extern void gxio_config(void);
    252   1.5  kiyohara extern void gxio_config_expansion(char *);
    253   1.3  kiyohara 
    254   1.1  kiyohara 
    255  1.25  kiyohara static inline pd_entry_t *
    256   1.1  kiyohara read_ttb(void)
    257   1.1  kiyohara {
    258  1.27  kiyohara 	long ttb;
    259   1.1  kiyohara 
    260  1.27  kiyohara 	__asm volatile("mrc	p15, 0, %0, c2, c0, 0" : "=r" (ttb));
    261   1.1  kiyohara 
    262  1.27  kiyohara 	return (pd_entry_t *)(ttb & ~((1<<14)-1));
    263   1.1  kiyohara }
    264   1.1  kiyohara 
    265   1.1  kiyohara /*
    266   1.1  kiyohara  * Static device mappings. These peripheral registers are mapped at
    267   1.1  kiyohara  * fixed virtual addresses very early in initarm() so that we can use
    268   1.1  kiyohara  * them while booting the kernel, and stay at the same address
    269   1.1  kiyohara  * throughout whole kernel's life time.
    270   1.1  kiyohara  *
    271   1.1  kiyohara  * We use this table twice; once with bootstrap page table, and once
    272   1.1  kiyohara  * with kernel's page table which we build up in initarm().
    273   1.1  kiyohara  *
    274   1.1  kiyohara  * Since we map these registers into the bootstrap page table using
    275   1.1  kiyohara  * pmap_devmap_bootstrap() which calls pmap_map_chunk(), we map
    276   1.1  kiyohara  * registers segment-aligned and segment-rounded in order to avoid
    277   1.1  kiyohara  * using the 2nd page tables.
    278   1.1  kiyohara  */
    279   1.1  kiyohara 
    280   1.1  kiyohara #define	_A(a)	((a) & ~L1_S_OFFSET)
    281   1.1  kiyohara #define	_S(s)	(((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1))
    282   1.1  kiyohara 
    283   1.1  kiyohara static const struct pmap_devmap gumstix_devmap[] = {
    284  1.27  kiyohara #if defined(GUMSTIX)
    285   1.1  kiyohara 	{
    286   1.1  kiyohara 		GUMSTIX_GPIO_VBASE,
    287   1.1  kiyohara 		_A(PXA2X0_GPIO_BASE),
    288   1.1  kiyohara 		_S(PXA250_GPIO_SIZE),
    289  1.27  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    290  1.27  kiyohara 		PTE_NOCACHE,
    291   1.1  kiyohara 	},
    292   1.1  kiyohara 	{
    293  1.12     cliff 		GUMSTIX_CLKMAN_VBASE,
    294  1.12     cliff 		_A(PXA2X0_CLKMAN_BASE),
    295  1.12     cliff 		_S(PXA2X0_CLKMAN_SIZE),
    296  1.27  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    297  1.27  kiyohara 		PTE_NOCACHE,
    298   1.1  kiyohara 	},
    299   1.1  kiyohara 	{
    300   1.1  kiyohara 		GUMSTIX_INTCTL_VBASE,
    301   1.1  kiyohara 		_A(PXA2X0_INTCTL_BASE),
    302   1.1  kiyohara 		_S(PXA2X0_INTCTL_SIZE),
    303  1.27  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    304  1.27  kiyohara 		PTE_NOCACHE,
    305   1.1  kiyohara 	},
    306   1.1  kiyohara 	{
    307   1.1  kiyohara 		GUMSTIX_FFUART_VBASE,
    308   1.1  kiyohara 		_A(PXA2X0_FFUART_BASE),
    309   1.1  kiyohara 		_S(4 * COM_NPORTS),
    310  1.27  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    311  1.27  kiyohara 		PTE_NOCACHE,
    312   1.1  kiyohara 	},
    313   1.1  kiyohara 	{
    314   1.3  kiyohara 		GUMSTIX_STUART_VBASE,
    315   1.3  kiyohara 		_A(PXA2X0_STUART_BASE),
    316   1.3  kiyohara 		_S(4 * COM_NPORTS),
    317  1.27  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    318  1.27  kiyohara 		PTE_NOCACHE,
    319   1.3  kiyohara 	},
    320   1.3  kiyohara 	{
    321   1.1  kiyohara 		GUMSTIX_BTUART_VBASE,
    322   1.1  kiyohara 		_A(PXA2X0_BTUART_BASE),
    323   1.1  kiyohara 		_S(4 * COM_NPORTS),
    324  1.27  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    325  1.27  kiyohara 		PTE_NOCACHE,
    326   1.1  kiyohara 	},
    327   1.3  kiyohara 	{
    328   1.3  kiyohara 		GUMSTIX_HWUART_VBASE,
    329   1.3  kiyohara 		_A(PXA2X0_HWUART_BASE),
    330   1.3  kiyohara 		_S(4 * COM_NPORTS),
    331  1.27  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    332  1.27  kiyohara 		PTE_NOCACHE,
    333   1.3  kiyohara 	},
    334  1.15  kiyohara 	{
    335  1.15  kiyohara 		GUMSTIX_LCDC_VBASE,
    336  1.15  kiyohara 		_A(PXA2X0_LCDC_BASE),
    337  1.15  kiyohara 		_S(4 * COM_NPORTS),
    338  1.27  kiyohara 		VM_PROT_READ | VM_PROT_WRITE,
    339  1.27  kiyohara 		PTE_NOCACHE,
    340  1.27  kiyohara 	},
    341  1.27  kiyohara #endif
    342  1.27  kiyohara 	{ 0, 0, 0, 0, 0 }
    343   1.1  kiyohara };
    344   1.1  kiyohara 
    345   1.1  kiyohara #undef	_A
    346   1.1  kiyohara #undef	_S
    347   1.1  kiyohara 
    348  1.62     skrll extern uint32_t *uboot_args;
    349   1.1  kiyohara 
    350   1.1  kiyohara /*
    351  1.63     skrll  * vaddr_t initarm(...)
    352   1.1  kiyohara  *
    353   1.1  kiyohara  * Initial entry point on startup. This gets called before main() is
    354   1.1  kiyohara  * entered.
    355   1.1  kiyohara  * It should be responsible for setting up everything that must be
    356   1.1  kiyohara  * in place when main is called.
    357   1.1  kiyohara  * This includes
    358   1.1  kiyohara  *   Taking a copy of the boot configuration structure.
    359   1.1  kiyohara  *   Initialising the physical console so characters can be printed.
    360   1.1  kiyohara  *   Setting up page tables for the kernel
    361   1.1  kiyohara  *   Relocating the kernel to the bottom of physical memory
    362   1.1  kiyohara  */
    363  1.63     skrll vaddr_t
    364   1.1  kiyohara initarm(void *arg)
    365   1.1  kiyohara {
    366  1.49  kiyohara 	extern char KERNEL_BASE_phys[];
    367  1.62     skrll 	uint32_t ram_size = 0x400000;
    368  1.15  kiyohara 	enum { r0 = 0, r1 = 1, r2 = 2, r3 = 3 }; /* args from u-boot */
    369  1.27  kiyohara 
    370  1.62     skrll #if defined(CPU_XSCALE)
    371  1.62     skrll 
    372  1.27  kiyohara 	/*
    373  1.48  kiyohara 	 * We mapped PA == VA in gumstix_start.S.
    374  1.48  kiyohara 	 * Also mapped SDRAM to KERNEL_BASE first 64Mbyte only with cachable.
    375  1.27  kiyohara 	 *
    376  1.27  kiyohara 	 * Gumstix (basix, connex, verdex, verdex-pro):
    377  1.27  kiyohara 	 * Physical Address Range     Description
    378  1.27  kiyohara 	 * -----------------------    ----------------------------------
    379  1.27  kiyohara 	 * 0x00000000 - 0x00ffffff    flash Memory   (16MB or 4MB)
    380  1.27  kiyohara 	 * 0x40000000 - 0x480fffff    Processor Registers
    381  1.27  kiyohara 	 * 0xa0000000 - 0xa3ffffff    SDRAM Bank 0 (64MB or 128MB)
    382  1.48  kiyohara 	 * 0xc0000000 - 0xc3ffffff    KERNEL_BASE
    383  1.27  kiyohara 	 */
    384  1.58     skrll 	extern vaddr_t xscale_cache_clean_addr;
    385  1.58     skrll 	xscale_cache_clean_addr = 0xff000000U;
    386  1.58     skrll 
    387  1.49  kiyohara 	cpu_reset_address = NULL;
    388  1.48  kiyohara #endif
    389  1.48  kiyohara 
    390  1.27  kiyohara 	/*
    391  1.27  kiyohara 	 * Heads up ... Setup the CPU / MMU / TLB functions
    392  1.27  kiyohara 	 */
    393  1.27  kiyohara 	if (set_cpufuncs())
    394  1.27  kiyohara 		panic("cpu not recognized!");
    395   1.1  kiyohara 
    396   1.1  kiyohara 	/* map some peripheral registers at static I/O area */
    397   1.1  kiyohara 	pmap_devmap_bootstrap((vaddr_t)read_ttb(), gumstix_devmap);
    398   1.1  kiyohara 
    399  1.52  kiyohara #if defined(CPU_XSCALE)
    400   1.1  kiyohara 	/* start 32.768kHz OSC */
    401  1.12     cliff 	ioreg_write(GUMSTIX_CLKMAN_VBASE + CLKMAN_OSCC, OSCC_OON);
    402   1.1  kiyohara 
    403   1.1  kiyohara 	/* Get ready for splfoo() */
    404   1.1  kiyohara 	pxa2x0_intr_bootstrap(GUMSTIX_INTCTL_VBASE);
    405   1.1  kiyohara 
    406  1.27  kiyohara 	/* setup GPIO for {FF,ST,HW}UART. */
    407  1.27  kiyohara 	pxa2x0_gpio_bootstrap(GUMSTIX_GPIO_VBASE);
    408  1.27  kiyohara 
    409  1.27  kiyohara 	pxa2x0_clkman_bootstrap(GUMSTIX_CLKMAN_VBASE);
    410  1.27  kiyohara #endif
    411   1.1  kiyohara 
    412   1.1  kiyohara 	cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
    413   1.1  kiyohara 
    414  1.52  kiyohara 	/* configure MUX, GPIO and CLK. */
    415  1.52  kiyohara 	gxio_config();
    416  1.21  kiyohara 
    417  1.25  kiyohara #ifndef GUMSTIX_NETBSD_ARGS_CONSOLE
    418   1.1  kiyohara 	consinit();
    419  1.25  kiyohara #endif
    420   1.1  kiyohara #ifdef KGDB
    421   1.1  kiyohara 	kgdb_port_init();
    422   1.1  kiyohara #endif
    423   1.1  kiyohara 
    424  1.46  kiyohara 	/*
    425   1.1  kiyohara 	 * Examine the boot args string for options we need to know about
    426   1.1  kiyohara 	 * now.
    427   1.1  kiyohara 	 */
    428  1.27  kiyohara #if defined(GUMSTIX)
    429  1.15  kiyohara #define SDRAM_START	0xa0000000UL
    430  1.27  kiyohara #endif
    431  1.62     skrll 	if (uboot_args[r0] < SDRAM_START ||
    432  1.62     skrll 	    uboot_args[r0] >= SDRAM_START + ram_size)
    433  1.15  kiyohara 		/* Maybe r0 is 'argc'.  We are booted by command 'go'. */
    434  1.62     skrll 		process_kernel_args(uboot_args[r0], (char **)uboot_args[r1]);
    435  1.15  kiyohara 	else
    436  1.15  kiyohara 		/*
    437  1.15  kiyohara 		 * Maybe r3 is 'boot args string' of 'bootm'.  This string is
    438  1.15  kiyohara 		 * linely.
    439  1.15  kiyohara 		 */
    440  1.62     skrll 		process_kernel_args_liner((char *)uboot_args[r3]);
    441  1.25  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_CONSOLE
    442  1.25  kiyohara 	consinit();
    443  1.25  kiyohara #endif
    444  1.25  kiyohara 
    445  1.25  kiyohara 	/* Talk to the user */
    446  1.29  kiyohara #define BDSTR(s)	_BDSTR(s)
    447  1.29  kiyohara #define _BDSTR(s)	#s
    448  1.29  kiyohara 	printf("\nNetBSD/evbarm (" BDSTR(EVBARM_BOARDTYPE) ") booting ...\n");
    449  1.25  kiyohara 
    450  1.25  kiyohara 	/* Read system serial */
    451  1.27  kiyohara #if defined(GUMSTIX)
    452  1.25  kiyohara 	read_system_serial();
    453  1.27  kiyohara #endif
    454   1.1  kiyohara 
    455  1.62     skrll 	VPRINTF("initarm: Configuring system ...\n");
    456   1.1  kiyohara 
    457   1.1  kiyohara 	/* Fake bootconfig structure for the benefit of pmap.c */
    458   1.2       wiz 	/* XXX must make the memory description h/w independent */
    459   1.1  kiyohara 	bootconfig.dramblocks = 1;
    460  1.49  kiyohara 	bootconfig.dram[0].address = SDRAM_START;
    461  1.49  kiyohara 	bootconfig.dram[0].pages = ram_size / PAGE_SIZE;
    462   1.1  kiyohara 
    463  1.49  kiyohara 	KASSERT(ram_size <= KERNEL_VM_BASE - KERNEL_BASE);
    464   1.1  kiyohara 
    465  1.49  kiyohara 	arm32_bootmem_init(bootconfig.dram[0].address, ram_size,
    466  1.49  kiyohara 	    (uintptr_t) KERNEL_BASE_phys);
    467  1.49  kiyohara 	arm32_kernel_vm_init(KERNEL_VM_BASE,
    468  1.52  kiyohara #if defined(CPU_XSCALE)
    469  1.49  kiyohara 	    ARM_VECTORS_LOW,
    470  1.27  kiyohara #endif
    471  1.49  kiyohara 	    0, gumstix_devmap, true);
    472   1.1  kiyohara 
    473  1.28  kiyohara 	evbarm_device_register = gumstix_device_register;
    474  1.28  kiyohara 
    475  1.72  jmcneill 	return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0);
    476   1.1  kiyohara }
    477   1.1  kiyohara 
    478  1.27  kiyohara #if defined(GUMSTIX)
    479   1.3  kiyohara static void
    480  1.14    cegger read_system_serial(void)
    481   1.1  kiyohara {
    482   1.1  kiyohara #define GUMSTIX_SYSTEM_SERIAL_ADDR	0
    483   1.1  kiyohara #define GUMSTIX_SYSTEM_SERIAL_SIZE	8
    484   1.1  kiyohara #define FLASH_OFFSET_INTEL_PROTECTION	0x81
    485   1.1  kiyohara #define FLASH_OFFSET_USER_PROTECTION	0x85
    486   1.1  kiyohara #define FLASH_CMD_READ_ID		0x90
    487   1.1  kiyohara #define FLASH_CMD_RESET			0xff
    488   1.1  kiyohara 	int i;
    489   1.1  kiyohara 	char system_serial[GUMSTIX_SYSTEM_SERIAL_SIZE], *src;
    490   1.1  kiyohara 	char x;
    491   1.1  kiyohara 
    492   1.1  kiyohara 	src = (char *)(FLASH_OFFSET_USER_PROTECTION * 2 /*word*/);
    493   1.1  kiyohara 	*(volatile uint16_t *)0 = FLASH_CMD_READ_ID;
    494   1.1  kiyohara 	memcpy(system_serial,
    495   1.1  kiyohara 	    src + GUMSTIX_SYSTEM_SERIAL_ADDR, sizeof (system_serial));
    496   1.1  kiyohara 	*(volatile uint16_t *)0 = FLASH_CMD_RESET;
    497   1.1  kiyohara 
    498   1.1  kiyohara 	for (i = 1, x = system_serial[0]; i < sizeof (system_serial); i++)
    499   1.1  kiyohara 		x &= system_serial[i];
    500   1.1  kiyohara 	if (x == 0xff) {
    501   1.1  kiyohara 		src = (char *)(FLASH_OFFSET_INTEL_PROTECTION * 2 /*word*/);
    502   1.1  kiyohara 		*(volatile uint16_t *)0 = FLASH_CMD_READ_ID;
    503   1.1  kiyohara 		memcpy(system_serial,
    504   1.1  kiyohara 		    src + GUMSTIX_SYSTEM_SERIAL_ADDR, sizeof (system_serial));
    505   1.1  kiyohara 		*(volatile uint16_t *)0 = FLASH_CMD_RESET;
    506   1.1  kiyohara 
    507   1.1  kiyohara 		/*
    508   1.1  kiyohara 		 * XXXX: Don't need ???
    509   1.1  kiyohara 		 * gumstix_serial_hash(system_serial);
    510   1.1  kiyohara 		 */
    511   1.1  kiyohara 	}
    512   1.1  kiyohara 	system_serial_high = system_serial[0] << 24 | system_serial[1] << 16 |
    513   1.1  kiyohara 	    system_serial[2] << 8 | system_serial[3];
    514   1.1  kiyohara 	system_serial_low = system_serial[4] << 24 | system_serial[5] << 16 |
    515   1.1  kiyohara 	    system_serial[6] << 8 | system_serial[7];
    516   1.1  kiyohara 
    517   1.1  kiyohara 	printf("system serial: 0x");
    518   1.1  kiyohara 	for (i = 0; i < sizeof (system_serial); i++)
    519   1.1  kiyohara 		printf("%02x", system_serial[i]);
    520   1.1  kiyohara 	printf("\n");
    521   1.1  kiyohara }
    522  1.52  kiyohara #endif
    523  1.49  kiyohara 
    524  1.25  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_BUSHEADER
    525  1.15  kiyohara static const char busheader_name[] = "busheader=";
    526  1.25  kiyohara #endif
    527  1.30  kiyohara #if defined(GUMSTIX_NETBSD_ARGS_BUSHEADER) || \
    528  1.30  kiyohara     defined(GUMSTIX_NETBSD_ARGS_EXPANSION)
    529  1.30  kiyohara static const char expansion_name[] = "expansion=";
    530  1.30  kiyohara #endif
    531  1.25  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_CONSOLE
    532  1.25  kiyohara static const char console_name[] = "console=";
    533  1.25  kiyohara #endif
    534   1.3  kiyohara static void
    535   1.1  kiyohara process_kernel_args(int argc, char *argv[])
    536   1.1  kiyohara {
    537   1.5  kiyohara 	int gxio_configured = 0, i, j;
    538   1.1  kiyohara 
    539   1.1  kiyohara 	boothowto = 0;
    540   1.1  kiyohara 
    541   1.1  kiyohara 	for (i = 1, j = 0; i < argc; i++) {
    542  1.25  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_BUSHEADER
    543   1.1  kiyohara 		if (!strncmp(argv[i], busheader_name, strlen(busheader_name))) {
    544  1.30  kiyohara 			/* Configure for GPIOs of busheader side */
    545   1.5  kiyohara 			gxio_config_expansion(argv[i] + strlen(busheader_name));
    546   1.5  kiyohara 			gxio_configured = 1;
    547   1.1  kiyohara 			continue;
    548   1.1  kiyohara 		}
    549  1.25  kiyohara #endif
    550  1.30  kiyohara #if defined(GUMSTIX_NETBSD_ARGS_BUSHEADER) || \
    551  1.30  kiyohara     defined(GUMSTIX_NETBSD_ARGS_EXPANSION)
    552  1.30  kiyohara 		if (!strncmp(argv[i], expansion_name, strlen(expansion_name))) {
    553  1.30  kiyohara 			/* Configure expansion */
    554  1.30  kiyohara 			gxio_config_expansion(argv[i] + strlen(expansion_name));
    555  1.30  kiyohara 			gxio_configured = 1;
    556  1.30  kiyohara 			continue;
    557  1.30  kiyohara 		}
    558  1.30  kiyohara #endif
    559  1.25  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_CONSOLE
    560  1.25  kiyohara 		if (!strncmp(argv[i], console_name, strlen(console_name))) {
    561  1.25  kiyohara 			strncpy(console, argv[i] + strlen(console_name),
    562  1.25  kiyohara 			    sizeof(console));
    563  1.25  kiyohara 			consinit();
    564  1.25  kiyohara 		}
    565  1.25  kiyohara #endif
    566  1.38       mrg 		if (j == bootargs_len) {
    567   1.1  kiyohara 			*(bootargs + j) = '\0';
    568   1.1  kiyohara 			continue;
    569   1.1  kiyohara 		}
    570   1.1  kiyohara 		if (j != 0)
    571   1.1  kiyohara 			*(bootargs + j++) = ' ';
    572  1.38       mrg 		strncpy(bootargs + j, argv[i], bootargs_len - j);
    573  1.38       mrg 		bootargs[bootargs_len] = '\0';
    574   1.1  kiyohara 		j += strlen(argv[i]);
    575   1.1  kiyohara 	}
    576   1.1  kiyohara 	boot_args = bootargs;
    577   1.1  kiyohara 
    578   1.1  kiyohara 	parse_mi_bootargs(boot_args);
    579   1.5  kiyohara 
    580   1.5  kiyohara 	if (!gxio_configured)
    581   1.5  kiyohara 		gxio_config_expansion(NULL);
    582   1.1  kiyohara }
    583   1.1  kiyohara 
    584  1.15  kiyohara static void
    585  1.25  kiyohara process_kernel_args_liner(char *args)
    586  1.15  kiyohara {
    587  1.30  kiyohara 	int i = 0;
    588  1.25  kiyohara 	char *p = NULL;
    589  1.15  kiyohara 
    590  1.15  kiyohara 	boothowto = 0;
    591  1.15  kiyohara 
    592  1.15  kiyohara 	strncpy(bootargs, args, sizeof(bootargs));
    593  1.30  kiyohara #if defined(GUMSTIX_NETBSD_ARGS_BUSHEADER) || \
    594  1.30  kiyohara     defined(GUMSTIX_NETBSD_ARGS_EXPANSION)
    595  1.30  kiyohara 	{
    596  1.30  kiyohara 		char *q;
    597  1.30  kiyohara 
    598  1.30  kiyohara 		if ((p = strstr(bootargs, expansion_name)))
    599  1.30  kiyohara 			q = p + strlen(expansion_name);
    600  1.25  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_BUSHEADER
    601  1.31  kiyohara 		else if ((p = strstr(bootargs, busheader_name)))
    602  1.30  kiyohara 			q = p + strlen(busheader_name);
    603  1.30  kiyohara #endif
    604  1.30  kiyohara 		if (p) {
    605  1.30  kiyohara 			char expansion[256], c;
    606  1.25  kiyohara 
    607  1.30  kiyohara 			i = 0;
    608  1.30  kiyohara 			do {
    609  1.30  kiyohara 				c = *(q + i);
    610  1.30  kiyohara 				if (c == ' ')
    611  1.30  kiyohara 					c = '\0';
    612  1.30  kiyohara 				expansion[i++] = c;
    613  1.30  kiyohara 			} while (c != '\0' && i < sizeof(expansion));
    614  1.30  kiyohara 			gxio_config_expansion(expansion);
    615  1.30  kiyohara 			strcpy(p, q + i);
    616  1.30  kiyohara 		}
    617  1.15  kiyohara 	}
    618  1.25  kiyohara #endif
    619  1.27  kiyohara 	if (p == NULL)
    620  1.25  kiyohara 		gxio_config_expansion(NULL);
    621  1.25  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_CONSOLE
    622  1.25  kiyohara 	p = strstr(bootargs, console_name);
    623  1.25  kiyohara 	if (p != NULL) {
    624  1.25  kiyohara 		char c;
    625  1.25  kiyohara 
    626  1.30  kiyohara 		i = 0;
    627  1.25  kiyohara 		do {
    628  1.25  kiyohara 			c = *(p + strlen(console_name) + i);
    629  1.25  kiyohara 			if (c == ' ')
    630  1.25  kiyohara 				c = '\0';
    631  1.25  kiyohara 			console[i++] = c;
    632  1.25  kiyohara 		} while (c != '\0' && i < sizeof(console));
    633  1.25  kiyohara 		consinit();
    634  1.30  kiyohara 		strcpy(p, p + strlen(console_name) + i);
    635  1.25  kiyohara 	}
    636  1.25  kiyohara #endif
    637  1.15  kiyohara 	boot_args = bootargs;
    638  1.15  kiyohara 
    639  1.15  kiyohara 	parse_mi_bootargs(boot_args);
    640  1.15  kiyohara }
    641  1.15  kiyohara 
    642   1.1  kiyohara #ifdef KGDB
    643   1.1  kiyohara #ifndef KGDB_DEVNAME
    644   1.6  kiyohara #define KGDB_DEVNAME	"ffuart"
    645   1.1  kiyohara #endif
    646   1.1  kiyohara const char kgdb_devname[] = KGDB_DEVNAME;
    647   1.1  kiyohara 
    648   1.6  kiyohara #ifndef KGDB_DEVRATE
    649   1.6  kiyohara #define KGDB_DEVRATE	CONSPEED
    650   1.6  kiyohara #endif
    651   1.6  kiyohara int kgdb_devrate = KGDB_DEVRATE;
    652   1.6  kiyohara 
    653   1.1  kiyohara #if (NCOM > 0)
    654   1.1  kiyohara #ifndef KGDB_DEVMODE
    655   1.6  kiyohara #define KGDB_DEVMODE	CONMODE
    656   1.1  kiyohara #endif
    657   1.1  kiyohara int comkgdbmode = KGDB_DEVMODE;
    658   1.1  kiyohara #endif /* NCOM */
    659   1.1  kiyohara 
    660   1.1  kiyohara #endif /* KGDB */
    661   1.1  kiyohara 
    662   1.1  kiyohara 
    663   1.1  kiyohara void
    664   1.1  kiyohara consinit(void)
    665   1.1  kiyohara {
    666   1.1  kiyohara 	static int consinit_called = 0;
    667   1.1  kiyohara 
    668   1.1  kiyohara 	if (consinit_called != 0)
    669   1.1  kiyohara 		return;
    670   1.1  kiyohara 
    671   1.1  kiyohara 	consinit_called = 1;
    672   1.1  kiyohara 
    673   1.1  kiyohara #if NCOM > 0
    674   1.1  kiyohara 
    675  1.33  kiyohara #ifdef GUMSTIX_NETBSD_ARGS_CONSOLE
    676  1.33  kiyohara 	/* Maybe passed Linux's bootargs 'console=ttyS?,<speed>...' */
    677  1.33  kiyohara 	if (strncmp(console, "ttyS", 4) == 0 && console[5] == ',') {
    678  1.33  kiyohara 		int i;
    679  1.33  kiyohara 
    680  1.33  kiyohara 		comcnspeed = 0;
    681  1.33  kiyohara 		for (i = 6; i < strlen(console) && isdigit(console[i]); i++)
    682  1.33  kiyohara 			comcnspeed = comcnspeed * 10 + (console[i] - '0');
    683  1.33  kiyohara 	}
    684  1.33  kiyohara #endif
    685  1.33  kiyohara 
    686  1.27  kiyohara #if defined(GUMSTIX)
    687  1.27  kiyohara 
    688   1.1  kiyohara #ifdef FFUARTCONSOLE
    689   1.1  kiyohara #ifdef KGDB
    690  1.25  kiyohara 	if (strcmp(kgdb_devname, "ffuart") == 0){
    691   1.1  kiyohara 		/* port is reserved for kgdb */
    692  1.17  kiyohara 	} else
    693   1.1  kiyohara #endif
    694  1.25  kiyohara #if defined(GUMSTIX_NETBSD_ARGS_CONSOLE)
    695  1.33  kiyohara 	if (console[0] == '\0' || strcasecmp(console, "ffuart") == 0 ||
    696  1.33  kiyohara 	    strncmp(console, "ttyS0,", 6) == 0)
    697  1.25  kiyohara #endif
    698   1.3  kiyohara 	{
    699  1.27  kiyohara 		int rv;
    700  1.27  kiyohara 
    701  1.25  kiyohara 		rv = comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_FFUART_BASE,
    702  1.25  kiyohara 		    comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode);
    703  1.25  kiyohara 		if (rv == 0) {
    704  1.21  kiyohara 			pxa2x0_clkman_config(CKEN_FFUART, 1);
    705   1.3  kiyohara 			return;
    706   1.3  kiyohara 		}
    707   1.1  kiyohara 	}
    708   1.1  kiyohara #endif /* FFUARTCONSOLE */
    709   1.1  kiyohara 
    710   1.3  kiyohara #ifdef STUARTCONSOLE
    711   1.3  kiyohara #ifdef KGDB
    712  1.25  kiyohara 	if (strcmp(kgdb_devname, "stuart") == 0) {
    713   1.3  kiyohara 		/* port is reserved for kgdb */
    714   1.3  kiyohara 	} else
    715   1.3  kiyohara #endif
    716  1.25  kiyohara #if defined(GUMSTIX_NETBSD_ARGS_CONSOLE)
    717  1.25  kiyohara 	if (console[0] == '\0' || strcasecmp(console, "stuart") == 0)
    718  1.25  kiyohara #endif
    719   1.3  kiyohara 	{
    720  1.27  kiyohara 		int rv;
    721  1.27  kiyohara 
    722  1.25  kiyohara 		rv = comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_STUART_BASE,
    723  1.25  kiyohara 		    comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode);
    724  1.25  kiyohara 		if (rv == 0) {
    725  1.21  kiyohara 			pxa2x0_clkman_config(CKEN_STUART, 1);
    726   1.3  kiyohara 			return;
    727   1.3  kiyohara 		}
    728   1.3  kiyohara 	}
    729   1.3  kiyohara #endif /* STUARTCONSOLE */
    730   1.3  kiyohara 
    731   1.1  kiyohara #ifdef BTUARTCONSOLE
    732   1.1  kiyohara #ifdef KGDB
    733  1.25  kiyohara 	if (strcmp(kgdb_devname, "btuart") == 0) {
    734   1.1  kiyohara 		/* port is reserved for kgdb */
    735   1.1  kiyohara 	} else
    736   1.1  kiyohara #endif
    737  1.25  kiyohara #if defined(GUMSTIX_NETBSD_ARGS_CONSOLE)
    738  1.25  kiyohara 	if (console[0] == '\0' || strcasecmp(console, "btuart") == 0)
    739  1.25  kiyohara #endif
    740   1.3  kiyohara 	{
    741  1.27  kiyohara 		int rv;
    742  1.27  kiyohara 
    743  1.25  kiyohara 		rv = comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_BTUART_BASE,
    744  1.25  kiyohara 		    comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode);
    745  1.25  kiyohara 		if (rv == 0) {
    746  1.21  kiyohara 			pxa2x0_clkman_config(CKEN_BTUART, 1);
    747   1.3  kiyohara 			return;
    748   1.3  kiyohara 		}
    749   1.1  kiyohara 	}
    750   1.1  kiyohara #endif /* BTUARTCONSOLE */
    751   1.1  kiyohara 
    752   1.3  kiyohara #ifdef HWUARTCONSOLE
    753   1.3  kiyohara #ifdef KGDB
    754  1.25  kiyohara 	if (strcmp(kgdb_devname, "hwuart") == 0) {
    755   1.3  kiyohara 		/* port is reserved for kgdb */
    756   1.3  kiyohara 	} else
    757   1.3  kiyohara #endif
    758  1.25  kiyohara #if defined(GUMSTIX_NETBSD_ARGS_CONSOLE)
    759  1.25  kiyohara 	if (console[0] == '\0' || strcasecmp(console, "hwuart") == 0)
    760  1.25  kiyohara #endif
    761   1.3  kiyohara 	{
    762  1.25  kiyohara 		rv = comcnattach(&pxa2x0_a4x_bs_tag, PXA2X0_HWUART_BASE,
    763  1.25  kiyohara 		    comcnspeed, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comcnmode);
    764  1.25  kiyohara 		if (rv == 0) {
    765  1.21  kiyohara 			pxa2x0_clkman_config(CKEN_HWUART, 1);
    766   1.3  kiyohara 			return;
    767   1.3  kiyohara 		}
    768   1.3  kiyohara 	}
    769   1.3  kiyohara #endif /* HWUARTCONSOLE */
    770   1.1  kiyohara 
    771  1.72  jmcneill #endif /* GUMSTIX */
    772  1.27  kiyohara 
    773   1.1  kiyohara #endif /* NCOM */
    774   1.1  kiyohara 
    775  1.15  kiyohara #if NLCD > 0
    776  1.25  kiyohara #if defined(GUMSTIX_NETBSD_ARGS_CONSOLE)
    777  1.25  kiyohara 	if (console[0] == '\0' || strcasecmp(console, "lcd") == 0)
    778  1.25  kiyohara #endif
    779  1.25  kiyohara 	{
    780  1.25  kiyohara 		gxlcd_cnattach();
    781  1.25  kiyohara 	}
    782  1.15  kiyohara #endif
    783   1.1  kiyohara }
    784   1.1  kiyohara 
    785   1.1  kiyohara #ifdef KGDB
    786   1.3  kiyohara static void
    787   1.1  kiyohara kgdb_port_init(void)
    788   1.1  kiyohara {
    789   1.1  kiyohara #if (NCOM > 0) && defined(COM_PXA2X0)
    790   1.1  kiyohara 	paddr_t paddr = 0;
    791  1.21  kiyohara 	int cken = 0;
    792   1.1  kiyohara 
    793   1.1  kiyohara 	if (0 == strcmp(kgdb_devname, "ffuart")) {
    794   1.1  kiyohara 		paddr = PXA2X0_FFUART_BASE;
    795  1.21  kiyohara 		cken = CKEN_FFUART;
    796   1.3  kiyohara 	} else if (0 == strcmp(kgdb_devname, "stuart")) {
    797   1.3  kiyohara 		paddr = PXA2X0_STUART_BASE;
    798  1.21  kiyohara 		cken = CKEN_STUART;
    799   1.3  kiyohara 	} else if (0 == strcmp(kgdb_devname, "btuart")) {
    800   1.1  kiyohara 		paddr = PXA2X0_BTUART_BASE;
    801  1.21  kiyohara 		cken = CKEN_BTUART;
    802   1.3  kiyohara 	} else if (0 == strcmp(kgdb_devname, "hwuart")) {
    803   1.3  kiyohara 		paddr = PXA2X0_HWUART_BASE;
    804  1.21  kiyohara 		cken = CKEN_HWUART;
    805   1.1  kiyohara 	}
    806   1.1  kiyohara 
    807   1.1  kiyohara 	if (paddr &&
    808   1.1  kiyohara 	    0 == com_kgdb_attach(&pxa2x0_a4x_bs_tag, paddr,
    809   1.6  kiyohara 		kgdb_devrate, PXA2X0_COM_FREQ, COM_TYPE_PXA2x0, comkgdbmode)) {
    810   1.1  kiyohara 
    811  1.21  kiyohara 		pxa2x0_clkman_config(cken, 1);
    812   1.1  kiyohara 	}
    813   1.1  kiyohara 
    814   1.1  kiyohara #endif
    815   1.1  kiyohara }
    816   1.1  kiyohara #endif
    817  1.28  kiyohara 
    818  1.28  kiyohara static void
    819  1.28  kiyohara gumstix_device_register(device_t dev, void *aux)
    820  1.28  kiyohara {
    821  1.46  kiyohara 	prop_dictionary_t dict = device_properties(dev);
    822  1.28  kiyohara 
    823  1.46  kiyohara 	if (device_is_a(dev, "ehci")) {
    824  1.48  kiyohara 		prop_dictionary_set_uint16(dict, "dpll5-m", 443);
    825  1.48  kiyohara 		prop_dictionary_set_uint16(dict, "dpll5-n", 11);
    826  1.48  kiyohara 		prop_dictionary_set_uint16(dict, "dpll5-m2", 4);
    827  1.46  kiyohara 	}
    828  1.28  kiyohara 	if (device_is_a(dev, "ohci")) {
    829  1.46  kiyohara 		if (prop_dictionary_set_bool(dict,
    830  1.28  kiyohara 		    "Ganged-power-mask-on-port1", 1) == false) {
    831  1.28  kiyohara 			printf("WARNING: unable to set power-mask for port1"
    832  1.44       chs 			    " property for %s\n", device_xname(dev));
    833  1.28  kiyohara 		}
    834  1.46  kiyohara 		if (prop_dictionary_set_bool(dict,
    835  1.28  kiyohara 		    "Ganged-power-mask-on-port2", 1) == false) {
    836  1.28  kiyohara 			printf("WARNING: unable to set power-mask for port2"
    837  1.44       chs 			    " property for %s\n", device_xname(dev));
    838  1.28  kiyohara 		}
    839  1.46  kiyohara 		if (prop_dictionary_set_bool(dict,
    840  1.28  kiyohara 		    "Ganged-power-mask-on-port3", 1) == false) {
    841  1.28  kiyohara 			printf("WARNING: unable to set power-mask for port3"
    842  1.44       chs 			    " property for %s\n", device_xname(dev));
    843  1.28  kiyohara 		}
    844  1.28  kiyohara 	}
    845  1.28  kiyohara }
    846