uba_cmi.c revision 1.12
11.12Sagc/* $NetBSD: uba_cmi.c,v 1.12 2003/08/07 16:30:14 agc Exp $ */ 21.12Sagc/* 31.12Sagc * Copyright (c) 1982, 1986 The Regents of the University of California. 41.12Sagc * All rights reserved. 51.12Sagc * 61.12Sagc * Redistribution and use in source and binary forms, with or without 71.12Sagc * modification, are permitted provided that the following conditions 81.12Sagc * are met: 91.12Sagc * 1. Redistributions of source code must retain the above copyright 101.12Sagc * notice, this list of conditions and the following disclaimer. 111.12Sagc * 2. Redistributions in binary form must reproduce the above copyright 121.12Sagc * notice, this list of conditions and the following disclaimer in the 131.12Sagc * documentation and/or other materials provided with the distribution. 141.12Sagc * 3. Neither the name of the University nor the names of its contributors 151.12Sagc * may be used to endorse or promote products derived from this software 161.12Sagc * without specific prior written permission. 171.12Sagc * 181.12Sagc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 191.12Sagc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 201.12Sagc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 211.12Sagc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 221.12Sagc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 231.12Sagc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 241.12Sagc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 251.12Sagc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 261.12Sagc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 271.12Sagc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 281.12Sagc * SUCH DAMAGE. 291.12Sagc * 301.12Sagc * @(#)uba.c 7.10 (Berkeley) 12/16/90 311.12Sagc * @(#)autoconf.c 7.20 (Berkeley) 5/9/91 321.12Sagc */ 331.12Sagc 341.1Sragge/* 351.1Sragge * Copyright (c) 1996 Jonathan Stone. 361.1Sragge * Copyright (c) 1994, 1996 Ludd, University of Lule}, Sweden. 371.1Sragge * 381.1Sragge * Redistribution and use in source and binary forms, with or without 391.1Sragge * modification, are permitted provided that the following conditions 401.1Sragge * are met: 411.1Sragge * 1. Redistributions of source code must retain the above copyright 421.1Sragge * notice, this list of conditions and the following disclaimer. 431.1Sragge * 2. Redistributions in binary form must reproduce the above copyright 441.1Sragge * notice, this list of conditions and the following disclaimer in the 451.1Sragge * documentation and/or other materials provided with the distribution. 461.1Sragge * 3. All advertising materials mentioning features or use of this software 471.1Sragge * must display the following acknowledgement: 481.1Sragge * This product includes software developed by the University of 491.1Sragge * California, Berkeley and its contributors. 501.1Sragge * 4. Neither the name of the University nor the names of its contributors 511.1Sragge * may be used to endorse or promote products derived from this software 521.1Sragge * without specific prior written permission. 531.1Sragge * 541.1Sragge * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 551.1Sragge * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 561.1Sragge * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 571.1Sragge * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 581.1Sragge * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 591.1Sragge * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 601.1Sragge * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 611.1Sragge * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 621.1Sragge * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 631.1Sragge * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 641.1Sragge * SUCH DAMAGE. 651.1Sragge * 661.1Sragge * @(#)uba.c 7.10 (Berkeley) 12/16/90 671.1Sragge * @(#)autoconf.c 7.20 (Berkeley) 5/9/91 681.1Sragge */ 691.11Slukem 701.11Slukem#include <sys/cdefs.h> 711.12Sagc__KERNEL_RCSID(0, "$NetBSD: uba_cmi.c,v 1.12 2003/08/07 16:30:14 agc Exp $"); 721.1Sragge 731.1Sragge#include <sys/param.h> 741.1Sragge#include <sys/device.h> 751.1Sragge#include <sys/systm.h> 761.1Sragge 771.1Sragge#define _VAX_BUS_DMA_PRIVATE 781.1Sragge#include <machine/bus.h> 791.1Sragge#include <machine/mtpr.h> 801.1Sragge#include <machine/nexus.h> 811.1Sragge#include <machine/cpu.h> 821.1Sragge#include <machine/sgmap.h> 831.1Sragge 841.1Sragge#include <dev/qbus/ubavar.h> 851.1Sragge 861.4Smatt#include <vax/uba/uba_common.h> 871.1Sragge 881.5Sragge#include "locators.h" 891.5Sragge 901.1Sragge/* Some CMI-specific defines */ 911.2Sragge#define UBASIZE ((UBAPAGES + UBAIOPAGES) * VAX_NBPG) 921.2Sragge#define UMEM750(i) (0xfc0000 - (i) * UBASIZE) 931.2Sragge#define UIOPAGE(x) (UMEM750(x) + (UBAPAGES * VAX_NBPG)) 941.1Sragge 951.1Sragge/* 961.1Sragge * The DW780 and DW750 are quite similar to their function from 971.1Sragge * a programmers point of view. Differencies are number of BDP's 981.1Sragge * and bus status/command registers, the latter are (partly) IPR's 991.1Sragge * on 750. 1001.1Sragge */ 1011.5Sraggestatic int dw750_match(struct device *, struct cfdata *, void *); 1021.5Sraggestatic void dw750_attach(struct device *, struct device *, void *); 1031.5Sraggestatic void dw750_init(struct uba_softc*); 1041.1Sragge#ifdef notyet 1051.5Sraggestatic void dw750_purge(struct uba_softc *, int); 1061.1Sragge#endif 1071.1Sragge 1081.9SthorpejCFATTACH_DECL(uba_cmi, sizeof(struct uba_vsoftc), 1091.10Sthorpej dw750_match, dw750_attach, NULL, NULL); 1101.1Sragge 1111.1Sraggeextern struct vax_bus_space vax_mem_bus_space; 1121.1Sragge 1131.1Sraggeint 1141.5Sraggedw750_match(struct device *parent, struct cfdata *cf, void *aux) 1151.1Sragge{ 1161.1Sragge struct sbi_attach_args *sa = (struct sbi_attach_args *)aux; 1171.1Sragge 1181.5Sragge if (cf->cf_loc[CMICF_TR] != sa->sa_nexnum && 1191.5Sragge cf->cf_loc[CMICF_TR] != CMICF_TR_DEFAULT) 1201.1Sragge return 0; 1211.1Sragge /* 1221.1Sragge * The uba type is actually only telling where the uba 1231.1Sragge * space is in nexus space. 1241.1Sragge */ 1251.5Sragge if ((sa->sa_type & ~3) != NEX_UBA0) 1261.1Sragge return 0; 1271.1Sragge 1281.1Sragge return 1; 1291.1Sragge} 1301.1Sragge 1311.1Sraggevoid 1321.5Sraggedw750_attach(struct device *parent, struct device *self, void *aux) 1331.1Sragge{ 1341.1Sragge struct uba_vsoftc *sc = (void *)self; 1351.1Sragge struct sbi_attach_args *sa = aux; 1361.1Sragge 1371.1Sragge printf(": DW750\n"); 1381.1Sragge /* 1391.1Sragge * Fill in bus specific data. 1401.1Sragge */ 1411.1Sragge sc->uv_sc.uh_ubainit = dw750_init; 1421.1Sragge#ifdef notyet 1431.1Sragge sc->uv_sc.uh_ubapurge = dw750_purge; 1441.1Sragge#endif 1451.1Sragge sc->uv_sc.uh_iot = &vax_mem_bus_space; 1461.1Sragge sc->uv_sc.uh_dmat = &sc->uv_dmat; 1471.6Sragge sc->uv_sc.uh_type = UBA_UBA; 1481.7Sragge sc->uv_sc.uh_nr = sa->sa_type == NEX_UBA1; 1491.1Sragge 1501.1Sragge /* 1511.1Sragge * Fill in variables used by the sgmap system. 1521.1Sragge */ 1531.3Sragge sc->uv_size = UBAPAGES * VAX_NBPG; 1541.5Sragge sc->uv_uba = (void *)sa->sa_ioh; /* Map registers is in adaptor */ 1551.1Sragge 1561.1Sragge uba_dma_init(sc); 1571.5Sragge uba_attach(&sc->uv_sc, UIOPAGE(sa->sa_type == NEX_UBA1)); 1581.1Sragge} 1591.1Sragge 1601.1Sraggevoid 1611.5Sraggedw750_init(struct uba_softc *sc) 1621.1Sragge{ 1631.1Sragge mtpr(0, PR_IUR); 1641.1Sragge DELAY(500000); 1651.1Sragge} 1661.1Sragge 1671.1Sragge#ifdef notyet 1681.1Sraggevoid 1691.5Sraggedw750_purge(struct uba_softc sc, int bdp) 1701.1Sragge{ 1711.1Sragge sc->uh_uba->uba_dpr[bdp] |= UBADPR_PURGE | UBADPR_NXM | UBADPR_UCE; 1721.1Sragge} 1731.1Sragge#endif 174