blob: a20365953bf8a7727285029f3c6d84ba56f941a0 [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_I8259_H
2#define _ASM_X86_I8259_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
David P. Reedbc0a7332008-02-18 13:58:34 -05004#include <linux/delay.h>
5
Linus Torvalds1da177e2005-04-16 15:20:36 -07006extern unsigned int cached_irq_mask;
7
Joe Perchesace4fdb2008-03-23 01:02:19 -07008#define __byte(x, y) (((unsigned char *)&(y))[x])
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#define cached_master_mask (__byte(0, cached_irq_mask))
10#define cached_slave_mask (__byte(1, cached_irq_mask))
11
Thomas Gleixnerf20ebee2008-01-30 13:30:29 +010012/* i8259A PIC registers */
13#define PIC_MASTER_CMD 0x20
14#define PIC_MASTER_IMR 0x21
15#define PIC_MASTER_ISR PIC_MASTER_CMD
16#define PIC_MASTER_POLL PIC_MASTER_ISR
17#define PIC_MASTER_OCW3 PIC_MASTER_ISR
18#define PIC_SLAVE_CMD 0xa0
19#define PIC_SLAVE_IMR 0xa1
20
21/* i8259A PIC related value */
22#define PIC_CASCADE_IR 2
23#define MASTER_ICW4_DEFAULT 0x01
24#define SLAVE_ICW4_DEFAULT 0x01
25#define PIC_ICW4_AEOI 2
26
Thomas Gleixner5619c282009-07-25 18:35:11 +020027extern raw_spinlock_t i8259A_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
David P. Reedbc0a7332008-02-18 13:58:34 -050029/* the PIC may need a careful delay on some platforms, hence specific calls */
30static inline unsigned char inb_pic(unsigned int port)
31{
32 unsigned char value = inb(port);
33
34 /*
35 * delay for some accesses to PIC on motherboard or in chipset
36 * must be at least one microsecond, so be safe here:
37 */
38 udelay(2);
39
40 return value;
41}
42
43static inline void outb_pic(unsigned char value, unsigned int port)
44{
45 outb(value, port);
46 /*
47 * delay for some accesses to PIC on motherboard or in chipset
48 * must be at least one microsecond, so be safe here:
49 */
50 udelay(2);
51}
Alan Cox466eed22008-01-30 13:33:14 +010052
Pavel Machek40bd2172008-05-21 11:44:02 +020053extern struct irq_chip i8259A_chip;
54
Jacob Panef354862009-11-09 11:24:14 -080055struct legacy_pic {
56 int nr_legacy_irqs;
57 struct irq_chip *chip;
Thomas Gleixner4305df92010-09-28 15:01:33 +020058 void (*mask)(unsigned int irq);
59 void (*unmask)(unsigned int irq);
Jacob Panef354862009-11-09 11:24:14 -080060 void (*mask_all)(void);
61 void (*restore_mask)(void);
62 void (*init)(int auto_eoi);
63 int (*irq_pending)(unsigned int irq);
64 void (*make_irq)(unsigned int irq);
65};
66
67extern struct legacy_pic *legacy_pic;
68extern struct legacy_pic null_legacy_pic;
69
H. Peter Anvin1965aae2008-10-22 22:26:29 -070070#endif /* _ASM_X86_I8259_H */