1 /* $OpenBSD: spc.c,v 1.8 2015/02/14 14:54:13 aoyama Exp $ */ 2 /* $NetBSD: spc.c,v 1.4 2003/07/05 19:00:17 tsutsui Exp $ */ 3 4 /*- 5 * Copyright (c) 2000 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation 9 * by Tohru Nishimura. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #include <sys/param.h> 34 #include <sys/systm.h> 35 #include <sys/device.h> 36 #include <sys/buf.h> 37 38 #include <machine/bus.h> 39 #include <machine/cpu.h> 40 #include <machine/autoconf.h> 41 42 #include <scsi/scsi_all.h> 43 #include <scsi/scsi_message.h> 44 #include <scsi/scsiconf.h> 45 46 #include <luna88k/dev/mb89352reg.h> 47 #include <luna88k/dev/mb89352var.h> 48 49 #include <luna88k/luna88k/isr.h> 50 51 int spc_mainbus_match(struct device *, void *, void *); 52 void spc_mainbus_attach(struct device *, struct device *, void *); 53 54 struct cfattach spc_ca = { 55 sizeof(struct spc_softc), spc_mainbus_match, spc_mainbus_attach 56 }; 57 58 struct cfdriver spc_cd = { 59 NULL, "spc", DV_DULL 60 }; 61 62 struct scsi_adapter spc_switch = { 63 spc_scsi_cmd, 64 scsi_minphys, /* no max at this level; handled by DMA code */ 65 NULL, 66 NULL, 67 }; 68 69 /* bus space tag for spc */ 70 struct luna88k_bus_space_tag spc_bst = { 71 4, /* when reading/writing 1 byte, the stride is 4. */ 72 0, /* not used */ 73 0, /* not used */ 74 0, /* not used */ 75 0, /* no offset */ 76 }; 77 78 int 79 spc_mainbus_match(struct device *parent, void *cf, void *aux) 80 { 81 struct mainbus_attach_args *ma = aux; 82 83 if (strcmp(ma->ma_name, spc_cd.cd_name)) 84 return 0; 85 #if 0 86 if (badaddr((caddr_t)ma->ma_addr, 4)) 87 return 0; 88 /* Experiments proved 2nd SPC address does NOT make a buserror. */ 89 #endif 90 return 1; 91 } 92 93 void 94 spc_mainbus_attach(struct device *parent, struct device *self, void *aux) 95 { 96 struct spc_softc *sc = (void *)self; 97 struct mainbus_attach_args *ma = aux; 98 99 printf ("\n"); 100 101 sc->sc_iot = &spc_bst; 102 sc->sc_ioh = ma->ma_addr; 103 sc->sc_initiator = 7; 104 sc->sc_dma_start = NULL; 105 sc->sc_dma_done = NULL; 106 107 isrlink_autovec(spc_intr, (void *)sc, ma->ma_ilvl, ISRPRI_BIO, 108 self->dv_xname); 109 110 spc_attach(sc, &spc_switch); 111 } 112