Lines Matching +full:irq +full:- +full:device

1 // SPDX-License-Identifier: GPL-2.0
3 * PCI IRQ handling code
9 #include <linux/device.h>
19 * pci_request_irq - allocate an interrupt line for a PCI device
20 * @dev: PCI device to operate on
21 * @nr: device-relative interrupt vector index (0-based).
22 * @handler: Function to be called when the IRQ occurs.
26 * @thread_fn: Function called from the IRQ handler thread
27 * If NULL, no IRQ thread is created
29 * @fmt: Printf-like format string naming the handler
32 * IRQ handling. From the point this call is made @handler and @thread_fn may
52 return -ENOMEM; in pci_request_irq()
63 * pci_free_irq - free an interrupt allocated with pci_request_irq
64 * @dev: PCI device to operate on
65 * @nr: device-relative interrupt vector index (0-based).
66 * @dev_id: Device identity to free
70 * ensure the interrupt is disabled on the device before calling this function.
71 * The function does not return until any executing interrupts for this IRQ
83 * pci_swizzle_interrupt_pin - swizzle INTx for device behind bridge
84 * @dev: the PCI device
87 * Perform INTx swizzling for a device behind one level of bridge. This is
88 * required by section 9.1 of the PCI-to-PCI bridge specification for devices
89 * behind bridges on add-in cards. For devices with ARI enabled, the slot
97 if (pci_ari_enabled(dev->bus)) in pci_swizzle_interrupt_pin()
100 slot = PCI_SLOT(dev->devfn); in pci_swizzle_interrupt_pin()
102 return (((pin - 1) + slot) % 4) + 1; in pci_swizzle_interrupt_pin()
109 pin = dev->pin; in pci_get_interrupt_pin()
111 return -1; in pci_get_interrupt_pin()
113 while (!pci_is_root_bus(dev->bus)) { in pci_get_interrupt_pin()
115 dev = dev->bus->self; in pci_get_interrupt_pin()
122 * pci_common_swizzle - swizzle INTx all the way to root bridge
123 * @dev: the PCI device
126 * Perform INTx swizzling for a device. This traverses through all PCI-to-PCI
133 while (!pci_is_root_bus(dev->bus)) { in pci_common_swizzle()
135 dev = dev->bus->self; in pci_common_swizzle()
138 return PCI_SLOT(dev->devfn); in pci_common_swizzle()
145 u8 slot = -1; in pci_assign_irq()
146 int irq = 0; in pci_assign_irq() local
147 struct pci_host_bridge *hbrg = pci_find_host_bridge(dev->bus); in pci_assign_irq()
149 if (!(hbrg->map_irq)) { in pci_assign_irq()
150 pci_dbg(dev, "runtime IRQ mapping not provided by arch\n"); in pci_assign_irq()
155 * If this device is not on the primary bus, we need to figure out in pci_assign_irq()
158 * time the interrupt line passes through a PCI-PCI bridge we must in pci_assign_irq()
168 if (hbrg->swizzle_irq) in pci_assign_irq()
169 slot = (*(hbrg->swizzle_irq))(dev, &pin); in pci_assign_irq()
175 irq = (*(hbrg->map_irq))(dev, slot, pin); in pci_assign_irq()
176 if (irq == -1) in pci_assign_irq()
177 irq = 0; in pci_assign_irq()
179 dev->irq = irq; in pci_assign_irq()
181 pci_dbg(dev, "assign IRQ: got %d\n", dev->irq); in pci_assign_irq()
184 * Always tell the device, so the driver knows what is the real IRQ in pci_assign_irq()
185 * to use; the device does not use it. in pci_assign_irq()
187 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); in pci_assign_irq()
192 struct pci_bus *bus = dev->bus; in pci_check_and_set_intx_mask()
208 bus->ops->read(bus, dev->devfn, PCI_COMMAND, 4, &cmd_status_dword); in pci_check_and_set_intx_mask()
213 * Check interrupt status register to see whether our device in pci_check_and_set_intx_mask()
214 * triggered the interrupt (when masking) or the next IRQ is in pci_check_and_set_intx_mask()
227 bus->ops->write(bus, dev->devfn, PCI_COMMAND, 2, newcmd); in pci_check_and_set_intx_mask()
236 * pci_check_and_mask_intx - mask INTx on pending interrupt
237 * @dev: the PCI device to operate on
239 * Check if the device dev has its INTx line asserted, mask it and return
249 * pci_check_and_unmask_intx - unmask INTx if no interrupt is pending
250 * @dev: the PCI device to operate on
252 * Check if the device dev has its INTx line asserted, unmask it if not and
263 * pcibios_penalize_isa_irq - penalize an ISA IRQ
264 * @irq: ISA IRQ to penalize
265 * @active: IRQ active or not
267 * Permits the platform to provide architecture-specific functionality when
271 void __weak pcibios_penalize_isa_irq(int irq, int active) {} in pcibios_penalize_isa_irq() argument