1/*-
2 * Copyright (c) 1998 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
--- 84 unchanged lines hidden (view full) ---
93 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
94 * SUCH DAMAGE.
95 *
96 * from: @(#)sbus.c 8.1 (Berkeley) 6/11/93
97 * from: NetBSD: sbus.c,v 1.46 2001/10/07 20:30:41 eeh Exp
98 */
99
100#include <sys/cdefs.h>
101__FBSDID("$FreeBSD: head/sys/sparc64/sbus/sbus.c 146391 2005-05-19 14:47:31Z marius $");
102
103/*
104 * SBus support.
105 */
106
107#include <sys/param.h>
108#include <sys/systm.h>
109#include <sys/bus.h>
110#include <sys/kernel.h>
111#include <sys/malloc.h>
112#include <sys/module.h>
113#include <sys/pcpu.h>
114#include <sys/reboot.h>
115
116#include <dev/ofw/ofw_bus.h>
117#include <dev/ofw/openfirm.h>
118
119#include <machine/bus.h>
120#include <machine/bus_private.h>
121#include <machine/iommureg.h>
122#include <machine/bus_common.h>
123#include <machine/intr_machdep.h>
124#include <machine/nexusvar.h>
--- 6 unchanged lines hidden (view full) ---
131
132#include <sparc64/sbus/ofw_sbus.h>
133#include <sparc64/sbus/sbusreg.h>
134#include <sparc64/sbus/sbusvar.h>
135
136struct sbus_devinfo {
137 int sdi_burstsz;
138 int sdi_clockfreq;
139 char *sdi_compat; /* PROM compatible */
140 char *sdi_model; /* PROM model */
141 char *sdi_name; /* PROM name */
142 phandle_t sdi_node; /* PROM node */
143 int sdi_slot;
144 char *sdi_type; /* PROM device_type */
145
146 struct resource_list sdi_rl;
147};
148
149/* Range descriptor, allocated for each sc_range. */
150struct sbus_rd {
151 bus_addr_t rd_poffset;
152 bus_addr_t rd_pend;
153 int rd_slot;
--- 47 unchanged lines hidden (view full) ---
201static bus_read_ivar_t sbus_read_ivar;
202static bus_get_resource_list_t sbus_get_resource_list;
203static bus_setup_intr_t sbus_setup_intr;
204static bus_teardown_intr_t sbus_teardown_intr;
205static bus_alloc_resource_t sbus_alloc_resource;
206static bus_release_resource_t sbus_release_resource;
207static bus_activate_resource_t sbus_activate_resource;
208static bus_deactivate_resource_t sbus_deactivate_resource;
209static ofw_bus_get_compat_t sbus_get_compat;
210static ofw_bus_get_model_t sbus_get_model;
211static ofw_bus_get_name_t sbus_get_name;
212static ofw_bus_get_node_t sbus_get_node;
213static ofw_bus_get_type_t sbus_get_type;
214
215static int sbus_inlist(const char *, const char **);
216static struct sbus_devinfo * sbus_setup_dinfo(struct sbus_softc *sc,
217 phandle_t node, char *name);
218static void sbus_destroy_dinfo(struct sbus_devinfo *dinfo);
219static void sbus_intr_stub(void *);
220static bus_space_tag_t sbus_alloc_bustag(struct sbus_softc *);
221static void sbus_overtemp(void *);
222static void sbus_pwrfail(void *);
223
224static device_method_t sbus_methods[] = {
225 /* Device interface */
226 DEVMETHOD(device_probe, sbus_probe),
227 DEVMETHOD(device_attach, sbus_attach),
228
229 /* Bus interface */
230 DEVMETHOD(bus_print_child, sbus_print_child),
--- 4 unchanged lines hidden (view full) ---
235 DEVMETHOD(bus_alloc_resource, sbus_alloc_resource),
236 DEVMETHOD(bus_activate_resource, sbus_activate_resource),
237 DEVMETHOD(bus_deactivate_resource, sbus_deactivate_resource),
238 DEVMETHOD(bus_release_resource, sbus_release_resource),
239 DEVMETHOD(bus_get_resource_list, sbus_get_resource_list),
240 DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
241
242 /* ofw_bus interface */
243 DEVMETHOD(ofw_bus_get_compat, sbus_get_compat),
244 DEVMETHOD(ofw_bus_get_model, sbus_get_model),
245 DEVMETHOD(ofw_bus_get_name, sbus_get_name),
246 DEVMETHOD(ofw_bus_get_node, sbus_get_node),
247 DEVMETHOD(ofw_bus_get_type, sbus_get_type),
248
249 { 0, 0 }
250};
251
252static driver_t sbus_driver = {
253 "sbus",
254 sbus_methods,
255 sizeof(struct sbus_softc),
--- 44 unchanged lines hidden (view full) ---
300{
301 struct sbus_softc *sc;
302 struct sbus_devinfo *sdi;
303 struct sbus_ranges *range;
304 struct resource *res;
305 device_t cdev;
306 bus_addr_t phys;
307 bus_size_t size;
308 char *name, *cname;
309 phandle_t child, node;
310 u_int64_t mr;
311 int intr, clock, rid, vec, i;
312
313 sc = device_get_softc(dev);
314 node = nexus_get_node(dev);
315
316 if ((sc->sc_nreg = OF_getprop_alloc(node, "reg", sizeof(*sc->sc_reg),
--- 134 unchanged lines hidden (view full) ---
451 /* Initialize the counter-timer. */
452 sparc64_counter_init(sc->sc_bustag, sc->sc_bushandle, SBR_TC0);
453
454 /*
455 * Loop through ROM children, fixing any relative addresses
456 * and then configuring each device.
457 */
458 for (child = OF_child(node); child != 0; child = OF_peer(child)) {
459 if ((OF_getprop_alloc(child, "name", 1, (void **)&cname)) == -1)
460 continue;
461
462 if ((sdi = sbus_setup_dinfo(sc, child, cname)) == NULL) {
463 device_printf(dev, "<%s>: incomplete\n", cname);
464 free(cname, M_OFWPROP);
465 continue;
466 }
467 /*
468 * For devices where there are variants that are actually
469 * split into two SBus devices (as opposed to the first
470 * half of the device being a SBus device and the second
471 * half hanging off of the first one) like 'auxio' and
472 * 'SUNW,fdtwo' or 'dma' and 'esp' probe the SBus device
473 * which is a prerequisite to the driver attaching to the
474 * second one with a lower order. Saves us from dealing
475 * with different probe orders in the respective device
476 * drivers which generally is more hackish.
477 */
478 cdev = device_add_child_ordered(dev, (OF_child(child) == 0 &&
479 sbus_inlist(cname, sbus_order_first)) ? SBUS_ORDER_FIRST :
480 SBUS_ORDER_NORMAL, NULL, -1);
481 if (cdev == NULL)
482 panic("%s: device_add_child_ordered failed", __func__);
483 device_set_ivars(cdev, sdi);
484 }
485 return (bus_generic_attach(dev));
486}
487
488static struct sbus_devinfo *
489sbus_setup_dinfo(struct sbus_softc *sc, phandle_t node, char *name)
490{
491 struct sbus_devinfo *sdi;
492 struct sbus_regs *reg;
493 u_int32_t base, iv, *intr;
494 int i, nreg, nintr, slot, rslot;
495
496 sdi = malloc(sizeof(*sdi), M_DEVBUF, M_ZERO | M_WAITOK);
497 if (sdi == NULL)
498 return (NULL);
499 resource_list_init(&sdi->sdi_rl);
500 sdi->sdi_name = name;
501 sdi->sdi_node = node;
502 OF_getprop_alloc(node, "compatible", 1, (void **)&sdi->sdi_compat);
503 OF_getprop_alloc(node, "device_type", 1, (void **)&sdi->sdi_type);
504 OF_getprop_alloc(node, "model", 1, (void **)&sdi->sdi_model);
505 slot = -1;
506 nreg = OF_getprop_alloc(node, "reg", sizeof(*reg), (void **)®);
507 if (nreg == -1) {
508 if (sdi->sdi_type == NULL ||
509 strcmp(sdi->sdi_type, "hierarchical") != 0) {
510 sbus_destroy_dinfo(sdi);
511 return (NULL);
512 }
513 } else {
514 for (i = 0; i < nreg; i++) {
515 base = reg[i].sbr_offset;
516 if (SBUS_ABS(base)) {
517 rslot = SBUS_ABS_TO_SLOT(base);
518 base = SBUS_ABS_TO_OFFSET(base);
519 } else
520 rslot = reg[i].sbr_slot;
521 if (slot != -1 && slot != rslot)
522 panic("%s: multiple slots", __func__);
523 slot = rslot;
524
525 resource_list_add(&sdi->sdi_rl, SYS_RES_MEMORY, i,
526 base, base + reg[i].sbr_size, reg[i].sbr_size);
527 }
528 free(reg, M_OFWPROP);
529 }
530 sdi->sdi_slot = slot;
--- 24 unchanged lines hidden (view full) ---
555 sdi->sdi_burstsz = sc->sc_burst;
556 else
557 sdi->sdi_burstsz &= sc->sc_burst;
558 if (OF_getprop(node, "clock-frequency", &sdi->sdi_clockfreq,
559 sizeof(sdi->sdi_clockfreq)) == -1)
560 sdi->sdi_clockfreq = sc->sc_clockfreq;
561
562 return (sdi);
563}
564
565/* Free everything except sdi_name, which is handled separately. */
566static void
567sbus_destroy_dinfo(struct sbus_devinfo *dinfo)
568{
569
570 resource_list_free(&dinfo->sdi_rl);
571 if (dinfo->sdi_compat != NULL)
572 free(dinfo->sdi_compat, M_OFWPROP);
573 if (dinfo->sdi_model != NULL)
574 free(dinfo->sdi_model, M_OFWPROP);
575 if (dinfo->sdi_type != NULL)
576 free(dinfo->sdi_type, M_OFWPROP);
577 free(dinfo, M_DEVBUF);
578}
579
580static int
581sbus_print_child(device_t dev, device_t child)
582{
583 struct sbus_devinfo *dinfo;
584 struct resource_list *rl;
585 int rv;
586
587 dinfo = device_get_ivars(child);
588 rl = &dinfo->sdi_rl;
589 rv = bus_print_child_header(dev, child);
590 rv += resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#lx");
591 rv += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
592 rv += bus_print_child_footer(dev, child);
593 return (rv);
594}
595
596static void
597sbus_probe_nomatch(device_t dev, device_t child)
598{
599 struct sbus_devinfo *dinfo;
600 struct resource_list *rl;
601
602 dinfo = device_get_ivars(child);
603 rl = &dinfo->sdi_rl;
604 device_printf(dev, "<%s>", dinfo->sdi_name);
605 resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#lx");
606 resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
607 printf(" type %s (no driver attached)\n",
608 dinfo->sdi_type != NULL ? dinfo->sdi_type : "unknown");
609}
610
611static int
612sbus_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
613{
614 struct sbus_softc *sc;
615 struct sbus_devinfo *dinfo;
616
--- 110 unchanged lines hidden (view full) ---
727 * Enable the interrupt and program the target module now we have the
728 * handler installed.
729 */
730 SYSIO_WRITE8(sc, intrmapptr, INTMAP_ENABLE(intrmap, PCPU_GET(mid)));
731 return (error);
732}
733
734static int
735sbus_teardown_intr(device_t dev, device_t child,
736 struct resource *vec, void *cookie)
737{
738 struct sbus_clr *scl;
739 int error;
740
741 scl = (struct sbus_clr *)cookie;
742 error = BUS_TEARDOWN_INTR(device_get_parent(dev), child, vec,
743 scl->scl_cookie);
744 /*
--- 135 unchanged lines hidden (view full) ---
880 if (rle == NULL)
881 panic("%s: cannot find resource", __func__);
882 if (rle->res == NULL)
883 panic("%s: resource entry is not busy", __func__);
884 rle->res = NULL;
885 return (0);
886}
887
888/*
889 * Handle an overtemp situation.
890 *
891 * SPARCs have temperature sensors which generate interrupts
892 * if the machine's temperature exceeds a certain threshold.
893 * This handles the interrupt and powers off the machine.
894 * The same needs to be done to PCI controller drivers.
895 */
--- 25 unchanged lines hidden (view full) ---
921 panic("%s: out of memory", __func__);
922
923 sbt->bst_cookie = sc;
924 sbt->bst_parent = sc->sc_bustag;
925 sbt->bst_type = SBUS_BUS_SPACE;
926 return (sbt);
927}
928
929static const char *
930sbus_get_compat(device_t bus, device_t dev)
931{
932 struct sbus_devinfo *dinfo;
933
934 dinfo = device_get_ivars(dev);
935 return (dinfo->sdi_compat);
936}
937
938static const char *
939sbus_get_model(device_t bus, device_t dev)
940{
941 struct sbus_devinfo *dinfo;
942
943 dinfo = device_get_ivars(dev);
944 return (dinfo->sdi_model);
945}
946
947static const char *
948sbus_get_name(device_t bus, device_t dev)
949{
950 struct sbus_devinfo *dinfo;
951
952 dinfo = device_get_ivars(dev);
953 return (dinfo->sdi_name);
954}
955
956static phandle_t
957sbus_get_node(device_t bus, device_t dev)
958{
959 struct sbus_devinfo *dinfo;
960
961 dinfo = device_get_ivars(dev);
962 return (dinfo->sdi_node);
963}
964
965static const char *
966sbus_get_type(device_t bus, device_t dev)
967{
968 struct sbus_devinfo *dinfo;
969
970 dinfo = device_get_ivars(dev);
971 return (dinfo->sdi_type);
972}
2 * Copyright (c) 1998 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
--- 84 unchanged lines hidden (view full) ---
93 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
94 * SUCH DAMAGE.
95 *
96 * from: @(#)sbus.c 8.1 (Berkeley) 6/11/93
97 * from: NetBSD: sbus.c,v 1.46 2001/10/07 20:30:41 eeh Exp
98 */
99
100#include <sys/cdefs.h>
101__FBSDID("$FreeBSD: head/sys/sparc64/sbus/sbus.c 146391 2005-05-19 14:47:31Z marius $");
102
103/*
104 * SBus support.
105 */
106
107#include <sys/param.h>
108#include <sys/systm.h>
109#include <sys/bus.h>
110#include <sys/kernel.h>
111#include <sys/malloc.h>
112#include <sys/module.h>
113#include <sys/pcpu.h>
114#include <sys/reboot.h>
115
116#include <dev/ofw/ofw_bus.h>
117#include <dev/ofw/openfirm.h>
118
119#include <machine/bus.h>
120#include <machine/bus_private.h>
121#include <machine/iommureg.h>
122#include <machine/bus_common.h>
123#include <machine/intr_machdep.h>
124#include <machine/nexusvar.h>
--- 6 unchanged lines hidden (view full) ---
131
132#include <sparc64/sbus/ofw_sbus.h>
133#include <sparc64/sbus/sbusreg.h>
134#include <sparc64/sbus/sbusvar.h>
135
136struct sbus_devinfo {
137 int sdi_burstsz;
138 int sdi_clockfreq;
139 char *sdi_compat; /* PROM compatible */
140 char *sdi_model; /* PROM model */
141 char *sdi_name; /* PROM name */
142 phandle_t sdi_node; /* PROM node */
143 int sdi_slot;
144 char *sdi_type; /* PROM device_type */
145
146 struct resource_list sdi_rl;
147};
148
149/* Range descriptor, allocated for each sc_range. */
150struct sbus_rd {
151 bus_addr_t rd_poffset;
152 bus_addr_t rd_pend;
153 int rd_slot;
--- 47 unchanged lines hidden (view full) ---
201static bus_read_ivar_t sbus_read_ivar;
202static bus_get_resource_list_t sbus_get_resource_list;
203static bus_setup_intr_t sbus_setup_intr;
204static bus_teardown_intr_t sbus_teardown_intr;
205static bus_alloc_resource_t sbus_alloc_resource;
206static bus_release_resource_t sbus_release_resource;
207static bus_activate_resource_t sbus_activate_resource;
208static bus_deactivate_resource_t sbus_deactivate_resource;
209static ofw_bus_get_compat_t sbus_get_compat;
210static ofw_bus_get_model_t sbus_get_model;
211static ofw_bus_get_name_t sbus_get_name;
212static ofw_bus_get_node_t sbus_get_node;
213static ofw_bus_get_type_t sbus_get_type;
214
215static int sbus_inlist(const char *, const char **);
216static struct sbus_devinfo * sbus_setup_dinfo(struct sbus_softc *sc,
217 phandle_t node, char *name);
218static void sbus_destroy_dinfo(struct sbus_devinfo *dinfo);
219static void sbus_intr_stub(void *);
220static bus_space_tag_t sbus_alloc_bustag(struct sbus_softc *);
221static void sbus_overtemp(void *);
222static void sbus_pwrfail(void *);
223
224static device_method_t sbus_methods[] = {
225 /* Device interface */
226 DEVMETHOD(device_probe, sbus_probe),
227 DEVMETHOD(device_attach, sbus_attach),
228
229 /* Bus interface */
230 DEVMETHOD(bus_print_child, sbus_print_child),
--- 4 unchanged lines hidden (view full) ---
235 DEVMETHOD(bus_alloc_resource, sbus_alloc_resource),
236 DEVMETHOD(bus_activate_resource, sbus_activate_resource),
237 DEVMETHOD(bus_deactivate_resource, sbus_deactivate_resource),
238 DEVMETHOD(bus_release_resource, sbus_release_resource),
239 DEVMETHOD(bus_get_resource_list, sbus_get_resource_list),
240 DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
241
242 /* ofw_bus interface */
243 DEVMETHOD(ofw_bus_get_compat, sbus_get_compat),
244 DEVMETHOD(ofw_bus_get_model, sbus_get_model),
245 DEVMETHOD(ofw_bus_get_name, sbus_get_name),
246 DEVMETHOD(ofw_bus_get_node, sbus_get_node),
247 DEVMETHOD(ofw_bus_get_type, sbus_get_type),
248
249 { 0, 0 }
250};
251
252static driver_t sbus_driver = {
253 "sbus",
254 sbus_methods,
255 sizeof(struct sbus_softc),
--- 44 unchanged lines hidden (view full) ---
300{
301 struct sbus_softc *sc;
302 struct sbus_devinfo *sdi;
303 struct sbus_ranges *range;
304 struct resource *res;
305 device_t cdev;
306 bus_addr_t phys;
307 bus_size_t size;
308 char *name, *cname;
309 phandle_t child, node;
310 u_int64_t mr;
311 int intr, clock, rid, vec, i;
312
313 sc = device_get_softc(dev);
314 node = nexus_get_node(dev);
315
316 if ((sc->sc_nreg = OF_getprop_alloc(node, "reg", sizeof(*sc->sc_reg),
--- 134 unchanged lines hidden (view full) ---
451 /* Initialize the counter-timer. */
452 sparc64_counter_init(sc->sc_bustag, sc->sc_bushandle, SBR_TC0);
453
454 /*
455 * Loop through ROM children, fixing any relative addresses
456 * and then configuring each device.
457 */
458 for (child = OF_child(node); child != 0; child = OF_peer(child)) {
459 if ((OF_getprop_alloc(child, "name", 1, (void **)&cname)) == -1)
460 continue;
461
462 if ((sdi = sbus_setup_dinfo(sc, child, cname)) == NULL) {
463 device_printf(dev, "<%s>: incomplete\n", cname);
464 free(cname, M_OFWPROP);
465 continue;
466 }
467 /*
468 * For devices where there are variants that are actually
469 * split into two SBus devices (as opposed to the first
470 * half of the device being a SBus device and the second
471 * half hanging off of the first one) like 'auxio' and
472 * 'SUNW,fdtwo' or 'dma' and 'esp' probe the SBus device
473 * which is a prerequisite to the driver attaching to the
474 * second one with a lower order. Saves us from dealing
475 * with different probe orders in the respective device
476 * drivers which generally is more hackish.
477 */
478 cdev = device_add_child_ordered(dev, (OF_child(child) == 0 &&
479 sbus_inlist(cname, sbus_order_first)) ? SBUS_ORDER_FIRST :
480 SBUS_ORDER_NORMAL, NULL, -1);
481 if (cdev == NULL)
482 panic("%s: device_add_child_ordered failed", __func__);
483 device_set_ivars(cdev, sdi);
484 }
485 return (bus_generic_attach(dev));
486}
487
488static struct sbus_devinfo *
489sbus_setup_dinfo(struct sbus_softc *sc, phandle_t node, char *name)
490{
491 struct sbus_devinfo *sdi;
492 struct sbus_regs *reg;
493 u_int32_t base, iv, *intr;
494 int i, nreg, nintr, slot, rslot;
495
496 sdi = malloc(sizeof(*sdi), M_DEVBUF, M_ZERO | M_WAITOK);
497 if (sdi == NULL)
498 return (NULL);
499 resource_list_init(&sdi->sdi_rl);
500 sdi->sdi_name = name;
501 sdi->sdi_node = node;
502 OF_getprop_alloc(node, "compatible", 1, (void **)&sdi->sdi_compat);
503 OF_getprop_alloc(node, "device_type", 1, (void **)&sdi->sdi_type);
504 OF_getprop_alloc(node, "model", 1, (void **)&sdi->sdi_model);
505 slot = -1;
506 nreg = OF_getprop_alloc(node, "reg", sizeof(*reg), (void **)®);
507 if (nreg == -1) {
508 if (sdi->sdi_type == NULL ||
509 strcmp(sdi->sdi_type, "hierarchical") != 0) {
510 sbus_destroy_dinfo(sdi);
511 return (NULL);
512 }
513 } else {
514 for (i = 0; i < nreg; i++) {
515 base = reg[i].sbr_offset;
516 if (SBUS_ABS(base)) {
517 rslot = SBUS_ABS_TO_SLOT(base);
518 base = SBUS_ABS_TO_OFFSET(base);
519 } else
520 rslot = reg[i].sbr_slot;
521 if (slot != -1 && slot != rslot)
522 panic("%s: multiple slots", __func__);
523 slot = rslot;
524
525 resource_list_add(&sdi->sdi_rl, SYS_RES_MEMORY, i,
526 base, base + reg[i].sbr_size, reg[i].sbr_size);
527 }
528 free(reg, M_OFWPROP);
529 }
530 sdi->sdi_slot = slot;
--- 24 unchanged lines hidden (view full) ---
555 sdi->sdi_burstsz = sc->sc_burst;
556 else
557 sdi->sdi_burstsz &= sc->sc_burst;
558 if (OF_getprop(node, "clock-frequency", &sdi->sdi_clockfreq,
559 sizeof(sdi->sdi_clockfreq)) == -1)
560 sdi->sdi_clockfreq = sc->sc_clockfreq;
561
562 return (sdi);
563}
564
565/* Free everything except sdi_name, which is handled separately. */
566static void
567sbus_destroy_dinfo(struct sbus_devinfo *dinfo)
568{
569
570 resource_list_free(&dinfo->sdi_rl);
571 if (dinfo->sdi_compat != NULL)
572 free(dinfo->sdi_compat, M_OFWPROP);
573 if (dinfo->sdi_model != NULL)
574 free(dinfo->sdi_model, M_OFWPROP);
575 if (dinfo->sdi_type != NULL)
576 free(dinfo->sdi_type, M_OFWPROP);
577 free(dinfo, M_DEVBUF);
578}
579
580static int
581sbus_print_child(device_t dev, device_t child)
582{
583 struct sbus_devinfo *dinfo;
584 struct resource_list *rl;
585 int rv;
586
587 dinfo = device_get_ivars(child);
588 rl = &dinfo->sdi_rl;
589 rv = bus_print_child_header(dev, child);
590 rv += resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#lx");
591 rv += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
592 rv += bus_print_child_footer(dev, child);
593 return (rv);
594}
595
596static void
597sbus_probe_nomatch(device_t dev, device_t child)
598{
599 struct sbus_devinfo *dinfo;
600 struct resource_list *rl;
601
602 dinfo = device_get_ivars(child);
603 rl = &dinfo->sdi_rl;
604 device_printf(dev, "<%s>", dinfo->sdi_name);
605 resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#lx");
606 resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
607 printf(" type %s (no driver attached)\n",
608 dinfo->sdi_type != NULL ? dinfo->sdi_type : "unknown");
609}
610
611static int
612sbus_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
613{
614 struct sbus_softc *sc;
615 struct sbus_devinfo *dinfo;
616
--- 110 unchanged lines hidden (view full) ---
727 * Enable the interrupt and program the target module now we have the
728 * handler installed.
729 */
730 SYSIO_WRITE8(sc, intrmapptr, INTMAP_ENABLE(intrmap, PCPU_GET(mid)));
731 return (error);
732}
733
734static int
735sbus_teardown_intr(device_t dev, device_t child,
736 struct resource *vec, void *cookie)
737{
738 struct sbus_clr *scl;
739 int error;
740
741 scl = (struct sbus_clr *)cookie;
742 error = BUS_TEARDOWN_INTR(device_get_parent(dev), child, vec,
743 scl->scl_cookie);
744 /*
--- 135 unchanged lines hidden (view full) ---
880 if (rle == NULL)
881 panic("%s: cannot find resource", __func__);
882 if (rle->res == NULL)
883 panic("%s: resource entry is not busy", __func__);
884 rle->res = NULL;
885 return (0);
886}
887
888/*
889 * Handle an overtemp situation.
890 *
891 * SPARCs have temperature sensors which generate interrupts
892 * if the machine's temperature exceeds a certain threshold.
893 * This handles the interrupt and powers off the machine.
894 * The same needs to be done to PCI controller drivers.
895 */
--- 25 unchanged lines hidden (view full) ---
921 panic("%s: out of memory", __func__);
922
923 sbt->bst_cookie = sc;
924 sbt->bst_parent = sc->sc_bustag;
925 sbt->bst_type = SBUS_BUS_SPACE;
926 return (sbt);
927}
928
929static const char *
930sbus_get_compat(device_t bus, device_t dev)
931{
932 struct sbus_devinfo *dinfo;
933
934 dinfo = device_get_ivars(dev);
935 return (dinfo->sdi_compat);
936}
937
938static const char *
939sbus_get_model(device_t bus, device_t dev)
940{
941 struct sbus_devinfo *dinfo;
942
943 dinfo = device_get_ivars(dev);
944 return (dinfo->sdi_model);
945}
946
947static const char *
948sbus_get_name(device_t bus, device_t dev)
949{
950 struct sbus_devinfo *dinfo;
951
952 dinfo = device_get_ivars(dev);
953 return (dinfo->sdi_name);
954}
955
956static phandle_t
957sbus_get_node(device_t bus, device_t dev)
958{
959 struct sbus_devinfo *dinfo;
960
961 dinfo = device_get_ivars(dev);
962 return (dinfo->sdi_node);
963}
964
965static const char *
966sbus_get_type(device_t bus, device_t dev)
967{
968 struct sbus_devinfo *dinfo;
969
970 dinfo = device_get_ivars(dev);
971 return (dinfo->sdi_type);
972}