dpt_eisa.c revision 1.3.2.2 1 1.3.2.2 he /* $NetBSD: dpt_eisa.c,v 1.3.2.2 2000/01/17 18:35:17 he Exp $ */
2 1.3.2.2 he
3 1.3.2.2 he /*
4 1.3.2.2 he * Copyright (c) 1999 Andy Doran <ad (at) NetBSD.org>
5 1.3.2.2 he * All rights reserved.
6 1.3.2.2 he *
7 1.3.2.2 he * Redistribution and use in source and binary forms, with or without
8 1.3.2.2 he * modification, are permitted provided that the following conditions
9 1.3.2.2 he * are met:
10 1.3.2.2 he * 1. Redistributions of source code must retain the above copyright
11 1.3.2.2 he * notice, this list of conditions and the following disclaimer.
12 1.3.2.2 he * 2. Redistributions in binary form must reproduce the above copyright
13 1.3.2.2 he * notice, this list of conditions and the following disclaimer in the
14 1.3.2.2 he * documentation and/or other materials provided with the distribution.
15 1.3.2.2 he *
16 1.3.2.2 he * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 1.3.2.2 he * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 1.3.2.2 he * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 1.3.2.2 he * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 1.3.2.2 he * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 1.3.2.2 he * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 1.3.2.2 he * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.3.2.2 he * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 1.3.2.2 he * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.3.2.2 he * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.3.2.2 he * SUCH DAMAGE.
27 1.3.2.2 he *
28 1.3.2.2 he */
29 1.3.2.2 he
30 1.3.2.2 he /*
31 1.3.2.2 he * EISA front-end for DPT EATA SCSI driver.
32 1.3.2.2 he */
33 1.3.2.2 he
34 1.3.2.2 he #include <sys/cdefs.h>
35 1.3.2.2 he __KERNEL_RCSID(0, "$NetBSD: dpt_eisa.c,v 1.3.2.2 2000/01/17 18:35:17 he Exp $");
36 1.3.2.2 he
37 1.3.2.2 he #include <sys/types.h>
38 1.3.2.2 he #include <sys/param.h>
39 1.3.2.2 he #include <sys/systm.h>
40 1.3.2.2 he #include <sys/device.h>
41 1.3.2.2 he
42 1.3.2.2 he #include <machine/bus.h>
43 1.3.2.2 he #include <machine/intr.h>
44 1.3.2.2 he
45 1.3.2.2 he #include <dev/scsipi/scsi_all.h>
46 1.3.2.2 he #include <dev/scsipi/scsipi_all.h>
47 1.3.2.2 he #include <dev/scsipi/scsiconf.h>
48 1.3.2.2 he
49 1.3.2.2 he #include <dev/eisa/eisavar.h>
50 1.3.2.2 he #include <dev/eisa/eisadevs.h>
51 1.3.2.2 he
52 1.3.2.2 he #include <dev/ic/dptreg.h>
53 1.3.2.2 he #include <dev/ic/dptvar.h>
54 1.3.2.2 he
55 1.3.2.2 he #define DPT_EISA_SLOT_OFFSET 0x0c00
56 1.3.2.2 he #define DPT_EISA_IOSIZE 0x0100
57 1.3.2.2 he #define DPT_EISA_IOCONF 0x90
58 1.3.2.2 he #define DPT_EISA_EATA_REG_OFFSET 0x88
59 1.3.2.2 he
60 1.3.2.2 he int dpt_eisa_irq __P((bus_space_tag_t, bus_space_handle_t, int *));
61 1.3.2.2 he int dpt_eisa_match __P((struct device *, struct cfdata *, void *));
62 1.3.2.2 he void dpt_eisa_attach __P((struct device *, struct device *, void *));
63 1.3.2.2 he
64 1.3.2.2 he struct cfattach dpt_eisa_ca = {
65 1.3.2.2 he sizeof(struct dpt_softc), dpt_eisa_match, dpt_eisa_attach
66 1.3.2.2 he };
67 1.3.2.2 he
68 1.3.2.2 he const char *dpt_eisa_boards[] = {
69 1.3.2.2 he "DPT2402",
70 1.3.2.2 he "DPTA401",
71 1.3.2.2 he "DPTA402",
72 1.3.2.2 he "DPTA410",
73 1.3.2.2 he "DPTA411",
74 1.3.2.2 he "DPTA412",
75 1.3.2.2 he "DPTA420",
76 1.3.2.2 he "DPTA501",
77 1.3.2.2 he "DPTA502",
78 1.3.2.2 he "DPTA701",
79 1.3.2.2 he "DPTBC01",
80 1.3.2.2 he "NEC8200", /* OEM */
81 1.3.2.2 he "ATT2408", /* OEM */
82 1.3.2.2 he NULL
83 1.3.2.2 he };
84 1.3.2.2 he
85 1.3.2.2 he int
86 1.3.2.2 he dpt_eisa_irq(iot, ioh, irq)
87 1.3.2.2 he bus_space_tag_t iot;
88 1.3.2.2 he bus_space_handle_t ioh;
89 1.3.2.2 he int *irq;
90 1.3.2.2 he {
91 1.3.2.2 he
92 1.3.2.2 he switch (bus_space_read_1(iot, ioh, DPT_EISA_IOCONF) & 0x38) {
93 1.3.2.2 he case 0x08:
94 1.3.2.2 he *irq = 11;
95 1.3.2.2 he break;
96 1.3.2.2 he case 0x10:
97 1.3.2.2 he *irq = 15;
98 1.3.2.2 he break;
99 1.3.2.2 he case 0x20:
100 1.3.2.2 he *irq = 14;
101 1.3.2.2 he break;
102 1.3.2.2 he default:
103 1.3.2.2 he return (-1);
104 1.3.2.2 he }
105 1.3.2.2 he
106 1.3.2.2 he return (0);
107 1.3.2.2 he }
108 1.3.2.2 he
109 1.3.2.2 he int
110 1.3.2.2 he dpt_eisa_match(parent, match, aux)
111 1.3.2.2 he struct device *parent;
112 1.3.2.2 he struct cfdata *match;
113 1.3.2.2 he void *aux;
114 1.3.2.2 he {
115 1.3.2.2 he struct eisa_attach_args *ea;
116 1.3.2.2 he int i;
117 1.3.2.2 he
118 1.3.2.2 he ea = aux;
119 1.3.2.2 he
120 1.3.2.2 he for (i = 0; dpt_eisa_boards[i] != NULL; i++)
121 1.3.2.2 he if (strcmp(ea->ea_idstring, dpt_eisa_boards[i]) == 0)
122 1.3.2.2 he break;
123 1.3.2.2 he
124 1.3.2.2 he return (dpt_eisa_boards[i] != NULL);
125 1.3.2.2 he }
126 1.3.2.2 he
127 1.3.2.2 he void
128 1.3.2.2 he dpt_eisa_attach(parent, self, aux)
129 1.3.2.2 he struct device *parent, *self;
130 1.3.2.2 he void *aux;
131 1.3.2.2 he {
132 1.3.2.2 he struct eisa_attach_args *ea;
133 1.3.2.2 he bus_space_handle_t ioh;
134 1.3.2.2 he eisa_chipset_tag_t ec;
135 1.3.2.2 he eisa_intr_handle_t ih;
136 1.3.2.2 he struct dpt_softc *sc;
137 1.3.2.2 he bus_space_tag_t iot;
138 1.3.2.2 he const char *intrstr;
139 1.3.2.2 he int irq;
140 1.3.2.2 he
141 1.3.2.2 he ea = aux;
142 1.3.2.2 he sc = (struct dpt_softc *)self;
143 1.3.2.2 he iot = ea->ea_iot;
144 1.3.2.2 he ec = ea->ea_ec;
145 1.3.2.2 he
146 1.3.2.2 he printf(": ");
147 1.3.2.2 he
148 1.3.2.2 he if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) +
149 1.3.2.2 he DPT_EISA_SLOT_OFFSET, DPT_EISA_IOSIZE, 0, &ioh)) {
150 1.3.2.2 he printf("can't map i/o space\n");
151 1.3.2.2 he return;
152 1.3.2.2 he }
153 1.3.2.2 he
154 1.3.2.2 he sc->sc_iot = iot;
155 1.3.2.2 he sc->sc_ioh = ioh;
156 1.3.2.2 he sc->sc_dmat = ea->ea_dmat;
157 1.3.2.2 he
158 1.3.2.2 he /* Map and establish the interrupt. */
159 1.3.2.2 he if (dpt_eisa_irq(iot, ioh, &irq)) {
160 1.3.2.2 he printf("HBA on invalid IRQ (%d)\n", irq);
161 1.3.2.2 he return;
162 1.3.2.2 he }
163 1.3.2.2 he
164 1.3.2.2 he if (eisa_intr_map(ec, irq, &ih)) {
165 1.3.2.2 he printf("can't map interrupt (%d)\n", irq);
166 1.3.2.2 he return;
167 1.3.2.2 he }
168 1.3.2.2 he
169 1.3.2.2 he intrstr = eisa_intr_string(ec, ih);
170 1.3.2.2 he sc->sc_ih = eisa_intr_establish(ec, ih, IST_LEVEL, IPL_BIO,
171 1.3.2.2 he dpt_intr, sc);
172 1.3.2.2 he if (sc->sc_ih == NULL) {
173 1.3.2.2 he printf("can't establish interrupt");
174 1.3.2.2 he if (intrstr != NULL)
175 1.3.2.2 he printf(" at %s", intrstr);
176 1.3.2.2 he printf("\n");
177 1.3.2.2 he return;
178 1.3.2.2 he }
179 1.3.2.2 he
180 1.3.2.2 he /* Read the EATA configuration */
181 1.3.2.2 he if (dpt_readcfg(sc)) {
182 1.3.2.2 he printf("%s: readcfg failed - see dpt(4)\n",
183 1.3.2.2 he sc->sc_dv.dv_xname);
184 1.3.2.2 he return;
185 1.3.2.2 he }
186 1.3.2.2 he
187 1.3.2.2 he /* Now attach to the bus-independent code */
188 1.3.2.2 he dpt_init(sc, intrstr);
189 1.3.2.2 he }
190