Deleted Added
full compact
if_hme_sbus.c (133599) if_hme_sbus.c (137982)
1/*-
2 * Copyright (c) 1999 The NetBSD Foundation, Inc.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Paul Kranenburg.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the NetBSD
19 * Foundation, Inc. and its contributors.
20 * 4. Neither the name of The NetBSD Foundation nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 *
36 * from: NetBSD: if_hme_sbus.c,v 1.19 2004/03/17 17:04:58 pk Exp
37 */
38
39#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1999 The NetBSD Foundation, Inc.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Paul Kranenburg.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the NetBSD
19 * Foundation, Inc. and its contributors.
20 * 4. Neither the name of The NetBSD Foundation nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 *
36 * from: NetBSD: if_hme_sbus.c,v 1.19 2004/03/17 17:04:58 pk Exp
37 */
38
39#include <sys/cdefs.h>
40__FBSDID("$FreeBSD: head/sys/dev/hme/if_hme_sbus.c 133599 2004-08-12 20:37:02Z marius $");
40__FBSDID("$FreeBSD: head/sys/dev/hme/if_hme_sbus.c 137982 2004-11-22 06:46:30Z yongari $");
41
42/*
43 * SBus front-end device driver for the HME ethernet device.
44 */
45
46#include <sys/param.h>
47#include <sys/systm.h>
48#include <sys/bus.h>
49#include <sys/kernel.h>
50#include <sys/module.h>
51#include <sys/resource.h>
52#include <sys/socket.h>
53
54#include <dev/ofw/ofw_bus.h>
55
56#include <machine/bus.h>
57#include <machine/ofw_machdep.h>
58#include <machine/resource.h>
59
60#include <sys/rman.h>
61
62#include <net/ethernet.h>
63#include <net/if.h>
64#include <net/if_arp.h>
65#include <net/if_dl.h>
66#include <net/if_media.h>
67
68#include <dev/mii/mii.h>
69#include <dev/mii/miivar.h>
70
71#include <sparc64/sbus/sbusvar.h>
72
73#include <dev/hme/if_hmereg.h>
74#include <dev/hme/if_hmevar.h>
75
76#include "miibus_if.h"
77
78struct hme_sbus_softc {
79 struct hme_softc hsc_hme; /* HME device */
80 struct resource *hsc_seb_res;
81 int hsc_seb_rid;
82 struct resource *hsc_etx_res;
83 int hsc_etx_rid;
84 struct resource *hsc_erx_res;
85 int hsc_erx_rid;
86 struct resource *hsc_mac_res;
87 int hsc_mac_rid;
88 struct resource *hsc_mif_res;
89 int hsc_mif_rid;
90 struct resource *hsc_ires;
91 int hsc_irid;
92 void *hsc_ih;
93};
94
95static int hme_sbus_probe(device_t);
96static int hme_sbus_attach(device_t);
97static int hme_sbus_detach(device_t);
98static int hme_sbus_suspend(device_t);
99static int hme_sbus_resume(device_t);
100
101static device_method_t hme_sbus_methods[] = {
102 /* Device interface */
103 DEVMETHOD(device_probe, hme_sbus_probe),
104 DEVMETHOD(device_attach, hme_sbus_attach),
105 DEVMETHOD(device_detach, hme_sbus_detach),
106 DEVMETHOD(device_suspend, hme_sbus_suspend),
107 DEVMETHOD(device_resume, hme_sbus_resume),
108 /* Can just use the suspend method here. */
109 DEVMETHOD(device_shutdown, hme_sbus_suspend),
110
111 /* bus interface */
112 DEVMETHOD(bus_print_child, bus_generic_print_child),
113 DEVMETHOD(bus_driver_added, bus_generic_driver_added),
114
115 /* MII interface */
116 DEVMETHOD(miibus_readreg, hme_mii_readreg),
117 DEVMETHOD(miibus_writereg, hme_mii_writereg),
118 DEVMETHOD(miibus_statchg, hme_mii_statchg),
119
120 { 0, 0 }
121};
122
123static driver_t hme_sbus_driver = {
124 "hme",
125 hme_sbus_methods,
126 sizeof(struct hme_sbus_softc)
127};
128
129DRIVER_MODULE(hme, sbus, hme_sbus_driver, hme_devclass, 0, 0);
130MODULE_DEPEND(hme, ether, 1, 1, 1);
131
132static int
133hme_sbus_probe(device_t dev)
134{
135 const char *name;
136
137 name = ofw_bus_get_name(dev);
138 if (strcmp(name, "SUNW,qfe") == 0 ||
139 strcmp(name, "SUNW,hme") == 0) {
140 device_set_desc(dev, "Sun HME 10/100 Ethernet");
141 return (0);
142 }
143 return (ENXIO);
144}
145
146static int
147hme_sbus_attach(device_t dev)
148{
149 struct hme_sbus_softc *hsc = device_get_softc(dev);
150 struct hme_softc *sc = &hsc->hsc_hme;
151 u_int32_t burst;
152 u_long start, count;
153 int error = 0;
154
41
42/*
43 * SBus front-end device driver for the HME ethernet device.
44 */
45
46#include <sys/param.h>
47#include <sys/systm.h>
48#include <sys/bus.h>
49#include <sys/kernel.h>
50#include <sys/module.h>
51#include <sys/resource.h>
52#include <sys/socket.h>
53
54#include <dev/ofw/ofw_bus.h>
55
56#include <machine/bus.h>
57#include <machine/ofw_machdep.h>
58#include <machine/resource.h>
59
60#include <sys/rman.h>
61
62#include <net/ethernet.h>
63#include <net/if.h>
64#include <net/if_arp.h>
65#include <net/if_dl.h>
66#include <net/if_media.h>
67
68#include <dev/mii/mii.h>
69#include <dev/mii/miivar.h>
70
71#include <sparc64/sbus/sbusvar.h>
72
73#include <dev/hme/if_hmereg.h>
74#include <dev/hme/if_hmevar.h>
75
76#include "miibus_if.h"
77
78struct hme_sbus_softc {
79 struct hme_softc hsc_hme; /* HME device */
80 struct resource *hsc_seb_res;
81 int hsc_seb_rid;
82 struct resource *hsc_etx_res;
83 int hsc_etx_rid;
84 struct resource *hsc_erx_res;
85 int hsc_erx_rid;
86 struct resource *hsc_mac_res;
87 int hsc_mac_rid;
88 struct resource *hsc_mif_res;
89 int hsc_mif_rid;
90 struct resource *hsc_ires;
91 int hsc_irid;
92 void *hsc_ih;
93};
94
95static int hme_sbus_probe(device_t);
96static int hme_sbus_attach(device_t);
97static int hme_sbus_detach(device_t);
98static int hme_sbus_suspend(device_t);
99static int hme_sbus_resume(device_t);
100
101static device_method_t hme_sbus_methods[] = {
102 /* Device interface */
103 DEVMETHOD(device_probe, hme_sbus_probe),
104 DEVMETHOD(device_attach, hme_sbus_attach),
105 DEVMETHOD(device_detach, hme_sbus_detach),
106 DEVMETHOD(device_suspend, hme_sbus_suspend),
107 DEVMETHOD(device_resume, hme_sbus_resume),
108 /* Can just use the suspend method here. */
109 DEVMETHOD(device_shutdown, hme_sbus_suspend),
110
111 /* bus interface */
112 DEVMETHOD(bus_print_child, bus_generic_print_child),
113 DEVMETHOD(bus_driver_added, bus_generic_driver_added),
114
115 /* MII interface */
116 DEVMETHOD(miibus_readreg, hme_mii_readreg),
117 DEVMETHOD(miibus_writereg, hme_mii_writereg),
118 DEVMETHOD(miibus_statchg, hme_mii_statchg),
119
120 { 0, 0 }
121};
122
123static driver_t hme_sbus_driver = {
124 "hme",
125 hme_sbus_methods,
126 sizeof(struct hme_sbus_softc)
127};
128
129DRIVER_MODULE(hme, sbus, hme_sbus_driver, hme_devclass, 0, 0);
130MODULE_DEPEND(hme, ether, 1, 1, 1);
131
132static int
133hme_sbus_probe(device_t dev)
134{
135 const char *name;
136
137 name = ofw_bus_get_name(dev);
138 if (strcmp(name, "SUNW,qfe") == 0 ||
139 strcmp(name, "SUNW,hme") == 0) {
140 device_set_desc(dev, "Sun HME 10/100 Ethernet");
141 return (0);
142 }
143 return (ENXIO);
144}
145
146static int
147hme_sbus_attach(device_t dev)
148{
149 struct hme_sbus_softc *hsc = device_get_softc(dev);
150 struct hme_softc *sc = &hsc->hsc_hme;
151 u_int32_t burst;
152 u_long start, count;
153 int error = 0;
154
155 mtx_init(&sc->sc_lock, device_get_nameunit(dev), MTX_NETWORK_LOCK,
156 MTX_DEF);
155 /*
156 * Map five register banks:
157 *
158 * bank 0: HME SEB registers
159 * bank 1: HME ETX registers
160 * bank 2: HME ERX registers
161 * bank 3: HME MAC registers
162 * bank 4: HME MIF registers
163 *
164 */
165 hsc->hsc_seb_rid = 0;
166 hsc->hsc_seb_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
167 &hsc->hsc_seb_rid, RF_ACTIVE);
168 if (hsc->hsc_seb_res == NULL) {
169 device_printf(dev, "cannot map SEB registers\n");
157 /*
158 * Map five register banks:
159 *
160 * bank 0: HME SEB registers
161 * bank 1: HME ETX registers
162 * bank 2: HME ERX registers
163 * bank 3: HME MAC registers
164 * bank 4: HME MIF registers
165 *
166 */
167 hsc->hsc_seb_rid = 0;
168 hsc->hsc_seb_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
169 &hsc->hsc_seb_rid, RF_ACTIVE);
170 if (hsc->hsc_seb_res == NULL) {
171 device_printf(dev, "cannot map SEB registers\n");
170 return (ENXIO);
172 error = ENXIO;
173 goto fail_mtx_res;
171 }
172 sc->sc_sebt = rman_get_bustag(hsc->hsc_seb_res);
173 sc->sc_sebh = rman_get_bushandle(hsc->hsc_seb_res);
174
175 hsc->hsc_etx_rid = 1;
176 hsc->hsc_etx_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
177 &hsc->hsc_etx_rid, RF_ACTIVE);
178 if (hsc->hsc_etx_res == NULL) {
179 device_printf(dev, "cannot map ETX registers\n");
180 error = ENXIO;
181 goto fail_seb_res;
182 }
183 sc->sc_etxt = rman_get_bustag(hsc->hsc_etx_res);
184 sc->sc_etxh = rman_get_bushandle(hsc->hsc_etx_res);
185
186 hsc->hsc_erx_rid = 2;
187 hsc->hsc_erx_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
188 &hsc->hsc_erx_rid, RF_ACTIVE);
189 if (hsc->hsc_erx_res == NULL) {
190 device_printf(dev, "cannot map ERX registers\n");
191 error = ENXIO;
192 goto fail_etx_res;
193 }
194 sc->sc_erxt = rman_get_bustag(hsc->hsc_erx_res);
195 sc->sc_erxh = rman_get_bushandle(hsc->hsc_erx_res);
196
197 hsc->hsc_mac_rid = 3;
198 hsc->hsc_mac_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
199 &hsc->hsc_mac_rid, RF_ACTIVE);
200 if (hsc->hsc_mac_res == NULL) {
201 device_printf(dev, "cannot map MAC registers\n");
202 error = ENXIO;
203 goto fail_erx_res;
204 }
205 sc->sc_mact = rman_get_bustag(hsc->hsc_mac_res);
206 sc->sc_mach = rman_get_bushandle(hsc->hsc_mac_res);
207
208 /*
209 * At least on some HMEs, the MIF registers seem to be inside the MAC
210 * range, so try to kludge around it.
211 */
212 hsc->hsc_mif_rid = 4;
213 hsc->hsc_mif_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
214 &hsc->hsc_mif_rid, RF_ACTIVE);
215 if (hsc->hsc_mif_res == NULL) {
216 if (bus_get_resource(dev, SYS_RES_MEMORY, hsc->hsc_mif_rid,
217 &start, &count) != 0) {
218 device_printf(dev, "cannot get MIF registers\n");
219 error = ENXIO;
220 goto fail_mac_res;
221 }
222 if (start < rman_get_start(hsc->hsc_mac_res) ||
223 start + count - 1 > rman_get_end(hsc->hsc_mac_res)) {
224 device_printf(dev, "cannot move MIF registers to MAC "
225 "bank\n");
226 error = ENXIO;
227 goto fail_mac_res;
228 }
229 sc->sc_mift = sc->sc_mact;
230 bus_space_subregion(sc->sc_mact, sc->sc_mach,
231 start - rman_get_start(hsc->hsc_mac_res), count,
232 &sc->sc_mifh);
233 } else {
234 sc->sc_mift = rman_get_bustag(hsc->hsc_mif_res);
235 sc->sc_mifh = rman_get_bushandle(hsc->hsc_mif_res);
236 }
237
238 hsc->hsc_irid = 0;
239 hsc->hsc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ,
240 &hsc->hsc_irid, RF_SHAREABLE | RF_ACTIVE);
241 if (hsc->hsc_ires == NULL) {
242 device_printf(dev, "could not allocate interrupt\n");
243 error = ENXIO;
244 goto fail_mif_res;
245 }
246
247 OF_getetheraddr(dev, sc->sc_arpcom.ac_enaddr);
248
249 burst = sbus_get_burstsz(dev);
250 /* Translate into plain numerical format */
251 if ((burst & SBUS_BURST_64))
252 sc->sc_burst = 64;
253 else if ((burst & SBUS_BURST_32))
254 sc->sc_burst = 32;
255 else if ((burst & SBUS_BURST_16))
256 sc->sc_burst = 16;
257 else
258 sc->sc_burst = 0;
259
260 sc->sc_pci = 0; /* XXX: should all be done in bus_dma. */
261 sc->sc_dev = dev;
262
263 if ((error = hme_config(sc)) != 0) {
264 device_printf(dev, "could not be configured\n");
265 goto fail_ires;
266 }
267
174 }
175 sc->sc_sebt = rman_get_bustag(hsc->hsc_seb_res);
176 sc->sc_sebh = rman_get_bushandle(hsc->hsc_seb_res);
177
178 hsc->hsc_etx_rid = 1;
179 hsc->hsc_etx_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
180 &hsc->hsc_etx_rid, RF_ACTIVE);
181 if (hsc->hsc_etx_res == NULL) {
182 device_printf(dev, "cannot map ETX registers\n");
183 error = ENXIO;
184 goto fail_seb_res;
185 }
186 sc->sc_etxt = rman_get_bustag(hsc->hsc_etx_res);
187 sc->sc_etxh = rman_get_bushandle(hsc->hsc_etx_res);
188
189 hsc->hsc_erx_rid = 2;
190 hsc->hsc_erx_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
191 &hsc->hsc_erx_rid, RF_ACTIVE);
192 if (hsc->hsc_erx_res == NULL) {
193 device_printf(dev, "cannot map ERX registers\n");
194 error = ENXIO;
195 goto fail_etx_res;
196 }
197 sc->sc_erxt = rman_get_bustag(hsc->hsc_erx_res);
198 sc->sc_erxh = rman_get_bushandle(hsc->hsc_erx_res);
199
200 hsc->hsc_mac_rid = 3;
201 hsc->hsc_mac_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
202 &hsc->hsc_mac_rid, RF_ACTIVE);
203 if (hsc->hsc_mac_res == NULL) {
204 device_printf(dev, "cannot map MAC registers\n");
205 error = ENXIO;
206 goto fail_erx_res;
207 }
208 sc->sc_mact = rman_get_bustag(hsc->hsc_mac_res);
209 sc->sc_mach = rman_get_bushandle(hsc->hsc_mac_res);
210
211 /*
212 * At least on some HMEs, the MIF registers seem to be inside the MAC
213 * range, so try to kludge around it.
214 */
215 hsc->hsc_mif_rid = 4;
216 hsc->hsc_mif_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
217 &hsc->hsc_mif_rid, RF_ACTIVE);
218 if (hsc->hsc_mif_res == NULL) {
219 if (bus_get_resource(dev, SYS_RES_MEMORY, hsc->hsc_mif_rid,
220 &start, &count) != 0) {
221 device_printf(dev, "cannot get MIF registers\n");
222 error = ENXIO;
223 goto fail_mac_res;
224 }
225 if (start < rman_get_start(hsc->hsc_mac_res) ||
226 start + count - 1 > rman_get_end(hsc->hsc_mac_res)) {
227 device_printf(dev, "cannot move MIF registers to MAC "
228 "bank\n");
229 error = ENXIO;
230 goto fail_mac_res;
231 }
232 sc->sc_mift = sc->sc_mact;
233 bus_space_subregion(sc->sc_mact, sc->sc_mach,
234 start - rman_get_start(hsc->hsc_mac_res), count,
235 &sc->sc_mifh);
236 } else {
237 sc->sc_mift = rman_get_bustag(hsc->hsc_mif_res);
238 sc->sc_mifh = rman_get_bushandle(hsc->hsc_mif_res);
239 }
240
241 hsc->hsc_irid = 0;
242 hsc->hsc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ,
243 &hsc->hsc_irid, RF_SHAREABLE | RF_ACTIVE);
244 if (hsc->hsc_ires == NULL) {
245 device_printf(dev, "could not allocate interrupt\n");
246 error = ENXIO;
247 goto fail_mif_res;
248 }
249
250 OF_getetheraddr(dev, sc->sc_arpcom.ac_enaddr);
251
252 burst = sbus_get_burstsz(dev);
253 /* Translate into plain numerical format */
254 if ((burst & SBUS_BURST_64))
255 sc->sc_burst = 64;
256 else if ((burst & SBUS_BURST_32))
257 sc->sc_burst = 32;
258 else if ((burst & SBUS_BURST_16))
259 sc->sc_burst = 16;
260 else
261 sc->sc_burst = 0;
262
263 sc->sc_pci = 0; /* XXX: should all be done in bus_dma. */
264 sc->sc_dev = dev;
265
266 if ((error = hme_config(sc)) != 0) {
267 device_printf(dev, "could not be configured\n");
268 goto fail_ires;
269 }
270
268 if ((error = bus_setup_intr(dev, hsc->hsc_ires, INTR_TYPE_NET, hme_intr,
269 sc, &hsc->hsc_ih)) != 0) {
271 if ((error = bus_setup_intr(dev, hsc->hsc_ires, INTR_TYPE_NET |
272 INTR_MPSAFE, hme_intr, sc, &hsc->hsc_ih)) != 0) {
270 device_printf(dev, "couldn't establish interrupt\n");
271 hme_detach(sc);
272 goto fail_ires;
273 }
274 return (0);
275
276fail_ires:
277 bus_release_resource(dev, SYS_RES_IRQ, hsc->hsc_irid, hsc->hsc_ires);
278fail_mif_res:
279 if (hsc->hsc_mif_res != NULL) {
280 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mif_rid,
281 hsc->hsc_mif_res);
282 }
283fail_mac_res:
284 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mac_rid,
285 hsc->hsc_mac_res);
286fail_erx_res:
287 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_erx_rid,
288 hsc->hsc_erx_res);
289fail_etx_res:
290 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_etx_rid,
291 hsc->hsc_etx_res);
292fail_seb_res:
293 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_seb_rid,
294 hsc->hsc_seb_res);
273 device_printf(dev, "couldn't establish interrupt\n");
274 hme_detach(sc);
275 goto fail_ires;
276 }
277 return (0);
278
279fail_ires:
280 bus_release_resource(dev, SYS_RES_IRQ, hsc->hsc_irid, hsc->hsc_ires);
281fail_mif_res:
282 if (hsc->hsc_mif_res != NULL) {
283 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mif_rid,
284 hsc->hsc_mif_res);
285 }
286fail_mac_res:
287 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mac_rid,
288 hsc->hsc_mac_res);
289fail_erx_res:
290 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_erx_rid,
291 hsc->hsc_erx_res);
292fail_etx_res:
293 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_etx_rid,
294 hsc->hsc_etx_res);
295fail_seb_res:
296 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_seb_rid,
297 hsc->hsc_seb_res);
298fail_mtx_res:
299 mtx_destroy(&sc->sc_lock);
295 return (error);
296}
297
298static int
299hme_sbus_detach(device_t dev)
300{
301 struct hme_sbus_softc *hsc = device_get_softc(dev);
302 struct hme_softc *sc = &hsc->hsc_hme;
303
300 return (error);
301}
302
303static int
304hme_sbus_detach(device_t dev)
305{
306 struct hme_sbus_softc *hsc = device_get_softc(dev);
307 struct hme_softc *sc = &hsc->hsc_hme;
308
304 hme_detach(sc);
305
306 bus_teardown_intr(dev, hsc->hsc_ires, hsc->hsc_ih);
309 bus_teardown_intr(dev, hsc->hsc_ires, hsc->hsc_ih);
310 hme_detach(sc);
307 if (hsc->hsc_mif_res != NULL) {
308 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mif_rid,
309 hsc->hsc_mif_res);
310 }
311 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mac_rid,
312 hsc->hsc_mac_res);
313 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_erx_rid,
314 hsc->hsc_erx_res);
315 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_etx_rid,
316 hsc->hsc_etx_res);
317 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_seb_rid,
318 hsc->hsc_seb_res);
311 if (hsc->hsc_mif_res != NULL) {
312 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mif_rid,
313 hsc->hsc_mif_res);
314 }
315 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mac_rid,
316 hsc->hsc_mac_res);
317 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_erx_rid,
318 hsc->hsc_erx_res);
319 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_etx_rid,
320 hsc->hsc_etx_res);
321 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_seb_rid,
322 hsc->hsc_seb_res);
323 mtx_destroy(&sc->sc_lock);
319 return (0);
320}
321
322static int
323hme_sbus_suspend(device_t dev)
324{
325 struct hme_sbus_softc *hsc = device_get_softc(dev);
326 struct hme_softc *sc = &hsc->hsc_hme;
327
328 hme_suspend(sc);
329 return (0);
330}
331
332static int
333hme_sbus_resume(device_t dev)
334{
335 struct hme_sbus_softc *hsc = device_get_softc(dev);
336 struct hme_softc *sc = &hsc->hsc_hme;
337
338 hme_resume(sc);
339 return (0);
340}
324 return (0);
325}
326
327static int
328hme_sbus_suspend(device_t dev)
329{
330 struct hme_sbus_softc *hsc = device_get_softc(dev);
331 struct hme_softc *sc = &hsc->hsc_hme;
332
333 hme_suspend(sc);
334 return (0);
335}
336
337static int
338hme_sbus_resume(device_t dev)
339{
340 struct hme_sbus_softc *hsc = device_get_softc(dev);
341 struct hme_softc *sc = &hsc->hsc_hme;
342
343 hme_resume(sc);
344 return (0);
345}