1 /* $NetBSD: sebuf.c,v 1.16 2008/04/28 20:23:37 martin Exp $ */
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * Sun3/E SCSI/Ethernet board. This is a VME board with some memory,
34 * an Intel Ether, and an NCR5380 SCSI with a cheap DMA engine.
35 * Note that the SCSI DMA engine can ONLY access the memory on
36 * the SE board, NOT the main memory, because it can not master
39 * This driver ("sebuf") is the parent of two child drivers:
40 * se: yet another variant of NCR 5380 SCSI H/W
41 * ie: yet anotehr variant of Intel 82586 Ethernet
43 * The job of this parent is to map the memory and partition it for
44 * the two children. This driver has no device nodes.
47 #include <sys/cdefs.h>
48 __KERNEL_RCSID(0, "$NetBSD: sebuf.c,v 1.16 2008/04/28 20:23:37 martin Exp $");
50 #include <sys/param.h>
51 #include <sys/systm.h>
53 #include <sys/device.h>
54 #include <sys/ioctl.h>
55 #include <sys/malloc.h>
60 #include <uvm/uvm_extern.h>
62 #include <machine/autoconf.h>
63 #include <machine/cpu.h>
69 device_t sc_dev
; /* base device (required) */
70 struct sebuf_regs
*sc_regs
;
74 * Autoconfig attachment
77 static int sebuf_match(device_t
, cfdata_t
, void *);
78 static void sebuf_attach(device_t
, device_t
, void *);
79 static int sebuf_print(void *, const char *);
81 CFATTACH_DECL_NEW(sebuf
, sizeof(struct sebuf_softc
),
82 sebuf_match
, sebuf_attach
, NULL
, NULL
);
85 sebuf_match(device_t parent
, cfdata_t cf
, void *args
)
87 struct confargs
*ca
= args
;
92 if (ca
->ca_paddr
== -1)
95 /* Is it there at all? */
97 x
= bus_peek(ca
->ca_bustype
, pa
, 2);
101 /* Look at the CSR for the SCSI part. */
102 pa
= ca
->ca_paddr
+ offsetof(struct sebuf_regs
, se_scsi_regs
);
103 sreg
= bus_tmapin(ca
->ca_bustype
, pa
);
104 /* Write some bits that are wired to zero. */
105 sreg
->se_csr
= 0xFFF3;
106 x
= peek_word((void *)(&sreg
->se_csr
));
108 if ((x
== -1) || (x
& 0xFCF0)) {
110 aprint_debug("%s: SCSI csr=0x%x\n", __func__
, x
);
115 /* Look at the CSR for the Ethernet part. */
116 pa
= ca
->ca_paddr
+ offsetof(struct sebuf_regs
, se_eth_regs
);
117 ereg
= bus_tmapin(ca
->ca_bustype
, pa
);
118 /* Write some bits that are wired to zero. */
119 ereg
->ie_csr
= 0x0FFF;
120 x
= peek_word((void *)(&ereg
->ie_csr
));
122 if ((x
== -1) || (x
& 0xFFF)) {
124 printf("%s: Ether csr=0x%x\n", __func__
, x
);
129 /* Default interrupt priority always splbio==2 */
130 if (ca
->ca_intpri
== -1)
137 sebuf_attach(device_t parent
, device_t self
, void *args
)
139 struct sebuf_softc
*sc
= device_private(self
);
140 struct confargs
*ca
= args
;
141 struct sebuf_attach_args aa
;
142 struct sebuf_regs
*regs
;
147 if (ca
->ca_intpri
!= 2)
148 panic("sebuf: bad level");
150 /* Map in the whole board. */
151 regs
= (struct sebuf_regs
*)bus_mapin(ca
->ca_bustype
, ca
->ca_paddr
,
152 sizeof(struct sebuf_regs
));
154 panic("%s", __func__
);
157 /* Attach the SCSI child. */
158 aa
.ca
= *ca
; /* structure copy */
159 aa
.ca
.ca_paddr
= 0; /* prevent misuse */
161 aa
.buf
= ®s
->se_scsi_buf
[0];
162 aa
.blen
= SE_NCRBUFSIZE
;
163 aa
.regs
= ®s
->se_scsi_regs
;
164 (void)config_found(self
, (void *)&aa
, sebuf_print
);
166 /* Attach the Ethernet child. */
170 aa
.buf
= ®s
->se_eth_buf
[0];
171 aa
.blen
= SE_IEBUFSIZE
;
172 aa
.regs
= ®s
->se_eth_regs
;
173 (void)config_found(self
, (void *)&aa
, sebuf_print
);
177 sebuf_print(void *aux
, const char *name
)
181 aprint_normal("%s: ", name
);