1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #ifndef INTEL_COMMON_ACPI_PIRQ_GEN_H
4 #define INTEL_COMMON_ACPI_PIRQ_GEN_H
7 #include <device/device.h>
17 PCI_INT_MAX
= PCI_INT_D
,
33 static inline size_t pirq_idx(enum pirq pirq
)
35 assert(pirq
> PIRQ_INVALID
&& pirq
<= PIRQ_H
);
36 return (size_t)(pirq
- PIRQ_A
);
40 * This struct represents an assignment of slot/pin -> IRQ. Some chipsets may
41 * want to provide both PIC-mode and APIC-mode IRQs (e.g. selected using PICM
42 * set by the OS), therefore a field for each of a PIRQ for PIC-mode and a
43 * GSI for APIC-mode are provided.
45 * For APIC mode, only GSIs are supported (`acpi_gsi`).
47 * For PIC mode, if the pirq_map_type is PIRQ_GSI, then `pic_pirq` is used as an
48 * index into `struct pic_pirq_map.gsi`, or for SOURCE_PATH, `pic_pirq` indexes
49 * into `struct pic_pirq_map.source_path` to pick the path to the LNKx device.
51 * The reasoning for this structure is related to older vs. newer Intel
52 * platforms; older platforms supported routing of PCI IRQs to a PIRQ
53 * only. Newer platforms support routing IRQs to either a PIRQ or (for some PCI
54 * devices) a non-PIRQ GSI.
56 struct slot_pin_irq_map
{
59 /* PIRQ # for PIC mode */
60 unsigned int pic_pirq
;
61 /* GSI # for APIC mode */
62 unsigned int apic_gsi
;
71 * A PIRQ can be either be statically assigned a GSI or OSPM can use the Methods
72 * on the ACPI device (source_path) to assign IRQs at runtime.
75 enum pirq_map_type type
;
77 unsigned int gsi
[PIRQ_COUNT
];
78 char source_path
[PIRQ_COUNT
][DEVICE_PATH_MAX
];
83 * Generate an ACPI _PRT table by providing PIRQ and/or GSI information for each
84 * slot/pin combination, and optionally providing paths to LNKx devices that can
85 * provide IRQs in PIC mode.
87 void intel_write_pci0_PRT(const struct slot_pin_irq_map
*pin_irq_map
,
88 unsigned int map_count
,
89 const struct pic_pirq_map
*pirq_map
);
91 bool is_slot_pin_assigned(const struct slot_pin_irq_map
*pin_irq_map
,
92 unsigned int map_count
, unsigned int slot
,