Home | History | Annotate | Line # | Download | only in uba
uba_mainbus.c revision 1.6
      1 /*	$NetBSD: uba_mainbus.c,v 1.6 2003/07/15 02:15:02 lukem Exp $	   */
      2 /*
      3  * Copyright (c) 1996 Jonathan Stone.
      4  * Copyright (c) 1994, 1996 Ludd, University of Lule}, Sweden.
      5  * Copyright (c) 1982, 1986 The Regents of the University of California.
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. All advertising materials mentioning features or use of this software
     17  *    must display the following acknowledgement:
     18  *	This product includes software developed by the University of
     19  *	California, Berkeley and its contributors.
     20  * 4. Neither the name of the University nor the names of its contributors
     21  *    may be used to endorse or promote products derived from this software
     22  *    without specific prior written permission.
     23  *
     24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34  * SUCH DAMAGE.
     35  *
     36  *	@(#)uba.c	7.10 (Berkeley) 12/16/90
     37  *	@(#)autoconf.c	7.20 (Berkeley) 5/9/91
     38  */
     39 
     40 #include <sys/cdefs.h>
     41 __KERNEL_RCSID(0, "$NetBSD: uba_mainbus.c,v 1.6 2003/07/15 02:15:02 lukem Exp $");
     42 
     43 #include <sys/param.h>
     44 #include <sys/device.h>
     45 #include <sys/systm.h>
     46 
     47 #define	_VAX_BUS_DMA_PRIVATE
     48 #include <machine/bus.h>
     49 #include <machine/mtpr.h>
     50 #include <machine/nexus.h>
     51 #include <machine/cpu.h>
     52 #include <machine/sgmap.h>
     53 
     54 #include <dev/qbus/ubavar.h>
     55 
     56 #include <arch/vax/uba/uba_common.h>
     57 
     58 /* Some Qbus-specific defines */
     59 #define	QBASIZE	(8192 * VAX_NBPG)
     60 #define	QBAMAP	0x20088000
     61 #define	QIOPAGE	0x20000000
     62 
     63 /*
     64  * The Q22 bus is the main IO bus on MicroVAX II/MicroVAX III systems.
     65  * It has an address space of 4MB (22 address bits), therefore the name,
     66  * and is hardware compatible with all 16 and 18 bits Q-bus devices.
     67  */
     68 static	int	qba_match __P((struct device *, struct cfdata *, void *));
     69 static	void	qba_attach __P((struct device *, struct device *, void *));
     70 static	void	qba_beforescan __P((struct uba_softc*));
     71 static	void	qba_init __P((struct uba_softc*));
     72 
     73 CFATTACH_DECL(uba_mainbus, sizeof(struct uba_vsoftc),
     74     qba_match, qba_attach, NULL, NULL);
     75 
     76 extern	struct vax_bus_space vax_mem_bus_space;
     77 
     78 int
     79 qba_match(parent, vcf, aux)
     80 	struct device *parent;
     81 	struct cfdata *vcf;
     82 	void *aux;
     83 {
     84 	struct	bp_conf *bp = aux;
     85 
     86 	if (strcmp(bp->type, "uba"))
     87 		return 0;
     88 
     89 	return 1;
     90 }
     91 
     92 void
     93 qba_attach(parent, self, aux)
     94 	struct device *parent, *self;
     95 	void *aux;
     96 {
     97 	struct uba_vsoftc *sc = (void *)self;
     98 
     99 	printf(": Q22\n");
    100 	/*
    101 	 * Fill in bus specific data.
    102 	 */
    103 	sc->uv_sc.uh_beforescan = qba_beforescan;
    104 	sc->uv_sc.uh_ubainit = qba_init;
    105 	sc->uv_sc.uh_iot = &vax_mem_bus_space;
    106 	sc->uv_sc.uh_dmat = &sc->uv_dmat;
    107 
    108 	/*
    109 	 * Fill in variables used by the sgmap system.
    110 	 */
    111 	sc->uv_size = QBASIZE;	/* Size in bytes of Qbus space */
    112 	sc->uv_addr = QBAMAP;	/* Physical address of map registers */
    113 
    114 	uba_dma_init(sc);
    115 	uba_attach(&sc->uv_sc, QIOPAGE);
    116 }
    117 
    118 /*
    119  * Called when the QBA is set up; to enable DMA access from
    120  * QBA devices to main memory.
    121  */
    122 void
    123 qba_beforescan(sc)
    124 	struct uba_softc *sc;
    125 {
    126 #define	QIPCR	0x1f40
    127 #define	Q_LMEAE	0x20
    128 	bus_space_write_2(sc->uh_tag, sc->uh_ioh, QIPCR, Q_LMEAE);
    129 }
    130 
    131 void
    132 qba_init(sc)
    133 	struct uba_softc *sc;
    134 {
    135 	mtpr(0, PR_IUR);
    136 	DELAY(500000);
    137 	qba_beforescan(sc);
    138 }
    139