Home | History | Annotate | Line # | Download | only in dev
vtpbc_mainbus.c revision 1.18
      1 /*	$NetBSD: vtpbc_mainbus.c,v 1.18 2011/07/09 16:03:01 matt 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  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #include <sys/cdefs.h>
     33 __KERNEL_RCSID(0, "$NetBSD: vtpbc_mainbus.c,v 1.18 2011/07/09 16:03:01 matt Exp $");
     34 
     35 #include "opt_algor_p4032.h"
     36 #include "opt_algor_p5064.h"
     37 
     38 #include <sys/param.h>
     39 #include <sys/bus.h>
     40 #include <sys/conf.h>
     41 #include <sys/device.h>
     42 #include <sys/reboot.h>
     43 #include <sys/systm.h>
     44 
     45 #include <algor/autoconf.h>
     46 
     47 #include <algor/pci/vtpbcvar.h>
     48 
     49 #ifdef ALGOR_P4032
     50 #include <algor/algor/algor_p4032var.h>
     51 #endif
     52 
     53 #ifdef ALGOR_P5064
     54 #include <algor/algor/algor_p5064var.h>
     55 #endif
     56 
     57 struct vtpbc_softc {
     58 	struct device sc_dev;
     59 	struct vtpbc_config *sc_vtpbc;
     60 };
     61 
     62 int	vtpbc_mainbus_match(struct device *, struct cfdata *, void *);
     63 void	vtpbc_mainbus_attach(struct device *, struct device *, void *);
     64 
     65 CFATTACH_DECL(vtpbc_mainbus, sizeof(struct vtpbc_softc),
     66     vtpbc_mainbus_match, vtpbc_mainbus_attach, NULL, NULL);
     67 extern struct cfdriver vtpbc_cd;
     68 
     69 int
     70 vtpbc_mainbus_match(struct device *parent, struct cfdata *cf, void *aux)
     71 {
     72 	struct mainbus_attach_args *ma = aux;
     73 
     74 	if (strcmp(ma->ma_name, vtpbc_cd.cd_name) == 0)
     75 		return (1);
     76 
     77 	return (0);
     78 }
     79 
     80 void
     81 vtpbc_mainbus_attach(struct device *parent, struct device *self, void *aux)
     82 {
     83 	struct vtpbc_softc *sc = (void *) self;
     84 	struct pcibus_attach_args pba;
     85 	struct vtpbc_config *vt;
     86 
     87 	/*
     88 	 * There is only one PCI controller on an Algorithmics board.
     89 	 */
     90 	vt = &vtpbc_configuration;
     91 	sc->sc_vtpbc = vt;
     92 
     93 	if (vt->vt_rev < vtpbc_nrevs)
     94 		printf(": V3 V962, revision %s\n", vtpbc_revs[vt->vt_rev]);
     95 	else
     96 		printf(": V3 V962, unknown revision %d\n", vt->vt_rev);
     97 
     98 	printf("%s: PCI memory space base: 0x%08lx\n", sc->sc_dev.dv_xname,
     99 	    (u_long) vt->vt_pci_membase);
    100 	printf("%s: PCI DMA window base: 0x%08lx\n", sc->sc_dev.dv_xname,
    101 	    (u_long) vt->vt_dma_winbase);
    102 
    103 	pba.pba_flags = PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY;
    104 	pba.pba_bus = 0;
    105 	pba.pba_bridgetag = NULL;
    106 
    107 	if (vt->vt_pci_iobase == (bus_addr_t) -1)
    108 		pba.pba_flags &= ~PCI_FLAGS_IO_OKAY;
    109 
    110 #if defined(ALGOR_P4032)
    111 	    {
    112 		struct p4032_config *acp = &p4032_configuration;
    113 
    114 		pba.pba_iot = &acp->ac_iot;
    115 		pba.pba_memt = &acp->ac_memt;
    116 		pba.pba_dmat = &acp->ac_pci_dmat;
    117 		pba.pba_dmat64 = NULL;
    118 		pba.pba_pc = &acp->ac_pc;
    119 	    }
    120 #elif defined(ALGOR_P5064)
    121 	    {
    122 		struct p5064_config *acp = &p5064_configuration;
    123 
    124 		pba.pba_iot = &acp->ac_iot;
    125 		pba.pba_memt = &acp->ac_memt;
    126 		pba.pba_dmat = &acp->ac_pci_dmat;
    127 		pba.pba_dmat64 = NULL;
    128 		pba.pba_pc = &acp->ac_pc;
    129 	    }
    130 #endif /* ALGOR_P4032 || ALGOR_P5064 */
    131 
    132 	(void) config_found_ia(self, "pcibus", &pba, pcibusprint);
    133 }
    134