These changes are the raw update to qemu-2.6.
[kvmfornfv.git] / qemu / roms / ipxe / src / arch / x86 / include / ipxe / pit8254.h
1 #ifndef _IPXE_PIT8254_H
2 #define _IPXE_PIT8254_H
3
4 /** @file
5  *
6  * 8254 Programmable Interval Timer
7  *
8  */
9
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11
12 /** IRQ0 channel */
13 #define PIT8254_CH_IRQ0 0
14
15 /** PC speaker channel */
16 #define PIT8254_CH_SPKR 2
17
18 /** Timer frequency (1.193182MHz) */
19 #define PIT8254_HZ 1193182UL
20
21 /** Data port */
22 #define PIT8254_DATA(channel) ( 0x40 + (channel) )
23
24 /** Mode/command register */
25 #define PIT8254_CMD 0x43
26
27 /** Select channel */
28 #define PIT8254_CMD_CHANNEL(channel) ( (channel) << 6 )
29
30 /** Access modes */
31 #define PIT8254_CMD_ACCESS_LATCH 0x00   /**< Latch count value command */
32 #define PIT8254_CMD_ACCESS_LO   0x10    /**< Low byte only */
33 #define PIT8254_CMD_ACCESS_HI   0x20    /**< High byte only */
34 #define PIT8254_CMD_ACCESS_LOHI 0x30    /**< Low-byte, high-byte pair */
35
36 /* Operating modes */
37 #define PIT8254_CMD_OP_TERMINAL 0x00    /**< Interrupt on terminal count */
38 #define PIT8254_CMD_OP_ONESHOT  0x02    /**< Hardware re-triggerable one-shot */
39 #define PIT8254_CMD_OP_RATE     0x04    /**< Rate generator */
40 #define PIT8254_CMD_OP_SQUARE   0x06    /**< Square wave generator */
41 #define PIT8254_CMD_OP_SWSTROBE 0x08    /**< Software triggered strobe */
42 #define PIT8254_CMD_OP_HWSTROBE 0x0a    /**< Hardware triggered strobe */
43 #define PIT8254_CMD_OP_RATE2    0x0c    /**< Rate generator (duplicate) */
44 #define PIT8254_CMD_OP_SQUARE2  0x0e    /**< Square wave generator (duplicate)*/
45
46 /** Binary mode */
47 #define PIT8254_CMD_BINARY 0x00
48
49 /** BCD mode */
50 #define PIT8254_CMD_BCD 0x01
51
52 /** PC speaker control register */
53 #define PIT8254_SPKR 0x61
54
55 /** PC speaker channel gate */
56 #define PIT8254_SPKR_GATE 0x01
57
58 /** PC speaker enabled */
59 #define PIT8254_SPKR_ENABLE 0x02
60
61 /** PC speaker channel output */
62 #define PIT8254_SPKR_OUT 0x20
63
64 extern void pit8254_speaker_delay ( unsigned int ticks );
65
66 /**
67  * Delay for a fixed number of microseconds
68  *
69  * @v usecs             Number of microseconds for which to delay
70  */
71 static inline __attribute__ (( always_inline )) void
72 pit8254_udelay ( unsigned long usecs ) {
73
74         /* Delays are invariably compile-time constants; force the
75          * multiplication and division to take place at compilation
76          * time rather than runtime.
77          */
78         pit8254_speaker_delay ( ( usecs * PIT8254_HZ ) / 1000000 );
79 }
80
81 #endif /* _IPXE_PIT8254_H */