1#ifndef HW_ICH9_H
2#define HW_ICH9_H
3
4#include "hw/hw.h"
5#include "hw/isa/isa.h"
6#include "hw/sysbus.h"
7#include "hw/i386/pc.h"
8#include "hw/isa/apm.h"
9#include "hw/i386/ioapic.h"
10#include "hw/pci/pci.h"
11#include "hw/pci/pcie_host.h"
12#include "hw/pci/pci_bridge.h"
13#include "hw/acpi/acpi.h"
14#include "hw/acpi/ich9.h"
15#include "hw/pci/pci_bus.h"
16
17void ich9_lpc_set_irq(void *opaque, int irq_num, int level);
18int ich9_lpc_map_irq(PCIDevice *pci_dev, int intx);
19PCIINTxRoute ich9_route_intx_pin_to_irq(void *opaque, int pirq_pin);
20void ich9_lpc_pm_init(PCIDevice *pci_lpc, bool smm_enabled);
21I2CBus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base);
22
23void ich9_generate_smi(void);
24void ich9_generate_nmi(void);
25
26#define ICH9_CC_SIZE (16 * 1024)
27
28#define TYPE_ICH9_LPC_DEVICE "ICH9-LPC"
29#define ICH9_LPC_DEVICE(obj) \
30 OBJECT_CHECK(ICH9LPCState, (obj), TYPE_ICH9_LPC_DEVICE)
31
32typedef struct ICH9LPCState {
33
34 PCIDevice d;
35
36
37
38
39
40
41
42
43 uint8_t irr[PCI_SLOT_MAX][PCI_NUM_PINS];
44
45 APMState apm;
46 ICH9LPCPMRegs pm;
47 uint32_t sci_level;
48 uint8_t sci_gsi;
49
50
51 struct {
52 bool spkr_hi;
53 } pin_strap;
54
55
56
57 uint8_t chip_config[ICH9_CC_SIZE];
58
59
60
61
62
63
64 uint8_t rst_cnt;
65 MemoryRegion rst_cnt_mem;
66
67
68 ISABus *isa_bus;
69 MemoryRegion rcrb_mem;
70 Notifier machine_ready;
71
72 qemu_irq gsi[GSI_NUM_PINS];
73} ICH9LPCState;
74
75Object *ich9_lpc_find(void);
76
77#define Q35_MASK(bit, ms_bit, ls_bit) \
78((uint##bit##_t)(((1ULL << ((ms_bit) + 1)) - 1) & ~((1ULL << ls_bit) - 1)))
79
80
81#define ICH9_CC_ADDR_MASK (ICH9_CC_SIZE - 1)
82
83#define ICH9_CC
84#define ICH9_CC_D28IP 0x310C
85#define ICH9_CC_D28IP_SHIFT 4
86#define ICH9_CC_D28IP_MASK 0xf
87#define ICH9_CC_D28IP_DEFAULT 0x00214321
88#define ICH9_CC_D31IR 0x3140
89#define ICH9_CC_D30IR 0x3142
90#define ICH9_CC_D29IR 0x3144
91#define ICH9_CC_D28IR 0x3146
92#define ICH9_CC_D27IR 0x3148
93#define ICH9_CC_D26IR 0x314C
94#define ICH9_CC_D25IR 0x3150
95#define ICH9_CC_DIR_DEFAULT 0x3210
96#define ICH9_CC_D30IR_DEFAULT 0x0
97#define ICH9_CC_DIR_SHIFT 4
98#define ICH9_CC_DIR_MASK 0x7
99#define ICH9_CC_OIC 0x31FF
100#define ICH9_CC_OIC_AEN 0x1
101#define ICH9_CC_GCS 0x3410
102#define ICH9_CC_GCS_DEFAULT 0x00000020
103#define ICH9_CC_GCS_NO_REBOOT (1 << 5)
104
105
106#define ICH9_PCIE_DEV 28
107#define ICH9_PCIE_FUNC_MAX 6
108
109
110
111#define ICH9_USB_UHCI1_DEV 29
112#define ICH9_USB_UHCI1_FUNC 0
113
114
115#define ICH9_D2P_BRIDGE "ICH9 D2P BRIDGE"
116#define ICH9_D2P_BRIDGE_SAVEVM_VERSION 0
117
118#define ICH9_D2P_BRIDGE_DEV 30
119#define ICH9_D2P_BRIDGE_FUNC 0
120
121#define ICH9_D2P_SECONDARY_DEFAULT (256 - 8)
122
123#define ICH9_D2P_A2_REVISION 0x92
124
125
126#define ICH9_RST_CNT_IOPORT 0xCF9
127
128
129#define ICH9_A2_LPC "ICH9 A2 LPC"
130#define ICH9_A2_LPC_SAVEVM_VERSION 0
131
132#define ICH9_LPC_DEV 31
133#define ICH9_LPC_FUNC 0
134
135#define ICH9_A2_LPC_REVISION 0x2
136#define ICH9_LPC_NB_PIRQS 8
137
138#define ICH9_LPC_PMBASE 0x40
139#define ICH9_LPC_PMBASE_BASE_ADDRESS_MASK Q35_MASK(32, 15, 7)
140#define ICH9_LPC_PMBASE_RTE 0x1
141#define ICH9_LPC_PMBASE_DEFAULT 0x1
142#define ICH9_LPC_ACPI_CTRL 0x44
143#define ICH9_LPC_ACPI_CTRL_ACPI_EN 0x80
144#define ICH9_LPC_ACPI_CTRL_SCI_IRQ_SEL_MASK Q35_MASK(8, 2, 0)
145#define ICH9_LPC_ACPI_CTRL_9 0x0
146#define ICH9_LPC_ACPI_CTRL_10 0x1
147#define ICH9_LPC_ACPI_CTRL_11 0x2
148#define ICH9_LPC_ACPI_CTRL_20 0x4
149#define ICH9_LPC_ACPI_CTRL_21 0x5
150#define ICH9_LPC_ACPI_CTRL_DEFAULT 0x0
151
152#define ICH9_LPC_PIRQA_ROUT 0x60
153#define ICH9_LPC_PIRQB_ROUT 0x61
154#define ICH9_LPC_PIRQC_ROUT 0x62
155#define ICH9_LPC_PIRQD_ROUT 0x63
156
157#define ICH9_LPC_PIRQE_ROUT 0x68
158#define ICH9_LPC_PIRQF_ROUT 0x69
159#define ICH9_LPC_PIRQG_ROUT 0x6a
160#define ICH9_LPC_PIRQH_ROUT 0x6b
161
162#define ICH9_LPC_PIRQ_ROUT_IRQEN 0x80
163#define ICH9_LPC_PIRQ_ROUT_MASK Q35_MASK(8, 3, 0)
164#define ICH9_LPC_PIRQ_ROUT_DEFAULT 0x80
165
166#define ICH9_LPC_GEN_PMCON_1 0xa0
167#define ICH9_LPC_GEN_PMCON_1_SMI_LOCK (1 << 4)
168#define ICH9_LPC_GEN_PMCON_2 0xa2
169#define ICH9_LPC_GEN_PMCON_3 0xa4
170#define ICH9_LPC_GEN_PMCON_LOCK 0xa6
171
172#define ICH9_LPC_RCBA 0xf0
173#define ICH9_LPC_RCBA_BA_MASK Q35_MASK(32, 31, 14)
174#define ICH9_LPC_RCBA_EN 0x1
175#define ICH9_LPC_RCBA_DEFAULT 0x0
176
177#define ICH9_LPC_PIC_NUM_PINS 16
178#define ICH9_LPC_IOAPIC_NUM_PINS 24
179
180#define ICH9_GPIO_GSI "gsi"
181
182
183#define ICH9_SATA1_DEV 31
184#define ICH9_SATA1_FUNC 2
185
186
187
188
189
190#define ICH9_PMIO_SIZE 128
191#define ICH9_PMIO_MASK (ICH9_PMIO_SIZE - 1)
192
193#define ICH9_PMIO_PM1_STS 0x00
194#define ICH9_PMIO_PM1_EN 0x02
195#define ICH9_PMIO_PM1_CNT 0x04
196#define ICH9_PMIO_PM1_TMR 0x08
197#define ICH9_PMIO_GPE0_STS 0x20
198#define ICH9_PMIO_GPE0_EN 0x28
199#define ICH9_PMIO_GPE0_LEN 16
200#define ICH9_PMIO_SMI_EN 0x30
201#define ICH9_PMIO_SMI_EN_APMC_EN (1 << 5)
202#define ICH9_PMIO_SMI_EN_TCO_EN (1 << 13)
203#define ICH9_PMIO_SMI_STS 0x34
204#define ICH9_PMIO_TCO_RLD 0x60
205#define ICH9_PMIO_TCO_LEN 32
206
207
208#define ICH9_APM_ACPI_ENABLE 0x2
209#define ICH9_APM_ACPI_DISABLE 0x3
210
211
212
213#define TYPE_ICH9_SMB_DEVICE "ICH9 SMB"
214
215#define ICH9_A2_SMB_REVISION 0x02
216#define ICH9_SMB_PI 0x00
217
218#define ICH9_SMB_SMBMBAR0 0x10
219#define ICH9_SMB_SMBMBAR1 0x14
220#define ICH9_SMB_SMBM_BAR 0
221#define ICH9_SMB_SMBM_SIZE (1 << 8)
222#define ICH9_SMB_SMB_BASE 0x20
223#define ICH9_SMB_SMB_BASE_BAR 4
224#define ICH9_SMB_SMB_BASE_SIZE (1 << 5)
225#define ICH9_SMB_HOSTC 0x40
226#define ICH9_SMB_HOSTC_SSRESET ((uint8_t)(1 << 3))
227#define ICH9_SMB_HOSTC_I2C_EN ((uint8_t)(1 << 2))
228#define ICH9_SMB_HOSTC_SMB_SMI_EN ((uint8_t)(1 << 1))
229#define ICH9_SMB_HOSTC_HST_EN ((uint8_t)(1 << 0))
230
231
232#define ICH9_SMB_DEV 31
233#define ICH9_SMB_FUNC 3
234
235#define ICH9_SMB_HST_STS 0x00
236#define ICH9_SMB_HST_CNT 0x02
237#define ICH9_SMB_HST_CMD 0x03
238#define ICH9_SMB_XMIT_SLVA 0x04
239#define ICH9_SMB_HST_D0 0x05
240#define ICH9_SMB_HST_D1 0x06
241#define ICH9_SMB_HOST_BLOCK_DB 0x07
242
243#endif
244