bcma: move PCI IRQ control function to host specific code
[firefly-linux-kernel-4.4.55.git] / drivers / bcma / host_pci.c
index a62a2f9091f529d8a9c7ccfdb607446accc6f676..0856189c065fd57826df7edab2dba3217d5e283c 100644 (file)
@@ -351,3 +351,37 @@ void bcma_host_pci_down(struct bcma_bus *bus)
                bcma_core_pci_down(&bus->drv_pci[0]);
 }
 EXPORT_SYMBOL_GPL(bcma_host_pci_down);
+
+/* See also si_pci_setup */
+int bcma_host_pci_irq_ctl(struct bcma_bus *bus, struct bcma_device *core,
+                         bool enable)
+{
+       struct pci_dev *pdev;
+       u32 coremask, tmp;
+       int err = 0;
+
+       if (bus->hosttype != BCMA_HOSTTYPE_PCI) {
+               /* This bcma device is not on a PCI host-bus. So the IRQs are
+                * not routed through the PCI core.
+                * So we must not enable routing through the PCI core. */
+               goto out;
+       }
+
+       pdev = bus->host_pci;
+
+       err = pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp);
+       if (err)
+               goto out;
+
+       coremask = BIT(core->core_index) << 8;
+       if (enable)
+               tmp |= coremask;
+       else
+               tmp &= ~coremask;
+
+       err = pci_write_config_dword(pdev, BCMA_PCI_IRQMASK, tmp);
+
+out:
+       return err;
+}
+EXPORT_SYMBOL_GPL(bcma_host_pci_irq_ctl);