diff options
Diffstat (limited to 'sys/powerpc/powermac')
-rw-r--r-- | sys/powerpc/powermac/ata_macio.c | 5 | ||||
-rw-r--r-- | sys/powerpc/powermac/hrowpic.c | 4 | ||||
-rw-r--r-- | sys/powerpc/powermac/macio.c | 122 | ||||
-rw-r--r-- | sys/powerpc/powermac/maciovar.h | 31 | ||||
-rw-r--r-- | sys/powerpc/powermac/openpic_macio.c | 4 |
5 files changed, 79 insertions, 87 deletions
diff --git a/sys/powerpc/powermac/ata_macio.c b/sys/powerpc/powermac/ata_macio.c index 127defe..5fb2865 100644 --- a/sys/powerpc/powermac/ata_macio.c +++ b/sys/powerpc/powermac/ata_macio.c @@ -47,8 +47,7 @@ #include <sys/ata.h> #include <dev/ata/ata-all.h> -#include <dev/ofw/openfirm.h> -#include <powerpc/powermac/maciovar.h> +#include <dev/ofw/ofw_bus.h> /* * Offset to control registers from base @@ -99,7 +98,7 @@ ata_macio_setmode(struct ata_device *atadev, int mode) static int ata_macio_probe(device_t dev) { - char *type = macio_get_devtype(dev); + const char *type = ofw_bus_get_type(dev); struct ata_channel *ch; struct resource *mem; int rid, i; diff --git a/sys/powerpc/powermac/hrowpic.c b/sys/powerpc/powermac/hrowpic.c index 6b8caff..0c1fd4b 100644 --- a/sys/powerpc/powermac/hrowpic.c +++ b/sys/powerpc/powermac/hrowpic.c @@ -46,6 +46,7 @@ #include <sys/conf.h> #include <sys/kernel.h> +#include <dev/ofw/ofw_bus.h> #include <dev/ofw/openfirm.h> #include <machine/bus.h> @@ -61,7 +62,6 @@ #include <sys/rman.h> -#include <powerpc/powermac/maciovar.h> #include <powerpc/powermac/hrowpicvar.h> #include "pic_if.h" @@ -434,7 +434,7 @@ DRIVER_MODULE(hrowpicmacio, macio, hrowpic_macio_driver, static int hrowpic_macio_probe(device_t dev) { - char *type = macio_get_devtype(dev); + const char *type = ofw_bus_get_type(dev); /* * OpenPIC cells have a type of "open-pic", so this diff --git a/sys/powerpc/powermac/macio.c b/sys/powerpc/powermac/macio.c index 300cbe7..1bf007d 100644 --- a/sys/powerpc/powermac/macio.c +++ b/sys/powerpc/powermac/macio.c @@ -47,6 +47,7 @@ #include <machine/resource.h> +#include <dev/ofw/ofw_bus.h> #include <dev/ofw/openfirm.h> #include <powerpc/powermac/maciovar.h> @@ -70,8 +71,6 @@ static int macio_probe(device_t); static int macio_attach(device_t); static int macio_print_child(device_t dev, device_t child); static void macio_probe_nomatch(device_t, device_t); -static int macio_read_ivar(device_t, device_t, int, uintptr_t *); -static int macio_write_ivar(device_t, device_t, int, uintptr_t); static struct resource *macio_alloc_resource(device_t, device_t, int, int *, u_long, u_long, u_long, u_int); static int macio_activate_resource(device_t, device_t, int, int, @@ -81,6 +80,11 @@ static int macio_deactivate_resource(device_t, device_t, int, int, static int macio_release_resource(device_t, device_t, int, int, struct resource *); static struct resource_list *macio_get_resource_list (device_t, device_t); +static ofw_bus_get_compat_t macio_get_compat; +static ofw_bus_get_model_t macio_get_model; +static ofw_bus_get_name_t macio_get_name; +static ofw_bus_get_node_t macio_get_node; +static ofw_bus_get_type_t macio_get_type; /* * Bus interface definition @@ -97,8 +101,6 @@ static device_method_t macio_methods[] = { /* Bus interface */ DEVMETHOD(bus_print_child, macio_print_child), DEVMETHOD(bus_probe_nomatch, macio_probe_nomatch), - DEVMETHOD(bus_read_ivar, macio_read_ivar), - DEVMETHOD(bus_write_ivar, macio_write_ivar), DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), @@ -108,6 +110,13 @@ static device_method_t macio_methods[] = { DEVMETHOD(bus_deactivate_resource, macio_deactivate_resource), DEVMETHOD(bus_get_resource_list, macio_get_resource_list), + /* ofw_bus interface */ + DEVMETHOD(ofw_bus_get_compat, macio_get_compat), + DEVMETHOD(ofw_bus_get_model, macio_get_model), + DEVMETHOD(ofw_bus_get_name, macio_get_name), + DEVMETHOD(ofw_bus_get_node, macio_get_node), + DEVMETHOD(ofw_bus_get_type, macio_get_type), + { 0, 0 } }; @@ -206,9 +215,6 @@ macio_add_reg(phandle_t devnode, struct macio_devinfo *dinfo) if (nreg == -1) return; - dinfo->mdi_nregs = nreg; - dinfo->mdi_regs = reg; - for (i = 0; i < nreg; i++) { resource_list_add(&dinfo->mdi_resources, SYS_RES_MEMORY, i, reg[i].mr_base, reg[i].mr_base + reg[i].mr_size, @@ -250,7 +256,7 @@ macio_attach(device_t dev) phandle_t subchild; device_t cdev; u_int reg[3]; - char *name, *type; + char *name; int quirks; sc = device_get_softc(dev); @@ -281,12 +287,10 @@ macio_attach(device_t dev) */ for (child = OF_child(root); child != 0; child = OF_peer(child)) { OF_getprop_alloc(child, "name", 1, (void **)&name); - OF_getprop_alloc(child, "device_type", 1, (void **)&type); quirks = macio_get_quirks(name); if ((quirks & MACIO_QUIRK_IGNORE) != 0) { free(name, M_OFWPROP); - free(type, M_OFWPROP); continue; } @@ -297,7 +301,12 @@ macio_attach(device_t dev) resource_list_init(&dinfo->mdi_resources); dinfo->mdi_node = child; dinfo->mdi_name = name; - dinfo->mdi_device_type = type; + OF_getprop_alloc(child, "compatible", 1, + (void **)&dinfo->mdi_compat); + OF_getprop_alloc(child, "device_type", 1, + (void **)&dinfo->mdi_type); + OF_getprop_alloc(child, "model", 1, + (void **)&dinfo->mdi_model); dinfo->mdi_ninterrupts = 0; macio_add_intr(child, dinfo); macio_add_reg(child, dinfo); @@ -313,7 +322,6 @@ macio_attach(device_t dev) device_set_ivars(cdev, dinfo); } else { free(name, M_OFWPROP); - free(type, M_OFWPROP); } } @@ -347,13 +355,15 @@ macio_probe_nomatch(device_t dev, device_t child) { struct macio_devinfo *dinfo; struct resource_list *rl; + const char *type; if (bootverbose) { dinfo = device_get_ivars(child); rl = &dinfo->mdi_resources; - device_printf(dev, "<%s, %s>", macio_get_devtype(child), - macio_get_name(child)); + if ((type = ofw_bus_get_type(child)) == NULL) + type = "(unknown)"; + device_printf(dev, "<%s, %s>", type, ofw_bus_get_name(child)); resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#lx"); resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld"); printf(" (no driver attached)\n"); @@ -361,45 +371,6 @@ macio_probe_nomatch(device_t dev, device_t child) } -static int -macio_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) -{ - struct macio_devinfo *dinfo; - - if ((dinfo = device_get_ivars(child)) == 0) - return (ENOENT); - - switch (which) { - case MACIO_IVAR_NODE: - *result = dinfo->mdi_node; - break; - case MACIO_IVAR_NAME: - *result = (uintptr_t)dinfo->mdi_name; - break; - case MACIO_IVAR_DEVTYPE: - *result = (uintptr_t)dinfo->mdi_device_type; - break; - case MACIO_IVAR_NREGS: - *result = dinfo->mdi_nregs; - break; - case MACIO_IVAR_REGS: - *result = (uintptr_t)dinfo->mdi_regs; - break; - default: - return (ENOENT); - } - - return (0); -} - - -static int -macio_write_ivar(device_t dev, device_t child, int which, uintptr_t value) -{ - return (EINVAL); -} - - static struct resource * macio_alloc_resource(device_t bus, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags) @@ -572,3 +543,48 @@ macio_get_resource_list (device_t dev, device_t child) return (rl); } + +const char * +macio_get_compat(device_t bus, device_t dev) +{ + struct macio_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + return (dinfo->mdi_compat); +} + +const char * +macio_get_model(device_t bus, device_t dev) +{ + struct macio_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + return (dinfo->mdi_model); +} + +const char * +macio_get_name(device_t bus, device_t dev) +{ + struct macio_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + return (dinfo->mdi_name); +} + +static phandle_t +macio_get_node(device_t bus, device_t dev) +{ + struct macio_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + return (dinfo->mdi_node); +} + +const char * +macio_get_type(device_t bus, device_t dev) +{ + struct macio_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + return (dinfo->mdi_type); +} diff --git a/sys/powerpc/powermac/maciovar.h b/sys/powerpc/powermac/maciovar.h index d28f946..2de15e2 100644 --- a/sys/powerpc/powermac/maciovar.h +++ b/sys/powerpc/powermac/maciovar.h @@ -31,29 +31,6 @@ #define _MACIO_MACIOVAR_H_ /* - * Accessors for macio devices - */ - -enum macio_ivars { - MACIO_IVAR_NODE, - MACIO_IVAR_NAME, - MACIO_IVAR_DEVTYPE, - MACIO_IVAR_NREGS, - MACIO_IVAR_REGS, -}; - -#define MACIO_ACCESSOR(var, ivar, type) \ - __BUS_ACCESSOR(macio, var, MACIO, ivar, type) - -MACIO_ACCESSOR(node, NODE, phandle_t) -MACIO_ACCESSOR(name, NAME, char *) -MACIO_ACCESSOR(devtype, DEVTYPE, char *) -MACIO_ACCESSOR(nregs, NREGS, u_int) -MACIO_ACCESSOR(regs, REGS, struct macio_reg *) - -#undef MACIO_ACCESSOR - -/* * The addr space size * XXX it would be better if this could be determined by querying the * PCI device, but there isn't an access method for this @@ -72,14 +49,14 @@ struct macio_reg { * Per macio device structure. */ struct macio_devinfo { + char *mdi_compat; + char *mdi_model; + char *mdi_name; phandle_t mdi_node; - char *mdi_name; - char *mdi_device_type; + char *mdi_type; int mdi_interrupts[5]; int mdi_ninterrupts; int mdi_base; - int mdi_nregs; - struct macio_reg *mdi_regs; struct resource_list mdi_resources; }; diff --git a/sys/powerpc/powermac/openpic_macio.c b/sys/powerpc/powermac/openpic_macio.c index 0f8b0e2..fac08d8 100644 --- a/sys/powerpc/powermac/openpic_macio.c +++ b/sys/powerpc/powermac/openpic_macio.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include <sys/conf.h> #include <sys/kernel.h> +#include <dev/ofw/ofw_bus.h> #include <dev/ofw/openfirm.h> #include <machine/bus.h> @@ -61,7 +62,6 @@ __FBSDID("$FreeBSD$"); #include <sys/rman.h> #include <machine/openpicvar.h> -#include <powerpc/powermac/maciovar.h> #include "pic_if.h" @@ -186,7 +186,7 @@ DRIVER_MODULE(openpicmacio, macio, openpic_macio_driver, static int openpic_macio_probe(device_t dev) { - char *type = macio_get_devtype(dev); + const char *type = ofw_bus_get_type(dev); if (strcmp(type, "open-pic") != 0) return (ENXIO); |