1/*-
2 * Copyright (c) 1995, David Greenman
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice unmodified, this list of conditions, and the following
10 * disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/ed/if_ed_isa.c 154391 2006-01-15 04:10:47Z imp $");
31
32#include "opt_ed.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/socket.h>
37#include <sys/kernel.h>
38
39#include <sys/module.h>
40#include <sys/bus.h>
41#include <machine/bus.h>
42
43#include <net/ethernet.h>
44#include <net/if.h>
45#include <net/if_arp.h>
46#include <net/if_media.h>
47#include <net/if_mib.h>
48
49#include <isa/isavar.h>
50
51#include <dev/ed/if_edvar.h>
52#include <dev/ed/if_edreg.h>
53
54static int ed_isa_probe(device_t);
55static int ed_isa_attach(device_t);
56
57static struct isa_pnp_id ed_ids[] = {
58 { 0x0131d805, NULL }, /* ANX3101 */
59 { 0x4cf48906, NULL }, /* ATIf44c */
60 { 0x01200507, NULL }, /* AXE2001 */
61 { 0x0090252a, NULL }, /* JQE9000 */
62 { 0x0020832e, NULL }, /* KTC2000 */
63 { 0xd680d041, NULL }, /* PNP80d6 */
64 { 0x6081d041, NULL }, /* PNP8160 */
65 { 0x19808c4a, NULL }, /* RTL8019 */
66 { 0x1684a34d, NULL }, /* SMC8416 */
67 { 0x1980635e, NULL }, /* WSC8019 */
68 { 0, NULL }
69};
70
71static int
72ed_isa_probe_Novell(device_t dev)
73{
74 struct ed_softc *sc = device_get_softc(dev);
75 int flags = device_get_flags(dev);
76 int err;
77
78 err = ed_probe_Novell(dev, 0, flags);
79 if (err)
80 return err;
81 ed_Novell_read_mac(sc);
82 /*
83 * Final sanity check for Gateway Ethernet cards before
84 * believing that they really are Gateway AT.
85 */
86 if ((ED_FLAGS_GETTYPE(flags) == ED_FLAGS_GWETHER) &&
87 (sc->enaddr[2] == 0x86)) {
88 sc->type_str = "Gateway AT";
89 }
90
91 return (0);
92}
93
94static int
95ed_isa_probe(device_t dev)
96{
97 struct ed_softc *sc = device_get_softc(dev);
98 int flags = device_get_flags(dev);
99 int error = 0;
100
101 /* Check isapnp ids */
102 error = ISA_PNP_PROBE(device_get_parent(dev), dev, ed_ids);
103
104 /* If the card had a PnP ID that didn't match any we know about */
105 if (error == ENXIO)
106 goto end;
107
108 /* If we had some other problem. */
109 if (!(error == 0 || error == ENOENT))
110 goto end;
111
112 /* Heuristic probes */
113
114 error = ed_probe_WD80x3(dev, 0, flags);
115 if (error == 0)
116 goto end;
117 ed_release_resources(dev);
118
119 error = ed_probe_RTL80x9(dev, 0, flags);
120 if (error == 0) {
121 ed_Novell_read_mac(sc);
122 goto end;
123 }
124 ed_release_resources(dev);
125
126#ifdef ED_3C503
127 error = ed_probe_3Com(dev, 0, flags);
128 if (error == 0)
129 goto end;
130 ed_release_resources(dev);
131#endif
132
133#ifdef ED_SIC
134 error = ed_probe_SIC(dev, 0, flags);
135 if (error == 0)
136 goto end;
137 ed_release_resources(dev);
138#endif
139 error = ed_isa_probe_Novell(dev);
140 if (error == 0)
141 goto end;
142 ed_release_resources(dev);
143
144#ifdef ED_HPP
145 error = ed_probe_HP_pclanp(dev, 0, flags);
146 if (error == 0)
147 goto end;
148 ed_release_resources(dev);
149#endif
150end:
151 if (error == 0)
152 error = ed_alloc_irq(dev, 0, 0);
153
154 ed_release_resources(dev);
155 return (error);
156}
157
158static int
159ed_isa_attach(device_t dev)
160{
161 struct ed_softc *sc = device_get_softc(dev);
162 int error;
163
164 if (sc->port_used > 0)
165 ed_alloc_port(dev, sc->port_rid, sc->port_used);
166 if (sc->mem_used)
167 ed_alloc_memory(dev, sc->mem_rid, sc->mem_used);
168
169 ed_alloc_irq(dev, sc->irq_rid, 0);
170
171 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE,
172 edintr, sc, &sc->irq_handle);
173 if (error) {
174 ed_release_resources(dev);
175 return (error);
176 }
177
178#ifdef ED_HPP
179 if (sc->vendor == ED_VENDOR_HP && sc->type == ED_TYPE_HP_PCLANPLUS)
180 sc->readmem = ed_hpp_readmem;
181#endif
182 return ed_attach(dev);
183}
184
185static device_method_t ed_isa_methods[] = {
186 /* Device interface */
187 DEVMETHOD(device_probe, ed_isa_probe),
188 DEVMETHOD(device_attach, ed_isa_attach),
189 DEVMETHOD(device_detach, ed_detach),
190
191 { 0, 0 }
192};
193
194static driver_t ed_isa_driver = {
195 "ed",
196 ed_isa_methods,
197 sizeof(struct ed_softc)
198};
199
200DRIVER_MODULE(ed, isa, ed_isa_driver, ed_devclass, 0, 0);
201MODULE_DEPEND(ed, isa, 1, 1, 1);
202MODULE_DEPEND(ed, ether, 1, 1, 1);
2 * Copyright (c) 1995, David Greenman
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice unmodified, this list of conditions, and the following
10 * disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/ed/if_ed_isa.c 154391 2006-01-15 04:10:47Z imp $");
31
32#include "opt_ed.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/socket.h>
37#include <sys/kernel.h>
38
39#include <sys/module.h>
40#include <sys/bus.h>
41#include <machine/bus.h>
42
43#include <net/ethernet.h>
44#include <net/if.h>
45#include <net/if_arp.h>
46#include <net/if_media.h>
47#include <net/if_mib.h>
48
49#include <isa/isavar.h>
50
51#include <dev/ed/if_edvar.h>
52#include <dev/ed/if_edreg.h>
53
54static int ed_isa_probe(device_t);
55static int ed_isa_attach(device_t);
56
57static struct isa_pnp_id ed_ids[] = {
58 { 0x0131d805, NULL }, /* ANX3101 */
59 { 0x4cf48906, NULL }, /* ATIf44c */
60 { 0x01200507, NULL }, /* AXE2001 */
61 { 0x0090252a, NULL }, /* JQE9000 */
62 { 0x0020832e, NULL }, /* KTC2000 */
63 { 0xd680d041, NULL }, /* PNP80d6 */
64 { 0x6081d041, NULL }, /* PNP8160 */
65 { 0x19808c4a, NULL }, /* RTL8019 */
66 { 0x1684a34d, NULL }, /* SMC8416 */
67 { 0x1980635e, NULL }, /* WSC8019 */
68 { 0, NULL }
69};
70
71static int
72ed_isa_probe_Novell(device_t dev)
73{
74 struct ed_softc *sc = device_get_softc(dev);
75 int flags = device_get_flags(dev);
76 int err;
77
78 err = ed_probe_Novell(dev, 0, flags);
79 if (err)
80 return err;
81 ed_Novell_read_mac(sc);
82 /*
83 * Final sanity check for Gateway Ethernet cards before
84 * believing that they really are Gateway AT.
85 */
86 if ((ED_FLAGS_GETTYPE(flags) == ED_FLAGS_GWETHER) &&
87 (sc->enaddr[2] == 0x86)) {
88 sc->type_str = "Gateway AT";
89 }
90
91 return (0);
92}
93
94static int
95ed_isa_probe(device_t dev)
96{
97 struct ed_softc *sc = device_get_softc(dev);
98 int flags = device_get_flags(dev);
99 int error = 0;
100
101 /* Check isapnp ids */
102 error = ISA_PNP_PROBE(device_get_parent(dev), dev, ed_ids);
103
104 /* If the card had a PnP ID that didn't match any we know about */
105 if (error == ENXIO)
106 goto end;
107
108 /* If we had some other problem. */
109 if (!(error == 0 || error == ENOENT))
110 goto end;
111
112 /* Heuristic probes */
113
114 error = ed_probe_WD80x3(dev, 0, flags);
115 if (error == 0)
116 goto end;
117 ed_release_resources(dev);
118
119 error = ed_probe_RTL80x9(dev, 0, flags);
120 if (error == 0) {
121 ed_Novell_read_mac(sc);
122 goto end;
123 }
124 ed_release_resources(dev);
125
126#ifdef ED_3C503
127 error = ed_probe_3Com(dev, 0, flags);
128 if (error == 0)
129 goto end;
130 ed_release_resources(dev);
131#endif
132
133#ifdef ED_SIC
134 error = ed_probe_SIC(dev, 0, flags);
135 if (error == 0)
136 goto end;
137 ed_release_resources(dev);
138#endif
139 error = ed_isa_probe_Novell(dev);
140 if (error == 0)
141 goto end;
142 ed_release_resources(dev);
143
144#ifdef ED_HPP
145 error = ed_probe_HP_pclanp(dev, 0, flags);
146 if (error == 0)
147 goto end;
148 ed_release_resources(dev);
149#endif
150end:
151 if (error == 0)
152 error = ed_alloc_irq(dev, 0, 0);
153
154 ed_release_resources(dev);
155 return (error);
156}
157
158static int
159ed_isa_attach(device_t dev)
160{
161 struct ed_softc *sc = device_get_softc(dev);
162 int error;
163
164 if (sc->port_used > 0)
165 ed_alloc_port(dev, sc->port_rid, sc->port_used);
166 if (sc->mem_used)
167 ed_alloc_memory(dev, sc->mem_rid, sc->mem_used);
168
169 ed_alloc_irq(dev, sc->irq_rid, 0);
170
171 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE,
172 edintr, sc, &sc->irq_handle);
173 if (error) {
174 ed_release_resources(dev);
175 return (error);
176 }
177
178#ifdef ED_HPP
179 if (sc->vendor == ED_VENDOR_HP && sc->type == ED_TYPE_HP_PCLANPLUS)
180 sc->readmem = ed_hpp_readmem;
181#endif
182 return ed_attach(dev);
183}
184
185static device_method_t ed_isa_methods[] = {
186 /* Device interface */
187 DEVMETHOD(device_probe, ed_isa_probe),
188 DEVMETHOD(device_attach, ed_isa_attach),
189 DEVMETHOD(device_detach, ed_detach),
190
191 { 0, 0 }
192};
193
194static driver_t ed_isa_driver = {
195 "ed",
196 ed_isa_methods,
197 sizeof(struct ed_softc)
198};
199
200DRIVER_MODULE(ed, isa, ed_isa_driver, ed_devclass, 0, 0);
201MODULE_DEPEND(ed, isa, 1, 1, 1);
202MODULE_DEPEND(ed, ether, 1, 1, 1);