91b064da6ce5f6d816ae3919f52abeba53b63d59
[linux-2.6-microblaze.git] / arch / x86 / include / asm / hw_irq.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_HW_IRQ_H
3 #define _ASM_X86_HW_IRQ_H
4
5 /*
6  * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar
7  *
8  * moved some of the old arch/i386/kernel/irq.h to here. VY
9  *
10  * IRQ/IPI changes taken from work by Thomas Radke
11  * <tomsoft@informatik.tu-chemnitz.de>
12  *
13  * hacked by Andi Kleen for x86-64.
14  * unified by tglx
15  */
16
17 #include <asm/irq_vectors.h>
18
19 #define IRQ_MATRIX_BITS         NR_VECTORS
20
21 #ifndef __ASSEMBLY__
22
23 #include <linux/percpu.h>
24 #include <linux/profile.h>
25 #include <linux/smp.h>
26
27 #include <linux/atomic.h>
28 #include <asm/irq.h>
29 #include <asm/sections.h>
30
31 #ifdef  CONFIG_X86_LOCAL_APIC
32 struct irq_data;
33 struct pci_dev;
34 struct msi_desc;
35
36 enum irq_alloc_type {
37         X86_IRQ_ALLOC_TYPE_IOAPIC = 1,
38         X86_IRQ_ALLOC_TYPE_HPET,
39         X86_IRQ_ALLOC_TYPE_PCI_MSI,
40         X86_IRQ_ALLOC_TYPE_PCI_MSIX,
41         X86_IRQ_ALLOC_TYPE_DMAR,
42         X86_IRQ_ALLOC_TYPE_UV,
43         X86_IRQ_ALLOC_TYPE_IOAPIC_GET_PARENT,
44         X86_IRQ_ALLOC_TYPE_HPET_GET_PARENT,
45 };
46
47 struct irq_alloc_info {
48         enum irq_alloc_type     type;
49         u32                     flags;
50         const struct cpumask    *mask;  /* CPU mask for vector allocation */
51         union {
52                 int             unused;
53 #ifdef  CONFIG_HPET_TIMER
54                 struct {
55                         int             hpet_id;
56                         int             hpet_index;
57                         void            *hpet_data;
58                 };
59 #endif
60 #ifdef  CONFIG_PCI_MSI
61                 struct {
62                         struct pci_dev  *msi_dev;
63                         irq_hw_number_t msi_hwirq;
64                 };
65 #endif
66 #ifdef  CONFIG_X86_IO_APIC
67                 struct {
68                         int             ioapic_id;
69                         int             ioapic_pin;
70                         int             ioapic_node;
71                         u32             ioapic_trigger : 1;
72                         u32             ioapic_polarity : 1;
73                         u32             ioapic_valid : 1;
74                         struct IO_APIC_route_entry *ioapic_entry;
75                 };
76 #endif
77 #ifdef  CONFIG_DMAR_TABLE
78                 struct {
79                         int             dmar_id;
80                         void            *dmar_data;
81                 };
82 #endif
83 #ifdef  CONFIG_X86_UV
84                 struct {
85                         int             uv_limit;
86                         int             uv_blade;
87                         unsigned long   uv_offset;
88                         char            *uv_name;
89                 };
90 #endif
91 #if IS_ENABLED(CONFIG_VMD)
92                 struct {
93                         struct msi_desc *desc;
94                 };
95 #endif
96         };
97 };
98
99 struct irq_cfg {
100         unsigned int            dest_apicid;
101         unsigned int            vector;
102 };
103
104 extern struct irq_cfg *irq_cfg(unsigned int irq);
105 extern struct irq_cfg *irqd_cfg(struct irq_data *irq_data);
106 extern void lock_vector_lock(void);
107 extern void unlock_vector_lock(void);
108 #ifdef CONFIG_SMP
109 extern void send_cleanup_vector(struct irq_cfg *);
110 extern void irq_complete_move(struct irq_cfg *cfg);
111 #else
112 static inline void send_cleanup_vector(struct irq_cfg *c) { }
113 static inline void irq_complete_move(struct irq_cfg *c) { }
114 #endif
115
116 extern void apic_ack_edge(struct irq_data *data);
117 #else   /*  CONFIG_X86_LOCAL_APIC */
118 static inline void lock_vector_lock(void) {}
119 static inline void unlock_vector_lock(void) {}
120 #endif  /* CONFIG_X86_LOCAL_APIC */
121
122 /* Statistics */
123 extern atomic_t irq_err_count;
124 extern atomic_t irq_mis_count;
125
126 extern void elcr_set_level_irq(unsigned int irq);
127
128 extern char irq_entries_start[];
129 #ifdef CONFIG_TRACING
130 #define trace_irq_entries_start irq_entries_start
131 #endif
132
133 extern char spurious_entries_start[];
134
135 #define VECTOR_UNUSED           NULL
136 #define VECTOR_SHUTDOWN         ((void *)-1L)
137 #define VECTOR_RETRIGGERED      ((void *)-2L)
138
139 typedef struct irq_desc* vector_irq_t[NR_VECTORS];
140 DECLARE_PER_CPU(vector_irq_t, vector_irq);
141
142 #endif /* !ASSEMBLY_ */
143
144 #endif /* _ASM_X86_HW_IRQ_H */