Changeset View
Changeset View
Standalone View
Standalone View
sys/arm/arm/nexus.c
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/pmap.h> | #include <vm/pmap.h> | ||||
#include <machine/resource.h> | #include <machine/resource.h> | ||||
#include <machine/intr.h> | #include <machine/intr.h> | ||||
#ifdef FDT | #ifdef FDT | ||||
#include <machine/fdt.h> | #include <machine/fdt.h> | ||||
#include <dev/ofw/ofw_bus_subr.h> | |||||
#include "ofw_bus_if.h" | #include "ofw_bus_if.h" | ||||
#endif | #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; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 299 Lines • ▼ Show 20 Lines | #else | ||||
if (vaddr == 0) { | if (vaddr == 0) { | ||||
rman_deactivate_resource(r); | rman_deactivate_resource(r); | ||||
return (ENOMEM); | return (ENOMEM); | ||||
} | } | ||||
rman_set_bustag(r, (void *)1); | rman_set_bustag(r, (void *)1); | ||||
#endif | #endif | ||||
rman_set_virtual(r, (void *)vaddr); | rman_set_virtual(r, (void *)vaddr); | ||||
rman_set_bushandle(r, vaddr); | rman_set_bushandle(r, vaddr); | ||||
return (0); | |||||
} else if (type == SYS_RES_IRQ) { | |||||
#ifdef INTRNG | |||||
intr_activate_irq(child, r); | |||||
#endif | |||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
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_size_t psize; | bus_size_t psize; | ||||
bus_space_handle_t vaddr; | bus_space_handle_t vaddr; | ||||
if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) { | |||||
psize = (bus_size_t)rman_get_size(r); | psize = (bus_size_t)rman_get_size(r); | ||||
vaddr = rman_get_bushandle(r); | vaddr = rman_get_bushandle(r); | ||||
if (vaddr != 0) { | if (vaddr != 0) { | ||||
#ifdef FDT | #ifdef FDT | ||||
bus_space_unmap(fdtbus_bs_tag, vaddr, psize); | bus_space_unmap(fdtbus_bs_tag, vaddr, psize); | ||||
#else | #else | ||||
pmap_unmapdev((vm_offset_t)vaddr, (vm_size_t)psize); | pmap_unmapdev((vm_offset_t)vaddr, (vm_size_t)psize); | ||||
#endif | #endif | ||||
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) { | |||||
#ifdef INTRNG | |||||
intr_deactivate_irq(child, r); | |||||
#endif | |||||
} | |||||
return (rman_deactivate_resource(r)); | return (rman_deactivate_resource(r)); | ||||
} | } | ||||
#ifdef FDT | #ifdef FDT | ||||
static int | static int | ||||
nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent, int icells, | nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent, int icells, | ||||
pcell_t *intr) | pcell_t *intr) | ||||
{ | { | ||||
#ifndef INTRNG | |||||
#ifdef INTRNG | |||||
return (INTR_IRQ_INVALID); | |||||
#else | |||||
return (intr_fdt_map_irq(iparent, intr, icells)); | return (intr_fdt_map_irq(iparent, intr, icells)); | ||||
#endif | #else | ||||
u_int irq; | |||||
struct intr_map_data_fdt *fdt_data; | |||||
size_t len; | |||||
len = sizeof(*fdt_data) + icells * sizeof(pcell_t); | |||||
fdt_data = (struct intr_map_data_fdt *)intr_alloc_map_data( | |||||
INTR_MAP_DATA_FDT, len, M_WAITOK | M_ZERO); | |||||
fdt_data->iparent = iparent; | |||||
fdt_data->ncells = icells; | |||||
memcpy(fdt_data->cells, intr, icells * sizeof(pcell_t)); | |||||
irq = intr_map_irq(NULL, iparent, (struct intr_map_data *)fdt_data); | |||||
return (irq); | |||||
#endif /* INTRNG */ | |||||
} | } | ||||
#endif | #endif /* FDT */ | ||||