]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/x86/include/asm/i8259.h
x86/tsc: Allow TSC calibration without PIT
[mirror_ubuntu-bionic-kernel.git] / arch / x86 / include / asm / i8259.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1965aae3
PA
2#ifndef _ASM_X86_I8259_H
3#define _ASM_X86_I8259_H
1da177e4 4
bc0a733f
DR
5#include <linux/delay.h>
6
1da177e4
LT
7extern unsigned int cached_irq_mask;
8
ace4fdbb 9#define __byte(x, y) (((unsigned char *)&(y))[x])
1da177e4
LT
10#define cached_master_mask (__byte(0, cached_irq_mask))
11#define cached_slave_mask (__byte(1, cached_irq_mask))
12
f20ebee4
TG
13/* i8259A PIC registers */
14#define PIC_MASTER_CMD 0x20
15#define PIC_MASTER_IMR 0x21
16#define PIC_MASTER_ISR PIC_MASTER_CMD
17#define PIC_MASTER_POLL PIC_MASTER_ISR
18#define PIC_MASTER_OCW3 PIC_MASTER_ISR
19#define PIC_SLAVE_CMD 0xa0
20#define PIC_SLAVE_IMR 0xa1
21
22/* i8259A PIC related value */
23#define PIC_CASCADE_IR 2
24#define MASTER_ICW4_DEFAULT 0x01
25#define SLAVE_ICW4_DEFAULT 0x01
26#define PIC_ICW4_AEOI 2
27
5619c280 28extern raw_spinlock_t i8259A_lock;
1da177e4 29
bc0a733f
DR
30/* the PIC may need a careful delay on some platforms, hence specific calls */
31static inline unsigned char inb_pic(unsigned int port)
32{
33 unsigned char value = inb(port);
34
35 /*
36 * delay for some accesses to PIC on motherboard or in chipset
37 * must be at least one microsecond, so be safe here:
38 */
39 udelay(2);
40
41 return value;
42}
43
44static inline void outb_pic(unsigned char value, unsigned int port)
45{
46 outb(value, port);
47 /*
48 * delay for some accesses to PIC on motherboard or in chipset
49 * must be at least one microsecond, so be safe here:
50 */
51 udelay(2);
52}
466eed22 53
40bd2174
PM
54extern struct irq_chip i8259A_chip;
55
ef354866
JP
56struct legacy_pic {
57 int nr_legacy_irqs;
58 struct irq_chip *chip;
4305df94
TG
59 void (*mask)(unsigned int irq);
60 void (*unmask)(unsigned int irq);
ef354866
JP
61 void (*mask_all)(void);
62 void (*restore_mask)(void);
63 void (*init)(int auto_eoi);
8c058b0b 64 int (*probe)(void);
ef354866
JP
65 int (*irq_pending)(unsigned int irq);
66 void (*make_irq)(unsigned int irq);
67};
68
69extern struct legacy_pic *legacy_pic;
70extern struct legacy_pic null_legacy_pic;
71
faed5cdf
PZ
72static inline bool has_legacy_pic(void)
73{
74 return legacy_pic != &null_legacy_pic;
75}
76
95d76acc
JL
77static inline int nr_legacy_irqs(void)
78{
79 return legacy_pic->nr_legacy_irqs;
80}
81
1965aae3 82#endif /* _ASM_X86_I8259_H */