spc.c revision 1.24 1 /* $NetBSD: spc.c,v 1.24 2002/10/02 16:02:43 thorpej 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 CFATTACH_DECL(spc_intio, sizeof (struct spc_softc),
64 spc_intio_match, spc_intio_attach, NULL, NULL);
65
66 static int
67 spc_intio_match(parent, cf, aux)
68 struct device *parent;
69 struct cfdata *cf;
70 void *aux;
71 {
72 struct intio_attach_args *ia = aux;
73 bus_space_tag_t iot = ia->ia_bst;
74 bus_space_handle_t ioh;
75
76 ia->ia_size=0x20;
77
78 if (intio_map_allocate_region(parent->dv_parent, ia,
79 INTIO_MAP_TESTONLY) < 0)
80 return 0;
81
82 if (bus_space_map(iot, ia->ia_addr, 0x20, BUS_SPACE_MAP_SHIFTED,
83 &ioh) < 0)
84 return 0;
85 if (badaddr ((caddr_t)INTIO_ADDR(ia->ia_addr + BDID)))
86 return 0;
87 bus_space_unmap(iot, ioh, 0x20);
88
89 return 1;
90 }
91
92 static void
93 spc_intio_attach(parent, self, aux)
94 struct device *parent, *self;
95 void *aux;
96 {
97 struct spc_softc *sc = (struct spc_softc *)self;
98 struct intio_attach_args *ia = aux;
99 bus_space_tag_t iot = ia->ia_bst;
100 bus_space_handle_t ioh;
101
102 printf ("\n");
103
104 intio_map_allocate_region(parent->dv_parent, ia,
105 INTIO_MAP_ALLOCATE);
106 if (bus_space_map(iot, ia->ia_addr, 0x20, BUS_SPACE_MAP_SHIFTED,
107 &ioh)) {
108 printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
109 return;
110 }
111
112 sc->sc_iot = iot;
113 sc->sc_ioh = ioh;
114 sc->sc_initiator = IODEVbase->io_sram[0x70] & 0x7; /* XXX */
115
116 if (intio_intr_establish(ia->ia_intr, "spc", spcintr, sc))
117 panic ("spcattach: interrupt vector busy");
118
119 spcattach(sc);
120 }
121