blob: 9f5d81dc31b702727390d7f4f6e6331da27eb441 [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>
26#include <spi-generic.h>
27#include <elog.h>
Patrick Georgi546953c2014-11-29 10:38:17 +010028#include <halt.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070029#include <pc80/mc146818rtc.h>
Julius Werner4ee4bd52014-10-20 13:46:39 -070030#include <soc/lpc.h>
31#include <soc/nvs.h>
32#include <soc/pci_devs.h>
33#include <soc/pm.h>
34#include <soc/rcba.h>
35#include <soc/smm.h>
36#include <soc/xhci.h>
Duncan Laurief3e0a132015-01-14 17:33:00 -080037#include <drivers/intel/gma/i915_reg.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070038
39static u8 smm_initialized = 0;
40
41/*
42 * GNVS needs to be updated by an 0xEA PM Trap (B2) after it has been located
43 * by coreboot.
44 */
45static global_nvs_t *gnvs;
46global_nvs_t *smm_get_gnvs(void)
47{
48 return gnvs;
49}
50
51int southbridge_io_trap_handler(int smif)
52{
53 switch (smif) {
54 case 0x32:
55 printk(BIOS_DEBUG, "OS Init\n");
56 /* gnvs->smif:
57 * On success, the IO Trap Handler returns 0
58 * On failure, the IO Trap Handler returns a value != 0
59 */
60 gnvs->smif = 0;
61 return 1; /* IO trap handled */
62 }
63
64 /* Not handled */
65 return 0;
66}
67
68/**
69 * @brief Set the EOS bit
70 */
71void southbridge_smi_set_eos(void)
72{
73 enable_smi(EOS);
74}
75
76static void busmaster_disable_on_bus(int bus)
77{
Lee Leahy26b7cd02017-03-16 18:47:55 -070078 int slot, func;
79 unsigned int val;
80 unsigned char hdr;
Duncan Lauriec88c54c2014-04-30 16:36:13 -070081
Lee Leahy26b7cd02017-03-16 18:47:55 -070082 for (slot = 0; slot < 0x20; slot++) {
83 for (func = 0; func < 8; func++) {
84 u32 reg32;
Duncan Lauriec88c54c2014-04-30 16:36:13 -070085
Kyösti Mälkkie16c9df2018-12-29 08:04:16 +020086 pci_devfn_t dev = PCI_DEV(bus, slot, func);
Lee Leahy26b7cd02017-03-16 18:47:55 -070087 val = pci_read_config32(dev, PCI_VENDOR_ID);
Duncan Lauriec88c54c2014-04-30 16:36:13 -070088
Lee Leahy26b7cd02017-03-16 18:47:55 -070089 if (val == 0xffffffff || val == 0x00000000 ||
90 val == 0x0000ffff || val == 0xffff0000)
91 continue;
Duncan Lauriec88c54c2014-04-30 16:36:13 -070092
Lee Leahy26b7cd02017-03-16 18:47:55 -070093 /* Disable Bus Mastering for this one device */
94 reg32 = pci_read_config32(dev, PCI_COMMAND);
95 reg32 &= ~PCI_COMMAND_MASTER;
96 pci_write_config32(dev, PCI_COMMAND, reg32);
Duncan Lauriec88c54c2014-04-30 16:36:13 -070097
Lee Leahy26b7cd02017-03-16 18:47:55 -070098 /* If this is a bridge, then follow it. */
99 hdr = pci_read_config8(dev, PCI_HEADER_TYPE);
100 hdr &= 0x7f;
101 if (hdr == PCI_HEADER_TYPE_BRIDGE ||
102 hdr == PCI_HEADER_TYPE_CARDBUS) {
103 unsigned int buses;
104 buses = pci_read_config32(dev, PCI_PRIMARY_BUS);
105 busmaster_disable_on_bus((buses >> 8) & 0xff);
106 }
107 }
108 }
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700109}
110
Duncan Laurief3e0a132015-01-14 17:33:00 -0800111/*
112 * Turn off the backlight if it is on, and wait for the specified
113 * backlight off delay. This will allow panel power timings to meet
114 * spec and prevent brief garbage on the screen when turned off
115 * during firmware with power button triggered SMI.
116 */
117static void backlight_off(void)
118{
119 void *reg_base;
120 uint32_t pp_ctrl;
121 uint32_t bl_off_delay;
122
Lee Leahy6ef51922017-03-17 10:56:08 -0700123 reg_base = (void *)((uintptr_t)pci_read_config32(SA_DEV_IGD,
124 PCI_BASE_ADDRESS_0) & ~0xf);
Duncan Laurief3e0a132015-01-14 17:33:00 -0800125
126 /* Check if backlight is enabled */
127 pp_ctrl = read32(reg_base + PCH_PP_CONTROL);
128 if (!(pp_ctrl & EDP_BLC_ENABLE))
129 return;
130
131 /* Enable writes to this register */
132 pp_ctrl &= ~PANEL_UNLOCK_MASK;
133 pp_ctrl |= PANEL_UNLOCK_REGS;
134
135 /* Turn off backlight */
136 pp_ctrl &= ~EDP_BLC_ENABLE;
137
138 write32(reg_base + PCH_PP_CONTROL, pp_ctrl);
139 read32(reg_base + PCH_PP_CONTROL);
140
141 /* Read backlight off delay in 100us units */
142 bl_off_delay = read32(reg_base + PCH_PP_OFF_DELAYS);
143 bl_off_delay &= PANEL_LIGHT_OFF_DELAY_MASK;
144 bl_off_delay *= 100;
145
146 /* Wait for backlight to turn off */
147 udelay(bl_off_delay);
148
149 printk(BIOS_INFO, "Backlight turned off\n");
150}
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700151
152static void southbridge_smi_sleep(void)
153{
154 u8 reg8;
155 u32 reg32;
156 u8 slp_typ;
Nico Huber9faae2b2018-11-14 00:00:35 +0100157 u8 s5pwr = CONFIG_MAINBOARD_POWER_FAILURE_STATE;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700158
159 /* save and recover RTC port values */
160 u8 tmp70, tmp72;
161 tmp70 = inb(0x70);
162 tmp72 = inb(0x72);
163 get_option(&s5pwr, "power_on_after_fail");
164 outb(tmp70, 0x70);
165 outb(tmp72, 0x72);
166
167 /* First, disable further SMIs */
168 disable_smi(SLP_SMI_EN);
169
170 /* Figure out SLP_TYP */
171 reg32 = inl(ACPI_BASE_ADDRESS + PM1_CNT);
172 printk(BIOS_SPEW, "SMI#: SLP = 0x%08x\n", reg32);
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500173 slp_typ = acpi_sleep_from_pm1(reg32);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700174
175 /* Do any mainboard sleep handling */
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500176 mainboard_smi_sleep(slp_typ);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700177
178 /* USB sleep preparations */
179 usb_xhci_sleep_prepare(PCH_DEV_XHCI, slp_typ);
180
Martin Rothe6ff1592017-06-24 21:34:29 -0600181#if IS_ENABLED(CONFIG_ELOG_GSMI)
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700182 /* Log S3, S4, and S5 entry */
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500183 if (slp_typ >= ACPI_S3)
184 elog_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700185#endif
186
Duncan Lauried775dda2014-10-25 01:49:32 -0700187 /* Clear pending GPE events */
188 clear_gpe_status();
189
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700190 /* Next, do the deed.
191 */
192
193 switch (slp_typ) {
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500194 case ACPI_S0:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700195 printk(BIOS_DEBUG, "SMI#: Entering S0 (On)\n");
196 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500197 case ACPI_S1:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700198 printk(BIOS_DEBUG, "SMI#: Entering S1 (Assert STPCLK#)\n");
199 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500200 case ACPI_S3:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700201 printk(BIOS_DEBUG, "SMI#: Entering S3 (Suspend-To-RAM)\n");
202
203 /* Invalidate the cache before going to S3 */
204 wbinvd();
205 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500206 case ACPI_S4:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700207 printk(BIOS_DEBUG, "SMI#: Entering S4 (Suspend-To-Disk)\n");
208 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500209 case ACPI_S5:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700210 printk(BIOS_DEBUG, "SMI#: Entering S5 (Soft Power off)\n");
211
Duncan Laurief3e0a132015-01-14 17:33:00 -0800212 /* Turn off backlight if needed */
213 backlight_off();
214
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700215 /* Disable all GPE */
216 disable_all_gpe();
217
218 /* Always set the flag in case CMOS was changed on runtime. For
219 * "KEEP", switch to "OFF" - KEEP is software emulated
220 */
221 reg8 = pci_read_config8(PCH_DEV_LPC, GEN_PMCON_3);
222 if (s5pwr == MAINBOARD_POWER_ON)
223 reg8 &= ~1;
224 else
225 reg8 |= 1;
226 pci_write_config8(PCH_DEV_LPC, GEN_PMCON_3, reg8);
227
228 /* also iterates over all bridges on bus 0 */
229 busmaster_disable_on_bus(0);
230 break;
231 default:
232 printk(BIOS_DEBUG, "SMI#: ERROR: SLP_TYP reserved\n");
233 break;
234 }
235
236 /*
237 * Write back to the SLP register to cause the originally intended
238 * event again. We need to set BIT13 (SLP_EN) though to make the
239 * sleep happen.
240 */
241 enable_pm1_control(SLP_EN);
242
243 /* Make sure to stop executing code here for S3/S4/S5 */
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500244 if (slp_typ >= ACPI_S3)
Patrick Georgi546953c2014-11-29 10:38:17 +0100245 halt();
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700246
247 /*
248 * In most sleep states, the code flow of this function ends at
249 * the line above. However, if we entered sleep state S1 and wake
250 * up again, we will continue to execute code in this function.
251 */
252 reg32 = inl(ACPI_BASE_ADDRESS + PM1_CNT);
253 if (reg32 & SCI_EN) {
254 /* The OS is not an ACPI OS, so we set the state to S0 */
255 disable_pm1_control(SLP_EN | SLP_TYP);
256 }
257}
258
259/*
260 * Look for Synchronous IO SMI and use save state from that
261 * core in case we are not running on the same core that
262 * initiated the IO transaction.
263 */
264static em64t101_smm_state_save_area_t *smi_apmc_find_state_save(u8 cmd)
265{
266 em64t101_smm_state_save_area_t *state;
267 int node;
268
269 /* Check all nodes looking for the one that issued the IO */
270 for (node = 0; node < CONFIG_MAX_CPUS; node++) {
271 state = smm_get_save_state(node);
272
273 /* Check for Synchronous IO (bit0==1) */
274 if (!(state->io_misc_info & (1 << 0)))
275 continue;
276
277 /* Make sure it was a write (bit4==0) */
278 if (state->io_misc_info & (1 << 4))
279 continue;
280
281 /* Check for APMC IO port */
282 if (((state->io_misc_info >> 16) & 0xff) != APM_CNT)
283 continue;
284
285 /* Check AX against the requested command */
286 if ((state->rax & 0xff) != cmd)
287 continue;
288
289 return state;
290 }
291
292 return NULL;
293}
294
Martin Rothe6ff1592017-06-24 21:34:29 -0600295#if IS_ENABLED(CONFIG_ELOG_GSMI)
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700296static void southbridge_smi_gsmi(void)
297{
298 u32 *ret, *param;
299 u8 sub_command;
300 em64t101_smm_state_save_area_t *io_smi =
Patrick Georgid61839c2018-12-03 16:10:33 +0100301 smi_apmc_find_state_save(APM_CNT_ELOG_GSMI);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700302
303 if (!io_smi)
304 return;
305
306 /* Command and return value in EAX */
Lee Leahy26b7cd02017-03-16 18:47:55 -0700307 ret = (u32 *)&io_smi->rax;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700308 sub_command = (u8)(*ret >> 8);
309
310 /* Parameter buffer in EBX */
Lee Leahy26b7cd02017-03-16 18:47:55 -0700311 param = (u32 *)&io_smi->rbx;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700312
313 /* drivers/elog/gsmi.c */
314 *ret = gsmi_exec(sub_command, param);
315}
316#endif
317
318static void finalize(void)
319{
320 static int finalize_done;
321
322 if (finalize_done) {
323 printk(BIOS_DEBUG, "SMM already finalized.\n");
324 return;
325 }
326 finalize_done = 1;
327
Martin Rothe6ff1592017-06-24 21:34:29 -0600328#if IS_ENABLED(CONFIG_SPI_FLASH_SMM)
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700329 /* Re-init SPI driver to handle locked BAR */
330 spi_init();
331#endif
332}
333
334static void southbridge_smi_apmc(void)
335{
336 u8 reg8;
337 em64t101_smm_state_save_area_t *state;
338
339 /* Emulate B2 register as the FADT / Linux expects it */
340
341 reg8 = inb(APM_CNT);
342 switch (reg8) {
343 case APM_CNT_CST_CONTROL:
344 printk(BIOS_DEBUG, "C-state control\n");
345 break;
346 case APM_CNT_PST_CONTROL:
347 printk(BIOS_DEBUG, "P-state control\n");
348 break;
349 case APM_CNT_ACPI_DISABLE:
350 disable_pm1_control(SCI_EN);
351 printk(BIOS_DEBUG, "SMI#: ACPI disabled.\n");
352 break;
353 case APM_CNT_ACPI_ENABLE:
354 enable_pm1_control(SCI_EN);
355 printk(BIOS_DEBUG, "SMI#: ACPI enabled.\n");
356 break;
357 case APM_CNT_FINALIZE:
358 finalize();
359 break;
360 case APM_CNT_GNVS_UPDATE:
361 if (smm_initialized) {
362 printk(BIOS_DEBUG,
363 "SMI#: SMM structures already initialized!\n");
364 return;
365 }
366 state = smi_apmc_find_state_save(reg8);
367 if (state) {
368 /* EBX in the state save contains the GNVS pointer */
369 gnvs = (global_nvs_t *)((u32)state->rbx);
370 smm_initialized = 1;
371 printk(BIOS_DEBUG, "SMI#: Setting GNVS to %p\n", gnvs);
372 }
373 break;
Martin Rothe6ff1592017-06-24 21:34:29 -0600374#if IS_ENABLED(CONFIG_ELOG_GSMI)
Patrick Georgid61839c2018-12-03 16:10:33 +0100375 case APM_CNT_ELOG_GSMI:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700376 southbridge_smi_gsmi();
377 break;
378#endif
379 }
380
381 mainboard_smi_apmc(reg8);
382}
383
384static void southbridge_smi_pm1(void)
385{
386 u16 pm1_sts = clear_pm1_status();
387
388 /* While OSPM is not active, poweroff immediately
389 * on a power button event.
390 */
391 if (pm1_sts & PWRBTN_STS) {
392 /* power button pressed */
Martin Rothe6ff1592017-06-24 21:34:29 -0600393#if IS_ENABLED(CONFIG_ELOG_GSMI)
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700394 elog_add_event(ELOG_TYPE_POWER_BUTTON);
395#endif
396 disable_pm1_control(-1UL);
397 enable_pm1_control(SLP_EN | (SLP_TYP_S5 << 10));
398 }
399}
400
401static void southbridge_smi_gpe0(void)
402{
403 clear_gpe_status();
404}
405
406static void southbridge_smi_gpi(void)
407{
408 mainboard_smi_gpi(clear_alt_smi_status());
409
410 /* Clear again after mainboard handler */
411 clear_alt_smi_status();
412}
413
414static void southbridge_smi_mc(void)
415{
416 u32 reg32 = inl(ACPI_BASE_ADDRESS + SMI_EN);
417
418 /* Are microcontroller SMIs enabled? */
419 if ((reg32 & MCSMI_EN) == 0)
420 return;
421
422 printk(BIOS_DEBUG, "Microcontroller SMI.\n");
423}
424
425static void southbridge_smi_tco(void)
426{
427 u32 tco_sts = clear_tco_status();
428
429 /* Any TCO event? */
430 if (!tco_sts)
431 return;
432
Lee Leahy8a9c7dc2017-03-17 10:43:25 -0700433 // BIOSWR
434 if (tco_sts & (1 << 8)) {
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700435 u8 bios_cntl = pci_read_config16(PCH_DEV_LPC, BIOS_CNTL);
436
437 if (bios_cntl & 1) {
438 /*
439 * BWE is RW, so the SMI was caused by a
440 * write to BWE, not by a write to the BIOS
441 *
442 * This is the place where we notice someone
443 * is trying to tinker with the BIOS. We are
444 * trying to be nice and just ignore it. A more
445 * resolute answer would be to power down the
446 * box.
447 */
448 printk(BIOS_DEBUG, "Switching back to RO\n");
449 pci_write_config32(PCH_DEV_LPC, BIOS_CNTL,
450 (bios_cntl & ~1));
451 } /* No else for now? */
452 } else if (tco_sts & (1 << 3)) { /* TIMEOUT */
453 /* Handle TCO timeout */
454 printk(BIOS_DEBUG, "TCO Timeout.\n");
455 }
456}
457
458static void southbridge_smi_periodic(void)
459{
460 u32 reg32 = inl(ACPI_BASE_ADDRESS + SMI_EN);
461
462 /* Are periodic SMIs enabled? */
463 if ((reg32 & PERIODIC_EN) == 0)
464 return;
465
466 printk(BIOS_DEBUG, "Periodic SMI.\n");
467}
468
469static void southbridge_smi_monitor(void)
470{
471#define IOTRAP(x) (trap_sts & (1 << x))
472 u32 trap_sts, trap_cycle;
473 u32 data, mask = 0;
474 int i;
475
476 trap_sts = RCBA32(0x1e00); // TRSR - Trap Status Register
477 RCBA32(0x1e00) = trap_sts; // Clear trap(s) in TRSR
478
479 trap_cycle = RCBA32(0x1e10);
Lee Leahy26b7cd02017-03-16 18:47:55 -0700480 for (i = 16; i < 20; i++) {
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700481 if (trap_cycle & (1 << i))
482 mask |= (0xff << ((i - 16) << 2));
483 }
484
485
486 /* IOTRAP(3) SMI function call */
487 if (IOTRAP(3)) {
488 if (gnvs && gnvs->smif)
489 io_trap_handler(gnvs->smif); // call function smif
490 return;
491 }
492
493 /* IOTRAP(2) currently unused
494 * IOTRAP(1) currently unused */
495
496 /* IOTRAP(0) SMIC */
497 if (IOTRAP(0)) {
Lee Leahy8a9c7dc2017-03-17 10:43:25 -0700498 // It's a write
499 if (!(trap_cycle & (1 << 24))) {
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700500 printk(BIOS_DEBUG, "SMI1 command\n");
501 data = RCBA32(0x1e18);
502 data &= mask;
503 // if (smi1)
Lee Leahy26b7cd02017-03-16 18:47:55 -0700504 // southbridge_smi_command(data);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700505 // return;
506 }
507 // Fall through to debug
508 }
509
510 printk(BIOS_DEBUG, " trapped io address = 0x%x\n",
511 trap_cycle & 0xfffc);
Lee Leahy26b7cd02017-03-16 18:47:55 -0700512 for (i = 0; i < 4; i++)
Lee Leahy8a9c7dc2017-03-17 10:43:25 -0700513 if (IOTRAP(i))
514 printk(BIOS_DEBUG, " TRAP = %d\n", i);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700515 printk(BIOS_DEBUG, " AHBE = %x\n", (trap_cycle >> 16) & 0xf);
516 printk(BIOS_DEBUG, " MASK = 0x%08x\n", mask);
517 printk(BIOS_DEBUG, " read/write: %s\n",
518 (trap_cycle & (1 << 24)) ? "read" : "write");
519
520 if (!(trap_cycle & (1 << 24))) {
521 /* Write Cycle */
522 data = RCBA32(0x1e18);
523 printk(BIOS_DEBUG, " iotrap written data = 0x%08x\n", data);
524 }
525#undef IOTRAP
526}
527
528typedef void (*smi_handler_t)(void);
529
530static smi_handler_t southbridge_smi[32] = {
531 NULL, // [0] reserved
532 NULL, // [1] reserved
533 NULL, // [2] BIOS_STS
534 NULL, // [3] LEGACY_USB_STS
535 southbridge_smi_sleep, // [4] SLP_SMI_STS
536 southbridge_smi_apmc, // [5] APM_STS
537 NULL, // [6] SWSMI_TMR_STS
538 NULL, // [7] reserved
539 southbridge_smi_pm1, // [8] PM1_STS
540 southbridge_smi_gpe0, // [9] GPE0_STS
541 southbridge_smi_gpi, // [10] GPI_STS
542 southbridge_smi_mc, // [11] MCSMI_STS
543 NULL, // [12] DEVMON_STS
544 southbridge_smi_tco, // [13] TCO_STS
545 southbridge_smi_periodic, // [14] PERIODIC_STS
546 NULL, // [15] SERIRQ_SMI_STS
547 NULL, // [16] SMBUS_SMI_STS
548 NULL, // [17] LEGACY_USB2_STS
549 NULL, // [18] INTEL_USB2_STS
550 NULL, // [19] reserved
551 NULL, // [20] PCI_EXP_SMI_STS
552 southbridge_smi_monitor, // [21] MONITOR_STS
553 NULL, // [22] reserved
554 NULL, // [23] reserved
555 NULL, // [24] reserved
556 NULL, // [25] EL_SMI_STS
557 NULL, // [26] SPI_STS
558 NULL, // [27] reserved
559 NULL, // [28] reserved
560 NULL, // [29] reserved
561 NULL, // [30] reserved
562 NULL // [31] reserved
563};
564
565/**
566 * @brief Interrupt handler for SMI#
567 *
568 * @param smm_revision revision of the smm state save map
569 */
570
571void southbridge_smi_handler(void)
572{
573 int i;
574 u32 smi_sts;
575
576 /* We need to clear the SMI status registers, or we won't see what's
577 * happening in the following calls.
578 */
579 smi_sts = clear_smi_status();
580
581 /* Call SMI sub handler for each of the status bits */
582 for (i = 0; i < 31; i++) {
583 if (smi_sts & (1 << i)) {
584 if (southbridge_smi[i]) {
585 southbridge_smi[i]();
586 } else {
587 printk(BIOS_DEBUG,
Martin Rothde7ed6f2014-12-07 14:58:18 -0700588 "SMI_STS[%d] occurred, but no "
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700589 "handler available.\n", i);
590 }
591 }
592 }
593}