Lines Matching refs:msi_data
36 struct ls_scfg_msi *msi_data; member
87 struct ls_scfg_msi *msi_data = irq_data_get_irq_chip_data(data); in ls_scfg_msi_compose_msg() local
89 msg->address_hi = upper_32_bits(msi_data->msiir_addr); in ls_scfg_msi_compose_msg()
90 msg->address_lo = lower_32_bits(msi_data->msiir_addr); in ls_scfg_msi_compose_msg()
106 struct ls_scfg_msi *msi_data = irq_data_get_irq_chip_data(irq_data); in ls_scfg_msi_set_affinity() local
117 if (cpu >= msi_data->msir_num) in ls_scfg_msi_set_affinity()
120 if (msi_data->msir[cpu].gic_irq <= 0) { in ls_scfg_msi_set_affinity()
142 struct ls_scfg_msi *msi_data = domain->host_data; in ls_scfg_msi_domain_irq_alloc() local
147 spin_lock(&msi_data->lock); in ls_scfg_msi_domain_irq_alloc()
148 pos = find_first_zero_bit(msi_data->used, msi_data->irqs_num); in ls_scfg_msi_domain_irq_alloc()
149 if (pos < msi_data->irqs_num) in ls_scfg_msi_domain_irq_alloc()
150 __set_bit(pos, msi_data->used); in ls_scfg_msi_domain_irq_alloc()
153 spin_unlock(&msi_data->lock); in ls_scfg_msi_domain_irq_alloc()
158 err = iommu_dma_prepare_msi(info->desc, msi_data->msiir_addr); in ls_scfg_msi_domain_irq_alloc()
163 &ls_scfg_msi_parent_chip, msi_data, in ls_scfg_msi_domain_irq_alloc()
173 struct ls_scfg_msi *msi_data = irq_data_get_irq_chip_data(d); in ls_scfg_msi_domain_irq_free() local
177 if (pos < 0 || pos >= msi_data->irqs_num) { in ls_scfg_msi_domain_irq_free()
182 spin_lock(&msi_data->lock); in ls_scfg_msi_domain_irq_free()
183 __clear_bit(pos, msi_data->used); in ls_scfg_msi_domain_irq_free()
184 spin_unlock(&msi_data->lock); in ls_scfg_msi_domain_irq_free()
195 struct ls_scfg_msi *msi_data = msir->msi_data; in ls_scfg_msi_irq_handler() local
207 hwirq = ((msir->bit_end - pos) << msi_data->cfg->ibs_shift) | in ls_scfg_msi_irq_handler()
209 generic_handle_domain_irq(msi_data->parent, hwirq); in ls_scfg_msi_irq_handler()
215 static int ls_scfg_msi_domains_init(struct ls_scfg_msi *msi_data) in ls_scfg_msi_domains_init() argument
218 msi_data->parent = irq_domain_add_linear(NULL, in ls_scfg_msi_domains_init()
219 msi_data->irqs_num, in ls_scfg_msi_domains_init()
221 msi_data); in ls_scfg_msi_domains_init()
222 if (!msi_data->parent) { in ls_scfg_msi_domains_init()
223 dev_err(&msi_data->pdev->dev, "failed to create IRQ domain\n"); in ls_scfg_msi_domains_init()
227 msi_data->msi_domain = pci_msi_create_irq_domain( in ls_scfg_msi_domains_init()
228 of_node_to_fwnode(msi_data->pdev->dev.of_node), in ls_scfg_msi_domains_init()
230 msi_data->parent); in ls_scfg_msi_domains_init()
231 if (!msi_data->msi_domain) { in ls_scfg_msi_domains_init()
232 dev_err(&msi_data->pdev->dev, "failed to create MSI domain\n"); in ls_scfg_msi_domains_init()
233 irq_domain_remove(msi_data->parent); in ls_scfg_msi_domains_init()
240 static int ls_scfg_msi_setup_hwirq(struct ls_scfg_msi *msi_data, int index) in ls_scfg_msi_setup_hwirq() argument
245 virq = platform_get_irq(msi_data->pdev, index); in ls_scfg_msi_setup_hwirq()
249 msir = &msi_data->msir[index]; in ls_scfg_msi_setup_hwirq()
251 msir->msi_data = msi_data; in ls_scfg_msi_setup_hwirq()
253 msir->reg = msi_data->regs + msi_data->cfg->msir_base + 4 * index; in ls_scfg_msi_setup_hwirq()
255 if (msi_data->cfg->msir_irqs == MSI_LS1043V1_1_IRQS_PER_MSIR) { in ls_scfg_msi_setup_hwirq()
262 msir->bit_end = msi_data->cfg->msir_irqs - 1; in ls_scfg_msi_setup_hwirq()
278 for (i = 0; i < msi_data->cfg->msir_irqs; i++) { in ls_scfg_msi_setup_hwirq()
279 hwirq = i << msi_data->cfg->ibs_shift | msir->index; in ls_scfg_msi_setup_hwirq()
280 bitmap_clear(msi_data->used, hwirq, 1); in ls_scfg_msi_setup_hwirq()
289 struct ls_scfg_msi *msi_data = msir->msi_data; in ls_scfg_msi_teardown_hwirq() local
295 for (i = 0; i < msi_data->cfg->msir_irqs; i++) { in ls_scfg_msi_teardown_hwirq()
296 hwirq = i << msi_data->cfg->ibs_shift | msir->index; in ls_scfg_msi_teardown_hwirq()
297 bitmap_set(msi_data->used, hwirq, 1); in ls_scfg_msi_teardown_hwirq()
338 struct ls_scfg_msi *msi_data; in ls_scfg_msi_probe() local
346 msi_data = devm_kzalloc(&pdev->dev, sizeof(*msi_data), GFP_KERNEL); in ls_scfg_msi_probe()
347 if (!msi_data) in ls_scfg_msi_probe()
350 msi_data->cfg = (struct ls_scfg_msi_cfg *) match->data; in ls_scfg_msi_probe()
353 msi_data->regs = devm_ioremap_resource(&pdev->dev, res); in ls_scfg_msi_probe()
354 if (IS_ERR(msi_data->regs)) { in ls_scfg_msi_probe()
356 return PTR_ERR(msi_data->regs); in ls_scfg_msi_probe()
358 msi_data->msiir_addr = res->start; in ls_scfg_msi_probe()
360 msi_data->pdev = pdev; in ls_scfg_msi_probe()
361 spin_lock_init(&msi_data->lock); in ls_scfg_msi_probe()
363 msi_data->irqs_num = MSI_IRQS_PER_MSIR * in ls_scfg_msi_probe()
364 (1 << msi_data->cfg->ibs_shift); in ls_scfg_msi_probe()
365 msi_data->used = devm_bitmap_zalloc(&pdev->dev, msi_data->irqs_num, GFP_KERNEL); in ls_scfg_msi_probe()
366 if (!msi_data->used) in ls_scfg_msi_probe()
372 bitmap_set(msi_data->used, 0, msi_data->irqs_num); in ls_scfg_msi_probe()
374 msi_data->msir_num = of_irq_count(pdev->dev.of_node); in ls_scfg_msi_probe()
380 if (msi_data->msir_num >= cpu_num) in ls_scfg_msi_probe()
381 msi_data->msir_num = cpu_num; in ls_scfg_msi_probe()
386 msi_data->msir = devm_kcalloc(&pdev->dev, msi_data->msir_num, in ls_scfg_msi_probe()
387 sizeof(*msi_data->msir), in ls_scfg_msi_probe()
389 if (!msi_data->msir) in ls_scfg_msi_probe()
392 for (i = 0; i < msi_data->msir_num; i++) in ls_scfg_msi_probe()
393 ls_scfg_msi_setup_hwirq(msi_data, i); in ls_scfg_msi_probe()
395 ret = ls_scfg_msi_domains_init(msi_data); in ls_scfg_msi_probe()
399 platform_set_drvdata(pdev, msi_data); in ls_scfg_msi_probe()
406 struct ls_scfg_msi *msi_data = platform_get_drvdata(pdev); in ls_scfg_msi_remove() local
409 for (i = 0; i < msi_data->msir_num; i++) in ls_scfg_msi_remove()
410 ls_scfg_msi_teardown_hwirq(&msi_data->msir[i]); in ls_scfg_msi_remove()
412 irq_domain_remove(msi_data->msi_domain); in ls_scfg_msi_remove()
413 irq_domain_remove(msi_data->parent); in ls_scfg_msi_remove()