aha_mca.c revision 1.1.6.3 1 1.1.6.3 bouyer /* $NetBSD: aha_mca.c,v 1.1.6.3 2001/04/21 17:48:50 bouyer Exp $ */
2 1.1.6.2 bouyer
3 1.1.6.2 bouyer /*
4 1.1.6.2 bouyer * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 1.1.6.2 bouyer * Copyright (c) 1996-1999 Scott D. Telford.
6 1.1.6.2 bouyer * Copyright (c) 1994, 1996 Charles M. Hannum. All rights reserved.
7 1.1.6.2 bouyer * Portions:
8 1.1.6.2 bouyer *
9 1.1.6.2 bouyer * Redistribution and use in source and binary forms, with or without
10 1.1.6.2 bouyer * modification, are permitted provided that the following conditions
11 1.1.6.2 bouyer * are met:
12 1.1.6.2 bouyer * 1. Redistributions of source code must retain the above copyright
13 1.1.6.2 bouyer * notice, this list of conditions and the following disclaimer.
14 1.1.6.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
15 1.1.6.2 bouyer * notice, this list of conditions and the following disclaimer in the
16 1.1.6.2 bouyer * documentation and/or other materials provided with the distribution.
17 1.1.6.2 bouyer * 3. All advertising materials mentioning features or use of this software
18 1.1.6.2 bouyer * must display the following acknowledgement:
19 1.1.6.2 bouyer * This product includes software developed by Charles M. Hannum.
20 1.1.6.2 bouyer * 4. The name of the author may not be used to endorse or promote products
21 1.1.6.2 bouyer * derived from this software without specific prior written permission.
22 1.1.6.2 bouyer *
23 1.1.6.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 1.1.6.2 bouyer * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 1.1.6.2 bouyer * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 1.1.6.2 bouyer * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 1.1.6.2 bouyer * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 1.1.6.2 bouyer * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 1.1.6.2 bouyer * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 1.1.6.2 bouyer * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 1.1.6.2 bouyer * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 1.1.6.2 bouyer * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 1.1.6.2 bouyer */
34 1.1.6.2 bouyer
35 1.1.6.2 bouyer /*
36 1.1.6.2 bouyer * Originally written by Julian Elischer (julian (at) tfs.com)
37 1.1.6.2 bouyer * for TRW Financial Systems for use under the MACH(2.5) operating system.
38 1.1.6.2 bouyer *
39 1.1.6.2 bouyer * TRW Financial Systems, in accordance with their agreement with Carnegie
40 1.1.6.2 bouyer * Mellon University, makes this software available to CMU to distribute
41 1.1.6.2 bouyer * or use in any manner that they see fit as long as this message is kept with
42 1.1.6.2 bouyer * the software. For this reason TFS also grants any other persons or
43 1.1.6.2 bouyer * organisations permission to use or modify this software.
44 1.1.6.2 bouyer *
45 1.1.6.2 bouyer * TFS supplies this software to be publicly redistributed
46 1.1.6.2 bouyer * on the understanding that TFS is not responsible for the correct
47 1.1.6.2 bouyer * functioning of this software in any circumstances.
48 1.1.6.2 bouyer */
49 1.1.6.2 bouyer
50 1.1.6.2 bouyer /*
51 1.1.6.2 bouyer * AHA-1640 MCA bus code by Scott Telford
52 1.1.6.2 bouyer */
53 1.1.6.2 bouyer
54 1.1.6.2 bouyer #include <sys/param.h>
55 1.1.6.2 bouyer #include <sys/types.h>
56 1.1.6.2 bouyer #include <sys/systm.h>
57 1.1.6.2 bouyer #include <sys/device.h>
58 1.1.6.2 bouyer
59 1.1.6.2 bouyer #include <machine/bus.h>
60 1.1.6.2 bouyer #include <machine/intr.h>
61 1.1.6.2 bouyer
62 1.1.6.2 bouyer #include <dev/scsipi/scsi_all.h>
63 1.1.6.2 bouyer #include <dev/scsipi/scsipi_all.h>
64 1.1.6.2 bouyer #include <dev/scsipi/scsiconf.h>
65 1.1.6.2 bouyer
66 1.1.6.2 bouyer #include <dev/isa/isavar.h>
67 1.1.6.2 bouyer #include <dev/isa/isadmavar.h>
68 1.1.6.2 bouyer
69 1.1.6.2 bouyer #include <dev/ic/ahareg.h>
70 1.1.6.2 bouyer #include <dev/ic/ahavar.h>
71 1.1.6.2 bouyer
72 1.1.6.2 bouyer #include <dev/mca/mcareg.h>
73 1.1.6.2 bouyer #include <dev/mca/mcavar.h>
74 1.1.6.2 bouyer #include <dev/mca/mcadevs.h>
75 1.1.6.2 bouyer
76 1.1.6.2 bouyer #define AHA_ISA_IOSIZE 4
77 1.1.6.2 bouyer
78 1.1.6.2 bouyer int aha_mca_probe __P((struct device *, struct cfdata *, void *));
79 1.1.6.2 bouyer void aha_mca_attach __P((struct device *, struct device *, void *));
80 1.1.6.2 bouyer
81 1.1.6.2 bouyer struct cfattach aha_mca_ca = {
82 1.1.6.2 bouyer sizeof(struct aha_softc), aha_mca_probe, aha_mca_attach
83 1.1.6.2 bouyer };
84 1.1.6.2 bouyer
85 1.1.6.2 bouyer
86 1.1.6.2 bouyer int
87 1.1.6.2 bouyer aha_mca_probe(parent, match, aux)
88 1.1.6.2 bouyer struct device *parent;
89 1.1.6.2 bouyer struct cfdata *match;
90 1.1.6.2 bouyer void *aux;
91 1.1.6.2 bouyer {
92 1.1.6.2 bouyer register struct mca_attach_args *ma = aux;
93 1.1.6.2 bouyer
94 1.1.6.2 bouyer switch(ma->ma_id) {
95 1.1.6.2 bouyer case MCA_PRODUCT_AHA1640:
96 1.1.6.2 bouyer return 1;
97 1.1.6.2 bouyer }
98 1.1.6.2 bouyer
99 1.1.6.2 bouyer return 0;
100 1.1.6.2 bouyer }
101 1.1.6.2 bouyer
102 1.1.6.2 bouyer
103 1.1.6.2 bouyer /*
104 1.1.6.2 bouyer * Attach all the sub-devices we can find
105 1.1.6.2 bouyer */
106 1.1.6.2 bouyer void
107 1.1.6.2 bouyer aha_mca_attach(parent, self, aux)
108 1.1.6.2 bouyer struct device *parent, *self;
109 1.1.6.2 bouyer void *aux;
110 1.1.6.2 bouyer {
111 1.1.6.2 bouyer struct mca_attach_args *ma = aux;
112 1.1.6.2 bouyer struct aha_softc *sc = (void *)self;
113 1.1.6.2 bouyer bus_space_tag_t iot = ma->ma_iot;
114 1.1.6.2 bouyer bus_space_handle_t ioh;
115 1.1.6.2 bouyer struct aha_probe_data apd;
116 1.1.6.2 bouyer mca_chipset_tag_t mc = ma->ma_mc;
117 1.1.6.2 bouyer bus_addr_t iobase;
118 1.1.6.2 bouyer
119 1.1.6.3 bouyer printf(" slot %d: Adaptec AHA-1640 SCSI Adapter\n", ma->ma_slot + 1);
120 1.1.6.2 bouyer
121 1.1.6.2 bouyer iobase=((ma->ma_pos[3] & 0x03) << 8) + 0x30 +
122 1.1.6.2 bouyer ((ma->ma_pos[3] & 0x40) >> 4);
123 1.1.6.2 bouyer
124 1.1.6.2 bouyer if (bus_space_map(iot, iobase, AHA_ISA_IOSIZE, 0, &ioh)) {
125 1.1.6.2 bouyer printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
126 1.1.6.2 bouyer return;
127 1.1.6.2 bouyer }
128 1.1.6.2 bouyer
129 1.1.6.2 bouyer sc->sc_iot = iot;
130 1.1.6.2 bouyer sc->sc_ioh = ioh;
131 1.1.6.2 bouyer sc->sc_dmat = ma->ma_dmat;
132 1.1.6.2 bouyer
133 1.1.6.2 bouyer apd.sc_irq=(ma->ma_pos[4] & 0x7) + 8;
134 1.1.6.2 bouyer apd.sc_drq=ma->ma_pos[5] & 0xf;
135 1.1.6.2 bouyer apd.sc_scsi_dev=(ma->ma_pos[4] & 0xe0) >> 5;
136 1.1.6.2 bouyer
137 1.1.6.2 bouyer #ifdef notyet
138 1.1.6.2 bouyer if (apd.sc_drq != -1)
139 1.1.6.2 bouyer isa_dmacascade(mc, apd.sc_drq);
140 1.1.6.2 bouyer #endif
141 1.1.6.2 bouyer
142 1.1.6.2 bouyer sc->sc_ih = mca_intr_establish(mc, apd.sc_irq, IPL_BIO, aha_intr, sc);
143 1.1.6.2 bouyer if (sc->sc_ih == NULL) {
144 1.1.6.2 bouyer printf("%s: couldn't establish interrupt\n",
145 1.1.6.2 bouyer sc->sc_dev.dv_xname);
146 1.1.6.2 bouyer return;
147 1.1.6.2 bouyer }
148 1.1.6.2 bouyer
149 1.1.6.2 bouyer aha_attach(sc, &apd);
150 1.1.6.2 bouyer }
151