1 /* $NetBSD: depca_eisa.c,v 1.11 2008/04/04 12:25:07 tsutsui Exp $ */
4 * Copyright (c) 2000 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 * EISA bus front-end for the Digital DEPCA Ethernet controller.
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: depca_eisa.c,v 1.11 2008/04/04 12:25:07 tsutsui Exp $");
42 #include <sys/param.h>
43 #include <sys/systm.h>
45 #include <sys/syslog.h>
46 #include <sys/socket.h>
47 #include <sys/device.h>
50 #include <net/if_media.h>
51 #include <net/if_ether.h>
54 #include <netinet/in.h>
55 #include <netinet/if_inarp.h>
61 #include <dev/eisa/eisareg.h>
62 #include <dev/eisa/eisavar.h>
63 #include <dev/eisa/eisadevs.h>
65 #include <dev/ic/lancereg.h>
66 #include <dev/ic/lancevar.h>
67 #include <dev/ic/am7990reg.h>
68 #include <dev/ic/am7990var.h>
69 #include <dev/ic/depcareg.h>
70 #include <dev/ic/depcavar.h>
72 static int depca_eisa_match(device_t
, cfdata_t
, void *);
73 static void depca_eisa_attach(device_t
, device_t
, void *);
75 struct depca_eisa_softc
{
76 struct depca_softc sc_depca
;
78 eisa_chipset_tag_t sc_ec
;
83 CFATTACH_DECL_NEW(depca_eisa
, sizeof(struct depca_eisa_softc
),
84 depca_eisa_match
, depca_eisa_attach
, NULL
, NULL
);
86 static void *depca_eisa_intr_establish(struct depca_softc
*,
87 struct lance_softc
*);
90 depca_eisa_match(device_t parent
, cfdata_t cf
, void *aux
)
92 struct eisa_attach_args
*ea
= aux
;
94 return (strcmp(ea
->ea_idstring
, "DEC4220") == 0);
97 #define DEPCA_ECU_FUNC_NETINTR 0
98 #define DEPCA_ECU_FUNC_NETBUF 1
101 depca_eisa_attach(device_t parent
, device_t self
, void *aux
)
103 struct depca_eisa_softc
*esc
= device_private(self
);
104 struct depca_softc
*sc
= &esc
->sc_depca
;
105 struct eisa_attach_args
*ea
= aux
;
106 struct eisa_cfg_mem ecm
;
107 struct eisa_cfg_irq eci
;
110 aprint_error(": DEC DE422 Ethernet\n");
112 sc
->sc_iot
= ea
->ea_iot
;
113 sc
->sc_memt
= ea
->ea_memt
;
115 esc
->sc_ec
= ea
->ea_ec
;
117 sc
->sc_intr_establish
= depca_eisa_intr_establish
;
119 if (eisa_conf_read_mem(ea
->ea_ec
, ea
->ea_slot
,
120 DEPCA_ECU_FUNC_NETBUF
, 0, &ecm
) != 0) {
121 aprint_error_dev(self
, "unable to find network buffer\n");
125 aprint_normal_dev(self
, "shared memory at 0x%lx-0x%lx\n",
126 ecm
.ecm_addr
, ecm
.ecm_addr
+ ecm
.ecm_size
- 1);
128 sc
->sc_memsize
= ecm
.ecm_size
;
130 if (bus_space_map(sc
->sc_iot
, EISA_SLOT_ADDR(ea
->ea_slot
) + 0xc00, 16,
131 0, &sc
->sc_ioh
) != 0) {
132 aprint_error_dev(self
, "unable to map i/o space\n");
135 if (bus_space_map(sc
->sc_memt
, ecm
.ecm_addr
, sc
->sc_memsize
,
136 0, &sc
->sc_memh
) != 0) {
137 aprint_error_dev(self
, "unable to map memory space\n");
141 if (eisa_conf_read_irq(ea
->ea_ec
, ea
->ea_slot
,
142 DEPCA_ECU_FUNC_NETINTR
, 0, &eci
) != 0) {
143 aprint_error_dev(self
, "unable to determine IRQ\n");
147 esc
->sc_irq
= eci
.eci_irq
;
148 esc
->sc_ist
= eci
.eci_ist
;
154 depca_eisa_intr_establish(struct depca_softc
*parent
, struct lance_softc
*child
)
156 struct depca_eisa_softc
*esc
= (struct depca_eisa_softc
*)parent
;
157 eisa_intr_handle_t ih
;
161 if (eisa_intr_map(esc
->sc_ec
, esc
->sc_irq
, &ih
)) {
162 aprint_error_dev(parent
->sc_dev
,
163 "unable to map interrupt (%d)\n", esc
->sc_irq
);
166 intrstr
= eisa_intr_string(esc
->sc_ec
, ih
);
167 rv
= eisa_intr_establish(esc
->sc_ec
, ih
, esc
->sc_ist
, IPL_NET
,
168 (esc
->sc_ist
== IST_LEVEL
) ? am7990_intr
: depca_intredge
, child
);
170 aprint_error_dev(parent
->sc_dev
,
171 "unable to establish interrupt");
173 aprint_error(" at %s", intrstr
);
178 aprint_normal_dev(parent
->sc_dev
, "interrupting at %s\n",