5 #include <vga-overlay.h>
6 #include <reg-82801b.h>
8 static uint16_t _get_PMBASE()
10 return pci_read32(ICH2_LPC_BUS, ICH2_LPC_DEV, ICH2_LPC_FN, ICH2_LPC_PCI_PMBASE) & ICH2_PMBASE_MASK;
15 unsigned short smi_en = _get_PMBASE() + ICH2_PMBASE_SMI_EN;
16 outl(smi_en, inl(smi_en) & ~ICH2_SMI_EN_GBL_SMI_EN);
21 unsigned short smi_en = _get_PMBASE() + ICH2_PMBASE_SMI_EN;
22 outl(smi_en, inl(smi_en) | ICH2_SMI_EN_GBL_SMI_EN);
25 unsigned long smi_status()
27 unsigned short smi_sts = _get_PMBASE() + ICH2_PMBASE_SMI_STS;
33 unsigned long sts = smi_status();
35 if (sts & ICH2_SMI_STS_BIOS_STS)
37 dolog("Unhandled: BIOS_STS");
38 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_BIOS_STS);
41 if (sts & ICH2_SMI_STS_LEGACY_USB_STS)
43 dolog("Unhandled: LEGACY_USB_STS");
44 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_LEGACY_USB_STS);
47 if (sts & ICH2_SMI_STS_SLP_SMI_STS)
49 dolog("Unhandled: SLP_SMI_STS");
50 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_SLP_SMI_STS);
53 if (sts & ICH2_SMI_STS_APM_STS)
55 dolog("Unhandled: APM_STS");
56 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_SLP_SMI_STS);
59 if (sts & ICH2_SMI_STS_SWSMI_TMR_STS) // Ack it, then request another.
61 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_SLP_SMI_STS);
62 outl(_get_PMBASE() + ICH2_PMBASE_SMI_EN,
63 inl(_get_PMBASE() + ICH2_PMBASE_SMI_EN) & ~ICH2_SMI_EN_SWSMI_TMR_EN);
64 outl(_get_PMBASE() + ICH2_PMBASE_SMI_EN,
65 inl(_get_PMBASE() + ICH2_PMBASE_SMI_EN) | ICH2_SMI_EN_SWSMI_TMR_EN);
68 if (sts & ICH2_SMI_STS_PM1_STS_REG)
70 /* XXX -- trawl through PMBASE+00h to see what happened */
73 if (sts & ICH2_SMI_STS_GPE0_STS)
75 /* XXX -- trawl through GPE0_STS to see what happened */
78 if (sts & ICH2_SMI_STS_MCSMI_STS)
80 dolog("Unhandled: MCSMI_STS");
81 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_MCSMI_STS);
84 if (sts & ICH2_SMI_STS_DEVMON_STS)
86 /* XXX -- trawl through DEVx_TRAP_STS to see what happened */
87 /* XXX -- trawl through DEVTRAP_STS to see what happened */
90 if (sts & ICH2_SMI_STS_TCO_STS)
92 dolog("Unhandled: TCO_STS");
93 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_TCO_STS);
96 if (sts & ICH2_SMI_STS_PERIODIC_STS)
98 dolog("Unhandled: PERIODIC_STS");
99 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_PERIODIC_STS);
102 if (sts & ICH2_SMI_STS_SERIRQ_SMI_STS)
104 dolog("Unhandled: SERIRQ_SMI_STS");
105 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_SERIRQ_SMI_STS);
108 if (sts & ICH2_SMI_STS_SMBUS_SMI_STS)
110 dolog("Unhandled: SMBUS_SMI_STS");
111 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_SMBUS_SMI_STS);
115 dolog("WARNING: failed to clear SMI_STS!");
117 outl(_get_PMBASE() + ICH2_PMBASE_SMI_EN,
118 inl(_get_PMBASE() + ICH2_PMBASE_SMI_EN) |
120 ICH2_SMI_EN_GBL_SMI_EN);