Lines Matching refs:v2m
99 static phys_addr_t gicv2m_get_msi_addr(struct v2m_data *v2m, int hwirq) in gicv2m_get_msi_addr() argument
101 if (v2m->flags & GICV2M_GRAVITON_ADDRESS_ONLY) in gicv2m_get_msi_addr()
102 return v2m->res.start | ((hwirq - 32) << 3); in gicv2m_get_msi_addr()
104 return v2m->res.start + V2M_MSI_SETSPI_NS; in gicv2m_get_msi_addr()
109 struct v2m_data *v2m = irq_data_get_irq_chip_data(data); in gicv2m_compose_msi_msg() local
110 phys_addr_t addr = gicv2m_get_msi_addr(v2m, data->hwirq); in gicv2m_compose_msi_msg()
115 if (v2m->flags & GICV2M_GRAVITON_ADDRESS_ONLY) in gicv2m_compose_msi_msg()
119 if (v2m->flags & GICV2M_NEEDS_SPI_OFFSET) in gicv2m_compose_msi_msg()
120 msg->data -= v2m->spi_offset; in gicv2m_compose_msi_msg()
167 static void gicv2m_unalloc_msi(struct v2m_data *v2m, unsigned int hwirq, in gicv2m_unalloc_msi() argument
171 bitmap_release_region(v2m->bm, hwirq - v2m->spi_start, in gicv2m_unalloc_msi()
180 struct v2m_data *v2m = NULL, *tmp; in gicv2m_irq_domain_alloc() local
188 v2m = tmp; in gicv2m_irq_domain_alloc()
194 if (!v2m) in gicv2m_irq_domain_alloc()
197 hwirq = v2m->spi_start + offset; in gicv2m_irq_domain_alloc()
200 gicv2m_get_msi_addr(v2m, hwirq)); in gicv2m_irq_domain_alloc()
210 &gicv2m_irq_chip, v2m); in gicv2m_irq_domain_alloc()
217 gicv2m_unalloc_msi(v2m, hwirq, nr_irqs); in gicv2m_irq_domain_alloc()
225 struct v2m_data *v2m = irq_data_get_irq_chip_data(d); in gicv2m_irq_domain_free() local
227 gicv2m_unalloc_msi(v2m, d->hwirq, nr_irqs); in gicv2m_irq_domain_free()
267 struct v2m_data *v2m, *tmp; in gicv2m_teardown() local
269 list_for_each_entry_safe(v2m, tmp, &v2m_nodes, entry) { in gicv2m_teardown()
270 list_del(&v2m->entry); in gicv2m_teardown()
271 bitmap_free(v2m->bm); in gicv2m_teardown()
272 iounmap(v2m->base); in gicv2m_teardown()
273 of_node_put(to_of_node(v2m->fwnode)); in gicv2m_teardown()
274 if (is_fwnode_irqchip(v2m->fwnode)) in gicv2m_teardown()
275 irq_domain_free_fwnode(v2m->fwnode); in gicv2m_teardown()
276 kfree(v2m); in gicv2m_teardown()
283 struct v2m_data *v2m; in gicv2m_allocate_domains() local
285 v2m = list_first_entry_or_null(&v2m_nodes, struct v2m_data, entry); in gicv2m_allocate_domains()
286 if (!v2m) in gicv2m_allocate_domains()
289 inner_domain = irq_domain_create_tree(v2m->fwnode, in gicv2m_allocate_domains()
290 &gicv2m_domain_ops, v2m); in gicv2m_allocate_domains()
298 pci_domain = pci_msi_create_irq_domain(v2m->fwnode, in gicv2m_allocate_domains()
301 plat_domain = platform_msi_create_irq_domain(v2m->fwnode, in gicv2m_allocate_domains()
322 struct v2m_data *v2m; in gicv2m_init_one() local
324 v2m = kzalloc(sizeof(struct v2m_data), GFP_KERNEL); in gicv2m_init_one()
325 if (!v2m) in gicv2m_init_one()
328 INIT_LIST_HEAD(&v2m->entry); in gicv2m_init_one()
329 v2m->fwnode = fwnode; in gicv2m_init_one()
330 v2m->flags = flags; in gicv2m_init_one()
332 memcpy(&v2m->res, res, sizeof(struct resource)); in gicv2m_init_one()
334 v2m->base = ioremap(v2m->res.start, resource_size(&v2m->res)); in gicv2m_init_one()
335 if (!v2m->base) { in gicv2m_init_one()
342 v2m->spi_start = spi_start; in gicv2m_init_one()
343 v2m->nr_spis = nr_spis; in gicv2m_init_one()
348 if (v2m->flags & GICV2M_GRAVITON_ADDRESS_ONLY) { in gicv2m_init_one()
352 typer = readl_relaxed(v2m->base + V2M_MSI_TYPER); in gicv2m_init_one()
354 v2m->spi_start = V2M_MSI_TYPER_BASE_SPI(typer); in gicv2m_init_one()
355 v2m->nr_spis = V2M_MSI_TYPER_NUM_SPI(typer); in gicv2m_init_one()
358 if (!is_msi_spi_valid(v2m->spi_start, v2m->nr_spis)) { in gicv2m_init_one()
376 if (!(v2m->flags & GICV2M_GRAVITON_ADDRESS_ONLY)) { in gicv2m_init_one()
377 switch (readl_relaxed(v2m->base + V2M_MSI_IIDR)) { in gicv2m_init_one()
379 v2m->flags |= GICV2M_NEEDS_SPI_OFFSET; in gicv2m_init_one()
380 v2m->spi_offset = v2m->spi_start; in gicv2m_init_one()
383 v2m->flags |= GICV2M_NEEDS_SPI_OFFSET; in gicv2m_init_one()
384 v2m->spi_offset = 32; in gicv2m_init_one()
388 v2m->bm = bitmap_zalloc(v2m->nr_spis, GFP_KERNEL); in gicv2m_init_one()
389 if (!v2m->bm) { in gicv2m_init_one()
394 list_add_tail(&v2m->entry, &v2m_nodes); in gicv2m_init_one()
397 v2m->spi_start, (v2m->spi_start + v2m->nr_spis - 1)); in gicv2m_init_one()
401 iounmap(v2m->base); in gicv2m_init_one()
403 kfree(v2m); in gicv2m_init_one()