Lines Matching full:v2m

3  * ARM GIC v2m MSI(-X) support
58 /* List of flags for specific v2m implementation */
74 u32 flags; /* v2m flags for specific implementation */
77 static phys_addr_t gicv2m_get_msi_addr(struct v2m_data *v2m, int hwirq) in gicv2m_get_msi_addr() argument
79 if (v2m->flags & GICV2M_GRAVITON_ADDRESS_ONLY) in gicv2m_get_msi_addr()
80 return v2m->res.start | ((hwirq - 32) << 3); in gicv2m_get_msi_addr()
82 return v2m->res.start + V2M_MSI_SETSPI_NS; in gicv2m_get_msi_addr()
87 struct v2m_data *v2m = irq_data_get_irq_chip_data(data); in gicv2m_compose_msi_msg() local
88 phys_addr_t addr = gicv2m_get_msi_addr(v2m, data->hwirq); in gicv2m_compose_msi_msg()
93 if (v2m->flags & GICV2M_GRAVITON_ADDRESS_ONLY) in gicv2m_compose_msi_msg()
97 if (v2m->flags & GICV2M_NEEDS_SPI_OFFSET) in gicv2m_compose_msi_msg()
98 msg->data -= v2m->spi_offset; in gicv2m_compose_msi_msg()
145 static void gicv2m_unalloc_msi(struct v2m_data *v2m, unsigned int hwirq, in gicv2m_unalloc_msi() argument
149 bitmap_release_region(v2m->bm, hwirq - v2m->spi_start, in gicv2m_unalloc_msi()
158 struct v2m_data *v2m = NULL, *tmp; in gicv2m_irq_domain_alloc() local
166 v2m = tmp; in gicv2m_irq_domain_alloc()
172 if (!v2m) in gicv2m_irq_domain_alloc()
175 hwirq = v2m->spi_start + offset; in gicv2m_irq_domain_alloc()
178 gicv2m_get_msi_addr(v2m, hwirq)); in gicv2m_irq_domain_alloc()
188 &gicv2m_irq_chip, v2m); in gicv2m_irq_domain_alloc()
195 gicv2m_unalloc_msi(v2m, hwirq, nr_irqs); in gicv2m_irq_domain_alloc()
203 struct v2m_data *v2m = irq_data_get_irq_chip_data(d); in gicv2m_irq_domain_free() local
205 gicv2m_unalloc_msi(v2m, d->hwirq, nr_irqs); in gicv2m_irq_domain_free()
233 struct v2m_data *v2m, *tmp; in gicv2m_teardown() local
235 list_for_each_entry_safe(v2m, tmp, &v2m_nodes, entry) { in gicv2m_teardown()
236 list_del(&v2m->entry); in gicv2m_teardown()
237 bitmap_free(v2m->bm); in gicv2m_teardown()
238 iounmap(v2m->base); in gicv2m_teardown()
239 of_node_put(to_of_node(v2m->fwnode)); in gicv2m_teardown()
240 if (is_fwnode_irqchip(v2m->fwnode)) in gicv2m_teardown()
241 irq_domain_free_fwnode(v2m->fwnode); in gicv2m_teardown()
242 kfree(v2m); in gicv2m_teardown()
267 struct v2m_data *v2m; in gicv2m_allocate_domains() local
269 v2m = list_first_entry_or_null(&v2m_nodes, struct v2m_data, entry); in gicv2m_allocate_domains()
270 if (!v2m) in gicv2m_allocate_domains()
273 inner_domain = irq_domain_create_hierarchy(parent, 0, 0, v2m->fwnode, in gicv2m_allocate_domains()
274 &gicv2m_domain_ops, v2m); in gicv2m_allocate_domains()
291 struct v2m_data *v2m; in gicv2m_init_one() local
293 v2m = kzalloc(sizeof(struct v2m_data), GFP_KERNEL); in gicv2m_init_one()
294 if (!v2m) in gicv2m_init_one()
297 INIT_LIST_HEAD(&v2m->entry); in gicv2m_init_one()
298 v2m->fwnode = fwnode; in gicv2m_init_one()
299 v2m->flags = flags; in gicv2m_init_one()
301 memcpy(&v2m->res, res, sizeof(struct resource)); in gicv2m_init_one()
303 v2m->base = ioremap(v2m->res.start, resource_size(&v2m->res)); in gicv2m_init_one()
304 if (!v2m->base) { in gicv2m_init_one()
311 v2m->spi_start = spi_start; in gicv2m_init_one()
312 v2m->nr_spis = nr_spis; in gicv2m_init_one()
317 if (v2m->flags & GICV2M_GRAVITON_ADDRESS_ONLY) { in gicv2m_init_one()
321 typer = readl_relaxed(v2m->base + V2M_MSI_TYPER); in gicv2m_init_one()
323 v2m->spi_start = V2M_MSI_TYPER_BASE_SPI(typer); in gicv2m_init_one()
324 v2m->nr_spis = V2M_MSI_TYPER_NUM_SPI(typer); in gicv2m_init_one()
327 if (!is_msi_spi_valid(v2m->spi_start, v2m->nr_spis)) { in gicv2m_init_one()
345 if (!(v2m->flags & GICV2M_GRAVITON_ADDRESS_ONLY)) { in gicv2m_init_one()
346 switch (readl_relaxed(v2m->base + V2M_MSI_IIDR)) { in gicv2m_init_one()
348 v2m->flags |= GICV2M_NEEDS_SPI_OFFSET; in gicv2m_init_one()
349 v2m->spi_offset = v2m->spi_start; in gicv2m_init_one()
352 v2m->flags |= GICV2M_NEEDS_SPI_OFFSET; in gicv2m_init_one()
353 v2m->spi_offset = 32; in gicv2m_init_one()
357 v2m->bm = bitmap_zalloc(v2m->nr_spis, GFP_KERNEL); in gicv2m_init_one()
358 if (!v2m->bm) { in gicv2m_init_one()
363 list_add_tail(&v2m->entry, &v2m_nodes); in gicv2m_init_one()
366 v2m->spi_start, (v2m->spi_start + v2m->nr_spis - 1)); in gicv2m_init_one()
370 iounmap(v2m->base); in gicv2m_init_one()
372 kfree(v2m); in gicv2m_init_one()
377 { .compatible = "arm,gic-v2m-frame", },
398 pr_err("Failed to allocate v2m resource.\n"); in gicv2m_of_init()
405 pr_info("DT overriding V2M MSI_TYPER (base:%u, num:%u)\n", in gicv2m_of_init()
490 pr_info("ACPI overriding V2M MSI_TYPER (base:%u, num:%u)\n", in acpi_parse_madt_msi()