uba_bi.c revision 1.13
11.13Scegger/* $NetBSD: uba_bi.c,v 1.13 2008/04/06 07:23:57 cegger 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.10Sperry * 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.13Scegger__KERNEL_RCSID(0, "$NetBSD: uba_bi.c,v 1.13 2008/04/06 07:23:57 cegger 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.12Smattstatic int uba_bi_match(device_t, cfdata_t, void *); 661.12Smattstatic void uba_bi_attach(device_t, device_t, void *); 671.9Sperrystatic void bua_init(struct uba_softc *); 681.9Sperrystatic void bua_purge(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.12SmattCFATTACH_DECL_NEW(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.12Smattuba_bi_match(device_t parent, cfdata_t cf, void *aux) 1181.1Sragge{ 1191.1Sragge struct bi_attach_args *ba = aux; 1201.1Sragge 1211.1Sragge if ((ba->ba_node->biic.bi_dtype != BIDT_DWBUA) && 1221.1Sragge (ba->ba_node->biic.bi_dtype != BIDT_KLESI)) 1231.1Sragge return 0; 1241.1Sragge 1251.1Sragge if (cf->cf_loc[BICF_NODE] != BICF_NODE_DEFAULT && 1261.1Sragge cf->cf_loc[BICF_NODE] != ba->ba_nodenr) 1271.1Sragge return 0; 1281.1Sragge 1291.1Sragge return 1; 1301.1Sragge} 1311.1Sragge 1321.1Sraggevoid 1331.12Smattuba_bi_attach(device_t parent, device_t self, void *aux) 1341.1Sragge{ 1351.12Smatt struct uba_softc *sc = device_private(self); 1361.12Smatt struct bi_attach_args *ba = aux; 1371.1Sragge volatile int timo; 1381.1Sragge 1391.1Sragge if (ba->ba_node->biic.bi_dtype == BIDT_DWBUA) 1401.1Sragge printf(": DWBUA\n"); 1411.1Sragge else 1421.1Sragge printf(": KLESI-B\n"); 1431.1Sragge 1441.1Sragge /* 1451.1Sragge * Fill in bus specific data. 1461.1Sragge */ 1471.12Smatt sc->uh_dev = self; 1481.1Sragge sc->uh_uba = (void *)ba->ba_node; 1491.1Sragge sc->uh_nbdp = NBDPBUA; 1501.1Sragge/* sc->uh_nr is 0; uninteresting here */ 1511.1Sragge/* sc->uh_afterscan; not used */ 1521.1Sragge/* sc->uh_errchk; not used */ 1531.1Sragge/* sc->uh_beforescan */ 1541.1Sragge sc->uh_ubapurge = bua_purge; 1551.1Sragge sc->uh_ubainit = bua_init; 1561.1Sragge/* sc->uh_type not used */ 1571.1Sragge sc->uh_memsize = UBAPAGES; 1581.1Sragge sc->uh_mr = BUA(sc->uh_uba)->bn_map; 1591.1Sragge 1601.1Sragge#ifdef notdef 1611.1Sragge /* Can we get separate interrupts? */ 1621.1Sragge scb->scb_nexvec[1][ba->ba_nodenr] = &sc->sc_ivec; 1631.1Sragge#endif 1641.1Sragge BUA(sc->uh_uba)->bn_biic.bi_csr |= BICSR_ARB_NONE; 1651.1Sragge BUA(sc->uh_uba)->bn_biic.bi_csr |= BICSR_STS | BICSR_INIT; 1661.1Sragge DELAY(1000); 1671.1Sragge timo = 1000; 1681.1Sragge while (BUA(sc->uh_uba)->bn_biic.bi_csr & BICSR_BROKE) 1691.1Sragge if (timo == 0) { 1701.13Scegger aprint_error_dev(self, "BROKE bit set\n"); 1711.1Sragge return; 1721.1Sragge } 1731.1Sragge 1741.1Sragge BUA(sc->uh_uba)->bn_biic.bi_intrdes = ba->ba_intcpu; 1751.10Sperry BUA(sc->uh_uba)->bn_biic.bi_csr = 1761.1Sragge (BUA(sc->uh_uba)->bn_biic.bi_csr&~BICSR_ARB_MASK) | BICSR_ARB_HIGH; 1771.3Sragge BUA(sc->uh_uba)->bn_vor = VAX_NBPG + (VAX_NBPG * allocvec++); 1781.1Sragge 1791.2Sragge uba_attach(sc, BUA(sc->uh_uba)->bn_biic.bi_sadr + UBAPAGES * VAX_NBPG); 1801.1Sragge} 1811.1Sragge 1821.1Sragge 1831.1Sraggevoid 1841.1Sraggebua_init(sc) 1851.1Sragge struct uba_softc *sc; 1861.1Sragge{ 1871.1Sragge BUA(sc->uh_uba)->bn_csr |= BUACSR_UPI; 1881.1Sragge DELAY(500000); 1891.1Sragge}; 1901.1Sragge 1911.1Sraggevoid 1921.1Sraggebua_purge(sc, bdp) 1931.1Sragge struct uba_softc *sc; 1941.1Sragge int bdp; 1951.1Sragge{ 1961.1Sragge BUA(sc->uh_uba)->bn_dpcsr[bdp] |= BUADPR_PURGE; 1971.1Sragge} 198