Home | History | Annotate | Line # | Download | only in gemini
gemini_obio.c revision 1.7.8.3
      1  1.7.8.3  yamt /*	$NetBSD: gemini_obio.c,v 1.7.8.3 2010/03/11 15:02:06 yamt Exp $	*/
      2  1.7.8.2  yamt 
      3  1.7.8.2  yamt /* adapted from:
      4  1.7.8.2  yamt  *      NetBSD: omap2_obio.c,v 1.5 2008/10/21 18:50:25 matt Exp
      5  1.7.8.2  yamt  */
      6  1.7.8.2  yamt 
      7  1.7.8.2  yamt /*
      8  1.7.8.2  yamt  * Autoconfiguration support for the Gemini "On Board" I/O.
      9  1.7.8.2  yamt  *
     10  1.7.8.2  yamt  * Based on arm/omap/omap2_obio.c which in turn was derived
     11  1.7.8.2  yamt  * Based on arm/omap/omap_emifs.c which in turn was derived
     12  1.7.8.2  yamt  * Based on arm/xscale/pxa2x0.c which in turn was derived
     13  1.7.8.2  yamt  * from arm/sa11x0/sa11x0.c
     14  1.7.8.2  yamt  *
     15  1.7.8.2  yamt  * Copyright (c) 2002, 2005  Genetec Corporation.  All rights reserved.
     16  1.7.8.2  yamt  * Written by Hiroyuki Bessho for Genetec Corporation.
     17  1.7.8.2  yamt  *
     18  1.7.8.2  yamt  * Redistribution and use in source and binary forms, with or without
     19  1.7.8.2  yamt  * modification, are permitted provided that the following conditions
     20  1.7.8.2  yamt  * are met:
     21  1.7.8.2  yamt  * 1. Redistributions of source code must retain the above copyright
     22  1.7.8.2  yamt  *    notice, this list of conditions and the following disclaimer.
     23  1.7.8.2  yamt  * 2. Redistributions in binary form must reproduce the above copyright
     24  1.7.8.2  yamt  *    notice, this list of conditions and the following disclaimer in the
     25  1.7.8.2  yamt  *    documentation and/or other materials provided with the distribution.
     26  1.7.8.2  yamt  * 3. All advertising materials mentioning features or use of this software
     27  1.7.8.2  yamt  *    must display the following acknowledgement:
     28  1.7.8.2  yamt  *	This product includes software developed for the NetBSD Project by
     29  1.7.8.2  yamt  *	Genetec Corporation.
     30  1.7.8.2  yamt  * 4. The name of Genetec Corporation may not be used to endorse or
     31  1.7.8.2  yamt  *    promote products derived from this software without specific prior
     32  1.7.8.2  yamt  *    written permission.
     33  1.7.8.2  yamt  *
     34  1.7.8.2  yamt  * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
     35  1.7.8.2  yamt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     36  1.7.8.2  yamt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     37  1.7.8.2  yamt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
     38  1.7.8.2  yamt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     39  1.7.8.2  yamt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     40  1.7.8.2  yamt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     41  1.7.8.2  yamt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     42  1.7.8.2  yamt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     43  1.7.8.2  yamt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     44  1.7.8.2  yamt  * POSSIBILITY OF SUCH DAMAGE.
     45  1.7.8.2  yamt  *
     46  1.7.8.2  yamt  * Copyright (c) 1997,1998, 2001, The NetBSD Foundation, Inc.
     47  1.7.8.2  yamt  * All rights reserved.
     48  1.7.8.2  yamt  *
     49  1.7.8.2  yamt  * This code is derived from software contributed to The NetBSD Foundation
     50  1.7.8.2  yamt  * by IWAMOTO Toshihiro, Ichiro FUKUHARA and Paul Kranenburg.
     51  1.7.8.2  yamt  *
     52  1.7.8.2  yamt  * Redistribution and use in source and binary forms, with or without
     53  1.7.8.2  yamt  * modification, are permitted provided that the following conditions
     54  1.7.8.2  yamt  * are met:
     55  1.7.8.2  yamt  * 1. Redistributions of source code must retain the above copyright
     56  1.7.8.2  yamt  *    notice, this list of conditions and the following disclaimer.
     57  1.7.8.2  yamt  * 2. Redistributions in binary form must reproduce the above copyright
     58  1.7.8.2  yamt  *    notice, this list of conditions and the following disclaimer in the
     59  1.7.8.2  yamt  *    documentation and/or other materials provided with the distribution.
     60  1.7.8.2  yamt  *
     61  1.7.8.2  yamt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     62  1.7.8.2  yamt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     63  1.7.8.2  yamt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     64  1.7.8.2  yamt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     65  1.7.8.2  yamt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     66  1.7.8.2  yamt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     67  1.7.8.2  yamt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     68  1.7.8.2  yamt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     69  1.7.8.2  yamt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     70  1.7.8.2  yamt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     71  1.7.8.2  yamt  * POSSIBILITY OF SUCH DAMAGE.
     72  1.7.8.2  yamt  *
     73  1.7.8.2  yamt  * Copyright (c) 1999
     74  1.7.8.2  yamt  *         Shin Takemura and PocketBSD Project. All rights reserved.
     75  1.7.8.2  yamt  *
     76  1.7.8.2  yamt  * Redistribution and use in source and binary forms, with or without
     77  1.7.8.2  yamt  * modification, are permitted provided that the following conditions
     78  1.7.8.2  yamt  * are met:
     79  1.7.8.2  yamt  * 1. Redistributions of source code must retain the above copyright
     80  1.7.8.2  yamt  *    notice, this list of conditions and the following disclaimer.
     81  1.7.8.2  yamt  * 2. Redistributions in binary form must reproduce the above copyright
     82  1.7.8.2  yamt  *    notice, this list of conditions and the following disclaimer in the
     83  1.7.8.2  yamt  *    documentation and/or other materials provided with the distribution.
     84  1.7.8.2  yamt  * 3. All advertising materials mentioning features or use of this software
     85  1.7.8.2  yamt  *    must display the following acknowledgement:
     86  1.7.8.2  yamt  *	This product includes software developed by the PocketBSD project
     87  1.7.8.2  yamt  *	and its contributors.
     88  1.7.8.2  yamt  * 4. Neither the name of the project nor the names of its contributors
     89  1.7.8.2  yamt  *    may be used to endorse or promote products derived from this software
     90  1.7.8.2  yamt  *    without specific prior written permission.
     91  1.7.8.2  yamt  *
     92  1.7.8.2  yamt  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     93  1.7.8.2  yamt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     94  1.7.8.2  yamt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     95  1.7.8.2  yamt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     96  1.7.8.2  yamt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     97  1.7.8.2  yamt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     98  1.7.8.2  yamt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     99  1.7.8.2  yamt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    100  1.7.8.2  yamt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    101  1.7.8.2  yamt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    102  1.7.8.2  yamt  * SUCH DAMAGE.
    103  1.7.8.2  yamt  */
    104  1.7.8.2  yamt 
    105  1.7.8.2  yamt #include "opt_gemini.h"
    106  1.7.8.2  yamt #include <sys/cdefs.h>
    107  1.7.8.3  yamt __KERNEL_RCSID(0, "$NetBSD: gemini_obio.c,v 1.7.8.3 2010/03/11 15:02:06 yamt Exp $");
    108  1.7.8.2  yamt 
    109  1.7.8.2  yamt #include "locators.h"
    110  1.7.8.2  yamt #include "obio.h"
    111  1.7.8.2  yamt #include "geminiicu.h"
    112  1.7.8.2  yamt #include "pci.h"
    113  1.7.8.2  yamt 
    114  1.7.8.2  yamt #include <sys/param.h>
    115  1.7.8.2  yamt #include <sys/systm.h>
    116  1.7.8.2  yamt #include <sys/device.h>
    117  1.7.8.2  yamt #include <sys/kernel.h>
    118  1.7.8.2  yamt #include <sys/reboot.h>
    119  1.7.8.2  yamt 
    120  1.7.8.2  yamt #include <machine/cpu.h>
    121  1.7.8.2  yamt #include <machine/bus.h>
    122  1.7.8.2  yamt 
    123  1.7.8.2  yamt #include <arm/cpufunc.h>
    124  1.7.8.2  yamt #include <arm/mainbus/mainbus.h>
    125  1.7.8.2  yamt #include <arm/gemini/gemini_var.h>
    126  1.7.8.2  yamt #include <arm/gemini/gemini_reg.h>
    127  1.7.8.2  yamt 
    128  1.7.8.2  yamt #include <arm/gemini/gemini_obiovar.h>
    129  1.7.8.2  yamt 
    130  1.7.8.2  yamt typedef struct {
    131  1.7.8.2  yamt 	boolean_t	cs_valid;
    132  1.7.8.2  yamt 	ulong		cs_addr;
    133  1.7.8.2  yamt 	ulong		cs_size;
    134  1.7.8.2  yamt } obio_csconfig_t;
    135  1.7.8.2  yamt 
    136  1.7.8.2  yamt /* prototypes */
    137  1.7.8.2  yamt static int	obio_match(device_t, cfdata_t, void *);
    138  1.7.8.2  yamt static void	obio_attach(device_t, device_t, void *);
    139  1.7.8.2  yamt static int 	obio_search(device_t, cfdata_t, const int *, void *);
    140  1.7.8.2  yamt static int	obio_find(device_t, cfdata_t, const int *, void *);
    141  1.7.8.2  yamt static int	obio_print(void *, const char *);
    142  1.7.8.2  yamt static void	obio_attach_critical(struct obio_softc *);
    143  1.7.8.2  yamt 
    144  1.7.8.2  yamt /* attach structures */
    145  1.7.8.2  yamt CFATTACH_DECL_NEW(obio, sizeof(struct obio_softc),
    146  1.7.8.2  yamt 	obio_match, obio_attach, NULL, NULL);
    147  1.7.8.2  yamt 
    148  1.7.8.2  yamt 
    149  1.7.8.2  yamt static int
    150  1.7.8.2  yamt obio_match(device_t parent, cfdata_t match, void *aux)
    151  1.7.8.2  yamt {
    152  1.7.8.2  yamt 	return 1;
    153  1.7.8.2  yamt }
    154  1.7.8.2  yamt 
    155  1.7.8.2  yamt static void
    156  1.7.8.2  yamt obio_attach(device_t parent, device_t self, void *aux)
    157  1.7.8.2  yamt {
    158  1.7.8.2  yamt 	struct obio_softc *sc = device_private(self);
    159  1.7.8.2  yamt 	struct mainbus_attach_args *mb = (struct mainbus_attach_args *)aux;
    160  1.7.8.2  yamt #if NPCI > 0
    161  1.7.8.2  yamt 	struct pcibus_attach_args pba;
    162  1.7.8.2  yamt #endif
    163  1.7.8.2  yamt 
    164  1.7.8.2  yamt 	sc->sc_dev = self;
    165  1.7.8.2  yamt 
    166  1.7.8.2  yamt 	sc->sc_iot = &gemini_bs_tag;
    167  1.7.8.2  yamt 
    168  1.7.8.2  yamt 	aprint_normal(": On-Board IO\n");
    169  1.7.8.2  yamt 
    170  1.7.8.2  yamt #if (GEMINI_BUSBASE != 0)
    171  1.7.8.2  yamt 	sc->sc_dmarange.dr_sysbase = 0;
    172  1.7.8.2  yamt 	sc->sc_dmarange.dr_busbase = (GEMINI_BUSBASE * 1024 * 1024);
    173  1.7.8.2  yamt 	sc->sc_dmarange.dr_len = MEMSIZE * 1024 * 1024;
    174  1.7.8.2  yamt 	gemini_bus_dma_tag._ranges = &sc->sc_dmarange;
    175  1.7.8.2  yamt 	gemini_bus_dma_tag._nranges = 1;
    176  1.7.8.2  yamt #endif
    177  1.7.8.2  yamt 
    178  1.7.8.2  yamt 	sc->sc_ioh = 0;
    179  1.7.8.2  yamt 	sc->sc_dmat = &gemini_bus_dma_tag;
    180  1.7.8.2  yamt 	sc->sc_base = mb->mb_iobase;
    181  1.7.8.2  yamt 	sc->sc_size = mb->mb_iosize;
    182  1.7.8.2  yamt 
    183  1.7.8.2  yamt 	/*
    184  1.7.8.2  yamt 	 * Attach critical devices first.
    185  1.7.8.2  yamt 	 */
    186  1.7.8.2  yamt 	obio_attach_critical(sc);
    187  1.7.8.2  yamt 
    188  1.7.8.2  yamt #if NPCI > 0
    189  1.7.8.2  yamt 	/*
    190  1.7.8.2  yamt 	 * map PCI controller registers
    191  1.7.8.2  yamt 	 */
    192  1.7.8.2  yamt 	if (bus_space_map(sc->sc_iot, GEMINI_PCICFG_BASE,
    193  1.7.8.2  yamt 		GEMINI_PCI_CFG_DATA+4, 0, &sc->sc_pcicfg_ioh)) {
    194  1.7.8.2  yamt 			aprint_error("cannot map PCI controller at %#x\n",
    195  1.7.8.2  yamt 				GEMINI_PCICFG_BASE);
    196  1.7.8.2  yamt 			return;
    197  1.7.8.2  yamt 	}
    198  1.7.8.2  yamt 	/*
    199  1.7.8.2  yamt 	 * initialize the PCI chipset tag
    200  1.7.8.2  yamt 	 */
    201  1.7.8.2  yamt 	gemini_pci_init(&sc->sc_pci_chipset, sc);
    202  1.7.8.2  yamt #endif	/* NPCI */
    203  1.7.8.2  yamt 
    204  1.7.8.2  yamt 	/*
    205  1.7.8.2  yamt 	 * attach the rest of our devices
    206  1.7.8.2  yamt 	 */
    207  1.7.8.2  yamt 	config_search_ia(obio_search, self, "obio", NULL);
    208  1.7.8.2  yamt 
    209  1.7.8.2  yamt #if NPCI > 0
    210  1.7.8.2  yamt 	/*
    211  1.7.8.2  yamt 	 * attach the PCI bus
    212  1.7.8.2  yamt 	 */
    213  1.7.8.2  yamt 	pba.pba_memt = sc->sc_iot;
    214  1.7.8.3  yamt 	pba.pba_iot =  sc->sc_iot;
    215  1.7.8.2  yamt 	pba.pba_dmat = sc->sc_dmat;
    216  1.7.8.2  yamt 	pba.pba_dmat64 = NULL;
    217  1.7.8.2  yamt 	pba.pba_pc = &sc->sc_pci_chipset;
    218  1.7.8.2  yamt 	pba.pba_bus = 0;
    219  1.7.8.2  yamt 	pba.pba_bridgetag = NULL;
    220  1.7.8.2  yamt 	pba.pba_intrswiz = 0;
    221  1.7.8.2  yamt 	pba.pba_intrtag = 0;
    222  1.7.8.2  yamt 	pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED |
    223  1.7.8.2  yamt 	    PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;
    224  1.7.8.2  yamt 
    225  1.7.8.2  yamt 	(void) config_found_ia(sc->sc_dev, "pcibus", &pba, pcibusprint);
    226  1.7.8.2  yamt #endif	/* NPCI */
    227  1.7.8.2  yamt 
    228  1.7.8.2  yamt }
    229  1.7.8.2  yamt 
    230  1.7.8.2  yamt static int
    231  1.7.8.2  yamt obio_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
    232  1.7.8.2  yamt {
    233  1.7.8.2  yamt 	struct obio_softc * const sc = device_private(parent);
    234  1.7.8.2  yamt 	struct obio_attach_args oa;
    235  1.7.8.2  yamt 
    236  1.7.8.2  yamt 	/* Set up the attach args. */
    237  1.7.8.2  yamt 	if (cf->cf_loc[OBIOCF_NOBYTEACC] == 1) {
    238  1.7.8.2  yamt #if 0
    239  1.7.8.2  yamt 		if (cf->cf_loc[OBIOCF_MULT] == 1)
    240  1.7.8.2  yamt 			oa.obio_iot = &nobyteacc_bs_tag;
    241  1.7.8.2  yamt 		else
    242  1.7.8.2  yamt #endif
    243  1.7.8.2  yamt 			panic("nobyteacc specified for device with "
    244  1.7.8.2  yamt 				"non-byte multiplier\n");
    245  1.7.8.2  yamt 	} else {
    246  1.7.8.2  yamt 		switch (cf->cf_loc[OBIOCF_MULT]) {
    247  1.7.8.2  yamt 		case 1:
    248  1.7.8.2  yamt 			oa.obio_iot = &gemini_bs_tag;
    249  1.7.8.2  yamt 			break;
    250  1.7.8.2  yamt #if 0
    251  1.7.8.2  yamt 		case 2:
    252  1.7.8.2  yamt 			oa.obio_iot = &gemini_a2x_bs_tag;
    253  1.7.8.2  yamt 			break;
    254  1.7.8.2  yamt #endif
    255  1.7.8.2  yamt 		case 4:
    256  1.7.8.2  yamt 			oa.obio_iot = &gemini_a4x_bs_tag;
    257  1.7.8.2  yamt 			break;
    258  1.7.8.2  yamt 		default:
    259  1.7.8.2  yamt 			panic("Unsupported obio bus multiplier.");
    260  1.7.8.2  yamt 			break;
    261  1.7.8.2  yamt 		}
    262  1.7.8.2  yamt 	}
    263  1.7.8.2  yamt 
    264  1.7.8.2  yamt 	oa.obio_dmat = sc->sc_dmat;
    265  1.7.8.2  yamt 	oa.obio_addr = cf->cf_loc[OBIOCF_ADDR];
    266  1.7.8.2  yamt 	oa.obio_size = cf->cf_loc[OBIOCF_SIZE];
    267  1.7.8.2  yamt 	oa.obio_intr = cf->cf_loc[OBIOCF_INTR];
    268  1.7.8.2  yamt 	oa.obio_intrbase = cf->cf_loc[OBIOCF_INTRBASE];
    269  1.7.8.2  yamt 
    270  1.7.8.2  yamt 	if (config_match(parent, cf, &oa)) {
    271  1.7.8.2  yamt 		config_attach(parent, cf, &oa, obio_print);
    272  1.7.8.2  yamt 		return 0;			/* love it */
    273  1.7.8.2  yamt 	}
    274  1.7.8.2  yamt 
    275  1.7.8.2  yamt 	return UNCONF;	/* NG */
    276  1.7.8.2  yamt }
    277  1.7.8.2  yamt 
    278  1.7.8.2  yamt static int
    279  1.7.8.2  yamt obio_find(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
    280  1.7.8.2  yamt {
    281  1.7.8.2  yamt 	struct obio_attach_args * const oa = aux;
    282  1.7.8.2  yamt 
    283  1.7.8.2  yamt 	if (oa->obio_addr != OBIOCF_ADDR_DEFAULT
    284  1.7.8.2  yamt 	    && oa->obio_addr != cf->cf_loc[OBIOCF_ADDR])
    285  1.7.8.2  yamt 		return 0;
    286  1.7.8.2  yamt 	if (oa->obio_size != OBIOCF_SIZE_DEFAULT
    287  1.7.8.2  yamt 	    && oa->obio_size != cf->cf_loc[OBIOCF_SIZE])
    288  1.7.8.2  yamt 		return 0;
    289  1.7.8.2  yamt 	if (oa->obio_intr != OBIOCF_INTR_DEFAULT
    290  1.7.8.2  yamt 	    && oa->obio_intr != cf->cf_loc[OBIOCF_INTR])
    291  1.7.8.2  yamt 		return 0;
    292  1.7.8.2  yamt 	if (oa->obio_intrbase != OBIOCF_INTRBASE_DEFAULT
    293  1.7.8.2  yamt 	    && oa->obio_intrbase != cf->cf_loc[OBIOCF_INTRBASE])
    294  1.7.8.2  yamt 		return 0;
    295  1.7.8.2  yamt 
    296  1.7.8.2  yamt 	/* Set up the attach args. */
    297  1.7.8.2  yamt 	if (cf->cf_loc[OBIOCF_NOBYTEACC] == 1) {
    298  1.7.8.2  yamt #if 0
    299  1.7.8.2  yamt 		if (cf->cf_loc[OBIOCF_MULT] == 1)
    300  1.7.8.2  yamt 			oa->obio_iot = &nobyteacc_bs_tag;
    301  1.7.8.2  yamt 		else
    302  1.7.8.2  yamt #endif
    303  1.7.8.2  yamt 			panic("nobyteacc specified for device with "
    304  1.7.8.2  yamt 				"non-byte multiplier\n");
    305  1.7.8.2  yamt 	} else {
    306  1.7.8.2  yamt 		switch (cf->cf_loc[OBIOCF_MULT]) {
    307  1.7.8.2  yamt 		case 1:
    308  1.7.8.2  yamt 			oa->obio_iot = &gemini_bs_tag;
    309  1.7.8.2  yamt 			break;
    310  1.7.8.2  yamt #if 0
    311  1.7.8.2  yamt 		case 2:
    312  1.7.8.2  yamt 			oa->obio_iot = &gemini_a2x_bs_tag;
    313  1.7.8.2  yamt 			break;
    314  1.7.8.2  yamt #endif
    315  1.7.8.2  yamt 		case 4:
    316  1.7.8.2  yamt 			oa->obio_iot = &gemini_a4x_bs_tag;
    317  1.7.8.2  yamt 			break;
    318  1.7.8.2  yamt 		default:
    319  1.7.8.2  yamt 			panic("Unsupported obio bus multiplier.");
    320  1.7.8.2  yamt 			break;
    321  1.7.8.2  yamt 		}
    322  1.7.8.2  yamt 	}
    323  1.7.8.2  yamt 	oa->obio_addr = cf->cf_loc[OBIOCF_ADDR];
    324  1.7.8.2  yamt 	oa->obio_size = cf->cf_loc[OBIOCF_SIZE];
    325  1.7.8.2  yamt 	oa->obio_intr = cf->cf_loc[OBIOCF_INTR];
    326  1.7.8.2  yamt 	oa->obio_intrbase = cf->cf_loc[OBIOCF_INTRBASE];
    327  1.7.8.2  yamt 
    328  1.7.8.2  yamt 	return config_match(parent, cf, oa);
    329  1.7.8.2  yamt }
    330  1.7.8.2  yamt 
    331  1.7.8.2  yamt #if NGEMINIICU == 0
    332  1.7.8.2  yamt #error no geminiicu present in config file
    333  1.7.8.2  yamt #endif
    334  1.7.8.2  yamt 
    335  1.7.8.2  yamt static const struct {
    336  1.7.8.2  yamt 	const char *name;
    337  1.7.8.2  yamt 	bus_addr_t addr;
    338  1.7.8.2  yamt 	bool required;
    339  1.7.8.2  yamt } critical_devs[] = {
    340  1.7.8.2  yamt #if defined(GEMINI_MASTER) || defined(GEMINI_SINGLE)
    341  1.7.8.2  yamt 	{ .name = "geminiicu0",   .addr = 0x48000000, .required = true },
    342  1.7.8.2  yamt 	{ .name = "geminiwdt0",   .addr = 0x41000000, .required = true },
    343  1.7.8.2  yamt 	{ .name = "geminitmr0",   .addr = 0x43000000, .required = true },
    344  1.7.8.2  yamt 	{ .name = "geminitmr2",   .addr = 0x43000000, .required = true },
    345  1.7.8.2  yamt 	{ .name = "com0",         .addr = 0x42000000, .required = true },
    346  1.7.8.2  yamt #elif defined(GEMINI_SLAVE)
    347  1.7.8.2  yamt 	{ .name = "geminiicu1",   .addr = 0x49000000, .required = true },
    348  1.7.8.2  yamt 	{ .name = "geminitmr1",   .addr = 0x43000000, .required = true },
    349  1.7.8.2  yamt 	{ .name = "geminitmr2",   .addr = 0x43000000, .required = true },
    350  1.7.8.2  yamt 	{ .name = "geminilpchc0", .addr = 0x47000000, .required = true },
    351  1.7.8.2  yamt #endif
    352  1.7.8.2  yamt };
    353  1.7.8.2  yamt 
    354  1.7.8.2  yamt static void
    355  1.7.8.2  yamt obio_attach_critical(struct obio_softc *sc)
    356  1.7.8.2  yamt {
    357  1.7.8.2  yamt 	struct obio_attach_args oa;
    358  1.7.8.2  yamt 	cfdata_t cf;
    359  1.7.8.2  yamt 	size_t i;
    360  1.7.8.2  yamt 
    361  1.7.8.2  yamt 	for (i = 0; i < __arraycount(critical_devs); i++) {
    362  1.7.8.2  yamt 		oa.obio_iot = sc->sc_iot;
    363  1.7.8.2  yamt 		oa.obio_dmat = sc->sc_dmat;
    364  1.7.8.2  yamt 
    365  1.7.8.2  yamt 		oa.obio_addr = critical_devs[i].addr;
    366  1.7.8.2  yamt 		oa.obio_size = OBIOCF_SIZE_DEFAULT;
    367  1.7.8.2  yamt 		oa.obio_intr = OBIOCF_INTR_DEFAULT;
    368  1.7.8.2  yamt 		oa.obio_intrbase = OBIOCF_INTRBASE_DEFAULT;
    369  1.7.8.2  yamt 
    370  1.7.8.2  yamt #if 0
    371  1.7.8.2  yamt 		if (oa.obio_addr != OBIOCF_ADDR_DEFAULT
    372  1.7.8.2  yamt 		    && (oa.obio_addr < sc->sc_base
    373  1.7.8.2  yamt 		        || oa.obio_addr >= sc->sc_base + sc->sc_size))
    374  1.7.8.2  yamt 			continue;
    375  1.7.8.2  yamt #endif
    376  1.7.8.2  yamt 
    377  1.7.8.2  yamt 		cf = config_search_ia(obio_find, sc->sc_dev, "obio", &oa);
    378  1.7.8.2  yamt 		if (cf == NULL && critical_devs[i].required)
    379  1.7.8.2  yamt 			panic("obio_attach_critical: failed to find %s!",
    380  1.7.8.2  yamt 			    critical_devs[i].name);
    381  1.7.8.2  yamt 
    382  1.7.8.2  yamt 		oa.obio_addr = cf->cf_loc[OBIOCF_ADDR];
    383  1.7.8.2  yamt 		oa.obio_size = cf->cf_loc[OBIOCF_SIZE];
    384  1.7.8.2  yamt 		oa.obio_intr = cf->cf_loc[OBIOCF_INTR];
    385  1.7.8.2  yamt 		oa.obio_intrbase = cf->cf_loc[OBIOCF_INTRBASE];
    386  1.7.8.2  yamt 		config_attach(sc->sc_dev, cf, &oa, obio_print);
    387  1.7.8.2  yamt 	}
    388  1.7.8.2  yamt }
    389  1.7.8.2  yamt 
    390  1.7.8.2  yamt static int
    391  1.7.8.2  yamt obio_print(void *aux, const char *name)
    392  1.7.8.2  yamt {
    393  1.7.8.2  yamt 	struct obio_attach_args *oa = (struct obio_attach_args*)aux;
    394  1.7.8.2  yamt 
    395  1.7.8.2  yamt 	if (oa->obio_addr != OBIOCF_ADDR_DEFAULT) {
    396  1.7.8.2  yamt 		aprint_normal(" addr 0x%08lx", oa->obio_addr);
    397  1.7.8.2  yamt 		if (oa->obio_size != OBIOCF_SIZE_DEFAULT)
    398  1.7.8.2  yamt 			aprint_normal("-0x%08lx",
    399  1.7.8.2  yamt 				oa->obio_addr + oa->obio_size-1);
    400  1.7.8.2  yamt 	}
    401  1.7.8.2  yamt 	if (oa->obio_intr != OBIOCF_INTR_DEFAULT)
    402  1.7.8.2  yamt 		aprint_normal(" intr %d", oa->obio_intr);
    403  1.7.8.2  yamt 	if (oa->obio_intrbase != OBIOCF_INTRBASE_DEFAULT)
    404  1.7.8.2  yamt 		aprint_normal(" intrbase %d", oa->obio_intrbase);
    405  1.7.8.2  yamt 
    406  1.7.8.2  yamt 	return UNCONF;
    407  1.7.8.2  yamt }
    408