Deleted Added
full compact
if_cm_isa.c (148887) if_cm_isa.c (150306)
1/* $NetBSD: if_bah_zbus.c,v 1.6 2000/01/23 21:06:12 aymeric Exp $ */
2
3#include <sys/cdefs.h>
1/* $NetBSD: if_bah_zbus.c,v 1.6 2000/01/23 21:06:12 aymeric Exp $ */
2
3#include <sys/cdefs.h>
4__FBSDID("$FreeBSD: head/sys/dev/cm/if_cm_isa.c 148887 2005-08-09 10:20:02Z rwatson $");
4__FBSDID("$FreeBSD: head/sys/dev/cm/if_cm_isa.c 150306 2005-09-19 03:10:21Z imp $");
5
6/*-
7 * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc.
8 * All rights reserved.
9 *
10 * This code is derived from software contributed to The NetBSD Foundation
11 * by Ignatios Souvatzis.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed by the NetBSD
24 * Foundation, Inc. and its contributors.
25 * 4. Neither the name of The NetBSD Foundation nor the names of its
26 * contributors may be used to endorse or promote products derived
27 * from this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
30 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
31 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
32 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
33 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGE.
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/socket.h>
45#include <sys/kernel.h>
46
47#include <sys/module.h>
48#include <sys/bus.h>
49
50#include <machine/bus.h>
51
52#include <net/if.h>
53#include <net/if_arc.h>
54
55#include <dev/cm/smc90cx6var.h>
56
57static int cm_isa_probe (device_t);
58static int cm_isa_attach (device_t);
59
60static int
61cm_isa_probe(dev)
62 device_t dev;
63{
64 struct cm_softc *sc = device_get_softc(dev);
65 int error;
66
67 bzero(sc, sizeof(struct cm_softc));
68
69 error = cm_probe(dev);
70 if (error == 0)
71 goto end;
72
73end:
74 if (error == 0)
75 error = cm_alloc_irq(dev, 0);
76
77 cm_release_resources(dev);
78 return (error);
79}
80
81static int
82cm_isa_attach(dev)
83 device_t dev;
84{
85 struct cm_softc *sc = device_get_softc(dev);
86 int error;
87
88 cm_alloc_port(dev, sc->port_rid, sc->port_used);
89 cm_alloc_memory(dev, sc->mem_rid, sc->mem_used);
90 cm_alloc_irq(dev, sc->irq_rid);
91
92 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
93 cmintr, sc, &sc->irq_handle);
94 if (error) {
95 cm_release_resources(dev);
96 return (error);
97 }
98
99 return cm_attach(dev);
100}
101
102static int
103cm_isa_detach(device_t dev)
104{
105 struct cm_softc *sc = device_get_softc(dev);
106 struct ifnet *ifp = sc->sc_ifp;
107 int s;
108
109 cm_stop(sc);
110 ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
111
112 s = splimp();
113 arc_ifdetach(ifp);
5
6/*-
7 * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc.
8 * All rights reserved.
9 *
10 * This code is derived from software contributed to The NetBSD Foundation
11 * by Ignatios Souvatzis.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed by the NetBSD
24 * Foundation, Inc. and its contributors.
25 * 4. Neither the name of The NetBSD Foundation nor the names of its
26 * contributors may be used to endorse or promote products derived
27 * from this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
30 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
31 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
32 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
33 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGE.
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/socket.h>
45#include <sys/kernel.h>
46
47#include <sys/module.h>
48#include <sys/bus.h>
49
50#include <machine/bus.h>
51
52#include <net/if.h>
53#include <net/if_arc.h>
54
55#include <dev/cm/smc90cx6var.h>
56
57static int cm_isa_probe (device_t);
58static int cm_isa_attach (device_t);
59
60static int
61cm_isa_probe(dev)
62 device_t dev;
63{
64 struct cm_softc *sc = device_get_softc(dev);
65 int error;
66
67 bzero(sc, sizeof(struct cm_softc));
68
69 error = cm_probe(dev);
70 if (error == 0)
71 goto end;
72
73end:
74 if (error == 0)
75 error = cm_alloc_irq(dev, 0);
76
77 cm_release_resources(dev);
78 return (error);
79}
80
81static int
82cm_isa_attach(dev)
83 device_t dev;
84{
85 struct cm_softc *sc = device_get_softc(dev);
86 int error;
87
88 cm_alloc_port(dev, sc->port_rid, sc->port_used);
89 cm_alloc_memory(dev, sc->mem_rid, sc->mem_used);
90 cm_alloc_irq(dev, sc->irq_rid);
91
92 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
93 cmintr, sc, &sc->irq_handle);
94 if (error) {
95 cm_release_resources(dev);
96 return (error);
97 }
98
99 return cm_attach(dev);
100}
101
102static int
103cm_isa_detach(device_t dev)
104{
105 struct cm_softc *sc = device_get_softc(dev);
106 struct ifnet *ifp = sc->sc_ifp;
107 int s;
108
109 cm_stop(sc);
110 ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
111
112 s = splimp();
113 arc_ifdetach(ifp);
114 if_free(ifp);
115 splx(s);
116
117 bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
114 splx(s);
115
116 bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
117 if_free(ifp);
118 cm_release_resources(dev);
119
120 return (0);
121}
122
123static device_method_t cm_isa_methods[] = {
124 /* Device interface */
125 DEVMETHOD(device_probe, cm_isa_probe),
126 DEVMETHOD(device_attach, cm_isa_attach),
127 DEVMETHOD(device_detach, cm_isa_detach),
128
129 { 0, 0 }
130};
131
132static driver_t cm_isa_driver = {
133 "cm",
134 cm_isa_methods,
135 sizeof(struct cm_softc)
136};
137
138DRIVER_MODULE(cm, isa, cm_isa_driver, cm_devclass, 0, 0);
139MODULE_DEPEND(cm, isa, 1, 1, 1);
118 cm_release_resources(dev);
119
120 return (0);
121}
122
123static device_method_t cm_isa_methods[] = {
124 /* Device interface */
125 DEVMETHOD(device_probe, cm_isa_probe),
126 DEVMETHOD(device_attach, cm_isa_attach),
127 DEVMETHOD(device_detach, cm_isa_detach),
128
129 { 0, 0 }
130};
131
132static driver_t cm_isa_driver = {
133 "cm",
134 cm_isa_methods,
135 sizeof(struct cm_softc)
136};
137
138DRIVER_MODULE(cm, isa, cm_isa_driver, cm_devclass, 0, 0);
139MODULE_DEPEND(cm, isa, 1, 1, 1);