Home | History | Annotate | Line # | Download | only in dev
vtpbc_mainbus.c revision 1.9
      1 /*	$NetBSD: vtpbc_mainbus.c,v 1.9 2002/10/02 03:36:20 thorpej Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2001 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the NetBSD
     21  *	Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #include "opt_algor_p4032.h"
     40 #include "opt_algor_p5064.h"
     41 
     42 #include <sys/param.h>
     43 #include <sys/systm.h>
     44 #include <sys/conf.h>
     45 #include <sys/reboot.h>
     46 #include <sys/device.h>
     47 
     48 #include <machine/bus.h>
     49 #include <machine/autoconf.h>
     50 
     51 #include <algor/pci/vtpbcvar.h>
     52 
     53 #ifdef ALGOR_P4032
     54 #include <algor/algor/algor_p4032var.h>
     55 #endif
     56 
     57 #ifdef ALGOR_P5064
     58 #include <algor/algor/algor_p5064var.h>
     59 #endif
     60 
     61 struct vtpbc_softc {
     62 	struct device sc_dev;
     63 	struct vtpbc_config *sc_vtpbc;
     64 };
     65 
     66 int	vtpbc_mainbus_match(struct device *, struct cfdata *, void *);
     67 void	vtpbc_mainbus_attach(struct device *, struct device *, void *);
     68 
     69 CFATTACH_DECL(vtpbc_mainbus, sizeof(struct vtpbc_softc),
     70     vtpbc_mainbus_match, vtpbc_mainbus_attach, NULL, NULL);
     71 extern struct cfdriver vtpbc_cd;
     72 
     73 int	vtpbc_mainbus_print(void *, const char *);
     74 
     75 int
     76 vtpbc_mainbus_match(struct device *parent, struct cfdata *cf, void *aux)
     77 {
     78 	struct mainbus_attach_args *ma = aux;
     79 
     80 	if (strcmp(ma->ma_name, vtpbc_cd.cd_name) == 0)
     81 		return (1);
     82 
     83 	return (0);
     84 }
     85 
     86 void
     87 vtpbc_mainbus_attach(struct device *parent, struct device *self, void *aux)
     88 {
     89 	struct vtpbc_softc *sc = (void *) self;
     90 	struct pcibus_attach_args pba;
     91 	struct vtpbc_config *vt;
     92 
     93 	/*
     94 	 * There is only one PCI controller on an Algorithmics board.
     95 	 */
     96 	vt = &vtpbc_configuration;
     97 	sc->sc_vtpbc = vt;
     98 
     99 	if (vt->vt_rev < vtpbc_nrevs)
    100 		printf(": V3 V962, revision %s\n", vtpbc_revs[vt->vt_rev]);
    101 	else
    102 		printf(": V3 V962, unknown revision %d\n", vt->vt_rev);
    103 
    104 	printf("%s: PCI memory space base: 0x%08lx\n", sc->sc_dev.dv_xname,
    105 	    (u_long) vt->vt_pci_membase);
    106 	printf("%s: PCI DMA window base: 0x%08lx\n", sc->sc_dev.dv_xname,
    107 	    (u_long) vt->vt_dma_winbase);
    108 
    109 	pba.pba_busname = "pci";
    110 	pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED;
    111 	pba.pba_bus = 0;
    112 	pba.pba_bridgetag = NULL;
    113 
    114 	if (vt->vt_pci_iobase == (bus_addr_t) -1)
    115 		pba.pba_flags &= ~PCI_FLAGS_IO_ENABLED;
    116 
    117 #if defined(ALGOR_P4032)
    118 	    {
    119 		struct p4032_config *acp = &p4032_configuration;
    120 
    121 		pba.pba_iot = &acp->ac_iot;
    122 		pba.pba_memt = &acp->ac_memt;
    123 		pba.pba_dmat = &acp->ac_pci_dmat;
    124 		pba.pba_pc = &acp->ac_pc;
    125 	    }
    126 #elif defined(ALGOR_P5064)
    127 	    {
    128 		struct p5064_config *acp = &p5064_configuration;
    129 
    130 		pba.pba_iot = &acp->ac_iot;
    131 		pba.pba_memt = &acp->ac_memt;
    132 		pba.pba_dmat = &acp->ac_pci_dmat;
    133 		pba.pba_pc = &acp->ac_pc;
    134 	    }
    135 #endif /* ALGOR_P4032 || ALGOR_P5064 */
    136 
    137 	(void) config_found(self, &pba, vtpbc_mainbus_print);
    138 }
    139 
    140 int
    141 vtpbc_mainbus_print(void *aux, const char *pnp)
    142 {
    143 	struct pcibus_attach_args *pba = aux;
    144 
    145 	/* only PCIs can attach to VTPBCs; easy. */
    146 	if (pnp)
    147 		printf("%s at %s", pba->pba_busname, pnp);
    148 	printf(" bus %d", pba->pba_bus);
    149 
    150 	return (UNCONF);
    151 }
    152