blob: 2c388870a0b33c2e983ae77b6692a89a0b9ae160 [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>
Kyösti Mälkkicbf95712020-01-05 08:05:45 +020030#include <option.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>
Julius Werner4ee4bd52014-10-20 13:46:39 -070036#include <soc/xhci.h>
Duncan Laurief3e0a132015-01-14 17:33:00 -080037#include <drivers/intel/gma/i915_reg.h>
Matt DeVillier3a7a3392018-12-25 22:22:47 -060038#include <smmstore.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
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)
Kyösti Mälkki9dd1a122019-11-06 11:04:27 +0200184 elog_gsmi_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700185
Duncan Lauried775dda2014-10-25 01:49:32 -0700186 /* Clear pending GPE events */
187 clear_gpe_status();
188
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700189 /* Next, do the deed.
190 */
191
192 switch (slp_typ) {
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500193 case ACPI_S0:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700194 printk(BIOS_DEBUG, "SMI#: Entering S0 (On)\n");
195 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500196 case ACPI_S1:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700197 printk(BIOS_DEBUG, "SMI#: Entering S1 (Assert STPCLK#)\n");
198 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500199 case ACPI_S3:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700200 printk(BIOS_DEBUG, "SMI#: Entering S3 (Suspend-To-RAM)\n");
201
202 /* Invalidate the cache before going to S3 */
203 wbinvd();
204 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500205 case ACPI_S4:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700206 printk(BIOS_DEBUG, "SMI#: Entering S4 (Suspend-To-Disk)\n");
207 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500208 case ACPI_S5:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700209 printk(BIOS_DEBUG, "SMI#: Entering S5 (Soft Power off)\n");
210
Duncan Laurief3e0a132015-01-14 17:33:00 -0800211 /* Turn off backlight if needed */
212 backlight_off();
213
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700214 /* Disable all GPE */
215 disable_all_gpe();
216
217 /* Always set the flag in case CMOS was changed on runtime. For
218 * "KEEP", switch to "OFF" - KEEP is software emulated
219 */
220 reg8 = pci_read_config8(PCH_DEV_LPC, GEN_PMCON_3);
221 if (s5pwr == MAINBOARD_POWER_ON)
222 reg8 &= ~1;
223 else
224 reg8 |= 1;
225 pci_write_config8(PCH_DEV_LPC, GEN_PMCON_3, reg8);
226
227 /* also iterates over all bridges on bus 0 */
228 busmaster_disable_on_bus(0);
229 break;
230 default:
231 printk(BIOS_DEBUG, "SMI#: ERROR: SLP_TYP reserved\n");
232 break;
233 }
234
235 /*
236 * Write back to the SLP register to cause the originally intended
237 * event again. We need to set BIT13 (SLP_EN) though to make the
238 * sleep happen.
239 */
240 enable_pm1_control(SLP_EN);
241
242 /* Make sure to stop executing code here for S3/S4/S5 */
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500243 if (slp_typ >= ACPI_S3)
Patrick Georgi546953c2014-11-29 10:38:17 +0100244 halt();
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700245
246 /*
247 * In most sleep states, the code flow of this function ends at
248 * the line above. However, if we entered sleep state S1 and wake
249 * up again, we will continue to execute code in this function.
250 */
251 reg32 = inl(ACPI_BASE_ADDRESS + PM1_CNT);
252 if (reg32 & SCI_EN) {
253 /* The OS is not an ACPI OS, so we set the state to S0 */
254 disable_pm1_control(SLP_EN | SLP_TYP);
255 }
256}
257
258/*
259 * Look for Synchronous IO SMI and use save state from that
260 * core in case we are not running on the same core that
261 * initiated the IO transaction.
262 */
263static em64t101_smm_state_save_area_t *smi_apmc_find_state_save(u8 cmd)
264{
265 em64t101_smm_state_save_area_t *state;
266 int node;
267
268 /* Check all nodes looking for the one that issued the IO */
269 for (node = 0; node < CONFIG_MAX_CPUS; node++) {
270 state = smm_get_save_state(node);
271
272 /* Check for Synchronous IO (bit0==1) */
273 if (!(state->io_misc_info & (1 << 0)))
274 continue;
275
276 /* Make sure it was a write (bit4==0) */
277 if (state->io_misc_info & (1 << 4))
278 continue;
279
280 /* Check for APMC IO port */
281 if (((state->io_misc_info >> 16) & 0xff) != APM_CNT)
282 continue;
283
284 /* Check AX against the requested command */
285 if ((state->rax & 0xff) != cmd)
286 continue;
287
288 return state;
289 }
290
291 return NULL;
292}
293
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700294static void southbridge_smi_gsmi(void)
295{
296 u32 *ret, *param;
297 u8 sub_command;
298 em64t101_smm_state_save_area_t *io_smi =
Patrick Georgid61839c2018-12-03 16:10:33 +0100299 smi_apmc_find_state_save(APM_CNT_ELOG_GSMI);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700300
301 if (!io_smi)
302 return;
303
304 /* Command and return value in EAX */
Lee Leahy26b7cd02017-03-16 18:47:55 -0700305 ret = (u32 *)&io_smi->rax;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700306 sub_command = (u8)(*ret >> 8);
307
308 /* Parameter buffer in EBX */
Lee Leahy26b7cd02017-03-16 18:47:55 -0700309 param = (u32 *)&io_smi->rbx;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700310
311 /* drivers/elog/gsmi.c */
312 *ret = gsmi_exec(sub_command, param);
313}
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700314
Matt DeVillier3a7a3392018-12-25 22:22:47 -0600315static void southbridge_smi_store(void)
316{
317 u8 sub_command, ret;
318 em64t101_smm_state_save_area_t *io_smi =
319 smi_apmc_find_state_save(APM_CNT_SMMSTORE);
320 uint32_t reg_ebx;
321
322 if (!io_smi)
323 return;
324 /* Command and return value in EAX */
325 sub_command = (io_smi->rax >> 8) & 0xff;
326
327 /* Parameter buffer in EBX */
328 reg_ebx = io_smi->rbx;
329
330 /* drivers/smmstore/smi.c */
331 ret = smmstore_exec(sub_command, (void *)reg_ebx);
332 io_smi->rax = ret;
333}
334
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700335static 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;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700358 case APM_CNT_GNVS_UPDATE:
359 if (smm_initialized) {
360 printk(BIOS_DEBUG,
361 "SMI#: SMM structures already initialized!\n");
362 return;
363 }
364 state = smi_apmc_find_state_save(reg8);
365 if (state) {
366 /* EBX in the state save contains the GNVS pointer */
367 gnvs = (global_nvs_t *)((u32)state->rbx);
368 smm_initialized = 1;
369 printk(BIOS_DEBUG, "SMI#: Setting GNVS to %p\n", gnvs);
370 }
371 break;
Patrick Georgid61839c2018-12-03 16:10:33 +0100372 case APM_CNT_ELOG_GSMI:
Kyösti Mälkki9dd1a122019-11-06 11:04:27 +0200373 if (CONFIG(ELOG_GSMI))
374 southbridge_smi_gsmi();
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700375 break;
Matt DeVillier3a7a3392018-12-25 22:22:47 -0600376 case APM_CNT_SMMSTORE:
377 if (CONFIG(SMMSTORE))
378 southbridge_smi_store();
379 break;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700380 }
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 */
Kyösti Mälkki9dd1a122019-11-06 11:04:27 +0200394 elog_gsmi_add_event(ELOG_TYPE_POWER_BUTTON);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700395 disable_pm1_control(-1UL);
396 enable_pm1_control(SLP_EN | (SLP_TYP_S5 << 10));
397 }
398}
399
400static void southbridge_smi_gpe0(void)
401{
402 clear_gpe_status();
403}
404
405static void southbridge_smi_gpi(void)
406{
407 mainboard_smi_gpi(clear_alt_smi_status());
408
409 /* Clear again after mainboard handler */
410 clear_alt_smi_status();
411}
412
413static void southbridge_smi_mc(void)
414{
415 u32 reg32 = inl(ACPI_BASE_ADDRESS + SMI_EN);
416
417 /* Are microcontroller SMIs enabled? */
418 if ((reg32 & MCSMI_EN) == 0)
419 return;
420
421 printk(BIOS_DEBUG, "Microcontroller SMI.\n");
422}
423
424static void southbridge_smi_tco(void)
425{
426 u32 tco_sts = clear_tco_status();
427
428 /* Any TCO event? */
429 if (!tco_sts)
430 return;
431
Lee Leahy8a9c7dc2017-03-17 10:43:25 -0700432 // BIOSWR
433 if (tco_sts & (1 << 8)) {
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700434 u8 bios_cntl = pci_read_config16(PCH_DEV_LPC, BIOS_CNTL);
435
436 if (bios_cntl & 1) {
437 /*
438 * BWE is RW, so the SMI was caused by a
439 * write to BWE, not by a write to the BIOS
440 *
441 * This is the place where we notice someone
442 * is trying to tinker with the BIOS. We are
443 * trying to be nice and just ignore it. A more
444 * resolute answer would be to power down the
445 * box.
446 */
447 printk(BIOS_DEBUG, "Switching back to RO\n");
448 pci_write_config32(PCH_DEV_LPC, BIOS_CNTL,
449 (bios_cntl & ~1));
450 } /* No else for now? */
451 } else if (tco_sts & (1 << 3)) { /* TIMEOUT */
452 /* Handle TCO timeout */
453 printk(BIOS_DEBUG, "TCO Timeout.\n");
454 }
455}
456
457static void southbridge_smi_periodic(void)
458{
459 u32 reg32 = inl(ACPI_BASE_ADDRESS + SMI_EN);
460
461 /* Are periodic SMIs enabled? */
462 if ((reg32 & PERIODIC_EN) == 0)
463 return;
464
465 printk(BIOS_DEBUG, "Periodic SMI.\n");
466}
467
468static void southbridge_smi_monitor(void)
469{
470#define IOTRAP(x) (trap_sts & (1 << x))
471 u32 trap_sts, trap_cycle;
472 u32 data, mask = 0;
473 int i;
474
475 trap_sts = RCBA32(0x1e00); // TRSR - Trap Status Register
476 RCBA32(0x1e00) = trap_sts; // Clear trap(s) in TRSR
477
478 trap_cycle = RCBA32(0x1e10);
Lee Leahy26b7cd02017-03-16 18:47:55 -0700479 for (i = 16; i < 20; i++) {
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700480 if (trap_cycle & (1 << i))
481 mask |= (0xff << ((i - 16) << 2));
482 }
483
484
485 /* IOTRAP(3) SMI function call */
486 if (IOTRAP(3)) {
487 if (gnvs && gnvs->smif)
488 io_trap_handler(gnvs->smif); // call function smif
489 return;
490 }
491
492 /* IOTRAP(2) currently unused
493 * IOTRAP(1) currently unused */
494
495 /* IOTRAP(0) SMIC */
496 if (IOTRAP(0)) {
Lee Leahy8a9c7dc2017-03-17 10:43:25 -0700497 // It's a write
498 if (!(trap_cycle & (1 << 24))) {
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700499 printk(BIOS_DEBUG, "SMI1 command\n");
500 data = RCBA32(0x1e18);
501 data &= mask;
502 // if (smi1)
Lee Leahy26b7cd02017-03-16 18:47:55 -0700503 // southbridge_smi_command(data);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700504 // return;
505 }
506 // Fall through to debug
507 }
508
509 printk(BIOS_DEBUG, " trapped io address = 0x%x\n",
510 trap_cycle & 0xfffc);
Lee Leahy26b7cd02017-03-16 18:47:55 -0700511 for (i = 0; i < 4; i++)
Lee Leahy8a9c7dc2017-03-17 10:43:25 -0700512 if (IOTRAP(i))
513 printk(BIOS_DEBUG, " TRAP = %d\n", i);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700514 printk(BIOS_DEBUG, " AHBE = %x\n", (trap_cycle >> 16) & 0xf);
515 printk(BIOS_DEBUG, " MASK = 0x%08x\n", mask);
516 printk(BIOS_DEBUG, " read/write: %s\n",
517 (trap_cycle & (1 << 24)) ? "read" : "write");
518
519 if (!(trap_cycle & (1 << 24))) {
520 /* Write Cycle */
521 data = RCBA32(0x1e18);
522 printk(BIOS_DEBUG, " iotrap written data = 0x%08x\n", data);
523 }
524#undef IOTRAP
525}
526
527typedef void (*smi_handler_t)(void);
528
529static smi_handler_t southbridge_smi[32] = {
530 NULL, // [0] reserved
531 NULL, // [1] reserved
532 NULL, // [2] BIOS_STS
533 NULL, // [3] LEGACY_USB_STS
534 southbridge_smi_sleep, // [4] SLP_SMI_STS
535 southbridge_smi_apmc, // [5] APM_STS
536 NULL, // [6] SWSMI_TMR_STS
537 NULL, // [7] reserved
538 southbridge_smi_pm1, // [8] PM1_STS
539 southbridge_smi_gpe0, // [9] GPE0_STS
540 southbridge_smi_gpi, // [10] GPI_STS
541 southbridge_smi_mc, // [11] MCSMI_STS
542 NULL, // [12] DEVMON_STS
543 southbridge_smi_tco, // [13] TCO_STS
544 southbridge_smi_periodic, // [14] PERIODIC_STS
545 NULL, // [15] SERIRQ_SMI_STS
546 NULL, // [16] SMBUS_SMI_STS
547 NULL, // [17] LEGACY_USB2_STS
548 NULL, // [18] INTEL_USB2_STS
549 NULL, // [19] reserved
550 NULL, // [20] PCI_EXP_SMI_STS
551 southbridge_smi_monitor, // [21] MONITOR_STS
552 NULL, // [22] reserved
553 NULL, // [23] reserved
554 NULL, // [24] reserved
555 NULL, // [25] EL_SMI_STS
556 NULL, // [26] SPI_STS
557 NULL, // [27] reserved
558 NULL, // [28] reserved
559 NULL, // [29] reserved
560 NULL, // [30] reserved
561 NULL // [31] reserved
562};
563
564/**
565 * @brief Interrupt handler for SMI#
566 *
567 * @param smm_revision revision of the smm state save map
568 */
569
570void southbridge_smi_handler(void)
571{
572 int i;
573 u32 smi_sts;
574
575 /* We need to clear the SMI status registers, or we won't see what's
576 * happening in the following calls.
577 */
578 smi_sts = clear_smi_status();
579
580 /* Call SMI sub handler for each of the status bits */
581 for (i = 0; i < 31; i++) {
582 if (smi_sts & (1 << i)) {
583 if (southbridge_smi[i]) {
584 southbridge_smi[i]();
585 } else {
586 printk(BIOS_DEBUG,
Martin Rothde7ed6f2014-12-07 14:58:18 -0700587 "SMI_STS[%d] occurred, but no "
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700588 "handler available.\n", i);
589 }
590 }
591 }
592}