11.16Sragge/* $NetBSD: uba_cmi.c,v 1.16 2017/05/22 17:15:45 ragge 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 * 471.1Sragge * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 481.1Sragge * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 491.1Sragge * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 501.1Sragge * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 511.1Sragge * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 521.1Sragge * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 531.1Sragge * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 541.1Sragge * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 551.1Sragge * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 561.1Sragge * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 571.1Sragge * SUCH DAMAGE. 581.1Sragge * 591.1Sragge * @(#)uba.c 7.10 (Berkeley) 12/16/90 601.1Sragge * @(#)autoconf.c 7.20 (Berkeley) 5/9/91 611.1Sragge */ 621.11Slukem 631.11Slukem#include <sys/cdefs.h> 641.16Sragge__KERNEL_RCSID(0, "$NetBSD: uba_cmi.c,v 1.16 2017/05/22 17:15:45 ragge Exp $"); 651.15Smatt 661.15Smatt#define _VAX_BUS_DMA_PRIVATE 671.1Sragge 681.1Sragge#include <sys/param.h> 691.15Smatt#include <sys/systm.h> 701.15Smatt#include <sys/cpu.h> 711.1Sragge#include <sys/device.h> 721.15Smatt#include <sys/bus.h> 731.1Sragge 741.1Sragge#include <machine/nexus.h> 751.1Sragge#include <machine/sgmap.h> 761.1Sragge 771.1Sragge#include <dev/qbus/ubavar.h> 781.1Sragge 791.4Smatt#include <vax/uba/uba_common.h> 801.1Sragge 811.5Sragge#include "locators.h" 821.5Sragge 831.1Sragge/* Some CMI-specific defines */ 841.2Sragge#define UBASIZE ((UBAPAGES + UBAIOPAGES) * VAX_NBPG) 851.2Sragge#define UMEM750(i) (0xfc0000 - (i) * UBASIZE) 861.2Sragge#define UIOPAGE(x) (UMEM750(x) + (UBAPAGES * VAX_NBPG)) 871.1Sragge 881.1Sragge/* 891.1Sragge * The DW780 and DW750 are quite similar to their function from 901.1Sragge * a programmers point of view. Differencies are number of BDP's 911.1Sragge * and bus status/command registers, the latter are (partly) IPR's 921.1Sragge * on 750. 931.1Sragge */ 941.14Smattstatic int dw750_match(device_t, cfdata_t, void *); 951.14Smattstatic void dw750_attach(device_t, device_t, void *); 961.14Smattstatic void dw750_init(struct uba_softc *); 971.1Sragge#ifdef notyet 981.5Sraggestatic void dw750_purge(struct uba_softc *, int); 991.1Sragge#endif 1001.1Sragge 1011.14SmattCFATTACH_DECL_NEW(uba_cmi, sizeof(struct uba_vsoftc), 1021.10Sthorpej dw750_match, dw750_attach, NULL, NULL); 1031.1Sragge 1041.1Sraggeint 1051.14Smattdw750_match(device_t parent, cfdata_t cf, void *aux) 1061.1Sragge{ 1071.14Smatt struct sbi_attach_args * const sa = aux; 1081.1Sragge 1091.5Sragge if (cf->cf_loc[CMICF_TR] != sa->sa_nexnum && 1101.5Sragge cf->cf_loc[CMICF_TR] != CMICF_TR_DEFAULT) 1111.1Sragge return 0; 1121.1Sragge /* 1131.1Sragge * The uba type is actually only telling where the uba 1141.1Sragge * space is in nexus space. 1151.1Sragge */ 1161.5Sragge if ((sa->sa_type & ~3) != NEX_UBA0) 1171.1Sragge return 0; 1181.1Sragge 1191.1Sragge return 1; 1201.1Sragge} 1211.1Sragge 1221.1Sraggevoid 1231.14Smattdw750_attach(device_t parent, device_t self, void *aux) 1241.1Sragge{ 1251.14Smatt struct uba_vsoftc * const sc = device_private(self); 1261.14Smatt struct sbi_attach_args * const sa = aux; 1271.14Smatt 1281.14Smatt aprint_normal(": DW750\n"); 1291.14Smatt 1301.14Smatt sc->uv_sc.uh_dev = self; 1311.1Sragge 1321.1Sragge /* 1331.1Sragge * Fill in bus specific data. 1341.1Sragge */ 1351.1Sragge sc->uv_sc.uh_ubainit = dw750_init; 1361.1Sragge#ifdef notyet 1371.1Sragge sc->uv_sc.uh_ubapurge = dw750_purge; 1381.1Sragge#endif 1391.14Smatt sc->uv_sc.uh_iot = sa->sa_iot; 1401.1Sragge sc->uv_sc.uh_dmat = &sc->uv_dmat; 1411.6Sragge sc->uv_sc.uh_type = UBA_UBA; 1421.7Sragge sc->uv_sc.uh_nr = sa->sa_type == NEX_UBA1; 1431.1Sragge 1441.1Sragge /* 1451.1Sragge * Fill in variables used by the sgmap system. 1461.1Sragge */ 1471.3Sragge sc->uv_size = UBAPAGES * VAX_NBPG; 1481.5Sragge sc->uv_uba = (void *)sa->sa_ioh; /* Map registers is in adaptor */ 1491.1Sragge 1501.1Sragge uba_dma_init(sc); 1511.5Sragge uba_attach(&sc->uv_sc, UIOPAGE(sa->sa_type == NEX_UBA1)); 1521.1Sragge} 1531.1Sragge 1541.1Sraggevoid 1551.5Sraggedw750_init(struct uba_softc *sc) 1561.1Sragge{ 1571.1Sragge mtpr(0, PR_IUR); 1581.1Sragge DELAY(500000); 1591.1Sragge} 1601.1Sragge 1611.1Sragge#ifdef notyet 1621.1Sraggevoid 1631.5Sraggedw750_purge(struct uba_softc sc, int bdp) 1641.1Sragge{ 1651.1Sragge sc->uh_uba->uba_dpr[bdp] |= UBADPR_PURGE | UBADPR_NXM | UBADPR_UCE; 1661.1Sragge} 1671.1Sragge#endif 168