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