uba_cmi.c revision 1.11
11.11Slukem/* $NetBSD: uba_cmi.c,v 1.11 2003/07/15 02:15:02 lukem Exp $ */ 21.1Sragge/* 31.1Sragge * Copyright (c) 1996 Jonathan Stone. 41.1Sragge * Copyright (c) 1994, 1996 Ludd, University of Lule}, Sweden. 51.1Sragge * Copyright (c) 1982, 1986 The Regents of the University of California. 61.1Sragge * All rights reserved. 71.1Sragge * 81.1Sragge * Redistribution and use in source and binary forms, with or without 91.1Sragge * modification, are permitted provided that the following conditions 101.1Sragge * are met: 111.1Sragge * 1. Redistributions of source code must retain the above copyright 121.1Sragge * notice, this list of conditions and the following disclaimer. 131.1Sragge * 2. Redistributions in binary form must reproduce the above copyright 141.1Sragge * notice, this list of conditions and the following disclaimer in the 151.1Sragge * documentation and/or other materials provided with the distribution. 161.1Sragge * 3. All advertising materials mentioning features or use of this software 171.1Sragge * must display the following acknowledgement: 181.1Sragge * This product includes software developed by the University of 191.1Sragge * California, Berkeley and its contributors. 201.1Sragge * 4. Neither the name of the University nor the names of its contributors 211.1Sragge * may be used to endorse or promote products derived from this software 221.1Sragge * without specific prior written permission. 231.1Sragge * 241.1Sragge * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 251.1Sragge * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 261.1Sragge * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 271.1Sragge * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 281.1Sragge * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 291.1Sragge * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 301.1Sragge * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 311.1Sragge * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 321.1Sragge * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 331.1Sragge * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 341.1Sragge * SUCH DAMAGE. 351.1Sragge * 361.1Sragge * @(#)uba.c 7.10 (Berkeley) 12/16/90 371.1Sragge * @(#)autoconf.c 7.20 (Berkeley) 5/9/91 381.1Sragge */ 391.11Slukem 401.11Slukem#include <sys/cdefs.h> 411.11Slukem__KERNEL_RCSID(0, "$NetBSD: uba_cmi.c,v 1.11 2003/07/15 02:15:02 lukem Exp $"); 421.1Sragge 431.1Sragge#include <sys/param.h> 441.1Sragge#include <sys/device.h> 451.1Sragge#include <sys/systm.h> 461.1Sragge 471.1Sragge#define _VAX_BUS_DMA_PRIVATE 481.1Sragge#include <machine/bus.h> 491.1Sragge#include <machine/mtpr.h> 501.1Sragge#include <machine/nexus.h> 511.1Sragge#include <machine/cpu.h> 521.1Sragge#include <machine/sgmap.h> 531.1Sragge 541.1Sragge#include <dev/qbus/ubavar.h> 551.1Sragge 561.4Smatt#include <vax/uba/uba_common.h> 571.1Sragge 581.5Sragge#include "locators.h" 591.5Sragge 601.1Sragge/* Some CMI-specific defines */ 611.2Sragge#define UBASIZE ((UBAPAGES + UBAIOPAGES) * VAX_NBPG) 621.2Sragge#define UMEM750(i) (0xfc0000 - (i) * UBASIZE) 631.2Sragge#define UIOPAGE(x) (UMEM750(x) + (UBAPAGES * VAX_NBPG)) 641.1Sragge 651.1Sragge/* 661.1Sragge * The DW780 and DW750 are quite similar to their function from 671.1Sragge * a programmers point of view. Differencies are number of BDP's 681.1Sragge * and bus status/command registers, the latter are (partly) IPR's 691.1Sragge * on 750. 701.1Sragge */ 711.5Sraggestatic int dw750_match(struct device *, struct cfdata *, void *); 721.5Sraggestatic void dw750_attach(struct device *, struct device *, void *); 731.5Sraggestatic void dw750_init(struct uba_softc*); 741.1Sragge#ifdef notyet 751.5Sraggestatic void dw750_purge(struct uba_softc *, int); 761.1Sragge#endif 771.1Sragge 781.9SthorpejCFATTACH_DECL(uba_cmi, sizeof(struct uba_vsoftc), 791.10Sthorpej dw750_match, dw750_attach, NULL, NULL); 801.1Sragge 811.1Sraggeextern struct vax_bus_space vax_mem_bus_space; 821.1Sragge 831.1Sraggeint 841.5Sraggedw750_match(struct device *parent, struct cfdata *cf, void *aux) 851.1Sragge{ 861.1Sragge struct sbi_attach_args *sa = (struct sbi_attach_args *)aux; 871.1Sragge 881.5Sragge if (cf->cf_loc[CMICF_TR] != sa->sa_nexnum && 891.5Sragge cf->cf_loc[CMICF_TR] != CMICF_TR_DEFAULT) 901.1Sragge return 0; 911.1Sragge /* 921.1Sragge * The uba type is actually only telling where the uba 931.1Sragge * space is in nexus space. 941.1Sragge */ 951.5Sragge if ((sa->sa_type & ~3) != NEX_UBA0) 961.1Sragge return 0; 971.1Sragge 981.1Sragge return 1; 991.1Sragge} 1001.1Sragge 1011.1Sraggevoid 1021.5Sraggedw750_attach(struct device *parent, struct device *self, void *aux) 1031.1Sragge{ 1041.1Sragge struct uba_vsoftc *sc = (void *)self; 1051.1Sragge struct sbi_attach_args *sa = aux; 1061.1Sragge 1071.1Sragge printf(": DW750\n"); 1081.1Sragge /* 1091.1Sragge * Fill in bus specific data. 1101.1Sragge */ 1111.1Sragge sc->uv_sc.uh_ubainit = dw750_init; 1121.1Sragge#ifdef notyet 1131.1Sragge sc->uv_sc.uh_ubapurge = dw750_purge; 1141.1Sragge#endif 1151.1Sragge sc->uv_sc.uh_iot = &vax_mem_bus_space; 1161.1Sragge sc->uv_sc.uh_dmat = &sc->uv_dmat; 1171.6Sragge sc->uv_sc.uh_type = UBA_UBA; 1181.7Sragge sc->uv_sc.uh_nr = sa->sa_type == NEX_UBA1; 1191.1Sragge 1201.1Sragge /* 1211.1Sragge * Fill in variables used by the sgmap system. 1221.1Sragge */ 1231.3Sragge sc->uv_size = UBAPAGES * VAX_NBPG; 1241.5Sragge sc->uv_uba = (void *)sa->sa_ioh; /* Map registers is in adaptor */ 1251.1Sragge 1261.1Sragge uba_dma_init(sc); 1271.5Sragge uba_attach(&sc->uv_sc, UIOPAGE(sa->sa_type == NEX_UBA1)); 1281.1Sragge} 1291.1Sragge 1301.1Sraggevoid 1311.5Sraggedw750_init(struct uba_softc *sc) 1321.1Sragge{ 1331.1Sragge mtpr(0, PR_IUR); 1341.1Sragge DELAY(500000); 1351.1Sragge} 1361.1Sragge 1371.1Sragge#ifdef notyet 1381.1Sraggevoid 1391.5Sraggedw750_purge(struct uba_softc sc, int bdp) 1401.1Sragge{ 1411.1Sragge sc->uh_uba->uba_dpr[bdp] |= UBADPR_PURGE | UBADPR_NXM | UBADPR_UCE; 1421.1Sragge} 1431.1Sragge#endif 144