Merge tag 'rtc-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
[linux-2.6-block.git] / arch / x86 / include / asm / io_apic.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1965aae3
PA
2#ifndef _ASM_X86_IO_APIC_H
3#define _ASM_X86_IO_APIC_H
e1d91978 4
a1a33fa3 5#include <linux/types.h>
e1d91978
TG
6#include <asm/mpspec.h>
7#include <asm/apicdef.h>
9d6a4d08 8#include <asm/irq_vectors.h>
4a8e2a31 9#include <asm/x86_init.h>
e1d91978
TG
10/*
11 * Intel IO-APIC support for SMP and UP systems.
12 *
13 * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar
14 */
15
16/*
17 * The structure of the IO-APIC:
18 */
19union IO_APIC_reg_00 {
20 u32 raw;
21 struct {
22 u32 __reserved_2 : 14,
23 LTS : 1,
24 delivery_type : 1,
25 __reserved_1 : 8,
26 ID : 8;
27 } __attribute__ ((packed)) bits;
28};
29
30union IO_APIC_reg_01 {
31 u32 raw;
32 struct {
33 u32 version : 8,
34 __reserved_2 : 7,
35 PRQ : 1,
36 entries : 8,
37 __reserved_1 : 8;
38 } __attribute__ ((packed)) bits;
39};
40
41union IO_APIC_reg_02 {
42 u32 raw;
43 struct {
44 u32 __reserved_2 : 24,
45 arbitration : 4,
46 __reserved_1 : 4;
47 } __attribute__ ((packed)) bits;
48};
49
50union IO_APIC_reg_03 {
51 u32 raw;
52 struct {
53 u32 boot_DT : 1,
54 __reserved_1 : 31;
55 } __attribute__ ((packed)) bits;
56};
57
e1d91978 58struct IO_APIC_route_entry {
341b4a72
TG
59 union {
60 struct {
61 u64 vector : 8,
62 delivery_mode : 3,
63 dest_mode_logical : 1,
64 delivery_status : 1,
65 active_low : 1,
66 irr : 1,
67 is_level : 1,
68 masked : 1,
69 reserved_0 : 15,
51130d21
DW
70 reserved_1 : 17,
71 virt_destid_8_14 : 7,
341b4a72
TG
72 destid_0_7 : 8;
73 };
74 struct {
75 u64 ir_shared_0 : 8,
76 ir_zero : 3,
77 ir_index_15 : 1,
78 ir_shared_1 : 5,
79 ir_reserved_0 : 31,
80 ir_format : 1,
81 ir_index_0_14 : 15;
82 };
83 struct {
84 u64 w1 : 32,
85 w2 : 32;
86 };
87 };
e1d91978
TG
88} __attribute__ ((packed));
89
c4d05a2c 90struct irq_alloc_info;
f7a0c786 91struct ioapic_domain_cfg;
c4d05a2c 92
d7f3d478
JL
93#define IOAPIC_MAP_ALLOC 0x1
94#define IOAPIC_MAP_CHECK 0x2
abb00522 95
e1d91978
TG
96#ifdef CONFIG_X86_IO_APIC
97
98/*
99 * # of IO-APICs and # of IRQ routing registers
100 */
101extern int nr_ioapics;
e1d91978 102
d5371430
SS
103extern int mpc_ioapic_id(int ioapic);
104extern unsigned int mpc_ioapic_addr(int ioapic);
e1d91978
TG
105
106/* # of MP IRQ source entries */
107extern int mp_irq_entries;
108
109/* MP IRQ source entries */
c2c21745 110extern struct mpc_intsrc mp_irqs[MAX_IRQ_SOURCES];
e1d91978 111
ecf600f8
TG
112/* True if "noapic" boot option passed */
113extern bool ioapic_is_disabled;
e1d91978 114
a9322f64
SA
115/* 1 if "noapic" boot option passed */
116extern int noioapicquirk;
117
9197979b
SA
118/* -1 if "noapic" boot option passed */
119extern int noioapicreroute;
120
154d9e50
JL
121extern u32 gsi_top;
122
8643e28d
JL
123extern unsigned long io_apic_irqs;
124
125#define IO_APIC_IRQ(x) (((x) >= NR_IRQS_LEGACY) || ((1 << (x)) & io_apic_irqs))
126
e1d91978
TG
127/*
128 * If we use the IO-APIC for IRQ routing, disable automatic
129 * assignment of PCI IRQ's.
130 */
131#define io_apic_assign_pci_irqs \
ecf600f8 132 (mp_irq_entries && !ioapic_is_disabled && io_apic_irqs)
e1d91978 133
9b1b0e42 134struct irq_cfg;
857fdc53 135extern void ioapic_insert_resources(void);
11d686e9 136extern int arch_early_ioapic_init(void);
e1d91978 137
31dce14a
SS
138extern int save_ioapic_entries(void);
139extern void mask_ioapic_entries(void);
140extern int restore_ioapic_entries(void);
4dc2f96c 141
de934103 142extern void setup_ioapic_ids_from_mpc(void);
a38c5380 143extern void setup_ioapic_ids_from_mpc_nocheck(void);
2a4ab640 144
3eb2be5f
JL
145extern int mp_find_ioapic(u32 gsi);
146extern int mp_find_ioapic_pin(int ioapic, u32 gsi);
c4d05a2c
JL
147extern int mp_map_gsi_to_irq(u32 gsi, unsigned int flags,
148 struct irq_alloc_info *info);
df334bea 149extern void mp_unmap_irq(int irq);
35ef9c94
JL
150extern int mp_register_ioapic(int id, u32 address, u32 gsi_base,
151 struct ioapic_domain_cfg *cfg);
15516a3b 152extern int mp_unregister_ioapic(u32 gsi_base);
e89900c9 153extern int mp_ioapic_registered(u32 gsi_base);
f7a0c786 154
c4d05a2c
JL
155extern void ioapic_set_alloc_attr(struct irq_alloc_info *info,
156 int node, int trigger, int polarity);
2a4ab640 157
2d8009ba
FT
158extern void mp_save_irq(struct mpc_intsrc *m);
159
7167d08e
HK
160extern void disable_ioapic_support(void);
161
ca1b8862 162extern void __init io_apic_init_mappings(void);
4a8e2a31 163extern unsigned int native_io_apic_read(unsigned int apic, unsigned int reg);
51b146c5 164extern void native_restore_boot_irq_mode(void);
4a8e2a31
KRW
165
166static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
167{
51b146c5 168 return x86_apic_ops.io_apic_read(apic, reg);
4a8e2a31
KRW
169}
170
8643e28d
JL
171extern void setup_IO_APIC(void);
172extern void enable_IO_APIC(void);
3c9e76db 173extern void clear_IO_APIC(void);
ce279cdc 174extern void restore_boot_irq_mode(void);
8643e28d
JL
175extern int IO_APIC_get_PCI_irq_vector(int bus, int devfn, int pin);
176extern void print_IO_APICs(void);
e1d91978 177#else /* !CONFIG_X86_IO_APIC */
78f28b7c 178
8643e28d 179#define IO_APIC_IRQ(x) 0
e1d91978 180#define io_apic_assign_pci_irqs 0
de934103 181#define setup_ioapic_ids_from_mpc x86_init_noop
ecf600f8 182#define nr_ioapics (0)
857fdc53 183static inline void ioapic_insert_resources(void) { }
11d686e9 184static inline int arch_early_ioapic_init(void) { return 0; }
8643e28d 185static inline void print_IO_APICs(void) {}
a4384df3 186#define gsi_top (NR_IRQS_LEGACY)
eddb0c55 187static inline int mp_find_ioapic(u32 gsi) { return 0; }
c4d05a2c
JL
188static inline int mp_map_gsi_to_irq(u32 gsi, unsigned int flags,
189 struct irq_alloc_info *info)
190{
191 return gsi;
192}
193
df334bea 194static inline void mp_unmap_irq(int irq) { }
78f28b7c 195
31dce14a 196static inline int save_ioapic_entries(void)
7d0f1926
HK
197{
198 return -ENOMEM;
199}
200
31dce14a
SS
201static inline void mask_ioapic_entries(void) { }
202static inline int restore_ioapic_entries(void)
7d0f1926
HK
203{
204 return -ENOMEM;
205}
206
ca1b8862 207static inline void mp_save_irq(struct mpc_intsrc *m) { }
7167d08e 208static inline void disable_ioapic_support(void) { }
ca1b8862 209static inline void io_apic_init_mappings(void) { }
4a8e2a31 210#define native_io_apic_read NULL
51b146c5 211#define native_restore_boot_irq_mode NULL
86866083
TG
212
213static inline void setup_IO_APIC(void) { }
214static inline void enable_IO_APIC(void) { }
ce279cdc 215static inline void restore_boot_irq_mode(void) { }
86866083 216
96a388de 217#endif
e1d91978 218
1965aae3 219#endif /* _ASM_X86_IO_APIC_H */