blob: bad158748d81cedff1ad977830a518093b894d42 [file] [log] [blame]
Duncan Lauriec88c54c2014-04-30 16:36:13 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008-2009 coresystems GmbH
5 * Copyright (C) 2014 Google Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Duncan Lauriec88c54c2014-04-30 16:36:13 -070015 */
16
17#include <delay.h>
18#include <types.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070019#include <arch/io.h>
Kyösti Mälkki13f66502019-03-03 08:01:05 +020020#include <device/mmio.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020021#include <device/pci_ops.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070022#include <console/console.h>
23#include <cpu/x86/cache.h>
24#include <device/pci_def.h>
25#include <cpu/x86/smm.h>
Kyösti Mälkkie31ec292019-08-10 17:27:01 +030026#include <cpu/intel/em64t101_save_state.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070027#include <spi-generic.h>
28#include <elog.h>
Patrick Georgi546953c2014-11-29 10:38:17 +010029#include <halt.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070030#include <pc80/mc146818rtc.h>
Julius Werner4ee4bd52014-10-20 13:46:39 -070031#include <soc/lpc.h>
32#include <soc/nvs.h>
33#include <soc/pci_devs.h>
34#include <soc/pm.h>
35#include <soc/rcba.h>
36#include <soc/smm.h>
37#include <soc/xhci.h>
Duncan Laurief3e0a132015-01-14 17:33:00 -080038#include <drivers/intel/gma/i915_reg.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070039
40static u8 smm_initialized = 0;
41
42/*
43 * GNVS needs to be updated by an 0xEA PM Trap (B2) after it has been located
44 * by coreboot.
45 */
46static global_nvs_t *gnvs;
47global_nvs_t *smm_get_gnvs(void)
48{
49 return gnvs;
50}
51
52int southbridge_io_trap_handler(int smif)
53{
54 switch (smif) {
55 case 0x32:
56 printk(BIOS_DEBUG, "OS Init\n");
57 /* gnvs->smif:
58 * On success, the IO Trap Handler returns 0
59 * On failure, the IO Trap Handler returns a value != 0
60 */
61 gnvs->smif = 0;
62 return 1; /* IO trap handled */
63 }
64
65 /* Not handled */
66 return 0;
67}
68
69/**
70 * @brief Set the EOS bit
71 */
72void southbridge_smi_set_eos(void)
73{
74 enable_smi(EOS);
75}
76
77static void busmaster_disable_on_bus(int bus)
78{
Lee Leahy26b7cd02017-03-16 18:47:55 -070079 int slot, func;
80 unsigned int val;
81 unsigned char hdr;
Duncan Lauriec88c54c2014-04-30 16:36:13 -070082
Lee Leahy26b7cd02017-03-16 18:47:55 -070083 for (slot = 0; slot < 0x20; slot++) {
84 for (func = 0; func < 8; func++) {
85 u32 reg32;
Duncan Lauriec88c54c2014-04-30 16:36:13 -070086
Kyösti Mälkkie16c9df2018-12-29 08:04:16 +020087 pci_devfn_t dev = PCI_DEV(bus, slot, func);
Lee Leahy26b7cd02017-03-16 18:47:55 -070088 val = pci_read_config32(dev, PCI_VENDOR_ID);
Duncan Lauriec88c54c2014-04-30 16:36:13 -070089
Lee Leahy26b7cd02017-03-16 18:47:55 -070090 if (val == 0xffffffff || val == 0x00000000 ||
91 val == 0x0000ffff || val == 0xffff0000)
92 continue;
Duncan Lauriec88c54c2014-04-30 16:36:13 -070093
Lee Leahy26b7cd02017-03-16 18:47:55 -070094 /* Disable Bus Mastering for this one device */
95 reg32 = pci_read_config32(dev, PCI_COMMAND);
96 reg32 &= ~PCI_COMMAND_MASTER;
97 pci_write_config32(dev, PCI_COMMAND, reg32);
Duncan Lauriec88c54c2014-04-30 16:36:13 -070098
Lee Leahy26b7cd02017-03-16 18:47:55 -070099 /* If this is a bridge, then follow it. */
100 hdr = pci_read_config8(dev, PCI_HEADER_TYPE);
101 hdr &= 0x7f;
102 if (hdr == PCI_HEADER_TYPE_BRIDGE ||
103 hdr == PCI_HEADER_TYPE_CARDBUS) {
104 unsigned int buses;
105 buses = pci_read_config32(dev, PCI_PRIMARY_BUS);
106 busmaster_disable_on_bus((buses >> 8) & 0xff);
107 }
108 }
109 }
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700110}
111
Duncan Laurief3e0a132015-01-14 17:33:00 -0800112/*
113 * Turn off the backlight if it is on, and wait for the specified
114 * backlight off delay. This will allow panel power timings to meet
115 * spec and prevent brief garbage on the screen when turned off
116 * during firmware with power button triggered SMI.
117 */
118static void backlight_off(void)
119{
120 void *reg_base;
121 uint32_t pp_ctrl;
122 uint32_t bl_off_delay;
123
Lee Leahy6ef51922017-03-17 10:56:08 -0700124 reg_base = (void *)((uintptr_t)pci_read_config32(SA_DEV_IGD,
125 PCI_BASE_ADDRESS_0) & ~0xf);
Duncan Laurief3e0a132015-01-14 17:33:00 -0800126
127 /* Check if backlight is enabled */
128 pp_ctrl = read32(reg_base + PCH_PP_CONTROL);
129 if (!(pp_ctrl & EDP_BLC_ENABLE))
130 return;
131
132 /* Enable writes to this register */
133 pp_ctrl &= ~PANEL_UNLOCK_MASK;
134 pp_ctrl |= PANEL_UNLOCK_REGS;
135
136 /* Turn off backlight */
137 pp_ctrl &= ~EDP_BLC_ENABLE;
138
139 write32(reg_base + PCH_PP_CONTROL, pp_ctrl);
140 read32(reg_base + PCH_PP_CONTROL);
141
142 /* Read backlight off delay in 100us units */
143 bl_off_delay = read32(reg_base + PCH_PP_OFF_DELAYS);
144 bl_off_delay &= PANEL_LIGHT_OFF_DELAY_MASK;
145 bl_off_delay *= 100;
146
147 /* Wait for backlight to turn off */
148 udelay(bl_off_delay);
149
150 printk(BIOS_INFO, "Backlight turned off\n");
151}
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700152
153static void southbridge_smi_sleep(void)
154{
155 u8 reg8;
156 u32 reg32;
157 u8 slp_typ;
Nico Huber9faae2b2018-11-14 00:00:35 +0100158 u8 s5pwr = CONFIG_MAINBOARD_POWER_FAILURE_STATE;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700159
160 /* save and recover RTC port values */
161 u8 tmp70, tmp72;
162 tmp70 = inb(0x70);
163 tmp72 = inb(0x72);
164 get_option(&s5pwr, "power_on_after_fail");
165 outb(tmp70, 0x70);
166 outb(tmp72, 0x72);
167
168 /* First, disable further SMIs */
169 disable_smi(SLP_SMI_EN);
170
171 /* Figure out SLP_TYP */
172 reg32 = inl(ACPI_BASE_ADDRESS + PM1_CNT);
173 printk(BIOS_SPEW, "SMI#: SLP = 0x%08x\n", reg32);
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500174 slp_typ = acpi_sleep_from_pm1(reg32);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700175
176 /* Do any mainboard sleep handling */
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500177 mainboard_smi_sleep(slp_typ);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700178
179 /* USB sleep preparations */
180 usb_xhci_sleep_prepare(PCH_DEV_XHCI, slp_typ);
181
Julius Wernercd49cce2019-03-05 16:53:33 -0800182#if CONFIG(ELOG_GSMI)
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700183 /* Log S3, S4, and S5 entry */
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500184 if (slp_typ >= ACPI_S3)
185 elog_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700186#endif
187
Duncan Lauried775dda2014-10-25 01:49:32 -0700188 /* Clear pending GPE events */
189 clear_gpe_status();
190
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700191 /* Next, do the deed.
192 */
193
194 switch (slp_typ) {
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500195 case ACPI_S0:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700196 printk(BIOS_DEBUG, "SMI#: Entering S0 (On)\n");
197 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500198 case ACPI_S1:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700199 printk(BIOS_DEBUG, "SMI#: Entering S1 (Assert STPCLK#)\n");
200 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500201 case ACPI_S3:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700202 printk(BIOS_DEBUG, "SMI#: Entering S3 (Suspend-To-RAM)\n");
203
204 /* Invalidate the cache before going to S3 */
205 wbinvd();
206 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500207 case ACPI_S4:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700208 printk(BIOS_DEBUG, "SMI#: Entering S4 (Suspend-To-Disk)\n");
209 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500210 case ACPI_S5:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700211 printk(BIOS_DEBUG, "SMI#: Entering S5 (Soft Power off)\n");
212
Duncan Laurief3e0a132015-01-14 17:33:00 -0800213 /* Turn off backlight if needed */
214 backlight_off();
215
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700216 /* Disable all GPE */
217 disable_all_gpe();
218
219 /* Always set the flag in case CMOS was changed on runtime. For
220 * "KEEP", switch to "OFF" - KEEP is software emulated
221 */
222 reg8 = pci_read_config8(PCH_DEV_LPC, GEN_PMCON_3);
223 if (s5pwr == MAINBOARD_POWER_ON)
224 reg8 &= ~1;
225 else
226 reg8 |= 1;
227 pci_write_config8(PCH_DEV_LPC, GEN_PMCON_3, reg8);
228
229 /* also iterates over all bridges on bus 0 */
230 busmaster_disable_on_bus(0);
231 break;
232 default:
233 printk(BIOS_DEBUG, "SMI#: ERROR: SLP_TYP reserved\n");
234 break;
235 }
236
237 /*
238 * Write back to the SLP register to cause the originally intended
239 * event again. We need to set BIT13 (SLP_EN) though to make the
240 * sleep happen.
241 */
242 enable_pm1_control(SLP_EN);
243
244 /* Make sure to stop executing code here for S3/S4/S5 */
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500245 if (slp_typ >= ACPI_S3)
Patrick Georgi546953c2014-11-29 10:38:17 +0100246 halt();
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700247
248 /*
249 * In most sleep states, the code flow of this function ends at
250 * the line above. However, if we entered sleep state S1 and wake
251 * up again, we will continue to execute code in this function.
252 */
253 reg32 = inl(ACPI_BASE_ADDRESS + PM1_CNT);
254 if (reg32 & SCI_EN) {
255 /* The OS is not an ACPI OS, so we set the state to S0 */
256 disable_pm1_control(SLP_EN | SLP_TYP);
257 }
258}
259
260/*
261 * Look for Synchronous IO SMI and use save state from that
262 * core in case we are not running on the same core that
263 * initiated the IO transaction.
264 */
265static em64t101_smm_state_save_area_t *smi_apmc_find_state_save(u8 cmd)
266{
267 em64t101_smm_state_save_area_t *state;
268 int node;
269
270 /* Check all nodes looking for the one that issued the IO */
271 for (node = 0; node < CONFIG_MAX_CPUS; node++) {
272 state = smm_get_save_state(node);
273
274 /* Check for Synchronous IO (bit0==1) */
275 if (!(state->io_misc_info & (1 << 0)))
276 continue;
277
278 /* Make sure it was a write (bit4==0) */
279 if (state->io_misc_info & (1 << 4))
280 continue;
281
282 /* Check for APMC IO port */
283 if (((state->io_misc_info >> 16) & 0xff) != APM_CNT)
284 continue;
285
286 /* Check AX against the requested command */
287 if ((state->rax & 0xff) != cmd)
288 continue;
289
290 return state;
291 }
292
293 return NULL;
294}
295
Julius Wernercd49cce2019-03-05 16:53:33 -0800296#if CONFIG(ELOG_GSMI)
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700297static void southbridge_smi_gsmi(void)
298{
299 u32 *ret, *param;
300 u8 sub_command;
301 em64t101_smm_state_save_area_t *io_smi =
Patrick Georgid61839c2018-12-03 16:10:33 +0100302 smi_apmc_find_state_save(APM_CNT_ELOG_GSMI);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700303
304 if (!io_smi)
305 return;
306
307 /* Command and return value in EAX */
Lee Leahy26b7cd02017-03-16 18:47:55 -0700308 ret = (u32 *)&io_smi->rax;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700309 sub_command = (u8)(*ret >> 8);
310
311 /* Parameter buffer in EBX */
Lee Leahy26b7cd02017-03-16 18:47:55 -0700312 param = (u32 *)&io_smi->rbx;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700313
314 /* drivers/elog/gsmi.c */
315 *ret = gsmi_exec(sub_command, param);
316}
317#endif
318
319static void finalize(void)
320{
321 static int finalize_done;
322
323 if (finalize_done) {
324 printk(BIOS_DEBUG, "SMM already finalized.\n");
325 return;
326 }
327 finalize_done = 1;
328
Julius Wernercd49cce2019-03-05 16:53:33 -0800329#if CONFIG(SPI_FLASH_SMM)
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700330 /* Re-init SPI driver to handle locked BAR */
331 spi_init();
332#endif
333}
334
335static void southbridge_smi_apmc(void)
336{
337 u8 reg8;
338 em64t101_smm_state_save_area_t *state;
339
340 /* Emulate B2 register as the FADT / Linux expects it */
341
342 reg8 = inb(APM_CNT);
343 switch (reg8) {
344 case APM_CNT_CST_CONTROL:
345 printk(BIOS_DEBUG, "C-state control\n");
346 break;
347 case APM_CNT_PST_CONTROL:
348 printk(BIOS_DEBUG, "P-state control\n");
349 break;
350 case APM_CNT_ACPI_DISABLE:
351 disable_pm1_control(SCI_EN);
352 printk(BIOS_DEBUG, "SMI#: ACPI disabled.\n");
353 break;
354 case APM_CNT_ACPI_ENABLE:
355 enable_pm1_control(SCI_EN);
356 printk(BIOS_DEBUG, "SMI#: ACPI enabled.\n");
357 break;
358 case APM_CNT_FINALIZE:
359 finalize();
360 break;
361 case APM_CNT_GNVS_UPDATE:
362 if (smm_initialized) {
363 printk(BIOS_DEBUG,
364 "SMI#: SMM structures already initialized!\n");
365 return;
366 }
367 state = smi_apmc_find_state_save(reg8);
368 if (state) {
369 /* EBX in the state save contains the GNVS pointer */
370 gnvs = (global_nvs_t *)((u32)state->rbx);
371 smm_initialized = 1;
372 printk(BIOS_DEBUG, "SMI#: Setting GNVS to %p\n", gnvs);
373 }
374 break;
Julius Wernercd49cce2019-03-05 16:53:33 -0800375#if CONFIG(ELOG_GSMI)
Patrick Georgid61839c2018-12-03 16:10:33 +0100376 case APM_CNT_ELOG_GSMI:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700377 southbridge_smi_gsmi();
378 break;
379#endif
380 }
381
382 mainboard_smi_apmc(reg8);
383}
384
385static void southbridge_smi_pm1(void)
386{
387 u16 pm1_sts = clear_pm1_status();
388
389 /* While OSPM is not active, poweroff immediately
390 * on a power button event.
391 */
392 if (pm1_sts & PWRBTN_STS) {
393 /* power button pressed */
Julius Wernercd49cce2019-03-05 16:53:33 -0800394#if CONFIG(ELOG_GSMI)
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700395 elog_add_event(ELOG_TYPE_POWER_BUTTON);
396#endif
397 disable_pm1_control(-1UL);
398 enable_pm1_control(SLP_EN | (SLP_TYP_S5 << 10));
399 }
400}
401
402static void southbridge_smi_gpe0(void)
403{
404 clear_gpe_status();
405}
406
407static void southbridge_smi_gpi(void)
408{
409 mainboard_smi_gpi(clear_alt_smi_status());
410
411 /* Clear again after mainboard handler */
412 clear_alt_smi_status();
413}
414
415static void southbridge_smi_mc(void)
416{
417 u32 reg32 = inl(ACPI_BASE_ADDRESS + SMI_EN);
418
419 /* Are microcontroller SMIs enabled? */
420 if ((reg32 & MCSMI_EN) == 0)
421 return;
422
423 printk(BIOS_DEBUG, "Microcontroller SMI.\n");
424}
425
426static void southbridge_smi_tco(void)
427{
428 u32 tco_sts = clear_tco_status();
429
430 /* Any TCO event? */
431 if (!tco_sts)
432 return;
433
Lee Leahy8a9c7dc2017-03-17 10:43:25 -0700434 // BIOSWR
435 if (tco_sts & (1 << 8)) {
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700436 u8 bios_cntl = pci_read_config16(PCH_DEV_LPC, BIOS_CNTL);
437
438 if (bios_cntl & 1) {
439 /*
440 * BWE is RW, so the SMI was caused by a
441 * write to BWE, not by a write to the BIOS
442 *
443 * This is the place where we notice someone
444 * is trying to tinker with the BIOS. We are
445 * trying to be nice and just ignore it. A more
446 * resolute answer would be to power down the
447 * box.
448 */
449 printk(BIOS_DEBUG, "Switching back to RO\n");
450 pci_write_config32(PCH_DEV_LPC, BIOS_CNTL,
451 (bios_cntl & ~1));
452 } /* No else for now? */
453 } else if (tco_sts & (1 << 3)) { /* TIMEOUT */
454 /* Handle TCO timeout */
455 printk(BIOS_DEBUG, "TCO Timeout.\n");
456 }
457}
458
459static void southbridge_smi_periodic(void)
460{
461 u32 reg32 = inl(ACPI_BASE_ADDRESS + SMI_EN);
462
463 /* Are periodic SMIs enabled? */
464 if ((reg32 & PERIODIC_EN) == 0)
465 return;
466
467 printk(BIOS_DEBUG, "Periodic SMI.\n");
468}
469
470static void southbridge_smi_monitor(void)
471{
472#define IOTRAP(x) (trap_sts & (1 << x))
473 u32 trap_sts, trap_cycle;
474 u32 data, mask = 0;
475 int i;
476
477 trap_sts = RCBA32(0x1e00); // TRSR - Trap Status Register
478 RCBA32(0x1e00) = trap_sts; // Clear trap(s) in TRSR
479
480 trap_cycle = RCBA32(0x1e10);
Lee Leahy26b7cd02017-03-16 18:47:55 -0700481 for (i = 16; i < 20; i++) {
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700482 if (trap_cycle & (1 << i))
483 mask |= (0xff << ((i - 16) << 2));
484 }
485
486
487 /* IOTRAP(3) SMI function call */
488 if (IOTRAP(3)) {
489 if (gnvs && gnvs->smif)
490 io_trap_handler(gnvs->smif); // call function smif
491 return;
492 }
493
494 /* IOTRAP(2) currently unused
495 * IOTRAP(1) currently unused */
496
497 /* IOTRAP(0) SMIC */
498 if (IOTRAP(0)) {
Lee Leahy8a9c7dc2017-03-17 10:43:25 -0700499 // It's a write
500 if (!(trap_cycle & (1 << 24))) {
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700501 printk(BIOS_DEBUG, "SMI1 command\n");
502 data = RCBA32(0x1e18);
503 data &= mask;
504 // if (smi1)
Lee Leahy26b7cd02017-03-16 18:47:55 -0700505 // southbridge_smi_command(data);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700506 // return;
507 }
508 // Fall through to debug
509 }
510
511 printk(BIOS_DEBUG, " trapped io address = 0x%x\n",
512 trap_cycle & 0xfffc);
Lee Leahy26b7cd02017-03-16 18:47:55 -0700513 for (i = 0; i < 4; i++)
Lee Leahy8a9c7dc2017-03-17 10:43:25 -0700514 if (IOTRAP(i))
515 printk(BIOS_DEBUG, " TRAP = %d\n", i);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700516 printk(BIOS_DEBUG, " AHBE = %x\n", (trap_cycle >> 16) & 0xf);
517 printk(BIOS_DEBUG, " MASK = 0x%08x\n", mask);
518 printk(BIOS_DEBUG, " read/write: %s\n",
519 (trap_cycle & (1 << 24)) ? "read" : "write");
520
521 if (!(trap_cycle & (1 << 24))) {
522 /* Write Cycle */
523 data = RCBA32(0x1e18);
524 printk(BIOS_DEBUG, " iotrap written data = 0x%08x\n", data);
525 }
526#undef IOTRAP
527}
528
529typedef void (*smi_handler_t)(void);
530
531static smi_handler_t southbridge_smi[32] = {
532 NULL, // [0] reserved
533 NULL, // [1] reserved
534 NULL, // [2] BIOS_STS
535 NULL, // [3] LEGACY_USB_STS
536 southbridge_smi_sleep, // [4] SLP_SMI_STS
537 southbridge_smi_apmc, // [5] APM_STS
538 NULL, // [6] SWSMI_TMR_STS
539 NULL, // [7] reserved
540 southbridge_smi_pm1, // [8] PM1_STS
541 southbridge_smi_gpe0, // [9] GPE0_STS
542 southbridge_smi_gpi, // [10] GPI_STS
543 southbridge_smi_mc, // [11] MCSMI_STS
544 NULL, // [12] DEVMON_STS
545 southbridge_smi_tco, // [13] TCO_STS
546 southbridge_smi_periodic, // [14] PERIODIC_STS
547 NULL, // [15] SERIRQ_SMI_STS
548 NULL, // [16] SMBUS_SMI_STS
549 NULL, // [17] LEGACY_USB2_STS
550 NULL, // [18] INTEL_USB2_STS
551 NULL, // [19] reserved
552 NULL, // [20] PCI_EXP_SMI_STS
553 southbridge_smi_monitor, // [21] MONITOR_STS
554 NULL, // [22] reserved
555 NULL, // [23] reserved
556 NULL, // [24] reserved
557 NULL, // [25] EL_SMI_STS
558 NULL, // [26] SPI_STS
559 NULL, // [27] reserved
560 NULL, // [28] reserved
561 NULL, // [29] reserved
562 NULL, // [30] reserved
563 NULL // [31] reserved
564};
565
566/**
567 * @brief Interrupt handler for SMI#
568 *
569 * @param smm_revision revision of the smm state save map
570 */
571
572void southbridge_smi_handler(void)
573{
574 int i;
575 u32 smi_sts;
576
577 /* We need to clear the SMI status registers, or we won't see what's
578 * happening in the following calls.
579 */
580 smi_sts = clear_smi_status();
581
582 /* Call SMI sub handler for each of the status bits */
583 for (i = 0; i < 31; i++) {
584 if (smi_sts & (1 << i)) {
585 if (southbridge_smi[i]) {
586 southbridge_smi[i]();
587 } else {
588 printk(BIOS_DEBUG,
Martin Rothde7ed6f2014-12-07 14:58:18 -0700589 "SMI_STS[%d] occurred, but no "
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700590 "handler available.\n", i);
591 }
592 }
593 }
594}