Lines Matching +full:msi +full:- +full:x

1 /*-
48 #define ERR_NOT_IN_MAP -1
66 {"annapurna-labs,al-msix", true},
67 {"annapurna-labs,alpine-msix", true},
120 if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) in al_msix_probe()
123 device_set_desc(dev, "Annapurna-Labs MSI-X Controller"); in al_msix_probe()
146 sc->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); in al_msix_attach()
147 if (sc->res == NULL) { in al_msix_attach()
152 sc->base_addr = (bus_addr_t)rman_get_start(sc->res); in al_msix_attach()
154 /* Register this device to handle MSI interrupts */ in al_msix_attach()
156 device_printf(dev, "could not register MSI-X controller\n"); in al_msix_attach()
160 device_printf(dev, "MSI-X controller registered\n"); in al_msix_attach()
165 device_printf(dev, "No interrupt-parrent found. " in al_msix_attach()
169 /* While at parent - store interrupt cells prop */ in al_msix_attach()
171 "#interrupt-cells", &icells, sizeof(icells)) == -1) { in al_msix_attach()
172 device_printf(dev, "DTB: Missing #interrupt-cells " in al_msix_attach()
183 sc->gic_dev = gic_dev; in al_msix_attach()
202 sc->irq_min = interrupts[0]; in al_msix_attach()
203 sc->irq_max = interrupts[1]; in al_msix_attach()
204 sc->irq_count = (sc->irq_max - sc->irq_min + 1); in al_msix_attach()
206 if (sc->irq_count > MAX_MSIX_COUNT) { in al_msix_attach()
207 device_printf(dev, "Available MSI-X count exceeds buffer size." in al_msix_attach()
209 sc->irq_count = MAX_MSIX_COUNT; in al_msix_attach()
212 mtx_init(&sc->msi_mtx, "msi_mtx", NULL, MTX_DEF); in al_msix_attach()
214 sc->irq_alloc = vmem_create("Alpine MSI-X IRQs", 0, sc->irq_count, in al_msix_attach()
217 device_printf(dev, "MSI-X SPI IRQ %d-%d\n", sc->irq_min, sc->irq_max); in al_msix_attach()
231 if (sc->isrcs[i] == isrc) in al_find_intr_pos_in_map()
249 spi = sc->irq_min + i; in al_msix_map_msi()
253 * [63:20] - MSIx TBAR in al_msix_map_msi()
255 * [19] - WFE_EXIT in al_msix_map_msi()
258 * [18:17] - Target GIC ID in al_msix_map_msi()
259 * Specifies which IO-GIC (external shared GIC) is targeted in al_msix_map_msi()
261 * 1: IO-GIC 0 in al_msix_map_msi()
264 * [16:13] - Local GIC Target List in al_msix_map_msi()
272 * [12:3] - SPIn in al_msix_map_msi()
277 * [2] - Function vector in al_msix_map_msi()
278 * MSI Data vector extension hint in al_msix_map_msi()
279 * [1:0] - Reserved in al_msix_map_msi()
282 *addr = (uint64_t)sc->base_addr + (uint64_t)((1 << 16) + (spi << 3)); in al_msix_map_msi()
286 device_printf(dev, "MSI mapping: SPI: %d addr: %jx data: %x\n", in al_msix_map_msi()
306 if (vmem_alloc(sc->irq_alloc, count, M_FIRSTFIT | M_NOWAIT, in al_msix_alloc_msi()
313 fdt_data->hdr.type = INTR_MAP_DATA_FDT; in al_msix_alloc_msi()
314 fdt_data->iparent = 0; in al_msix_alloc_msi()
315 fdt_data->ncells = GIC_INTR_CELL_CNT; in al_msix_alloc_msi()
316 fdt_data->cells[0] = AL_SPI_INTR; /* code for SPI interrupt */ in al_msix_alloc_msi()
317 fdt_data->cells[1] = 0; /* SPI number (uninitialized) */ in al_msix_alloc_msi()
318 fdt_data->cells[2] = AL_EDGE_HIGH; /* trig = edge, pol = high */ in al_msix_alloc_msi()
320 mtx_lock(&sc->msi_mtx); in al_msix_alloc_msi()
323 fdt_data->cells[1] = sc->irq_min + i; in al_msix_alloc_msi()
324 error = PIC_MAP_INTR(sc->gic_dev, in al_msix_alloc_msi()
328 sc->isrcs[j] = NULL; in al_msix_alloc_msi()
329 mtx_unlock(&sc->msi_mtx); in al_msix_alloc_msi()
330 vmem_free(sc->irq_alloc, irq_base, count); in al_msix_alloc_msi()
335 sc->isrcs[i] = *srcs; in al_msix_alloc_msi()
339 mtx_unlock(&sc->msi_mtx); in al_msix_alloc_msi()
344 "MSI-X allocation: start SPI %d, count %d\n", in al_msix_alloc_msi()
345 (int)irq_base + sc->irq_min, count); in al_msix_alloc_msi()
347 *pic = sc->gic_dev; in al_msix_alloc_msi()
361 mtx_lock(&sc->msi_mtx); in al_msix_release_msi()
364 vmem_free(sc->irq_alloc, pos, count); in al_msix_release_msi()
368 sc->isrcs[pos] = NULL; in al_msix_release_msi()
372 mtx_unlock(&sc->msi_mtx); in al_msix_release_msi()