1 /* $NetBSD: uba_cmi.c,v 1.10 2002/10/02 16:02:34 thorpej 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/param.h> 41 #include <sys/device.h> 42 #include <sys/systm.h> 43 44 #define _VAX_BUS_DMA_PRIVATE 45 #include <machine/bus.h> 46 #include <machine/mtpr.h> 47 #include <machine/nexus.h> 48 #include <machine/cpu.h> 49 #include <machine/sgmap.h> 50 51 #include <dev/qbus/ubavar.h> 52 53 #include <vax/uba/uba_common.h> 54 55 #include "locators.h" 56 57 /* Some CMI-specific defines */ 58 #define UBASIZE ((UBAPAGES + UBAIOPAGES) * VAX_NBPG) 59 #define UMEM750(i) (0xfc0000 - (i) * UBASIZE) 60 #define UIOPAGE(x) (UMEM750(x) + (UBAPAGES * VAX_NBPG)) 61 62 /* 63 * The DW780 and DW750 are quite similar to their function from 64 * a programmers point of view. Differencies are number of BDP's 65 * and bus status/command registers, the latter are (partly) IPR's 66 * on 750. 67 */ 68 static int dw750_match(struct device *, struct cfdata *, void *); 69 static void dw750_attach(struct device *, struct device *, void *); 70 static void dw750_init(struct uba_softc*); 71 #ifdef notyet 72 static void dw750_purge(struct uba_softc *, int); 73 #endif 74 75 CFATTACH_DECL(uba_cmi, sizeof(struct uba_vsoftc), 76 dw750_match, dw750_attach, NULL, NULL); 77 78 extern struct vax_bus_space vax_mem_bus_space; 79 80 int 81 dw750_match(struct device *parent, struct cfdata *cf, void *aux) 82 { 83 struct sbi_attach_args *sa = (struct sbi_attach_args *)aux; 84 85 if (cf->cf_loc[CMICF_TR] != sa->sa_nexnum && 86 cf->cf_loc[CMICF_TR] != CMICF_TR_DEFAULT) 87 return 0; 88 /* 89 * The uba type is actually only telling where the uba 90 * space is in nexus space. 91 */ 92 if ((sa->sa_type & ~3) != NEX_UBA0) 93 return 0; 94 95 return 1; 96 } 97 98 void 99 dw750_attach(struct device *parent, struct device *self, void *aux) 100 { 101 struct uba_vsoftc *sc = (void *)self; 102 struct sbi_attach_args *sa = aux; 103 104 printf(": DW750\n"); 105 /* 106 * Fill in bus specific data. 107 */ 108 sc->uv_sc.uh_ubainit = dw750_init; 109 #ifdef notyet 110 sc->uv_sc.uh_ubapurge = dw750_purge; 111 #endif 112 sc->uv_sc.uh_iot = &vax_mem_bus_space; 113 sc->uv_sc.uh_dmat = &sc->uv_dmat; 114 sc->uv_sc.uh_type = UBA_UBA; 115 sc->uv_sc.uh_nr = sa->sa_type == NEX_UBA1; 116 117 /* 118 * Fill in variables used by the sgmap system. 119 */ 120 sc->uv_size = UBAPAGES * VAX_NBPG; 121 sc->uv_uba = (void *)sa->sa_ioh; /* Map registers is in adaptor */ 122 123 uba_dma_init(sc); 124 uba_attach(&sc->uv_sc, UIOPAGE(sa->sa_type == NEX_UBA1)); 125 } 126 127 void 128 dw750_init(struct uba_softc *sc) 129 { 130 mtpr(0, PR_IUR); 131 DELAY(500000); 132 } 133 134 #ifdef notyet 135 void 136 dw750_purge(struct uba_softc sc, int bdp) 137 { 138 sc->uh_uba->uba_dpr[bdp] |= UBADPR_PURGE | UBADPR_NXM | UBADPR_UCE; 139 } 140 #endif 141