Changeset View
Changeset View
Standalone View
Standalone View
sys/arm64/arm64/nexus.c
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | |||||
static struct resource_list *nexus_get_reslist(device_t, device_t); | static struct resource_list *nexus_get_reslist(device_t, device_t); | ||||
static int nexus_set_resource(device_t, device_t, int, int, | static int nexus_set_resource(device_t, device_t, int, int, | ||||
rman_res_t, rman_res_t); | rman_res_t, rman_res_t); | ||||
static int nexus_deactivate_resource(device_t, device_t, int, int, | static int nexus_deactivate_resource(device_t, device_t, int, int, | ||||
struct resource *); | struct resource *); | ||||
static int nexus_release_resource(device_t, device_t, int, int, | static int nexus_release_resource(device_t, device_t, int, int, | ||||
struct resource *); | struct resource *); | ||||
static uint64_t nexus_get_parange(void); | |||||
static int nexus_setup_intr(device_t dev, device_t child, struct resource *res, | static int 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); | int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep); | ||||
static int nexus_teardown_intr(device_t, device_t, struct resource *, void *); | static int nexus_teardown_intr(device_t, device_t, struct resource *, void *); | ||||
static bus_space_tag_t nexus_get_bus_tag(device_t, device_t); | static bus_space_tag_t nexus_get_bus_tag(device_t, device_t); | ||||
#ifdef SMP | #ifdef SMP | ||||
static int nexus_bind_intr(device_t, device_t, struct resource *, int); | static int nexus_bind_intr(device_t, device_t, struct resource *, int); | ||||
#endif | #endif | ||||
Show All 29 Lines | static driver_t nexus_driver = { | ||||
1 /* no softc */ | 1 /* no softc */ | ||||
}; | }; | ||||
static int | static int | ||||
nexus_attach(device_t dev) | nexus_attach(device_t dev) | ||||
{ | { | ||||
mem_rman.rm_start = 0; | mem_rman.rm_start = 0; | ||||
mem_rman.rm_end = BUS_SPACE_MAXADDR; | mem_rman.rm_end = nexus_get_parange(); | ||||
mem_rman.rm_type = RMAN_ARRAY; | mem_rman.rm_type = RMAN_ARRAY; | ||||
mem_rman.rm_descr = "I/O memory addresses"; | mem_rman.rm_descr = "I/O memory addresses"; | ||||
if (rman_init(&mem_rman) || | if (rman_init(&mem_rman) || | ||||
rman_manage_region(&mem_rman, 0, BUS_SPACE_MAXADDR)) | rman_manage_region(&mem_rman, 0, mem_rman.rm_end)) | ||||
panic("nexus_attach mem_rman"); | panic("nexus_attach mem_rman"); | ||||
irq_rman.rm_start = 0; | irq_rman.rm_start = 0; | ||||
irq_rman.rm_end = ~0; | irq_rman.rm_end = ~0; | ||||
irq_rman.rm_type = RMAN_ARRAY; | irq_rman.rm_type = RMAN_ARRAY; | ||||
irq_rman.rm_descr = "Interrupts"; | irq_rman.rm_descr = "Interrupts"; | ||||
if (rman_init(&irq_rman) || rman_manage_region(&irq_rman, 0, ~0)) | if (rman_init(&irq_rman) || rman_manage_region(&irq_rman, 0, ~0)) | ||||
panic("nexus_attach irq_rman"); | panic("nexus_attach irq_rman"); | ||||
▲ Show 20 Lines • Show All 294 Lines • ▼ Show 20 Lines | nexus_map_resource(device_t bus, device_t child, int type, struct resource *r, | ||||
map->r_bustag = &memmap_bus; | map->r_bustag = &memmap_bus; | ||||
map->r_size = length; | map->r_size = length; | ||||
/* | /* | ||||
* The handle is the virtual address. | * The handle is the virtual address. | ||||
*/ | */ | ||||
map->r_bushandle = (bus_space_handle_t)map->r_vaddr; | map->r_bushandle = (bus_space_handle_t)map->r_vaddr; | ||||
return (0); | return (0); | ||||
} | |||||
static uint64_t | |||||
nexus_get_parange(void) | |||||
{ | |||||
uint64_t mmfr0, parange; | |||||
if (!get_kernel_reg(ID_AA64MMFR0_EL1, &mmfr0)) { | |||||
/* chosen arbitrarily */ | |||||
mmfr0 = ID_AA64MMFR0_PARange_1T; | |||||
} | |||||
switch (ID_AA64MMFR0_PARange_VAL(mmfr0)) { | |||||
case ID_AA64MMFR0_PARange_4G: | |||||
parange = (vm_paddr_t)4 << 30 /* GiB */; | |||||
break; | |||||
case ID_AA64MMFR0_PARange_64G: | |||||
parange = (vm_paddr_t)64 << 30 /* GiB */; | |||||
break; | |||||
case ID_AA64MMFR0_PARange_1T: | |||||
parange = (vm_paddr_t)1 << 40 /* TiB */; | |||||
break; | |||||
case ID_AA64MMFR0_PARange_4T: | |||||
parange = (vm_paddr_t)4 << 40 /* TiB */; | |||||
break; | |||||
case ID_AA64MMFR0_PARange_16T: | |||||
parange = (vm_paddr_t)16 << 40 /* TiB */; | |||||
break; | |||||
case ID_AA64MMFR0_PARange_256T: | |||||
parange = (vm_paddr_t)256 << 40 /* TiB */; | |||||
break; | |||||
case ID_AA64MMFR0_PARange_4P: | |||||
parange = (vm_paddr_t)4 << 50 /* PiB */; | |||||
break; | |||||
default: | |||||
/* chosen arbitrarily */ | |||||
parange = (vm_paddr_t)1 << 40 /* TiB */; | |||||
printf("Unknown value for PARange in mmfr0 (%#lx)\n", mmfr0); | |||||
break; | |||||
} | |||||
return (parange); | |||||
} | } | ||||
#ifdef FDT | #ifdef FDT | ||||
static device_method_t nexus_fdt_methods[] = { | static device_method_t nexus_fdt_methods[] = { | ||||
/* Device interface */ | /* Device interface */ | ||||
DEVMETHOD(device_probe, nexus_fdt_probe), | DEVMETHOD(device_probe, nexus_fdt_probe), | ||||
DEVMETHOD(device_attach, nexus_fdt_attach), | DEVMETHOD(device_attach, nexus_fdt_attach), | ||||
▲ Show 20 Lines • Show All 121 Lines • Show Last 20 Lines |