blob: e920cfe3e2f0978211edcde2923b89cb6d9c125a [file] [log] [blame]
Aaron Durbin76c37002012-10-30 09:03:43 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008-2009 coresystems GmbH
Duncan Laurie467f31d2013-03-08 17:00:37 -08005 * Copyright 2013 Google Inc.
Aaron Durbin76c37002012-10-30 09:03:43 -05006 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; version 2 of
10 * the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
20 * MA 02110-1301 USA
21 */
22
Duncan Laurie2d9d39a2013-05-29 15:27:55 -070023#include <delay.h>
Aaron Durbin76c37002012-10-30 09:03:43 -050024#include <types.h>
25#include <arch/hlt.h>
26#include <arch/io.h>
Aaron Durbin76c37002012-10-30 09:03:43 -050027#include <console/console.h>
28#include <cpu/x86/cache.h>
29#include <device/pci_def.h>
30#include <cpu/x86/smm.h>
31#include <elog.h>
32#include <pc80/mc146818rtc.h>
33#include "pch.h"
34
35#include "nvs.h"
36
Aaron Durbin76c37002012-10-30 09:03:43 -050037
38static u8 smm_initialized = 0;
39
40/* GNVS needs to be updated by an 0xEA PM Trap (B2) after it has been located
41 * by coreboot.
42 */
Aaron Durbin29ffa542012-12-21 21:21:48 -060043static global_nvs_t *gnvs;
Aaron Durbin76c37002012-10-30 09:03:43 -050044global_nvs_t *smm_get_gnvs(void)
45{
46 return gnvs;
47}
48
Aaron Durbin76c37002012-10-30 09:03:43 -050049int southbridge_io_trap_handler(int smif)
50{
51 switch (smif) {
52 case 0x32:
53 printk(BIOS_DEBUG, "OS Init\n");
54 /* gnvs->smif:
55 * On success, the IO Trap Handler returns 0
56 * On failure, the IO Trap Handler returns a value != 0
57 */
58 gnvs->smif = 0;
59 return 1; /* IO trap handled */
60 }
61
62 /* Not handled */
63 return 0;
64}
65
66/**
67 * @brief Set the EOS bit
68 */
69void southbridge_smi_set_eos(void)
70{
Duncan Laurie467f31d2013-03-08 17:00:37 -080071 enable_smi(EOS);
Aaron Durbin76c37002012-10-30 09:03:43 -050072}
73
74static void busmaster_disable_on_bus(int bus)
75{
76 int slot, func;
77 unsigned int val;
78 unsigned char hdr;
79
80 for (slot = 0; slot < 0x20; slot++) {
81 for (func = 0; func < 8; func++) {
82 u32 reg32;
83 device_t dev = PCI_DEV(bus, slot, func);
84
85 val = pci_read_config32(dev, PCI_VENDOR_ID);
86
87 if (val == 0xffffffff || val == 0x00000000 ||
88 val == 0x0000ffff || val == 0xffff0000)
89 continue;
90
91 /* Disable Bus Mastering for this one device */
92 reg32 = pci_read_config32(dev, PCI_COMMAND);
93 reg32 &= ~PCI_COMMAND_MASTER;
94 pci_write_config32(dev, PCI_COMMAND, reg32);
95
96 /* If this is a bridge, then follow it. */
97 hdr = pci_read_config8(dev, PCI_HEADER_TYPE);
98 hdr &= 0x7f;
99 if (hdr == PCI_HEADER_TYPE_BRIDGE ||
100 hdr == PCI_HEADER_TYPE_CARDBUS) {
101 unsigned int buses;
102 buses = pci_read_config32(dev, PCI_PRIMARY_BUS);
103 busmaster_disable_on_bus((buses >> 8) & 0xff);
104 }
105 }
106 }
107}
108
Duncan Laurie2d9d39a2013-05-29 15:27:55 -0700109
Aaron Durbin29ffa542012-12-21 21:21:48 -0600110static void southbridge_smi_sleep(void)
Aaron Durbin76c37002012-10-30 09:03:43 -0500111{
112 u8 reg8;
113 u32 reg32;
114 u8 slp_typ;
115 u8 s5pwr = CONFIG_MAINBOARD_POWER_ON_AFTER_POWER_FAIL;
Duncan Laurie467f31d2013-03-08 17:00:37 -0800116 u16 pmbase = get_pmbase();
Aaron Durbin76c37002012-10-30 09:03:43 -0500117
118 // save and recover RTC port values
119 u8 tmp70, tmp72;
120 tmp70 = inb(0x70);
121 tmp72 = inb(0x72);
122 get_option(&s5pwr, "power_on_after_fail");
123 outb(tmp70, 0x70);
124 outb(tmp72, 0x72);
125
Aaron Durbin76c37002012-10-30 09:03:43 -0500126 /* First, disable further SMIs */
Duncan Laurie467f31d2013-03-08 17:00:37 -0800127 disable_smi(SLP_SMI_EN);
Aaron Durbin76c37002012-10-30 09:03:43 -0500128
129 /* Figure out SLP_TYP */
130 reg32 = inl(pmbase + PM1_CNT);
131 printk(BIOS_SPEW, "SMI#: SLP = 0x%08x\n", reg32);
132 slp_typ = (reg32 >> 10) & 7;
133
134 /* Do any mainboard sleep handling */
Aaron Durbin29ffa542012-12-21 21:21:48 -0600135 mainboard_smi_sleep(slp_typ-2);
Aaron Durbin76c37002012-10-30 09:03:43 -0500136
Duncan Laurie2d9d39a2013-05-29 15:27:55 -0700137 /* USB sleep preparations */
Duncan Laurie1f529082013-07-30 15:53:45 -0700138 usb_ehci_sleep_prepare(PCH_EHCI1_DEV, slp_typ);
139 usb_ehci_sleep_prepare(PCH_EHCI2_DEV, slp_typ);
140 usb_xhci_sleep_prepare(PCH_XHCI_DEV, slp_typ);
Duncan Laurie2d9d39a2013-05-29 15:27:55 -0700141
Aaron Durbin76c37002012-10-30 09:03:43 -0500142#if CONFIG_ELOG_GSMI
143 /* Log S3, S4, and S5 entry */
144 if (slp_typ >= 5)
145 elog_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ-2);
146#endif
147
148 /* Next, do the deed.
149 */
150
151 switch (slp_typ) {
Duncan Laurie467f31d2013-03-08 17:00:37 -0800152 case SLP_TYP_S0:
153 printk(BIOS_DEBUG, "SMI#: Entering S0 (On)\n");
154 break;
155 case SLP_TYP_S1:
156 printk(BIOS_DEBUG, "SMI#: Entering S1 (Assert STPCLK#)\n");
157 break;
158 case SLP_TYP_S3:
Aaron Durbin76c37002012-10-30 09:03:43 -0500159 printk(BIOS_DEBUG, "SMI#: Entering S3 (Suspend-To-RAM)\n");
160
Aaron Durbin76c37002012-10-30 09:03:43 -0500161 /* Invalidate the cache before going to S3 */
162 wbinvd();
163 break;
Duncan Laurie467f31d2013-03-08 17:00:37 -0800164 case SLP_TYP_S4:
165 printk(BIOS_DEBUG, "SMI#: Entering S4 (Suspend-To-Disk)\n");
166 break;
167 case SLP_TYP_S5:
Aaron Durbin76c37002012-10-30 09:03:43 -0500168 printk(BIOS_DEBUG, "SMI#: Entering S5 (Soft Power off)\n");
169
Duncan Laurie467f31d2013-03-08 17:00:37 -0800170 /* Disable all GPE */
171 disable_all_gpe();
Aaron Durbin76c37002012-10-30 09:03:43 -0500172
173 /* Always set the flag in case CMOS was changed on runtime. For
174 * "KEEP", switch to "OFF" - KEEP is software emulated
175 */
Aaron Durbin89f79a02012-10-31 23:05:25 -0500176 reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), GEN_PMCON_3);
Aaron Durbin76c37002012-10-30 09:03:43 -0500177 if (s5pwr == MAINBOARD_POWER_ON) {
178 reg8 &= ~1;
179 } else {
180 reg8 |= 1;
181 }
Aaron Durbin89f79a02012-10-31 23:05:25 -0500182 pci_write_config8(PCI_DEV(0, 0x1f, 0), GEN_PMCON_3, reg8);
Aaron Durbin76c37002012-10-30 09:03:43 -0500183
184 /* also iterates over all bridges on bus 0 */
185 busmaster_disable_on_bus(0);
186 break;
Duncan Laurie467f31d2013-03-08 17:00:37 -0800187 default:
188 printk(BIOS_DEBUG, "SMI#: ERROR: SLP_TYP reserved\n");
189 break;
Aaron Durbin76c37002012-10-30 09:03:43 -0500190 }
191
192 /* Write back to the SLP register to cause the originally intended
193 * event again. We need to set BIT13 (SLP_EN) though to make the
194 * sleep happen.
195 */
Duncan Laurie467f31d2013-03-08 17:00:37 -0800196 enable_pm1_control(SLP_EN);
Aaron Durbin76c37002012-10-30 09:03:43 -0500197
198 /* Make sure to stop executing code here for S3/S4/S5 */
199 if (slp_typ > 1)
200 hlt();
201
202 /* In most sleep states, the code flow of this function ends at
203 * the line above. However, if we entered sleep state S1 and wake
204 * up again, we will continue to execute code in this function.
205 */
206 reg32 = inl(pmbase + PM1_CNT);
207 if (reg32 & SCI_EN) {
208 /* The OS is not an ACPI OS, so we set the state to S0 */
Duncan Laurie467f31d2013-03-08 17:00:37 -0800209 disable_pm1_control(SLP_EN | SLP_TYP);
Aaron Durbin76c37002012-10-30 09:03:43 -0500210 }
211}
212
213/*
214 * Look for Synchronous IO SMI and use save state from that
215 * core in case we are not running on the same core that
216 * initiated the IO transaction.
217 */
Aaron Durbin76c37002012-10-30 09:03:43 -0500218static em64t101_smm_state_save_area_t *smi_apmc_find_state_save(u8 cmd)
219{
220 em64t101_smm_state_save_area_t *state;
Aaron Durbin76c37002012-10-30 09:03:43 -0500221 int node;
222
223 /* Check all nodes looking for the one that issued the IO */
224 for (node = 0; node < CONFIG_MAX_CPUS; node++) {
Aaron Durbin29ffa542012-12-21 21:21:48 -0600225 state = smm_get_save_state(node);
Aaron Durbin76c37002012-10-30 09:03:43 -0500226
227 /* Check for Synchronous IO (bit0==1) */
228 if (!(state->io_misc_info & (1 << 0)))
229 continue;
230
231 /* Make sure it was a write (bit4==0) */
232 if (state->io_misc_info & (1 << 4))
233 continue;
234
235 /* Check for APMC IO port */
236 if (((state->io_misc_info >> 16) & 0xff) != APM_CNT)
237 continue;
238
239 /* Check AX against the requested command */
240 if ((state->rax & 0xff) != cmd)
241 continue;
242
243 return state;
244 }
245
246 return NULL;
247}
248
249#if CONFIG_ELOG_GSMI
250static void southbridge_smi_gsmi(void)
251{
252 u32 *ret, *param;
253 u8 sub_command;
254 em64t101_smm_state_save_area_t *io_smi =
255 smi_apmc_find_state_save(ELOG_GSMI_APM_CNT);
256
257 if (!io_smi)
258 return;
259
260 /* Command and return value in EAX */
261 ret = (u32*)&io_smi->rax;
262 sub_command = (u8)(*ret >> 8);
263
264 /* Parameter buffer in EBX */
265 param = (u32*)&io_smi->rbx;
266
267 /* drivers/elog/gsmi.c */
268 *ret = gsmi_exec(sub_command, param);
269}
270#endif
271
Aaron Durbin29ffa542012-12-21 21:21:48 -0600272static void southbridge_smi_apmc(void)
Aaron Durbin76c37002012-10-30 09:03:43 -0500273{
Aaron Durbin76c37002012-10-30 09:03:43 -0500274 u8 reg8;
Aaron Durbin76c37002012-10-30 09:03:43 -0500275 em64t101_smm_state_save_area_t *state;
276
277 /* Emulate B2 register as the FADT / Linux expects it */
278
279 reg8 = inb(APM_CNT);
280 switch (reg8) {
281 case APM_CNT_CST_CONTROL:
282 /* Calling this function seems to cause
283 * some kind of race condition in Linux
284 * and causes a kernel oops
285 */
286 printk(BIOS_DEBUG, "C-state control\n");
287 break;
288 case APM_CNT_PST_CONTROL:
289 /* Calling this function seems to cause
290 * some kind of race condition in Linux
291 * and causes a kernel oops
292 */
293 printk(BIOS_DEBUG, "P-state control\n");
294 break;
295 case APM_CNT_ACPI_DISABLE:
Duncan Laurie467f31d2013-03-08 17:00:37 -0800296 disable_pm1_control(SCI_EN);
Aaron Durbin76c37002012-10-30 09:03:43 -0500297 printk(BIOS_DEBUG, "SMI#: ACPI disabled.\n");
298 break;
299 case APM_CNT_ACPI_ENABLE:
Duncan Laurie467f31d2013-03-08 17:00:37 -0800300 enable_pm1_control(SCI_EN);
Aaron Durbin76c37002012-10-30 09:03:43 -0500301 printk(BIOS_DEBUG, "SMI#: ACPI enabled.\n");
302 break;
303 case APM_CNT_GNVS_UPDATE:
304 if (smm_initialized) {
Duncan Laurie467f31d2013-03-08 17:00:37 -0800305 printk(BIOS_DEBUG,
306 "SMI#: SMM structures already initialized!\n");
Aaron Durbin76c37002012-10-30 09:03:43 -0500307 return;
308 }
309 state = smi_apmc_find_state_save(reg8);
310 if (state) {
311 /* EBX in the state save contains the GNVS pointer */
312 gnvs = (global_nvs_t *)((u32)state->rbx);
313 smm_initialized = 1;
314 printk(BIOS_DEBUG, "SMI#: Setting GNVS to %p\n", gnvs);
315 }
316 break;
317#if CONFIG_ELOG_GSMI
318 case ELOG_GSMI_APM_CNT:
319 southbridge_smi_gsmi();
320 break;
321#endif
322 }
323
Aaron Durbin29ffa542012-12-21 21:21:48 -0600324 mainboard_smi_apmc(reg8);
Aaron Durbin76c37002012-10-30 09:03:43 -0500325}
326
Aaron Durbin29ffa542012-12-21 21:21:48 -0600327static void southbridge_smi_pm1(void)
Aaron Durbin76c37002012-10-30 09:03:43 -0500328{
Duncan Laurie467f31d2013-03-08 17:00:37 -0800329 u16 pm1_sts = clear_pm1_status();
Aaron Durbin76c37002012-10-30 09:03:43 -0500330
331 /* While OSPM is not active, poweroff immediately
332 * on a power button event.
333 */
334 if (pm1_sts & PWRBTN_STS) {
335 // power button pressed
Aaron Durbin76c37002012-10-30 09:03:43 -0500336#if CONFIG_ELOG_GSMI
337 elog_add_event(ELOG_TYPE_POWER_BUTTON);
338#endif
Duncan Laurie467f31d2013-03-08 17:00:37 -0800339 disable_pm1_control(-1UL);
340 enable_pm1_control(SLP_EN | (SLP_TYP_S5 << 10));
Aaron Durbin76c37002012-10-30 09:03:43 -0500341 }
342}
343
Aaron Durbin29ffa542012-12-21 21:21:48 -0600344static void southbridge_smi_gpe0(void)
Aaron Durbin76c37002012-10-30 09:03:43 -0500345{
Duncan Laurie467f31d2013-03-08 17:00:37 -0800346 clear_gpe_status();
Aaron Durbin76c37002012-10-30 09:03:43 -0500347}
348
Aaron Durbin29ffa542012-12-21 21:21:48 -0600349static void southbridge_smi_gpi(void)
Aaron Durbin76c37002012-10-30 09:03:43 -0500350{
Duncan Laurie467f31d2013-03-08 17:00:37 -0800351 mainboard_smi_gpi(clear_alt_smi_status());
Aaron Durbin76c37002012-10-30 09:03:43 -0500352
Duncan Laurie467f31d2013-03-08 17:00:37 -0800353 /* Clear again after mainboard handler */
354 clear_alt_smi_status();
Aaron Durbin76c37002012-10-30 09:03:43 -0500355}
356
Aaron Durbin29ffa542012-12-21 21:21:48 -0600357static void southbridge_smi_mc(void)
Aaron Durbin76c37002012-10-30 09:03:43 -0500358{
359 u32 reg32;
360
Duncan Laurie467f31d2013-03-08 17:00:37 -0800361 reg32 = inl(get_pmbase() + SMI_EN);
Aaron Durbin76c37002012-10-30 09:03:43 -0500362
Duncan Laurie467f31d2013-03-08 17:00:37 -0800363 /* Are microcontroller SMIs enabled? */
Aaron Durbin76c37002012-10-30 09:03:43 -0500364 if ((reg32 & MCSMI_EN) == 0)
365 return;
366
367 printk(BIOS_DEBUG, "Microcontroller SMI.\n");
368}
369
370
371
Aaron Durbin29ffa542012-12-21 21:21:48 -0600372static void southbridge_smi_tco(void)
Aaron Durbin76c37002012-10-30 09:03:43 -0500373{
Duncan Laurie467f31d2013-03-08 17:00:37 -0800374 u32 tco_sts = clear_tco_status();
Aaron Durbin76c37002012-10-30 09:03:43 -0500375
376 /* Any TCO event? */
377 if (!tco_sts)
378 return;
379
380 if (tco_sts & (1 << 8)) { // BIOSWR
381 u8 bios_cntl;
382
Aaron Durbin89f79a02012-10-31 23:05:25 -0500383 bios_cntl = pci_read_config16(PCI_DEV(0, 0x1f, 0), 0xdc);
Aaron Durbin76c37002012-10-30 09:03:43 -0500384
385 if (bios_cntl & 1) {
386 /* BWE is RW, so the SMI was caused by a
387 * write to BWE, not by a write to the BIOS
388 */
389
390 /* This is the place where we notice someone
391 * is trying to tinker with the BIOS. We are
392 * trying to be nice and just ignore it. A more
393 * resolute answer would be to power down the
394 * box.
395 */
396 printk(BIOS_DEBUG, "Switching back to RO\n");
Duncan Laurie467f31d2013-03-08 17:00:37 -0800397 pci_write_config32(PCI_DEV(0, 0x1f, 0), 0xdc,
398 (bios_cntl & ~1));
Aaron Durbin76c37002012-10-30 09:03:43 -0500399 } /* No else for now? */
400 } else if (tco_sts & (1 << 3)) { /* TIMEOUT */
401 /* Handle TCO timeout */
402 printk(BIOS_DEBUG, "TCO Timeout.\n");
Aaron Durbin76c37002012-10-30 09:03:43 -0500403 }
404}
405
Aaron Durbin29ffa542012-12-21 21:21:48 -0600406static void southbridge_smi_periodic(void)
Aaron Durbin76c37002012-10-30 09:03:43 -0500407{
408 u32 reg32;
409
Duncan Laurie467f31d2013-03-08 17:00:37 -0800410 reg32 = inl(get_pmbase() + SMI_EN);
Aaron Durbin76c37002012-10-30 09:03:43 -0500411
412 /* Are periodic SMIs enabled? */
413 if ((reg32 & PERIODIC_EN) == 0)
414 return;
415
416 printk(BIOS_DEBUG, "Periodic SMI.\n");
417}
418
Aaron Durbin29ffa542012-12-21 21:21:48 -0600419static void southbridge_smi_monitor(void)
Aaron Durbin76c37002012-10-30 09:03:43 -0500420{
421#define IOTRAP(x) (trap_sts & (1 << x))
422 u32 trap_sts, trap_cycle;
423 u32 data, mask = 0;
424 int i;
425
426 trap_sts = RCBA32(0x1e00); // TRSR - Trap Status Register
427 RCBA32(0x1e00) = trap_sts; // Clear trap(s) in TRSR
428
429 trap_cycle = RCBA32(0x1e10);
430 for (i=16; i<20; i++) {
431 if (trap_cycle & (1 << i))
432 mask |= (0xff << ((i - 16) << 2));
433 }
434
435
436 /* IOTRAP(3) SMI function call */
437 if (IOTRAP(3)) {
438 if (gnvs && gnvs->smif)
439 io_trap_handler(gnvs->smif); // call function smif
440 return;
441 }
442
443 /* IOTRAP(2) currently unused
444 * IOTRAP(1) currently unused */
445
446 /* IOTRAP(0) SMIC */
447 if (IOTRAP(0)) {
448 if (!(trap_cycle & (1 << 24))) { // It's a write
449 printk(BIOS_DEBUG, "SMI1 command\n");
450 data = RCBA32(0x1e18);
451 data &= mask;
452 // if (smi1)
453 // southbridge_smi_command(data);
454 // return;
455 }
456 // Fall through to debug
457 }
458
Duncan Laurie467f31d2013-03-08 17:00:37 -0800459 printk(BIOS_DEBUG, " trapped io address = 0x%x\n",
460 trap_cycle & 0xfffc);
461 for (i=0; i < 4; i++)
462 if(IOTRAP(i)) printk(BIOS_DEBUG, " TRAP = %d\n", i);
Aaron Durbin76c37002012-10-30 09:03:43 -0500463 printk(BIOS_DEBUG, " AHBE = %x\n", (trap_cycle >> 16) & 0xf);
464 printk(BIOS_DEBUG, " MASK = 0x%08x\n", mask);
Duncan Laurie467f31d2013-03-08 17:00:37 -0800465 printk(BIOS_DEBUG, " read/write: %s\n",
466 (trap_cycle & (1 << 24)) ? "read" : "write");
Aaron Durbin76c37002012-10-30 09:03:43 -0500467
468 if (!(trap_cycle & (1 << 24))) {
469 /* Write Cycle */
470 data = RCBA32(0x1e18);
471 printk(BIOS_DEBUG, " iotrap written data = 0x%08x\n", data);
472 }
473#undef IOTRAP
474}
475
Aaron Durbin29ffa542012-12-21 21:21:48 -0600476typedef void (*smi_handler_t)(void);
Aaron Durbin76c37002012-10-30 09:03:43 -0500477
478static smi_handler_t southbridge_smi[32] = {
479 NULL, // [0] reserved
480 NULL, // [1] reserved
481 NULL, // [2] BIOS_STS
482 NULL, // [3] LEGACY_USB_STS
483 southbridge_smi_sleep, // [4] SLP_SMI_STS
484 southbridge_smi_apmc, // [5] APM_STS
485 NULL, // [6] SWSMI_TMR_STS
486 NULL, // [7] reserved
487 southbridge_smi_pm1, // [8] PM1_STS
488 southbridge_smi_gpe0, // [9] GPE0_STS
489 southbridge_smi_gpi, // [10] GPI_STS
490 southbridge_smi_mc, // [11] MCSMI_STS
491 NULL, // [12] DEVMON_STS
492 southbridge_smi_tco, // [13] TCO_STS
493 southbridge_smi_periodic, // [14] PERIODIC_STS
494 NULL, // [15] SERIRQ_SMI_STS
495 NULL, // [16] SMBUS_SMI_STS
496 NULL, // [17] LEGACY_USB2_STS
497 NULL, // [18] INTEL_USB2_STS
498 NULL, // [19] reserved
499 NULL, // [20] PCI_EXP_SMI_STS
500 southbridge_smi_monitor, // [21] MONITOR_STS
501 NULL, // [22] reserved
502 NULL, // [23] reserved
503 NULL, // [24] reserved
504 NULL, // [25] EL_SMI_STS
505 NULL, // [26] SPI_STS
506 NULL, // [27] reserved
507 NULL, // [28] reserved
508 NULL, // [29] reserved
509 NULL, // [30] reserved
510 NULL // [31] reserved
511};
512
513/**
514 * @brief Interrupt handler for SMI#
515 *
516 * @param smm_revision revision of the smm state save map
517 */
518
Aaron Durbin29ffa542012-12-21 21:21:48 -0600519void southbridge_smi_handler(void)
Aaron Durbin76c37002012-10-30 09:03:43 -0500520{
Duncan Laurie467f31d2013-03-08 17:00:37 -0800521 int i;
Aaron Durbin76c37002012-10-30 09:03:43 -0500522 u32 smi_sts;
523
Aaron Durbin76c37002012-10-30 09:03:43 -0500524 /* We need to clear the SMI status registers, or we won't see what's
525 * happening in the following calls.
526 */
Duncan Laurie467f31d2013-03-08 17:00:37 -0800527 smi_sts = clear_smi_status();
Aaron Durbin76c37002012-10-30 09:03:43 -0500528
529 /* Call SMI sub handler for each of the status bits */
530 for (i = 0; i < 31; i++) {
531 if (smi_sts & (1 << i)) {
532 if (southbridge_smi[i]) {
Aaron Durbin29ffa542012-12-21 21:21:48 -0600533 southbridge_smi[i]();
Aaron Durbin76c37002012-10-30 09:03:43 -0500534 } else {
Duncan Laurie467f31d2013-03-08 17:00:37 -0800535 printk(BIOS_DEBUG,
536 "SMI_STS[%d] occured, but no "
537 "handler available.\n", i);
Aaron Durbin76c37002012-10-30 09:03:43 -0500538 }
539 }
540 }
Aaron Durbin76c37002012-10-30 09:03:43 -0500541}