Changeset View
Changeset View
Standalone View
Standalone View
sys/mips/mips/nexus.c
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | |||||
#undef NEXUS_DEBUG | #undef NEXUS_DEBUG | ||||
#ifdef NEXUS_DEBUG | #ifdef NEXUS_DEBUG | ||||
#define dprintf printf | #define dprintf printf | ||||
#else | #else | ||||
#define dprintf(x, arg...) | #define dprintf(x, arg...) | ||||
#endif /* NEXUS_DEBUG */ | #endif /* NEXUS_DEBUG */ | ||||
#define NUM_MIPS_IRQS 6 | #ifdef INTRNG | ||||
#define NUM_MIPS_IRQS NIRQ /* Any INTRNG-mapped IRQ */ | |||||
#else | |||||
#define NUM_MIPS_IRQS 6 /* HW IRQs only */ | |||||
#endif | |||||
static MALLOC_DEFINE(M_NEXUSDEV, "nexusdev", "Nexus device"); | static MALLOC_DEFINE(M_NEXUSDEV, "nexusdev", "Nexus device"); | ||||
struct nexus_device { | struct nexus_device { | ||||
struct resource_list nx_resources; | struct resource_list nx_resources; | ||||
}; | }; | ||||
#define DEVTONX(dev) ((struct nexus_device *)device_get_ivars(dev)) | #define DEVTONX(dev) ((struct nexus_device *)device_get_ivars(dev)) | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | nexus_probe(device_t dev) | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
nexus_attach(device_t dev) | nexus_attach(device_t dev) | ||||
{ | { | ||||
#if defined(INTRNG) && !defined(FDT) | |||||
int error; | |||||
if ((error = mips_pic_map_fixed_intrs())) | |||||
return (error); | |||||
#endif | |||||
bus_generic_probe(dev); | bus_generic_probe(dev); | ||||
bus_enumerate_hinted_children(dev); | bus_enumerate_hinted_children(dev); | ||||
bus_generic_attach(dev); | bus_generic_attach(dev); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, | ||||
passthrough = (device_get_parent(child) != bus); | passthrough = (device_get_parent(child) != bus); | ||||
rle = NULL; | rle = NULL; | ||||
/* | /* | ||||
* If this is an allocation of the "default" range for a given RID, | * If this is an allocation of the "default" range for a given RID, | ||||
* and we know what the resources for this device are (ie. they aren't | * and we know what the resources for this device are (ie. they aren't | ||||
* maintained by a child bus), then work out the start/end values. | * maintained by a child bus), then work out the start/end values. | ||||
*/ | */ | ||||
if (isdefault) { | if (!passthrough && isdefault) { | ||||
rle = resource_list_find(&ndev->nx_resources, type, *rid); | rle = resource_list_find(&ndev->nx_resources, type, *rid); | ||||
if (rle == NULL) | if (rle == NULL) | ||||
return (NULL); | return (NULL); | ||||
if (rle->res != NULL) { | if (rle->res != NULL) { | ||||
panic("%s: resource entry is busy", __func__); | panic("%s: resource entry is busy", __func__); | ||||
} | } | ||||
start = rle->start; | start = rle->start; | ||||
end = rle->end; | end = rle->end; | ||||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) { | ||||
if (err != 0) { | if (err != 0) { | ||||
rman_deactivate_resource(r); | rman_deactivate_resource(r); | ||||
return (err); | return (err); | ||||
} | } | ||||
rman_set_virtual(r, vaddr); | rman_set_virtual(r, vaddr); | ||||
rman_set_bushandle(r, (bus_space_handle_t)(uintptr_t)vaddr); | rman_set_bushandle(r, (bus_space_handle_t)(uintptr_t)vaddr); | ||||
} else if (type == SYS_RES_IRQ) { | } else if (type == SYS_RES_IRQ) { | ||||
#ifdef INTRNG | #ifdef INTRNG | ||||
#ifdef FDT | err = mips_pic_activate_intr(child, r); | ||||
err = intr_activate_irq(child, r); | |||||
if (err != 0) { | if (err != 0) { | ||||
rman_deactivate_resource(r); | rman_deactivate_resource(r); | ||||
return (err); | return (err); | ||||
} | } | ||||
#else | |||||
/* | |||||
* INTRNG without FDT needs to have the interrupt properly | |||||
* mapped first. cpu_create_intr_map() will do that and | |||||
* call intr_activate_irq() at the end. | |||||
*/ | |||||
cpu_create_intr_map(rman_get_start(r)); | |||||
#endif | #endif | ||||
#endif | |||||
} | } | ||||
return (rman_activate_resource(r)); | return (rman_activate_resource(r)); | ||||
} | } | ||||
static int | static int | ||||
nexus_deactivate_resource(device_t bus, device_t child, int type, int rid, | nexus_deactivate_resource(device_t bus, device_t child, int type, int rid, | ||||
struct resource *r) | struct resource *r) | ||||
{ | { | ||||
bus_space_handle_t vaddr; | bus_space_handle_t vaddr; | ||||
bus_size_t psize; | bus_size_t psize; | ||||
vaddr = rman_get_bushandle(r); | vaddr = rman_get_bushandle(r); | ||||
if (type == SYS_RES_MEMORY && vaddr != 0) { | if (type == SYS_RES_MEMORY && vaddr != 0) { | ||||
psize = (bus_size_t)rman_get_size(r); | psize = (bus_size_t)rman_get_size(r); | ||||
bus_space_unmap(rman_get_bustag(r), vaddr, psize); | bus_space_unmap(rman_get_bustag(r), vaddr, psize); | ||||
rman_set_virtual(r, NULL); | rman_set_virtual(r, NULL); | ||||
rman_set_bushandle(r, 0); | rman_set_bushandle(r, 0); | ||||
} else if (type == SYS_RES_IRQ) { | } else if (type == SYS_RES_IRQ) { | ||||
#ifdef INTRNG | #ifdef INTRNG | ||||
intr_deactivate_irq(child, r); | mips_pic_deactivate_intr(child, r); | ||||
#endif | #endif | ||||
} | } | ||||
return (rman_deactivate_resource(r)); | return (rman_deactivate_resource(r)); | ||||
} | } | ||||
static int | static int | ||||
nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags, | nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags, | ||||
driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep) | driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep) | ||||
{ | { | ||||
#ifdef INTRNG | #ifdef INTRNG | ||||
struct resource *r = res; | return (intr_setup_irq(child, res, filt, intr, arg, flags, cookiep)); | ||||
#ifndef FDT | |||||
r = cpu_get_irq_resource(rman_get_start(r)); | |||||
#endif | |||||
return (intr_setup_irq(child, r, filt, intr, arg, flags, cookiep)); | |||||
#else | #else | ||||
int irq; | int irq; | ||||
register_t s; | register_t s; | ||||
s = intr_disable(); | s = intr_disable(); | ||||
irq = rman_get_start(res); | irq = rman_get_start(res); | ||||
if (irq >= NUM_MIPS_IRQS) { | if (irq >= NUM_MIPS_IRQS) { | ||||
intr_restore(s); | intr_restore(s); | ||||
▲ Show 20 Lines • Show All 126 Lines • Show Last 20 Lines |