5 #include <vga-overlay.h>
6 #include <reg-82801b.h>
8 static uint16_t _get_PMBASE()
10 static long pmbase = -1;
12 if (pmbase == -1) /* Memoize it so that we don't have to hit PCI so often. */
13 pmbase = pci_read32(ICH2_LPC_BUS, ICH2_LPC_DEV, ICH2_LPC_FN, ICH2_LPC_PCI_PMBASE) & ICH2_PMBASE_MASK;
20 unsigned short smi_en = _get_PMBASE() + ICH2_PMBASE_SMI_EN;
21 outl(smi_en, inl(smi_en) & ~ICH2_SMI_EN_GBL_SMI_EN);
26 unsigned short smi_en = _get_PMBASE() + ICH2_PMBASE_SMI_EN;
27 outl(smi_en, inl(smi_en) | ICH2_SMI_EN_GBL_SMI_EN);
30 unsigned long smi_status()
32 unsigned short smi_sts = _get_PMBASE() + ICH2_PMBASE_SMI_STS;
38 unsigned long sts = smi_status();
40 if (sts & ICH2_SMI_STS_BIOS_STS)
42 dolog("Unhandled: BIOS_STS");
43 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_BIOS_STS);
46 if (sts & ICH2_SMI_STS_LEGACY_USB_STS)
48 dolog("Unhandled: LEGACY_USB_STS");
49 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_LEGACY_USB_STS);
52 if (sts & ICH2_SMI_STS_SLP_SMI_STS)
54 dolog("Unhandled: SLP_SMI_STS");
55 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_SLP_SMI_STS);
58 if (sts & ICH2_SMI_STS_APM_STS)
60 dolog("Unhandled: APM_STS");
61 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_APM_STS);
64 if (sts & ICH2_SMI_STS_SWSMI_TMR_STS) // Ack it, then request another.
66 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_SWSMI_TMR_STS);
67 outl(_get_PMBASE() + ICH2_PMBASE_SMI_EN,
68 inl(_get_PMBASE() + ICH2_PMBASE_SMI_EN) & ~ICH2_SMI_EN_SWSMI_TMR_EN);
69 outl(_get_PMBASE() + ICH2_PMBASE_SMI_EN,
70 inl(_get_PMBASE() + ICH2_PMBASE_SMI_EN) | ICH2_SMI_EN_SWSMI_TMR_EN);
73 if (sts & ICH2_SMI_STS_PM1_STS_REG)
75 unsigned short pm1_sts = inw(_get_PMBASE() + ICH2_PMBASE_PM1_STS);
76 unsigned short pm1_en = inw(_get_PMBASE() + ICH2_PMBASE_PM1_EN);
79 if (pm1_sts & ICH2_PM1_STS_RTC_STS)
81 dolog("Unhandled: PM1_STS: RTC_STS");
82 outw(_get_PMBASE() + ICH2_PMBASE_PM1_STS, ICH2_PM1_STS_RTC_STS);
85 if (pm1_sts & ICH2_PM1_STS_PWRBTN_STS)
87 dolog("Unhandled: PM1_STS: PWRBTN_STS");
88 outw(_get_PMBASE() + ICH2_PMBASE_PM1_STS, ICH2_PM1_STS_PWRBTN_STS);
91 if (pm1_sts & ICH2_PM1_STS_GBL_STS)
93 dolog("Unhandled: PM1_STS: GBL_STS");
94 outw(_get_PMBASE() + ICH2_PMBASE_PM1_STS, ICH2_PM1_STS_GBL_STS);
97 if (pm1_sts & ICH2_PM1_STS_TMROF_STS)
99 dolog("Unhandled: PM1_STS: TMROF_STS");
100 outw(_get_PMBASE() + ICH2_PMBASE_PM1_STS, ICH2_PM1_STS_TMROF_STS);
103 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_PM1_STS_REG);
106 if (sts & ICH2_SMI_STS_GPE0_STS)
108 /* XXX -- trawl through GPE0_STS to see what happened */
109 dolog("XXX Unhandled: GPE0_STS (expect lockup)");
112 if (sts & ICH2_SMI_STS_GPE1_STS)
114 /* XXX -- trawl through GPE1_STS to see what happened */
115 dolog("XXX Unhandled: GPE1_STS (expect lockup)");
118 if (sts & ICH2_SMI_STS_MCSMI_STS)
120 dolog("Unhandled: MCSMI_STS");
121 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_MCSMI_STS);
124 if (sts & ICH2_SMI_STS_DEVMON_STS)
126 unsigned short mon_smi = inw(_get_PMBASE() + ICH2_PMBASE_MON_SMI);
127 unsigned long devact_sts = inl(_get_PMBASE() + ICH2_PMBASE_DEVACT_STS);
128 unsigned long devtrap_en = inl(_get_PMBASE() + ICH2_PMBASE_DEVTRAP_EN);
129 if (((mon_smi & 0x0F00) >> 8) & ((mon_smi & 0xF000) >> 12))
130 dologf("Unhandled: MON_SMI (%04x)", mon_smi);
131 if (devact_sts & devtrap_en)
132 dologf("Unhandled: DEVTRAP (%08x)", devact_sts & devtrap_en);
135 if (sts & ICH2_SMI_STS_TCO_STS)
137 dolog("Unhandled: TCO_STS");
138 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_TCO_STS);
141 if (sts & ICH2_SMI_STS_PERIODIC_STS)
143 dolog("Unhandled: PERIODIC_STS");
144 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_PERIODIC_STS);
147 if (sts & ICH2_SMI_STS_SERIRQ_SMI_STS)
149 dolog("Unhandled: SERIRQ_SMI_STS");
150 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_SERIRQ_SMI_STS);
153 if (sts & ICH2_SMI_STS_SMBUS_SMI_STS)
155 dolog("Unhandled: SMBUS_SMI_STS");
156 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_SMBUS_SMI_STS);
159 if (smi_status() & ~ICH2_SMI_STS_PM1_STS_REG) /* Either the chipset is buggy, or we are. */
160 dologf("WARN: couldn't clear SMI_STS! (%08x)", smi_status());
162 outl(_get_PMBASE() + ICH2_PMBASE_SMI_EN,
163 inl(_get_PMBASE() + ICH2_PMBASE_SMI_EN) |
165 ICH2_SMI_EN_GBL_SMI_EN);