11a6981bbSBernhard Beschow #ifndef HW_SOUTHBRIDGE_ICH9_H 21a6981bbSBernhard Beschow #define HW_SOUTHBRIDGE_ICH9_H 31a6981bbSBernhard Beschow 41a6981bbSBernhard Beschow #include "hw/isa/apm.h" 51a6981bbSBernhard Beschow #include "hw/acpi/ich9.h" 61a6981bbSBernhard Beschow #include "hw/intc/ioapic.h" 71a6981bbSBernhard Beschow #include "hw/pci/pci.h" 81a6981bbSBernhard Beschow #include "hw/pci/pci_device.h" 9f0bc6bf7SBernhard Beschow #include "hw/rtc/mc146818rtc.h" 101a6981bbSBernhard Beschow #include "exec/memory.h" 111a6981bbSBernhard Beschow #include "qemu/notify.h" 121a6981bbSBernhard Beschow #include "qom/object.h" 131a6981bbSBernhard Beschow 141a6981bbSBernhard Beschow void ich9_generate_smi(void); 151a6981bbSBernhard Beschow 161a6981bbSBernhard Beschow #define ICH9_CC_SIZE (16 * 1024) /* 16KB. Chipset configuration registers */ 171a6981bbSBernhard Beschow 181a6981bbSBernhard Beschow #define TYPE_ICH9_LPC_DEVICE "ICH9-LPC" 191a6981bbSBernhard Beschow OBJECT_DECLARE_SIMPLE_TYPE(ICH9LPCState, ICH9_LPC_DEVICE) 201a6981bbSBernhard Beschow 211a6981bbSBernhard Beschow struct ICH9LPCState { 221a6981bbSBernhard Beschow /* ICH9 LPC PCI to ISA bridge */ 231a6981bbSBernhard Beschow PCIDevice d; 241a6981bbSBernhard Beschow 251a6981bbSBernhard Beschow /* (pci device, intx) -> pirq 261a6981bbSBernhard Beschow * In real chipset case, the unused slots are never used 271a6981bbSBernhard Beschow * as ICH9 supports only D25-D31 irq routing. 281a6981bbSBernhard Beschow * On the other hand in qemu case, any slot/function can be populated 291a6981bbSBernhard Beschow * via command line option. 301a6981bbSBernhard Beschow * So fallback interrupt routing for any devices in any slots is necessary. 311a6981bbSBernhard Beschow */ 321a6981bbSBernhard Beschow uint8_t irr[PCI_SLOT_MAX][PCI_NUM_PINS]; 331a6981bbSBernhard Beschow 34f0bc6bf7SBernhard Beschow MC146818RtcState rtc; 351a6981bbSBernhard Beschow APMState apm; 361a6981bbSBernhard Beschow ICH9LPCPMRegs pm; 371a6981bbSBernhard Beschow uint32_t sci_level; /* track sci level */ 381a6981bbSBernhard Beschow uint8_t sci_gsi; 391a6981bbSBernhard Beschow 401a6981bbSBernhard Beschow /* 2.24 Pin Straps */ 411a6981bbSBernhard Beschow struct { 421a6981bbSBernhard Beschow bool spkr_hi; 431a6981bbSBernhard Beschow } pin_strap; 441a6981bbSBernhard Beschow 451a6981bbSBernhard Beschow /* 10.1 Chipset Configuration registers(Memory Space) 461a6981bbSBernhard Beschow which is pointed by RCBA */ 471a6981bbSBernhard Beschow uint8_t chip_config[ICH9_CC_SIZE]; 481a6981bbSBernhard Beschow 491a6981bbSBernhard Beschow /* 501a6981bbSBernhard Beschow * 13.7.5 RST_CNT---Reset Control Register (LPC I/F---D31:F0) 511a6981bbSBernhard Beschow * 521a6981bbSBernhard Beschow * register contents and IO memory region 531a6981bbSBernhard Beschow */ 541a6981bbSBernhard Beschow uint8_t rst_cnt; 551a6981bbSBernhard Beschow MemoryRegion rst_cnt_mem; 561a6981bbSBernhard Beschow 571a6981bbSBernhard Beschow /* SMI feature negotiation via fw_cfg */ 581a6981bbSBernhard Beschow uint64_t smi_host_features; /* guest-invisible, host endian */ 591a6981bbSBernhard Beschow uint8_t smi_host_features_le[8]; /* guest-visible, read-only, little 601a6981bbSBernhard Beschow * endian uint64_t */ 611a6981bbSBernhard Beschow uint8_t smi_guest_features_le[8]; /* guest-visible, read-write, little 621a6981bbSBernhard Beschow * endian uint64_t */ 631a6981bbSBernhard Beschow uint8_t smi_features_ok; /* guest-visible, read-only; selecting it 641a6981bbSBernhard Beschow * triggers feature lockdown */ 651a6981bbSBernhard Beschow uint64_t smi_negotiated_features; /* guest-invisible, host endian */ 661a6981bbSBernhard Beschow 671a6981bbSBernhard Beschow MemoryRegion rcrb_mem; /* root complex register block */ 681a6981bbSBernhard Beschow Notifier machine_ready; 691a6981bbSBernhard Beschow 701a6981bbSBernhard Beschow qemu_irq gsi[IOAPIC_NUM_PINS]; 711a6981bbSBernhard Beschow }; 721a6981bbSBernhard Beschow 731a6981bbSBernhard Beschow #define ICH9_MASK(bit, ms_bit, ls_bit) \ 741a6981bbSBernhard Beschow ((uint##bit##_t)(((1ULL << ((ms_bit) + 1)) - 1) & ~((1ULL << ls_bit) - 1))) 751a6981bbSBernhard Beschow 761a6981bbSBernhard Beschow /* ICH9: Chipset Configuration Registers */ 771a6981bbSBernhard Beschow #define ICH9_CC_ADDR_MASK (ICH9_CC_SIZE - 1) 781a6981bbSBernhard Beschow 791a6981bbSBernhard Beschow #define ICH9_CC 801a6981bbSBernhard Beschow #define ICH9_CC_D28IP 0x310C 811a6981bbSBernhard Beschow #define ICH9_CC_D28IP_SHIFT 4 821a6981bbSBernhard Beschow #define ICH9_CC_D28IP_MASK 0xf 831a6981bbSBernhard Beschow #define ICH9_CC_D28IP_DEFAULT 0x00214321 841a6981bbSBernhard Beschow #define ICH9_CC_D31IR 0x3140 851a6981bbSBernhard Beschow #define ICH9_CC_D30IR 0x3142 861a6981bbSBernhard Beschow #define ICH9_CC_D29IR 0x3144 871a6981bbSBernhard Beschow #define ICH9_CC_D28IR 0x3146 881a6981bbSBernhard Beschow #define ICH9_CC_D27IR 0x3148 891a6981bbSBernhard Beschow #define ICH9_CC_D26IR 0x314C 901a6981bbSBernhard Beschow #define ICH9_CC_D25IR 0x3150 911a6981bbSBernhard Beschow #define ICH9_CC_DIR_DEFAULT 0x3210 921a6981bbSBernhard Beschow #define ICH9_CC_D30IR_DEFAULT 0x0 931a6981bbSBernhard Beschow #define ICH9_CC_DIR_SHIFT 4 941a6981bbSBernhard Beschow #define ICH9_CC_DIR_MASK 0x7 951a6981bbSBernhard Beschow #define ICH9_CC_OIC 0x31FF 961a6981bbSBernhard Beschow #define ICH9_CC_OIC_AEN 0x1 971a6981bbSBernhard Beschow #define ICH9_CC_GCS 0x3410 981a6981bbSBernhard Beschow #define ICH9_CC_GCS_DEFAULT 0x00000020 991a6981bbSBernhard Beschow #define ICH9_CC_GCS_NO_REBOOT (1 << 5) 1001a6981bbSBernhard Beschow 1011a6981bbSBernhard Beschow /* D28:F[0-5] */ 1021a6981bbSBernhard Beschow #define ICH9_PCIE_DEV 28 1031a6981bbSBernhard Beschow #define ICH9_PCIE_FUNC_MAX 6 1041a6981bbSBernhard Beschow 1051a6981bbSBernhard Beschow 1061a6981bbSBernhard Beschow /* D29:F0 USB UHCI Controller #1 */ 1071a6981bbSBernhard Beschow #define ICH9_USB_UHCI1_DEV 29 1081a6981bbSBernhard Beschow #define ICH9_USB_UHCI1_FUNC 0 1091a6981bbSBernhard Beschow 1101a6981bbSBernhard Beschow /* D30:F0 DMI-to-PCI bridge */ 1111a6981bbSBernhard Beschow #define ICH9_D2P_BRIDGE "ICH9 D2P BRIDGE" 1121a6981bbSBernhard Beschow #define ICH9_D2P_BRIDGE_SAVEVM_VERSION 0 1131a6981bbSBernhard Beschow 1141a6981bbSBernhard Beschow #define ICH9_D2P_BRIDGE_DEV 30 1151a6981bbSBernhard Beschow #define ICH9_D2P_BRIDGE_FUNC 0 1161a6981bbSBernhard Beschow 1171a6981bbSBernhard Beschow #define ICH9_D2P_SECONDARY_DEFAULT (256 - 8) 1181a6981bbSBernhard Beschow 1191a6981bbSBernhard Beschow #define ICH9_D2P_A2_REVISION 0x92 1201a6981bbSBernhard Beschow 1211a6981bbSBernhard Beschow /* D31:F0 LPC Processor Interface */ 1221a6981bbSBernhard Beschow #define ICH9_RST_CNT_IOPORT 0xCF9 1231a6981bbSBernhard Beschow 1241a6981bbSBernhard Beschow /* D31:F1 LPC controller */ 1251a6981bbSBernhard Beschow #define ICH9_A2_LPC "ICH9 A2 LPC" 1261a6981bbSBernhard Beschow #define ICH9_A2_LPC_SAVEVM_VERSION 0 1271a6981bbSBernhard Beschow 1281a6981bbSBernhard Beschow #define ICH9_LPC_DEV 31 1291a6981bbSBernhard Beschow #define ICH9_LPC_FUNC 0 1301a6981bbSBernhard Beschow 1311a6981bbSBernhard Beschow #define ICH9_A2_LPC_REVISION 0x2 1321a6981bbSBernhard Beschow #define ICH9_LPC_NB_PIRQS 8 /* PCI A-H */ 1331a6981bbSBernhard Beschow 1341a6981bbSBernhard Beschow #define ICH9_LPC_PMBASE 0x40 1351a6981bbSBernhard Beschow #define ICH9_LPC_PMBASE_BASE_ADDRESS_MASK ICH9_MASK(32, 15, 7) 1361a6981bbSBernhard Beschow #define ICH9_LPC_PMBASE_RTE 0x1 1371a6981bbSBernhard Beschow #define ICH9_LPC_PMBASE_DEFAULT 0x1 1381a6981bbSBernhard Beschow 1391a6981bbSBernhard Beschow #define ICH9_LPC_ACPI_CTRL 0x44 1401a6981bbSBernhard Beschow #define ICH9_LPC_ACPI_CTRL_ACPI_EN 0x80 1411a6981bbSBernhard Beschow #define ICH9_LPC_ACPI_CTRL_SCI_IRQ_SEL_MASK ICH9_MASK(8, 2, 0) 1421a6981bbSBernhard Beschow #define ICH9_LPC_ACPI_CTRL_9 0x0 1431a6981bbSBernhard Beschow #define ICH9_LPC_ACPI_CTRL_10 0x1 1441a6981bbSBernhard Beschow #define ICH9_LPC_ACPI_CTRL_11 0x2 1451a6981bbSBernhard Beschow #define ICH9_LPC_ACPI_CTRL_20 0x4 1461a6981bbSBernhard Beschow #define ICH9_LPC_ACPI_CTRL_21 0x5 1471a6981bbSBernhard Beschow #define ICH9_LPC_ACPI_CTRL_DEFAULT 0x0 1481a6981bbSBernhard Beschow 1491a6981bbSBernhard Beschow #define ICH9_LPC_PIRQA_ROUT 0x60 1501a6981bbSBernhard Beschow #define ICH9_LPC_PIRQB_ROUT 0x61 1511a6981bbSBernhard Beschow #define ICH9_LPC_PIRQC_ROUT 0x62 1521a6981bbSBernhard Beschow #define ICH9_LPC_PIRQD_ROUT 0x63 1531a6981bbSBernhard Beschow 1541a6981bbSBernhard Beschow #define ICH9_LPC_PIRQE_ROUT 0x68 1551a6981bbSBernhard Beschow #define ICH9_LPC_PIRQF_ROUT 0x69 1561a6981bbSBernhard Beschow #define ICH9_LPC_PIRQG_ROUT 0x6a 1571a6981bbSBernhard Beschow #define ICH9_LPC_PIRQH_ROUT 0x6b 1581a6981bbSBernhard Beschow 1591a6981bbSBernhard Beschow #define ICH9_LPC_PIRQ_ROUT_IRQEN 0x80 1601a6981bbSBernhard Beschow #define ICH9_LPC_PIRQ_ROUT_MASK ICH9_MASK(8, 3, 0) 1611a6981bbSBernhard Beschow #define ICH9_LPC_PIRQ_ROUT_DEFAULT 0x80 1621a6981bbSBernhard Beschow 1631a6981bbSBernhard Beschow #define ICH9_LPC_GEN_PMCON_1 0xa0 1641a6981bbSBernhard Beschow #define ICH9_LPC_GEN_PMCON_1_SMI_LOCK (1 << 4) 1651a6981bbSBernhard Beschow #define ICH9_LPC_GEN_PMCON_2 0xa2 1661a6981bbSBernhard Beschow #define ICH9_LPC_GEN_PMCON_3 0xa4 1671a6981bbSBernhard Beschow #define ICH9_LPC_GEN_PMCON_LOCK 0xa6 1681a6981bbSBernhard Beschow 1691a6981bbSBernhard Beschow #define ICH9_LPC_RCBA 0xf0 1701a6981bbSBernhard Beschow #define ICH9_LPC_RCBA_BA_MASK ICH9_MASK(32, 31, 14) 1711a6981bbSBernhard Beschow #define ICH9_LPC_RCBA_EN 0x1 1721a6981bbSBernhard Beschow #define ICH9_LPC_RCBA_DEFAULT 0x0 1731a6981bbSBernhard Beschow 1741a6981bbSBernhard Beschow #define ICH9_LPC_PIC_NUM_PINS 16 1751a6981bbSBernhard Beschow #define ICH9_LPC_IOAPIC_NUM_PINS 24 1761a6981bbSBernhard Beschow 1771a6981bbSBernhard Beschow #define ICH9_GPIO_GSI "gsi" 1781a6981bbSBernhard Beschow 1791a6981bbSBernhard Beschow /* D31:F2 SATA Controller #1 */ 1801a6981bbSBernhard Beschow #define ICH9_SATA1_DEV 31 1811a6981bbSBernhard Beschow #define ICH9_SATA1_FUNC 2 1821a6981bbSBernhard Beschow 1831a6981bbSBernhard Beschow /* D31:F0 power management I/O registers 1841a6981bbSBernhard Beschow offset from the address ICH9_LPC_PMBASE */ 1851a6981bbSBernhard Beschow 1861a6981bbSBernhard Beschow /* ICH9 LPC PM I/O registers are 128 ports and 128-aligned */ 1871a6981bbSBernhard Beschow #define ICH9_PMIO_SIZE 128 1881a6981bbSBernhard Beschow #define ICH9_PMIO_MASK (ICH9_PMIO_SIZE - 1) 1891a6981bbSBernhard Beschow 1901a6981bbSBernhard Beschow #define ICH9_PMIO_PM1_STS 0x00 1911a6981bbSBernhard Beschow #define ICH9_PMIO_PM1_EN 0x02 1921a6981bbSBernhard Beschow #define ICH9_PMIO_PM1_CNT 0x04 1931a6981bbSBernhard Beschow #define ICH9_PMIO_PM1_TMR 0x08 1941a6981bbSBernhard Beschow #define ICH9_PMIO_GPE0_STS 0x20 1951a6981bbSBernhard Beschow #define ICH9_PMIO_GPE0_EN 0x28 1961a6981bbSBernhard Beschow #define ICH9_PMIO_GPE0_LEN 16 1971a6981bbSBernhard Beschow #define ICH9_PMIO_SMI_EN 0x30 1981a6981bbSBernhard Beschow #define ICH9_PMIO_SMI_EN_APMC_EN (1 << 5) 199*6e3c2d58SDominic Prinz #define ICH9_PMIO_SMI_EN_SWSMI_EN (1 << 6) 2001a6981bbSBernhard Beschow #define ICH9_PMIO_SMI_EN_TCO_EN (1 << 13) 201*6e3c2d58SDominic Prinz #define ICH9_PMIO_SMI_EN_PERIODIC_EN (1 << 14) 2021a6981bbSBernhard Beschow #define ICH9_PMIO_SMI_STS 0x34 203*6e3c2d58SDominic Prinz #define ICH9_PMIO_SMI_STS_SWSMI_STS (1 << 6) 204*6e3c2d58SDominic Prinz #define ICH9_PMIO_SMI_STS_PERIODIC_STS (1 << 14) 2051a6981bbSBernhard Beschow #define ICH9_PMIO_TCO_RLD 0x60 2061a6981bbSBernhard Beschow #define ICH9_PMIO_TCO_LEN 32 2071a6981bbSBernhard Beschow 2081a6981bbSBernhard Beschow /* FADT ACPI_ENABLE/ACPI_DISABLE */ 2091a6981bbSBernhard Beschow #define ICH9_APM_ACPI_ENABLE 0x2 2101a6981bbSBernhard Beschow #define ICH9_APM_ACPI_DISABLE 0x3 2111a6981bbSBernhard Beschow 2121a6981bbSBernhard Beschow 2131a6981bbSBernhard Beschow /* D31:F3 SMBus controller */ 2141a6981bbSBernhard Beschow #define TYPE_ICH9_SMB_DEVICE "ICH9-SMB" 2151a6981bbSBernhard Beschow 2161a6981bbSBernhard Beschow #define ICH9_A2_SMB_REVISION 0x02 2171a6981bbSBernhard Beschow #define ICH9_SMB_PI 0x00 2181a6981bbSBernhard Beschow 2191a6981bbSBernhard Beschow #define ICH9_SMB_SMBMBAR0 0x10 2201a6981bbSBernhard Beschow #define ICH9_SMB_SMBMBAR1 0x14 2211a6981bbSBernhard Beschow #define ICH9_SMB_SMBM_BAR 0 2221a6981bbSBernhard Beschow #define ICH9_SMB_SMBM_SIZE (1 << 8) 2231a6981bbSBernhard Beschow #define ICH9_SMB_SMB_BASE 0x20 2241a6981bbSBernhard Beschow #define ICH9_SMB_SMB_BASE_BAR 4 2251a6981bbSBernhard Beschow #define ICH9_SMB_SMB_BASE_SIZE (1 << 5) 2261a6981bbSBernhard Beschow #define ICH9_SMB_HOSTC 0x40 2271a6981bbSBernhard Beschow #define ICH9_SMB_HOSTC_SSRESET ((uint8_t)(1 << 3)) 2281a6981bbSBernhard Beschow #define ICH9_SMB_HOSTC_I2C_EN ((uint8_t)(1 << 2)) 2291a6981bbSBernhard Beschow #define ICH9_SMB_HOSTC_SMB_SMI_EN ((uint8_t)(1 << 1)) 2301a6981bbSBernhard Beschow #define ICH9_SMB_HOSTC_HST_EN ((uint8_t)(1 << 0)) 2311a6981bbSBernhard Beschow 2321a6981bbSBernhard Beschow /* D31:F3 SMBus I/O and memory mapped I/O registers */ 2331a6981bbSBernhard Beschow #define ICH9_SMB_DEV 31 2341a6981bbSBernhard Beschow #define ICH9_SMB_FUNC 3 2351a6981bbSBernhard Beschow 2361a6981bbSBernhard Beschow #define ICH9_SMB_HST_STS 0x00 2371a6981bbSBernhard Beschow #define ICH9_SMB_HST_CNT 0x02 2381a6981bbSBernhard Beschow #define ICH9_SMB_HST_CMD 0x03 2391a6981bbSBernhard Beschow #define ICH9_SMB_XMIT_SLVA 0x04 2401a6981bbSBernhard Beschow #define ICH9_SMB_HST_D0 0x05 2411a6981bbSBernhard Beschow #define ICH9_SMB_HST_D1 0x06 2421a6981bbSBernhard Beschow #define ICH9_SMB_HOST_BLOCK_DB 0x07 2431a6981bbSBernhard Beschow 2441a6981bbSBernhard Beschow #define ICH9_LPC_SMI_NEGOTIATED_FEAT_PROP "x-smi-negotiated-features" 2451a6981bbSBernhard Beschow 2461a6981bbSBernhard Beschow /* bit positions used in fw_cfg SMI feature negotiation */ 2471a6981bbSBernhard Beschow #define ICH9_LPC_SMI_F_BROADCAST_BIT 0 2481a6981bbSBernhard Beschow #define ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT 1 2491a6981bbSBernhard Beschow #define ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT 2 2501a6981bbSBernhard Beschow 2511a6981bbSBernhard Beschow #endif /* HW_SOUTHBRIDGE_ICH9_H */ 252