spc.c revision 1.20 1 /* $NetBSD: spc.c,v 1.20 1999/03/16 16:30:20 minoura Exp $ */
2
3 /*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jarle Greipsland, Charles M. Hannum and Masaru Oki.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #include "opt_ddb.h"
40
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/kernel.h>
44 #include <sys/device.h>
45
46 #include <machine/bus.h>
47 #include <machine/cpu.h>
48
49 #include <dev/scsipi/scsi_all.h>
50 #include <dev/scsipi/scsipi_all.h>
51 #include <dev/scsipi/scsiconf.h>
52
53 #include <arch/x68k/dev/intiovar.h>
54 #include <arch/x68k/dev/scsiromvar.h>
55 #include <arch/x68k/x68k/iodevice.h>
56
57 #include <dev/ic/mb89352var.h>
58 #include <dev/ic/mb89352reg.h>
59
60 static int spc_intio_match __P((struct device *, struct cfdata *, void *));
61 static void spc_intio_attach __P((struct device *, struct device *, void *));
62
63 struct cfattach spc_intio_ca = {
64 sizeof (struct spc_softc), spc_intio_match, spc_intio_attach
65 };
66
67
68 static int
69 spc_intio_match(parent, cf, aux)
70 struct device *parent;
71 struct cfdata *cf;
72 void *aux;
73 {
74 struct intio_attach_args *ia = aux;
75 bus_space_tag_t iot = ia->ia_bst;
76 bus_space_handle_t ioh;
77
78 ia->ia_size=0x20;
79
80 if (intio_map_allocate_region(parent->dv_parent, ia,
81 INTIO_MAP_TESTONLY) < 0)
82 return 0;
83
84 if (bus_space_map(iot, ia->ia_addr, 0x20, BUS_SPACE_MAP_SHIFTED,
85 &ioh) < 0)
86 return 0;
87 if (badaddr (INTIO_ADDR(ia->ia_addr + BDID)))
88 return 0;
89 bus_space_unmap(iot, ioh, 0x20);
90
91 return 1;
92 }
93
94 static void
95 spc_intio_attach(parent, self, aux)
96 struct device *parent, *self;
97 void *aux;
98 {
99 struct spc_softc *sc = (struct spc_softc *)self;
100 struct intio_attach_args *ia = aux;
101 bus_space_tag_t iot = ia->ia_bst;
102 bus_space_handle_t ioh;
103
104 printf ("\n");
105
106 intio_map_allocate_region(parent->dv_parent, ia,
107 INTIO_MAP_ALLOCATE);
108 if (bus_space_map(iot, ia->ia_addr, 0x20, BUS_SPACE_MAP_SHIFTED,
109 &ioh)) {
110 printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
111 return;
112 }
113
114 sc->sc_iot = iot;
115 sc->sc_ioh = ioh;
116 sc->sc_initiator = IODEVbase->io_sram[0x70] & 0x7; /* XXX */
117
118 if (intio_intr_establish(ia->ia_intr, "spc", spcintr, sc))
119 panic ("spcattach: interrupt vector busy");
120
121 spcattach(sc);
122 }
123