ich9.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. #ifndef HW_ICH9_H
  2. #define HW_ICH9_H
  3. #include "hw.h"
  4. #include "qemu/range.h"
  5. #include "isa.h"
  6. #include "sysbus.h"
  7. #include "pc.h"
  8. #include "apm.h"
  9. #include "ioapic.h"
  10. #include "pci/pci.h"
  11. #include "pci/pcie_host.h"
  12. #include "pci/pci_bridge.h"
  13. #include "acpi.h"
  14. #include "acpi_ich9.h"
  15. #include "pam.h"
  16. #include "pci/pci_bus.h"
  17. void ich9_lpc_set_irq(void *opaque, int irq_num, int level);
  18. int ich9_lpc_map_irq(PCIDevice *pci_dev, int intx);
  19. PCIINTxRoute ich9_route_intx_pin_to_irq(void *opaque, int pirq_pin);
  20. void ich9_lpc_pm_init(PCIDevice *pci_lpc, qemu_irq cmos_s3);
  21. PCIBus *ich9_d2pbr_init(PCIBus *bus, int devfn, int sec_bus);
  22. i2c_bus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base);
  23. #define ICH9_CC_SIZE (16 * 1024) /* 16KB */
  24. #define TYPE_ICH9_LPC_DEVICE "ICH9 LPC"
  25. #define ICH9_LPC_DEVICE(obj) \
  26. OBJECT_CHECK(ICH9LPCState, (obj), TYPE_ICH9_LPC_DEVICE)
  27. typedef struct ICH9LPCState {
  28. /* ICH9 LPC PCI to ISA bridge */
  29. PCIDevice d;
  30. /* (pci device, intx) -> pirq
  31. * In real chipset case, the unused slots are never used
  32. * as ICH9 supports only D25-D32 irq routing.
  33. * On the other hand in qemu case, any slot/function can be populated
  34. * via command line option.
  35. * So fallback interrupt routing for any devices in any slots is necessary.
  36. */
  37. uint8_t irr[PCI_SLOT_MAX][PCI_NUM_PINS];
  38. APMState apm;
  39. ICH9LPCPMRegs pm;
  40. uint32_t sci_level; /* track sci level */
  41. /* 10.1 Chipset Configuration registers(Memory Space)
  42. which is pointed by RCBA */
  43. uint8_t chip_config[ICH9_CC_SIZE];
  44. /* isa bus */
  45. ISABus *isa_bus;
  46. MemoryRegion rbca_mem;
  47. Notifier machine_ready;
  48. qemu_irq *pic;
  49. qemu_irq *ioapic;
  50. } ICH9LPCState;
  51. #define Q35_MASK(bit, ms_bit, ls_bit) \
  52. ((uint##bit##_t)(((1ULL << ((ms_bit) + 1)) - 1) & ~((1ULL << ls_bit) - 1)))
  53. /* ICH9: Chipset Configuration Registers */
  54. #define ICH9_CC_ADDR_MASK (ICH9_CC_SIZE - 1)
  55. #define ICH9_CC
  56. #define ICH9_CC_D28IP 0x310C
  57. #define ICH9_CC_D28IP_SHIFT 4
  58. #define ICH9_CC_D28IP_MASK 0xf
  59. #define ICH9_CC_D28IP_DEFAULT 0x00214321
  60. #define ICH9_CC_D31IR 0x3140
  61. #define ICH9_CC_D30IR 0x3142
  62. #define ICH9_CC_D29IR 0x3144
  63. #define ICH9_CC_D28IR 0x3146
  64. #define ICH9_CC_D27IR 0x3148
  65. #define ICH9_CC_D26IR 0x314C
  66. #define ICH9_CC_D25IR 0x3150
  67. #define ICH9_CC_DIR_DEFAULT 0x3210
  68. #define ICH9_CC_D30IR_DEFAULT 0x0
  69. #define ICH9_CC_DIR_SHIFT 4
  70. #define ICH9_CC_DIR_MASK 0x7
  71. #define ICH9_CC_OIC 0x31FF
  72. #define ICH9_CC_OIC_AEN 0x1
  73. /* D28:F[0-5] */
  74. #define ICH9_PCIE_DEV 28
  75. #define ICH9_PCIE_FUNC_MAX 6
  76. /* D29:F0 USB UHCI Controller #1 */
  77. #define ICH9_USB_UHCI1_DEV 29
  78. #define ICH9_USB_UHCI1_FUNC 0
  79. /* D30:F0 DMI-to-PCI brdige */
  80. #define ICH9_D2P_BRIDGE "ICH9 D2P BRIDGE"
  81. #define ICH9_D2P_BRIDGE_SAVEVM_VERSION 0
  82. #define ICH9_D2P_BRIDGE_DEV 30
  83. #define ICH9_D2P_BRIDGE_FUNC 0
  84. #define ICH9_D2P_SECONDARY_DEFAULT (256 - 8)
  85. #define ICH9_D2P_A2_REVISION 0x92
  86. /* D31:F1 LPC controller */
  87. #define ICH9_A2_LPC "ICH9 A2 LPC"
  88. #define ICH9_A2_LPC_SAVEVM_VERSION 0
  89. #define ICH9_LPC_DEV 31
  90. #define ICH9_LPC_FUNC 0
  91. #define ICH9_A2_LPC_REVISION 0x2
  92. #define ICH9_LPC_NB_PIRQS 8 /* PCI A-H */
  93. #define ICH9_LPC_PMBASE 0x40
  94. #define ICH9_LPC_PMBASE_BASE_ADDRESS_MASK Q35_MASK(32, 15, 7)
  95. #define ICH9_LPC_PMBASE_RTE 0x1
  96. #define ICH9_LPC_PMBASE_DEFAULT 0x1
  97. #define ICH9_LPC_ACPI_CTRL 0x44
  98. #define ICH9_LPC_ACPI_CTRL_ACPI_EN 0x80
  99. #define ICH9_LPC_ACPI_CTRL_SCI_IRQ_SEL_MASK Q35_MASK(8, 2, 0)
  100. #define ICH9_LPC_ACPI_CTRL_9 0x0
  101. #define ICH9_LPC_ACPI_CTRL_10 0x1
  102. #define ICH9_LPC_ACPI_CTRL_11 0x2
  103. #define ICH9_LPC_ACPI_CTRL_20 0x4
  104. #define ICH9_LPC_ACPI_CTRL_21 0x5
  105. #define ICH9_LPC_ACPI_CTRL_DEFAULT 0x0
  106. #define ICH9_LPC_PIRQA_ROUT 0x60
  107. #define ICH9_LPC_PIRQB_ROUT 0x61
  108. #define ICH9_LPC_PIRQC_ROUT 0x62
  109. #define ICH9_LPC_PIRQD_ROUT 0x63
  110. #define ICH9_LPC_PIRQE_ROUT 0x68
  111. #define ICH9_LPC_PIRQF_ROUT 0x69
  112. #define ICH9_LPC_PIRQG_ROUT 0x6a
  113. #define ICH9_LPC_PIRQH_ROUT 0x6b
  114. #define ICH9_LPC_PIRQ_ROUT_IRQEN 0x80
  115. #define ICH9_LPC_PIRQ_ROUT_MASK Q35_MASK(8, 3, 0)
  116. #define ICH9_LPC_PIRQ_ROUT_DEFAULT 0x80
  117. #define ICH9_LPC_RCBA 0xf0
  118. #define ICH9_LPC_RCBA_BA_MASK Q35_MASK(32, 31, 14)
  119. #define ICH9_LPC_RCBA_EN 0x1
  120. #define ICH9_LPC_RCBA_DEFAULT 0x0
  121. #define ICH9_LPC_PIC_NUM_PINS 16
  122. #define ICH9_LPC_IOAPIC_NUM_PINS 24
  123. /* D31:F2 SATA Controller #1 */
  124. #define ICH9_SATA1_DEV 31
  125. #define ICH9_SATA1_FUNC 2
  126. /* D30:F1 power management I/O registers
  127. offset from the address ICH9_LPC_PMBASE */
  128. /* ICH9 LPC PM I/O registers are 128 ports and 128-aligned */
  129. #define ICH9_PMIO_SIZE 128
  130. #define ICH9_PMIO_MASK (ICH9_PMIO_SIZE - 1)
  131. #define ICH9_PMIO_PM1_STS 0x00
  132. #define ICH9_PMIO_PM1_EN 0x02
  133. #define ICH9_PMIO_PM1_CNT 0x04
  134. #define ICH9_PMIO_PM1_TMR 0x08
  135. #define ICH9_PMIO_GPE0_STS 0x20
  136. #define ICH9_PMIO_GPE0_EN 0x28
  137. #define ICH9_PMIO_GPE0_LEN 16
  138. #define ICH9_PMIO_SMI_EN 0x30
  139. #define ICH9_PMIO_SMI_EN_APMC_EN (1 << 5)
  140. #define ICH9_PMIO_SMI_STS 0x34
  141. /* FADT ACPI_ENABLE/ACPI_DISABLE */
  142. #define ICH9_APM_ACPI_ENABLE 0x2
  143. #define ICH9_APM_ACPI_DISABLE 0x3
  144. /* D31:F3 SMBus controller */
  145. #define ICH9_A2_SMB_REVISION 0x02
  146. #define ICH9_SMB_PI 0x00
  147. #define ICH9_SMB_SMBMBAR0 0x10
  148. #define ICH9_SMB_SMBMBAR1 0x14
  149. #define ICH9_SMB_SMBM_BAR 0
  150. #define ICH9_SMB_SMBM_SIZE (1 << 8)
  151. #define ICH9_SMB_SMB_BASE 0x20
  152. #define ICH9_SMB_SMB_BASE_BAR 4
  153. #define ICH9_SMB_SMB_BASE_SIZE (1 << 5)
  154. #define ICH9_SMB_HOSTC 0x40
  155. #define ICH9_SMB_HOSTC_SSRESET ((uint8_t)(1 << 3))
  156. #define ICH9_SMB_HOSTC_I2C_EN ((uint8_t)(1 << 2))
  157. #define ICH9_SMB_HOSTC_SMB_SMI_EN ((uint8_t)(1 << 1))
  158. #define ICH9_SMB_HOSTC_HST_EN ((uint8_t)(1 << 0))
  159. /* D31:F3 SMBus I/O and memory mapped I/O registers */
  160. #define ICH9_SMB_DEV 31
  161. #define ICH9_SMB_FUNC 3
  162. #define ICH9_SMB_HST_STS 0x00
  163. #define ICH9_SMB_HST_CNT 0x02
  164. #define ICH9_SMB_HST_CMD 0x03
  165. #define ICH9_SMB_XMIT_SLVA 0x04
  166. #define ICH9_SMB_HST_D0 0x05
  167. #define ICH9_SMB_HST_D1 0x06
  168. #define ICH9_SMB_HOST_BLOCK_DB 0x07
  169. #endif /* HW_ICH9_H */