1 /* $OpenBSD: spc.c,v 1.11 2020/02/05 16:29:29 krw 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, NULL, NULL, NULL, NULL 64 }; 65 66 /* bus space tag for spc */ 67 struct luna88k_bus_space_tag spc_bst = { 68 2, /* when reading/writing 1 byte, the stride is 4. */ 69 0, /* not used */ 70 0, /* not used */ 71 0, /* not used */ 72 0, /* no offset */ 73 }; 74 75 int 76 spc_mainbus_match(struct device *parent, void *cf, void *aux) 77 { 78 struct mainbus_attach_args *ma = aux; 79 80 if (strcmp(ma->ma_name, spc_cd.cd_name)) 81 return 0; 82 #if 0 83 if (badaddr((caddr_t)ma->ma_addr, 4)) 84 return 0; 85 /* Experiments proved 2nd SPC address does NOT make a buserror. */ 86 #endif 87 return 1; 88 } 89 90 void 91 spc_mainbus_attach(struct device *parent, struct device *self, void *aux) 92 { 93 struct spc_softc *sc = (void *)self; 94 struct mainbus_attach_args *ma = aux; 95 96 printf ("\n"); 97 98 sc->sc_iot = &spc_bst; 99 sc->sc_ioh = ma->ma_addr; 100 sc->sc_initiator = 7; 101 sc->sc_dma_start = NULL; 102 sc->sc_dma_done = NULL; 103 104 isrlink_autovec(spc_intr, (void *)sc, ma->ma_ilvl, ISRPRI_BIO, 105 self->dv_xname); 106 107 spc_attach(sc, &spc_switch); 108 } 109