uba_bi.c revision 1.8
11.8Sthorpej/* $NetBSD: uba_bi.c,v 1.8 2002/10/02 16:33:39 thorpej Exp $ */ 21.1Sragge/* 31.1Sragge * Copyright (c) 1998 Ludd, University of Lule}, Sweden. 41.1Sragge * All rights reserved. 51.1Sragge * 61.1Sragge * Redistribution and use in source and binary forms, with or without 71.1Sragge * modification, are permitted provided that the following conditions 81.1Sragge * are met: 91.1Sragge * 1. Redistributions of source code must retain the above copyright 101.1Sragge * notice, this list of conditions and the following disclaimer. 111.1Sragge * 2. Redistributions in binary form must reproduce the above copyright 121.1Sragge * notice, this list of conditions and the following disclaimer in the 131.1Sragge * documentation and/or other materials provided with the distribution. 141.1Sragge * 3. All advertising materials mentioning features or use of this software 151.1Sragge * must display the following acknowledgement: 161.1Sragge * This product includes software developed at Ludd, University of 171.1Sragge * Lule}, Sweden and its contributors. 181.1Sragge * 4. The name of the author may not be used to endorse or promote products 191.1Sragge * derived from this software without specific prior written permission 201.1Sragge * 211.1Sragge * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 221.1Sragge * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 231.1Sragge * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 241.1Sragge * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 251.1Sragge * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 261.1Sragge * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 271.1Sragge * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 281.1Sragge * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 291.1Sragge * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 301.1Sragge * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 311.1Sragge */ 321.1Sragge 331.1Sragge/* 341.1Sragge * DWBUA BI-Unibus adapter 351.1Sragge */ 361.5Slukem 371.5Slukem#include <sys/cdefs.h> 381.8Sthorpej__KERNEL_RCSID(0, "$NetBSD: uba_bi.c,v 1.8 2002/10/02 16:33:39 thorpej Exp $"); 391.1Sragge 401.1Sragge#include <sys/param.h> 411.1Sragge#include <sys/kernel.h> 421.1Sragge#include <sys/buf.h> 431.1Sragge#include <sys/device.h> 441.1Sragge#include <sys/proc.h> 451.1Sragge#include <sys/user.h> 461.1Sragge#include <sys/malloc.h> 471.1Sragge#include <sys/systm.h> 481.1Sragge 491.1Sragge#include <machine/sid.h> 501.1Sragge#include <machine/pte.h> 511.1Sragge#include <machine/pcb.h> 521.1Sragge#include <machine/trap.h> 531.1Sragge#include <machine/scb.h> 541.1Sragge 551.1Sragge#include <vax/bi/bireg.h> 561.1Sragge#include <vax/bi/bivar.h> 571.1Sragge 581.1Sragge#include <vax/uba/ubareg.h> 591.1Sragge#include <vax/uba/ubavar.h> 601.1Sragge 611.1Sragge#include "locators.h" 621.1Sragge 631.1Sragge#define BUA(uba) ((struct dwbua_regs *)(uba)) 641.1Sragge 651.1Sraggestatic int uba_bi_match __P((struct device *, struct cfdata *, void *)); 661.1Sraggestatic void uba_bi_attach __P((struct device *, struct device *, void *)); 671.1Sraggestatic void bua_init __P((struct uba_softc *)); 681.1Sraggestatic void bua_purge __P((struct uba_softc *, int)); 691.1Sragge 701.1Sragge/* bua_csr */ 711.1Sragge#define BUACSR_ERR 0x80000000 /* composite error */ 721.1Sragge#define BUACSR_BIF 0x10000000 /* BI failure */ 731.1Sragge#define BUACSR_SSYNTO 0x08000000 /* slave sync timeout */ 741.1Sragge#define BUACSR_UIE 0x04000000 /* unibus interlock error */ 751.1Sragge#define BUACSR_IVMR 0x02000000 /* invalid map register */ 761.1Sragge#define BUACSR_BADBDP 0x01000000 /* bad BDP select */ 771.1Sragge#define BUACSR_BUAEIE 0x00100000 /* bua error interrupt enable (?) */ 781.1Sragge#define BUACSR_UPI 0x00020000 /* unibus power init */ 791.1Sragge#define BUACSR_UREGDUMP 0x00010000 /* microdiag register dump */ 801.1Sragge#define BUACSR_IERRNO 0x000000ff /* mask for internal errror number */ 811.1Sragge 821.1Sragge/* bua_offset */ 831.1Sragge#define BUAOFFSET_MASK 0x00003e00 /* hence max offset = 15872 */ 841.1Sragge 851.1Sragge/* bua_dpr */ 861.1Sragge#define BUADPR_DPSEL 0x00e00000 /* data path select (?) */ 871.1Sragge#define BUADPR_PURGE 0x00000001 /* purge bdp */ 881.1Sragge 891.1Sragge/* bua_map -- in particular, those bits that are not in DW780s & DW750s */ 901.1Sragge#define BUAMR_IOADR 0x40000000 /* I/O address space */ 911.1Sragge#define BUAMR_LAE 0x04000000 /* longword access enable */ 921.1Sragge 931.1Sraggestatic int allocvec; 941.1Sragge 951.7SthorpejCFATTACH_DECL(uba_bi, sizeof(struct uba_softc), 961.8Sthorpej uba_bi_match, uba_bi_attach, NULL, NULL); 971.1Sragge 981.1Sraggestruct dwbua_regs { 991.1Sragge struct biiregs bn_biic; /* interface */ 1001.1Sragge int pad1[396]; 1011.1Sragge int bn_csr; 1021.1Sragge int bn_vor; /* Vector offset from SCB */ 1031.1Sragge int bn_fubar; /* Failed Unibus address register */ 1041.1Sragge int bn_bifar; /* BI failed address register */ 1051.1Sragge int bn_mdiag[5]; /* microdiag regs for BDP */ 1061.1Sragge int pad2[3]; 1071.1Sragge int bn_dpcsr[6]; /* Data path control and status register */ 1081.1Sragge int pad3[38]; 1091.1Sragge struct pte bn_map[UBAPAGES]; /* Unibus map registers */ 1101.1Sragge int pad4[UBAIOPAGES]; 1111.1Sragge}; 1121.1Sragge 1131.1Sragge/* 1141.1Sragge * Poke at a supposed DWBUA to see if it is there. 1151.1Sragge */ 1161.1Sraggestatic int 1171.1Sraggeuba_bi_match(parent, cf, aux) 1181.1Sragge struct device *parent; 1191.1Sragge struct cfdata *cf; 1201.1Sragge void *aux; 1211.1Sragge{ 1221.1Sragge struct bi_attach_args *ba = aux; 1231.1Sragge 1241.1Sragge if ((ba->ba_node->biic.bi_dtype != BIDT_DWBUA) && 1251.1Sragge (ba->ba_node->biic.bi_dtype != BIDT_KLESI)) 1261.1Sragge return 0; 1271.1Sragge 1281.1Sragge if (cf->cf_loc[BICF_NODE] != BICF_NODE_DEFAULT && 1291.1Sragge cf->cf_loc[BICF_NODE] != ba->ba_nodenr) 1301.1Sragge return 0; 1311.1Sragge 1321.1Sragge return 1; 1331.1Sragge} 1341.1Sragge 1351.1Sraggevoid 1361.1Sraggeuba_bi_attach(parent, self, aux) 1371.1Sragge struct device *parent, *self; 1381.1Sragge void *aux; 1391.1Sragge{ 1401.1Sragge struct uba_softc *sc = (void *)self; 1411.1Sragge struct bi_attach_args *ba = aux; 1421.1Sragge volatile int timo; 1431.1Sragge 1441.1Sragge if (ba->ba_node->biic.bi_dtype == BIDT_DWBUA) 1451.1Sragge printf(": DWBUA\n"); 1461.1Sragge else 1471.1Sragge printf(": KLESI-B\n"); 1481.1Sragge 1491.1Sragge /* 1501.1Sragge * Fill in bus specific data. 1511.1Sragge */ 1521.1Sragge sc->uh_uba = (void *)ba->ba_node; 1531.1Sragge sc->uh_nbdp = NBDPBUA; 1541.1Sragge/* sc->uh_nr is 0; uninteresting here */ 1551.1Sragge/* sc->uh_afterscan; not used */ 1561.1Sragge/* sc->uh_errchk; not used */ 1571.1Sragge/* sc->uh_beforescan */ 1581.1Sragge sc->uh_ubapurge = bua_purge; 1591.1Sragge sc->uh_ubainit = bua_init; 1601.1Sragge/* sc->uh_type not used */ 1611.1Sragge sc->uh_memsize = UBAPAGES; 1621.1Sragge sc->uh_mr = BUA(sc->uh_uba)->bn_map; 1631.1Sragge 1641.1Sragge#ifdef notdef 1651.1Sragge /* Can we get separate interrupts? */ 1661.1Sragge scb->scb_nexvec[1][ba->ba_nodenr] = &sc->sc_ivec; 1671.1Sragge#endif 1681.1Sragge BUA(sc->uh_uba)->bn_biic.bi_csr |= BICSR_ARB_NONE; 1691.1Sragge BUA(sc->uh_uba)->bn_biic.bi_csr |= BICSR_STS | BICSR_INIT; 1701.1Sragge DELAY(1000); 1711.1Sragge timo = 1000; 1721.1Sragge while (BUA(sc->uh_uba)->bn_biic.bi_csr & BICSR_BROKE) 1731.1Sragge if (timo == 0) { 1741.1Sragge printf("%s: BROKE bit set\n", self->dv_xname); 1751.1Sragge return; 1761.1Sragge } 1771.1Sragge 1781.1Sragge BUA(sc->uh_uba)->bn_biic.bi_intrdes = ba->ba_intcpu; 1791.1Sragge BUA(sc->uh_uba)->bn_biic.bi_csr = 1801.1Sragge (BUA(sc->uh_uba)->bn_biic.bi_csr&~BICSR_ARB_MASK) | BICSR_ARB_HIGH; 1811.3Sragge BUA(sc->uh_uba)->bn_vor = VAX_NBPG + (VAX_NBPG * allocvec++); 1821.1Sragge 1831.2Sragge uba_attach(sc, BUA(sc->uh_uba)->bn_biic.bi_sadr + UBAPAGES * VAX_NBPG); 1841.1Sragge} 1851.1Sragge 1861.1Sragge 1871.1Sraggevoid 1881.1Sraggebua_init(sc) 1891.1Sragge struct uba_softc *sc; 1901.1Sragge{ 1911.1Sragge BUA(sc->uh_uba)->bn_csr |= BUACSR_UPI; 1921.1Sragge DELAY(500000); 1931.1Sragge}; 1941.1Sragge 1951.1Sraggevoid 1961.1Sraggebua_purge(sc, bdp) 1971.1Sragge struct uba_softc *sc; 1981.1Sragge int bdp; 1991.1Sragge{ 2001.1Sragge BUA(sc->uh_uba)->bn_dpcsr[bdp] |= BUADPR_PURGE; 2011.1Sragge} 202