hcsc.c revision 1.1 1 /* $NetBSD: hcsc.c,v 1.1 2001/05/26 23:01:19 bjh21 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 Mark Brinicombe of Causality Limited.
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 /*
40 * HCCS 8-bit SCSI driver using the generic NCR5380 driver
41 */
42
43 #include <sys/param.h>
44
45 __KERNEL_RCSID(0, "$NetBSD: hcsc.c,v 1.1 2001/05/26 23:01:19 bjh21 Exp $");
46
47 #include <sys/systm.h>
48 #include <sys/kernel.h>
49 #include <sys/device.h>
50 #include <sys/buf.h>
51 #include <dev/scsipi/scsi_all.h>
52 #include <dev/scsipi/scsipi_all.h>
53 #include <dev/scsipi/scsiconf.h>
54
55 #include <dev/ic/ncr5380reg.h>
56 #include <dev/ic/ncr5380var.h>
57
58 #include <machine/bootconfig.h>
59
60 #include <dev/podulebus/podulebus.h>
61 #include <dev/podulebus/podules.h>
62
63 void hcsc_attach (struct device *, struct device *, void *);
64 int hcsc_match (struct device *, struct cfdata *, void *);
65
66 /*
67 * HCCS 8-bit SCSI softc structure.
68 *
69 * Contains the generic ncr5380 device node, podule information and
70 * global information required by the driver.
71 */
72
73 struct hcsc_softc {
74 struct ncr5380_softc sc_ncr5380;
75 void *sc_ih;
76 struct evcnt sc_intrcnt;
77 };
78
79 struct cfattach hcsc_ca = {
80 sizeof(struct hcsc_softc), hcsc_match, hcsc_attach
81 };
82
83 /*
84 * Card probe function
85 *
86 * Just match the manufacturer and podule ID's
87 */
88
89 int
90 hcsc_match(struct device *parent, struct cfdata *cf, void *aux)
91 {
92 struct podulebus_attach_args *pa = aux;
93
94 if (matchpodule(pa, MANUFACTURER_HCCS, PODULE_HCCS_IDESCSI, -1) == 0)
95 return(0);
96
97 return(1);
98 }
99
100 /*
101 * Card attach function
102 *
103 */
104
105 void
106 hcsc_attach(struct device *parent, struct device *self, void *aux)
107 {
108 struct hcsc_softc *sc = (struct hcsc_softc *)self;
109 struct podulebus_attach_args *pa = aux;
110 u_char *iobase;
111 char hi_option[sizeof(sc->sc_ncr5380.sc_dev.dv_xname) + 8];
112
113 sc->sc_ncr5380.sc_min_dma_len = 0;
114 sc->sc_ncr5380.sc_no_disconnect = 0xff;
115 sc->sc_ncr5380.sc_parity_disable = 0xff;
116
117 sc->sc_ncr5380.sc_dma_alloc = NULL;
118 sc->sc_ncr5380.sc_dma_free = NULL;
119 sc->sc_ncr5380.sc_dma_poll = NULL;
120 sc->sc_ncr5380.sc_dma_setup = NULL;
121 sc->sc_ncr5380.sc_dma_start = NULL;
122 sc->sc_ncr5380.sc_dma_eop = NULL;
123 sc->sc_ncr5380.sc_dma_stop = NULL;
124 sc->sc_ncr5380.sc_intr_on = NULL;
125 sc->sc_ncr5380.sc_intr_off = NULL;
126
127 #ifdef NCR5380_USE_BUS_SPACE
128 sc->sc_ncr5380.sc_regt = pa->pa_fast_t;
129 bus_space_map(sc->sc_ncr5380.sc_regt, pa->pa_fast_base + 0x2000, 8, 0,
130 &sc->sc_ncr5380.sc_regh);
131 sc->sc_ncr5380.sci_r0 = 0;
132 sc->sc_ncr5380.sci_r1 = 1;
133 sc->sc_ncr5380.sci_r2 = 2;
134 sc->sc_ncr5380.sci_r3 = 3;
135 sc->sc_ncr5380.sci_r4 = 4;
136 sc->sc_ncr5380.sci_r5 = 5;
137 sc->sc_ncr5380.sci_r6 = 6;
138 sc->sc_ncr5380.sci_r7 = 7;
139 #else
140 iobase = (u_char *)pa->pa_fast_base + 0x2000;
141 sc->sc_ncr5380.sci_r0 = iobase + 0;
142 sc->sc_ncr5380.sci_r1 = iobase + 4;
143 sc->sc_ncr5380.sci_r2 = iobase + 8;
144 sc->sc_ncr5380.sci_r3 = iobase + 12;
145 sc->sc_ncr5380.sci_r4 = iobase + 16;
146 sc->sc_ncr5380.sci_r5 = iobase + 20;
147 sc->sc_ncr5380.sci_r6 = iobase + 24;
148 sc->sc_ncr5380.sci_r7 = iobase + 28;
149 #endif
150
151 sc->sc_ncr5380.sc_rev = NCR_VARIANT_DP8490;
152
153 sc->sc_ncr5380.sc_pio_in = ncr5380_pio_in;
154 sc->sc_ncr5380.sc_pio_out = ncr5380_pio_out;
155
156 /* Provide an override for the host id */
157 sc->sc_ncr5380.sc_channel.chan_id = 7;
158 sprintf(hi_option, "%s.hostid", sc->sc_ncr5380.sc_dev.dv_xname);
159 (void)get_bootconf_option(boot_args, hi_option,
160 BOOTOPT_TYPE_INT, &sc->sc_ncr5380.sc_channel.chan_id);
161 sc->sc_ncr5380.sc_adapter.adapt_minphys = minphys;
162
163 printf(": host=%d, using 8 bit PIO\n",
164 sc->sc_ncr5380.sc_channel.chan_id);
165
166 evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, NULL,
167 self->dv_xname, "intr");
168 sc->sc_ih = podulebus_irq_establish(pa->pa_ih, IPL_BIO, ncr5380_intr,
169 sc, &sc->sc_intrcnt);
170
171 ncr5380_attach(&sc->sc_ncr5380);
172 }
173