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.9 2001/11/13 06:58:17 lukem 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.9 2001/11/13 06:58:17 lukem Exp 37 */ 38 39#include <sys/cdefs.h>
|
54#include <machine/ofw_machdep.h> 55#include <machine/resource.h> 56 57#include <sys/rman.h> 58 59#include <dev/ofw/openfirm.h> 60 61#include <net/ethernet.h> 62#include <net/if.h> 63#include <net/if_arp.h> 64#include <net/if_dl.h> 65#include <net/if_media.h> 66 67#include <dev/mii/mii.h> 68#include <dev/mii/miivar.h> 69 70#include <sparc64/sbus/sbusvar.h> 71 72#include <dev/hme/if_hmereg.h> 73#include <dev/hme/if_hmevar.h> 74 75#include "miibus_if.h" 76 77struct hme_sbus_softc { 78 struct hme_softc hsc_hme; /* HME device */ 79 struct resource *hsc_seb_res; 80 int hsc_seb_rid; 81 struct resource *hsc_etx_res; 82 int hsc_etx_rid; 83 struct resource *hsc_erx_res; 84 int hsc_erx_rid; 85 struct resource *hsc_mac_res; 86 int hsc_mac_rid; 87 struct resource *hsc_mif_res; 88 int hsc_mif_rid; 89 struct resource *hsc_ires; 90 int hsc_irid; 91 void *hsc_ih; 92}; 93 94static int hme_sbus_probe(device_t); 95static int hme_sbus_attach(device_t); 96static int hme_sbus_detach(device_t); 97static int hme_sbus_suspend(device_t); 98static int hme_sbus_resume(device_t); 99 100static device_method_t hme_sbus_methods[] = { 101 /* Device interface */ 102 DEVMETHOD(device_probe, hme_sbus_probe), 103 DEVMETHOD(device_attach, hme_sbus_attach), 104 DEVMETHOD(device_detach, hme_sbus_detach), 105 DEVMETHOD(device_suspend, hme_sbus_suspend), 106 DEVMETHOD(device_resume, hme_sbus_resume), 107 /* Can just use the suspend method here. */ 108 DEVMETHOD(device_shutdown, hme_sbus_suspend), 109 110 /* bus interface */ 111 DEVMETHOD(bus_print_child, bus_generic_print_child), 112 DEVMETHOD(bus_driver_added, bus_generic_driver_added), 113 114 /* MII interface */ 115 DEVMETHOD(miibus_readreg, hme_mii_readreg), 116 DEVMETHOD(miibus_writereg, hme_mii_writereg), 117 DEVMETHOD(miibus_statchg, hme_mii_statchg), 118 119 { 0, 0 } 120}; 121 122static driver_t hme_sbus_driver = { 123 "hme", 124 hme_sbus_methods, 125 sizeof(struct hme_sbus_softc) 126}; 127 128DRIVER_MODULE(hme, sbus, hme_sbus_driver, hme_devclass, 0, 0); 129MODULE_DEPEND(hme, ether, 1, 1, 1); 130 131static int 132hme_sbus_probe(device_t dev) 133{ 134 char *name; 135 136 name = sbus_get_name(dev); 137 if (strcmp(name, "SUNW,qfe") == 0 || 138 strcmp(name, "SUNW,hme") == 0) { 139 device_set_desc(dev, "Sun HME 10/100 Ethernet"); 140 return (0); 141 } 142 return (ENXIO); 143} 144 145static int 146hme_sbus_attach(device_t dev) 147{ 148 struct hme_sbus_softc *hsc = device_get_softc(dev); 149 struct hme_softc *sc = &hsc->hsc_hme; 150 u_int32_t burst; 151 u_long start, count; 152 int error; 153 154 /* 155 * Map five register banks: 156 * 157 * bank 0: HME SEB registers 158 * bank 1: HME ETX registers 159 * bank 2: HME ERX registers 160 * bank 3: HME MAC registers 161 * bank 4: HME MIF registers 162 * 163 */ 164 sc->sc_sebo = sc->sc_etxo = sc->sc_erxo = sc->sc_maco = sc->sc_mifo = 0; 165 hsc->hsc_seb_rid = 0; 166 hsc->hsc_seb_res = bus_alloc_resource(dev, SYS_RES_MEMORY, 167 &hsc->hsc_seb_rid, 0, ~0, 1, RF_ACTIVE); 168 if (hsc->hsc_seb_res == NULL) { 169 device_printf(dev, "cannot map SEB registers\n"); 170 return (ENXIO); 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(dev, SYS_RES_MEMORY, 177 &hsc->hsc_etx_rid, 0, ~0, 1, RF_ACTIVE); 178 if (hsc->hsc_etx_res == NULL) { 179 device_printf(dev, "cannot map ETX registers\n"); 180 goto fail_seb_res; 181 } 182 sc->sc_etxt = rman_get_bustag(hsc->hsc_etx_res); 183 sc->sc_etxh = rman_get_bushandle(hsc->hsc_etx_res); 184 185 hsc->hsc_erx_rid = 2; 186 hsc->hsc_erx_res = bus_alloc_resource(dev, SYS_RES_MEMORY, 187 &hsc->hsc_erx_rid, 0, ~0, 1, RF_ACTIVE); 188 if (hsc->hsc_erx_res == NULL) { 189 device_printf(dev, "cannot map ERX registers\n"); 190 goto fail_etx_res; 191 } 192 sc->sc_erxt = rman_get_bustag(hsc->hsc_erx_res); 193 sc->sc_erxh = rman_get_bushandle(hsc->hsc_erx_res); 194 195 hsc->hsc_mac_rid = 3; 196 hsc->hsc_mac_res = bus_alloc_resource(dev, SYS_RES_MEMORY, 197 &hsc->hsc_mac_rid, 0, ~0, 1, RF_ACTIVE); 198 if (hsc->hsc_mac_res == NULL) { 199 device_printf(dev, "cannot map MAC registers\n"); 200 goto fail_erx_res; 201 } 202 sc->sc_mact = rman_get_bustag(hsc->hsc_mac_res); 203 sc->sc_mach = rman_get_bushandle(hsc->hsc_mac_res); 204 205 /* 206 * At least on some HMEs, the MIF registers seem to be inside the MAC 207 * range, so map try to kluge around it. 208 */ 209 hsc->hsc_mif_rid = 4; 210 hsc->hsc_mif_res = bus_alloc_resource(dev, SYS_RES_MEMORY, 211 &hsc->hsc_mif_rid, 0, ~0, 1, RF_ACTIVE); 212 if (hsc->hsc_mif_res == NULL) { 213 if (bus_get_resource(dev, SYS_RES_MEMORY, hsc->hsc_mif_rid, 214 &start, &count) != 0) { 215 device_printf(dev, "cannot get MIF registers\n"); 216 goto fail_mac_res; 217 } 218 if (start < rman_get_start(hsc->hsc_mac_res) || 219 start + count - 1 > rman_get_end(hsc->hsc_mac_res)) { 220 device_printf(dev, "cannot move MIF registers to MAC " 221 "bank\n"); 222 goto fail_mac_res; 223 } 224 sc->sc_mift = sc->sc_mact; 225 sc->sc_mifh = sc->sc_mach; 226 sc->sc_mifo = sc->sc_maco + start - 227 rman_get_start(hsc->hsc_mac_res); 228 } else { 229 sc->sc_mift = rman_get_bustag(hsc->hsc_mif_res); 230 sc->sc_mifh = rman_get_bushandle(hsc->hsc_mif_res); 231 } 232 233 hsc->hsc_irid = 0; 234 hsc->hsc_ires = bus_alloc_resource(dev, SYS_RES_IRQ, &hsc->hsc_irid, 0, 235 ~0, 1, RF_SHAREABLE | RF_ACTIVE); 236 if (hsc->hsc_ires == NULL) { 237 device_printf(dev, "could not allocate interrupt\n"); 238 error = ENXIO; 239 goto fail_mif_res; 240 } 241 242 243 OF_getetheraddr(dev, sc->sc_arpcom.ac_enaddr); 244 245 burst = sbus_get_burstsz(dev); 246 /* Translate into plain numerical format */ 247 sc->sc_burst = (burst & SBUS_BURST_32) ? 32 : 248 (burst & SBUS_BURST_16) ? 16 : 0; 249 250 sc->sc_pci = 0; /* XXX: should all be done in bus_dma. */ 251 sc->sc_dev = dev; 252 253 if ((error = hme_config(sc)) != 0) { 254 device_printf(dev, "could not be configured\n"); 255 goto fail_ires; 256 } 257 258 259 if ((error = bus_setup_intr(dev, hsc->hsc_ires, INTR_TYPE_NET, hme_intr, 260 sc, &hsc->hsc_ih)) != 0) { 261 device_printf(dev, "couldn't establish interrupt\n"); 262 hme_detach(sc); 263 goto fail_ires; 264 } 265 return (0); 266 267fail_ires: 268 bus_release_resource(dev, SYS_RES_IRQ, hsc->hsc_irid, hsc->hsc_ires); 269fail_mif_res: 270 if (hsc->hsc_mif_res != NULL) { 271 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mif_rid, 272 hsc->hsc_mif_res); 273 } 274fail_mac_res: 275 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mac_rid, 276 hsc->hsc_mac_res); 277fail_erx_res: 278 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_erx_rid, 279 hsc->hsc_erx_res); 280fail_etx_res: 281 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_etx_rid, 282 hsc->hsc_etx_res); 283fail_seb_res: 284 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_seb_rid, 285 hsc->hsc_seb_res); 286 return (ENXIO); 287} 288 289static int 290hme_sbus_detach(device_t dev) 291{ 292 struct hme_sbus_softc *hsc = device_get_softc(dev); 293 struct hme_softc *sc = &hsc->hsc_hme; 294 295 hme_detach(sc); 296 297 bus_teardown_intr(dev, hsc->hsc_ires, hsc->hsc_ih); 298 if (hsc->hsc_mif_res != NULL) { 299 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mif_rid, 300 hsc->hsc_mif_res); 301 } 302 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mac_rid, 303 hsc->hsc_mac_res); 304 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_erx_rid, 305 hsc->hsc_erx_res); 306 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_etx_rid, 307 hsc->hsc_etx_res); 308 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_seb_rid, 309 hsc->hsc_seb_res); 310 return (0); 311} 312 313static int 314hme_sbus_suspend(device_t dev) 315{ 316 struct hme_sbus_softc *hsc = device_get_softc(dev); 317 struct hme_softc *sc = &hsc->hsc_hme; 318 319 hme_suspend(sc); 320 return (0); 321} 322 323static int 324hme_sbus_resume(device_t dev) 325{ 326 struct hme_sbus_softc *hsc = device_get_softc(dev); 327 struct hme_softc *sc = &hsc->hsc_hme; 328 329 hme_resume(sc); 330 return (0); 331}
| 55#include <machine/ofw_machdep.h> 56#include <machine/resource.h> 57 58#include <sys/rman.h> 59 60#include <dev/ofw/openfirm.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 char *name; 136 137 name = sbus_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; 154 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 sc->sc_sebo = sc->sc_etxo = sc->sc_erxo = sc->sc_maco = sc->sc_mifo = 0; 166 hsc->hsc_seb_rid = 0; 167 hsc->hsc_seb_res = bus_alloc_resource(dev, SYS_RES_MEMORY, 168 &hsc->hsc_seb_rid, 0, ~0, 1, RF_ACTIVE); 169 if (hsc->hsc_seb_res == NULL) { 170 device_printf(dev, "cannot map SEB registers\n"); 171 return (ENXIO); 172 } 173 sc->sc_sebt = rman_get_bustag(hsc->hsc_seb_res); 174 sc->sc_sebh = rman_get_bushandle(hsc->hsc_seb_res); 175 176 hsc->hsc_etx_rid = 1; 177 hsc->hsc_etx_res = bus_alloc_resource(dev, SYS_RES_MEMORY, 178 &hsc->hsc_etx_rid, 0, ~0, 1, RF_ACTIVE); 179 if (hsc->hsc_etx_res == NULL) { 180 device_printf(dev, "cannot map ETX registers\n"); 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(dev, SYS_RES_MEMORY, 188 &hsc->hsc_erx_rid, 0, ~0, 1, RF_ACTIVE); 189 if (hsc->hsc_erx_res == NULL) { 190 device_printf(dev, "cannot map ERX registers\n"); 191 goto fail_etx_res; 192 } 193 sc->sc_erxt = rman_get_bustag(hsc->hsc_erx_res); 194 sc->sc_erxh = rman_get_bushandle(hsc->hsc_erx_res); 195 196 hsc->hsc_mac_rid = 3; 197 hsc->hsc_mac_res = bus_alloc_resource(dev, SYS_RES_MEMORY, 198 &hsc->hsc_mac_rid, 0, ~0, 1, RF_ACTIVE); 199 if (hsc->hsc_mac_res == NULL) { 200 device_printf(dev, "cannot map MAC registers\n"); 201 goto fail_erx_res; 202 } 203 sc->sc_mact = rman_get_bustag(hsc->hsc_mac_res); 204 sc->sc_mach = rman_get_bushandle(hsc->hsc_mac_res); 205 206 /* 207 * At least on some HMEs, the MIF registers seem to be inside the MAC 208 * range, so map try to kluge around it. 209 */ 210 hsc->hsc_mif_rid = 4; 211 hsc->hsc_mif_res = bus_alloc_resource(dev, SYS_RES_MEMORY, 212 &hsc->hsc_mif_rid, 0, ~0, 1, RF_ACTIVE); 213 if (hsc->hsc_mif_res == NULL) { 214 if (bus_get_resource(dev, SYS_RES_MEMORY, hsc->hsc_mif_rid, 215 &start, &count) != 0) { 216 device_printf(dev, "cannot get MIF registers\n"); 217 goto fail_mac_res; 218 } 219 if (start < rman_get_start(hsc->hsc_mac_res) || 220 start + count - 1 > rman_get_end(hsc->hsc_mac_res)) { 221 device_printf(dev, "cannot move MIF registers to MAC " 222 "bank\n"); 223 goto fail_mac_res; 224 } 225 sc->sc_mift = sc->sc_mact; 226 sc->sc_mifh = sc->sc_mach; 227 sc->sc_mifo = sc->sc_maco + start - 228 rman_get_start(hsc->hsc_mac_res); 229 } else { 230 sc->sc_mift = rman_get_bustag(hsc->hsc_mif_res); 231 sc->sc_mifh = rman_get_bushandle(hsc->hsc_mif_res); 232 } 233 234 hsc->hsc_irid = 0; 235 hsc->hsc_ires = bus_alloc_resource(dev, SYS_RES_IRQ, &hsc->hsc_irid, 0, 236 ~0, 1, RF_SHAREABLE | RF_ACTIVE); 237 if (hsc->hsc_ires == NULL) { 238 device_printf(dev, "could not allocate interrupt\n"); 239 error = ENXIO; 240 goto fail_mif_res; 241 } 242 243 244 OF_getetheraddr(dev, sc->sc_arpcom.ac_enaddr); 245 246 burst = sbus_get_burstsz(dev); 247 /* Translate into plain numerical format */ 248 sc->sc_burst = (burst & SBUS_BURST_32) ? 32 : 249 (burst & SBUS_BURST_16) ? 16 : 0; 250 251 sc->sc_pci = 0; /* XXX: should all be done in bus_dma. */ 252 sc->sc_dev = dev; 253 254 if ((error = hme_config(sc)) != 0) { 255 device_printf(dev, "could not be configured\n"); 256 goto fail_ires; 257 } 258 259 260 if ((error = bus_setup_intr(dev, hsc->hsc_ires, INTR_TYPE_NET, hme_intr, 261 sc, &hsc->hsc_ih)) != 0) { 262 device_printf(dev, "couldn't establish interrupt\n"); 263 hme_detach(sc); 264 goto fail_ires; 265 } 266 return (0); 267 268fail_ires: 269 bus_release_resource(dev, SYS_RES_IRQ, hsc->hsc_irid, hsc->hsc_ires); 270fail_mif_res: 271 if (hsc->hsc_mif_res != NULL) { 272 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mif_rid, 273 hsc->hsc_mif_res); 274 } 275fail_mac_res: 276 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mac_rid, 277 hsc->hsc_mac_res); 278fail_erx_res: 279 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_erx_rid, 280 hsc->hsc_erx_res); 281fail_etx_res: 282 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_etx_rid, 283 hsc->hsc_etx_res); 284fail_seb_res: 285 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_seb_rid, 286 hsc->hsc_seb_res); 287 return (ENXIO); 288} 289 290static int 291hme_sbus_detach(device_t dev) 292{ 293 struct hme_sbus_softc *hsc = device_get_softc(dev); 294 struct hme_softc *sc = &hsc->hsc_hme; 295 296 hme_detach(sc); 297 298 bus_teardown_intr(dev, hsc->hsc_ires, hsc->hsc_ih); 299 if (hsc->hsc_mif_res != NULL) { 300 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mif_rid, 301 hsc->hsc_mif_res); 302 } 303 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mac_rid, 304 hsc->hsc_mac_res); 305 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_erx_rid, 306 hsc->hsc_erx_res); 307 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_etx_rid, 308 hsc->hsc_etx_res); 309 bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_seb_rid, 310 hsc->hsc_seb_res); 311 return (0); 312} 313 314static int 315hme_sbus_suspend(device_t dev) 316{ 317 struct hme_sbus_softc *hsc = device_get_softc(dev); 318 struct hme_softc *sc = &hsc->hsc_hme; 319 320 hme_suspend(sc); 321 return (0); 322} 323 324static int 325hme_sbus_resume(device_t dev) 326{ 327 struct hme_sbus_softc *hsc = device_get_softc(dev); 328 struct hme_softc *sc = &hsc->hsc_hme; 329 330 hme_resume(sc); 331 return (0); 332}
|