Lines Matching full:msi

19 #include <linux/msi.h>
150 /* MSI target adresses */
262 /* used indicates which MSI interrupts have been alloc'd */
267 int nr; /* No. of MSI available, depends on chip */
281 struct brcm_msi *msi; member
456 .name = "BRCM STB PCIe MSI",
463 /* Multi MSI is supported by the controller, but not by this driver */
472 struct brcm_msi *msi; in brcm_pcie_msi_isr() local
477 msi = irq_desc_get_handler_data(desc); in brcm_pcie_msi_isr()
478 dev = msi->dev; in brcm_pcie_msi_isr()
480 status = readl(msi->intr_base + MSI_INT_STATUS); in brcm_pcie_msi_isr()
481 status >>= msi->legacy_shift; in brcm_pcie_msi_isr()
483 for_each_set_bit(bit, &status, msi->nr) { in brcm_pcie_msi_isr()
484 virq = irq_find_mapping(msi->inner_domain, bit); in brcm_pcie_msi_isr()
488 dev_dbg(dev, "unexpected MSI\n"); in brcm_pcie_msi_isr()
496 struct brcm_msi *msi = irq_data_get_irq_chip_data(data); in brcm_msi_compose_msi_msg() local
498 msg->address_lo = lower_32_bits(msi->target_addr); in brcm_msi_compose_msi_msg()
499 msg->address_hi = upper_32_bits(msi->target_addr); in brcm_msi_compose_msi_msg()
511 struct brcm_msi *msi = irq_data_get_irq_chip_data(data); in brcm_msi_ack_irq() local
512 const int shift_amt = data->hwirq + msi->legacy_shift; in brcm_msi_ack_irq()
514 writel(1 << shift_amt, msi->intr_base + MSI_INT_CLR); in brcm_msi_ack_irq()
519 .name = "BRCM STB MSI",
525 static int brcm_msi_alloc(struct brcm_msi *msi) in brcm_msi_alloc() argument
529 mutex_lock(&msi->lock); in brcm_msi_alloc()
530 hwirq = bitmap_find_free_region(&msi->used, msi->nr, 0); in brcm_msi_alloc()
531 mutex_unlock(&msi->lock); in brcm_msi_alloc()
536 static void brcm_msi_free(struct brcm_msi *msi, unsigned long hwirq) in brcm_msi_free() argument
538 mutex_lock(&msi->lock); in brcm_msi_free()
539 bitmap_release_region(&msi->used, hwirq, 0); in brcm_msi_free()
540 mutex_unlock(&msi->lock); in brcm_msi_free()
546 struct brcm_msi *msi = domain->host_data; in brcm_irq_domain_alloc() local
549 hwirq = brcm_msi_alloc(msi); in brcm_irq_domain_alloc()
564 struct brcm_msi *msi = irq_data_get_irq_chip_data(d); in brcm_irq_domain_free() local
566 brcm_msi_free(msi, d->hwirq); in brcm_irq_domain_free()
574 static int brcm_allocate_domains(struct brcm_msi *msi) in brcm_allocate_domains() argument
576 struct fwnode_handle *fwnode = of_node_to_fwnode(msi->np); in brcm_allocate_domains()
577 struct device *dev = msi->dev; in brcm_allocate_domains()
579 msi->inner_domain = irq_domain_add_linear(NULL, msi->nr, &msi_domain_ops, msi); in brcm_allocate_domains()
580 if (!msi->inner_domain) { in brcm_allocate_domains()
585 msi->msi_domain = pci_msi_create_irq_domain(fwnode, in brcm_allocate_domains()
587 msi->inner_domain); in brcm_allocate_domains()
588 if (!msi->msi_domain) { in brcm_allocate_domains()
589 dev_err(dev, "failed to create MSI domain\n"); in brcm_allocate_domains()
590 irq_domain_remove(msi->inner_domain); in brcm_allocate_domains()
597 static void brcm_free_domains(struct brcm_msi *msi) in brcm_free_domains() argument
599 irq_domain_remove(msi->msi_domain); in brcm_free_domains()
600 irq_domain_remove(msi->inner_domain); in brcm_free_domains()
605 struct brcm_msi *msi = pcie->msi; in brcm_msi_remove() local
607 if (!msi) in brcm_msi_remove()
609 irq_set_chained_handler(msi->irq, NULL); in brcm_msi_remove()
610 irq_set_handler_data(msi->irq, NULL); in brcm_msi_remove()
611 brcm_free_domains(msi); in brcm_msi_remove()
614 static void brcm_msi_set_regs(struct brcm_msi *msi) in brcm_msi_set_regs() argument
616 u32 val = __GENMASK(31, msi->legacy_shift); in brcm_msi_set_regs()
618 writel(val, msi->intr_base + MSI_INT_MASK_CLR); in brcm_msi_set_regs()
619 writel(val, msi->intr_base + MSI_INT_CLR); in brcm_msi_set_regs()
622 * The 0 bit of PCIE_MISC_MSI_BAR_CONFIG_LO is repurposed to MSI in brcm_msi_set_regs()
625 writel(lower_32_bits(msi->target_addr) | 0x1, in brcm_msi_set_regs()
626 msi->base + PCIE_MISC_MSI_BAR_CONFIG_LO); in brcm_msi_set_regs()
627 writel(upper_32_bits(msi->target_addr), in brcm_msi_set_regs()
628 msi->base + PCIE_MISC_MSI_BAR_CONFIG_HI); in brcm_msi_set_regs()
630 val = msi->legacy ? PCIE_MISC_MSI_DATA_CONFIG_VAL_8 : PCIE_MISC_MSI_DATA_CONFIG_VAL_32; in brcm_msi_set_regs()
631 writel(val, msi->base + PCIE_MISC_MSI_DATA_CONFIG); in brcm_msi_set_regs()
636 struct brcm_msi *msi; in brcm_pcie_enable_msi() local
642 dev_err(dev, "cannot map MSI interrupt\n"); in brcm_pcie_enable_msi()
646 msi = devm_kzalloc(dev, sizeof(struct brcm_msi), GFP_KERNEL); in brcm_pcie_enable_msi()
647 if (!msi) in brcm_pcie_enable_msi()
650 mutex_init(&msi->lock); in brcm_pcie_enable_msi()
651 msi->dev = dev; in brcm_pcie_enable_msi()
652 msi->base = pcie->base; in brcm_pcie_enable_msi()
653 msi->np = pcie->np; in brcm_pcie_enable_msi()
654 msi->target_addr = pcie->msi_target_addr; in brcm_pcie_enable_msi()
655 msi->irq = irq; in brcm_pcie_enable_msi()
656 msi->legacy = pcie->hw_rev < BRCM_PCIE_HW_REV_33; in brcm_pcie_enable_msi()
658 if (msi->legacy) { in brcm_pcie_enable_msi()
659 msi->intr_base = msi->base + PCIE_INTR2_CPU_BASE; in brcm_pcie_enable_msi()
660 msi->nr = BRCM_INT_PCI_MSI_LEGACY_NR; in brcm_pcie_enable_msi()
661 msi->legacy_shift = 24; in brcm_pcie_enable_msi()
663 msi->intr_base = msi->base + PCIE_MSI_INTR2_BASE; in brcm_pcie_enable_msi()
664 msi->nr = BRCM_INT_PCI_MSI_NR; in brcm_pcie_enable_msi()
665 msi->legacy_shift = 0; in brcm_pcie_enable_msi()
668 ret = brcm_allocate_domains(msi); in brcm_pcie_enable_msi()
672 irq_set_chained_handler_and_data(msi->irq, brcm_pcie_msi_isr, msi); in brcm_pcie_enable_msi()
674 brcm_msi_set_regs(msi); in brcm_pcie_enable_msi()
675 pcie->msi = msi; in brcm_pcie_enable_msi()
838 * only address 32bits. We would also like to put the MSI under 4GB in brcm_pcie_get_rc_bar2_size_and_offset()
839 * as well, since some devices require a 32bit MSI target address. in brcm_pcie_get_rc_bar2_size_and_offset()
927 * We ideally want the MSI target address to be located in the 32bit in brcm_pcie_setup()
1175 if (pcie->msi) in brcm_pcie_resume()
1176 brcm_msi_set_regs(pcie->msi); in brcm_pcie_resume()
1282 msi_np = of_parse_phandle(pcie->np, "msi-parent", 0); in brcm_pcie_probe()
1286 dev_err(pcie->dev, "probe of internal MSI failed"); in brcm_pcie_probe()