Changeset View
Changeset View
Standalone View
Standalone View
sys/arm64/arm64/nexus.c
| Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
| #include "ofw_bus_if.h" | #include "ofw_bus_if.h" | ||||
| #endif | #endif | ||||
| #ifdef DEV_ACPI | #ifdef DEV_ACPI | ||||
| #include <contrib/dev/acpica/include/acpi.h> | #include <contrib/dev/acpica/include/acpi.h> | ||||
| #include <dev/acpica/acpivar.h> | #include <dev/acpica/acpivar.h> | ||||
| #include "acpi_bus_if.h" | #include "acpi_bus_if.h" | ||||
| #endif | #endif | ||||
| #include "pcib_if.h" | |||||
| extern struct bus_space memmap_bus; | extern struct bus_space memmap_bus; | ||||
| 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 All 35 Lines | |||||
| static bus_describe_intr_t nexus_describe_intr; | static bus_describe_intr_t nexus_describe_intr; | ||||
| static bus_setup_intr_t nexus_setup_intr; | static bus_setup_intr_t nexus_setup_intr; | ||||
| static bus_teardown_intr_t nexus_teardown_intr; | static bus_teardown_intr_t nexus_teardown_intr; | ||||
| static bus_get_bus_tag_t nexus_get_bus_tag; | static bus_get_bus_tag_t nexus_get_bus_tag; | ||||
| #ifdef FDT | #ifdef FDT | ||||
| static ofw_bus_map_intr_t nexus_ofw_map_intr; | static ofw_bus_map_intr_t nexus_ofw_map_intr; | ||||
| /* | |||||
| * PCIB interface | |||||
| */ | |||||
| static pcib_alloc_msi_t nexus_fdt_pcib_alloc_msi; | |||||
| static pcib_release_msi_t nexus_fdt_pcib_release_msi; | |||||
| static pcib_alloc_msix_t nexus_fdt_pcib_alloc_msix; | |||||
| static pcib_release_msix_t nexus_fdt_pcib_release_msix; | |||||
| static pcib_map_msi_t nexus_fdt_pcib_map_msi; | |||||
| #endif | #endif | ||||
| static device_method_t nexus_methods[] = { | static device_method_t nexus_methods[] = { | ||||
| /* Device interface */ | /* Device interface */ | ||||
| DEVMETHOD(device_shutdown, bus_generic_shutdown), | DEVMETHOD(device_shutdown, bus_generic_shutdown), | ||||
| /* Bus interface */ | /* Bus interface */ | ||||
| DEVMETHOD(bus_add_child, nexus_add_child), | DEVMETHOD(bus_add_child, nexus_add_child), | ||||
| ▲ Show 20 Lines • Show All 302 Lines • ▼ Show 20 Lines | static device_method_t nexus_fdt_methods[] = { | ||||
| DEVMETHOD(device_attach, nexus_fdt_attach), | DEVMETHOD(device_attach, nexus_fdt_attach), | ||||
| /* Bus interface */ | /* Bus interface */ | ||||
| DEVMETHOD(bus_activate_resource, nexus_fdt_activate_resource), | DEVMETHOD(bus_activate_resource, nexus_fdt_activate_resource), | ||||
| /* OFW interface */ | /* OFW interface */ | ||||
| DEVMETHOD(ofw_bus_map_intr, nexus_ofw_map_intr), | DEVMETHOD(ofw_bus_map_intr, nexus_ofw_map_intr), | ||||
| /* PCIB interface */ | |||||
| DEVMETHOD(pcib_alloc_msi, nexus_fdt_pcib_alloc_msi), | |||||
| DEVMETHOD(pcib_release_msi, nexus_fdt_pcib_release_msi), | |||||
| DEVMETHOD(pcib_alloc_msix, nexus_fdt_pcib_alloc_msix), | |||||
| DEVMETHOD(pcib_release_msix, nexus_fdt_pcib_release_msix), | |||||
| DEVMETHOD(pcib_map_msi, nexus_fdt_pcib_map_msi), | |||||
| DEVMETHOD_END, | DEVMETHOD_END, | ||||
| }; | }; | ||||
| #define nexus_baseclasses nexus_fdt_baseclasses | #define nexus_baseclasses nexus_fdt_baseclasses | ||||
| DEFINE_CLASS_1(nexus, nexus_fdt_driver, nexus_fdt_methods, 1, nexus_driver); | DEFINE_CLASS_1(nexus, nexus_fdt_driver, nexus_fdt_methods, 1, nexus_driver); | ||||
| #undef nexus_baseclasses | #undef nexus_baseclasses | ||||
| EARLY_DRIVER_MODULE(nexus_fdt, root, nexus_fdt_driver, 0, 0, | EARLY_DRIVER_MODULE(nexus_fdt, root, nexus_fdt_driver, 0, 0, | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent, int icells, | ||||
| len = sizeof(*fdt_data) + icells * sizeof(pcell_t); | len = sizeof(*fdt_data) + icells * sizeof(pcell_t); | ||||
| fdt_data = (struct intr_map_data_fdt *)intr_alloc_map_data( | fdt_data = (struct intr_map_data_fdt *)intr_alloc_map_data( | ||||
| INTR_MAP_DATA_FDT, len, M_WAITOK | M_ZERO); | INTR_MAP_DATA_FDT, len, M_WAITOK | M_ZERO); | ||||
| fdt_data->iparent = iparent; | fdt_data->iparent = iparent; | ||||
| fdt_data->ncells = icells; | fdt_data->ncells = icells; | ||||
| memcpy(fdt_data->cells, intr, icells * sizeof(pcell_t)); | memcpy(fdt_data->cells, intr, icells * sizeof(pcell_t)); | ||||
| irq = intr_map_irq(NULL, iparent, (struct intr_map_data *)fdt_data); | irq = intr_map_irq(NULL, iparent, (struct intr_map_data *)fdt_data); | ||||
| return (irq); | return (irq); | ||||
| } | |||||
| static int | |||||
| nexus_fdt_pcib_alloc_msi(device_t dev, device_t child, int count, int maxcount, | |||||
| int *irqs) | |||||
| { | |||||
| phandle_t msi_parent; | |||||
| int error; | |||||
| error = ofw_bus_msimap(ofw_bus_get_node(child), 0, &msi_parent, NULL); | |||||
| if (error != 0) | |||||
| return (error); | |||||
| return (intr_alloc_msi(dev, child, msi_parent, count, maxcount, irqs)); | |||||
| } | |||||
| static int | |||||
| nexus_fdt_pcib_release_msi(device_t dev, device_t child, int count, int *irqs) | |||||
| { | |||||
| phandle_t msi_parent; | |||||
| int error; | |||||
| error = ofw_bus_msimap(ofw_bus_get_node(child), 0, &msi_parent, NULL); | |||||
| if (error != 0) | |||||
| return (error); | |||||
| return (intr_release_msi(dev, child, msi_parent, count, irqs)); | |||||
| } | |||||
| static int | |||||
| nexus_fdt_pcib_alloc_msix(device_t dev, device_t child, int *irq) | |||||
| { | |||||
| phandle_t msi_parent; | |||||
| int error; | |||||
| error = ofw_bus_msimap(ofw_bus_get_node(child), 0, &msi_parent, NULL); | |||||
| if (error != 0) | |||||
| return (error); | |||||
| return (intr_alloc_msix(dev, child, msi_parent, irq)); | |||||
| } | |||||
| static int | |||||
| nexus_fdt_pcib_release_msix(device_t dev, device_t child, int irq) | |||||
| { | |||||
| phandle_t msi_parent; | |||||
| int error; | |||||
| error = ofw_bus_msimap(ofw_bus_get_node(child), 0, &msi_parent, NULL); | |||||
| if (error != 0) | |||||
| return (error); | |||||
| return (intr_release_msix(dev, child, msi_parent, irq)); | |||||
| } | |||||
| static int | |||||
| nexus_fdt_pcib_map_msi(device_t dev, device_t child, int irq, uint64_t *addr, | |||||
| uint32_t *data) | |||||
| { | |||||
| phandle_t msi_parent; | |||||
| int error; | |||||
| error = ofw_bus_msimap(ofw_bus_get_node(child), 0, &msi_parent, NULL); | |||||
| if (error != 0) | |||||
| return (error); | |||||
| return (intr_map_msi(dev, child, msi_parent, irq, addr, data)); | |||||
| } | } | ||||
| #endif | #endif | ||||
| #ifdef DEV_ACPI | #ifdef DEV_ACPI | ||||
| static int nexus_acpi_map_intr(device_t dev, device_t child, u_int irq, int trig, int pol); | static int nexus_acpi_map_intr(device_t dev, device_t child, u_int irq, int trig, int pol); | ||||
| static device_method_t nexus_acpi_methods[] = { | static device_method_t nexus_acpi_methods[] = { | ||||
| /* Device interface */ | /* Device interface */ | ||||
| ▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines | |||||