blob: 4a12d786dd780a19df566ee3ff723fc8bc8f7fe7 [file] [log] [blame]
Angel Ponsf94ac9a2020-04-05 15:46:48 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Duncan Lauriec88c54c2014-04-30 16:36:13 -07002
3#include <delay.h>
4#include <types.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -07005#include <arch/io.h>
Kyösti Mälkki13f66502019-03-03 08:01:05 +02006#include <device/mmio.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02007#include <device/pci_ops.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -07008#include <console/console.h>
9#include <cpu/x86/cache.h>
10#include <device/pci_def.h>
11#include <cpu/x86/smm.h>
Kyösti Mälkkie31ec292019-08-10 17:27:01 +030012#include <cpu/intel/em64t101_save_state.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070013#include <spi-generic.h>
14#include <elog.h>
Patrick Georgi546953c2014-11-29 10:38:17 +010015#include <halt.h>
Kyösti Mälkkicbf95712020-01-05 08:05:45 +020016#include <option.h>
Julius Werner4ee4bd52014-10-20 13:46:39 -070017#include <soc/lpc.h>
18#include <soc/nvs.h>
19#include <soc/pci_devs.h>
20#include <soc/pm.h>
21#include <soc/rcba.h>
Julius Werner4ee4bd52014-10-20 13:46:39 -070022#include <soc/xhci.h>
Duncan Laurief3e0a132015-01-14 17:33:00 -080023#include <drivers/intel/gma/i915_reg.h>
Matt DeVillier3a7a3392018-12-25 22:22:47 -060024#include <smmstore.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070025
26static u8 smm_initialized = 0;
27
Duncan Lauriec88c54c2014-04-30 16:36:13 -070028int southbridge_io_trap_handler(int smif)
29{
30 switch (smif) {
31 case 0x32:
32 printk(BIOS_DEBUG, "OS Init\n");
33 /* gnvs->smif:
34 * On success, the IO Trap Handler returns 0
35 * On failure, the IO Trap Handler returns a value != 0
36 */
37 gnvs->smif = 0;
38 return 1; /* IO trap handled */
39 }
40
41 /* Not handled */
42 return 0;
43}
44
45/**
46 * @brief Set the EOS bit
47 */
48void southbridge_smi_set_eos(void)
49{
50 enable_smi(EOS);
51}
52
53static void busmaster_disable_on_bus(int bus)
54{
Lee Leahy26b7cd02017-03-16 18:47:55 -070055 int slot, func;
56 unsigned int val;
57 unsigned char hdr;
Duncan Lauriec88c54c2014-04-30 16:36:13 -070058
Lee Leahy26b7cd02017-03-16 18:47:55 -070059 for (slot = 0; slot < 0x20; slot++) {
60 for (func = 0; func < 8; func++) {
Kyösti Mälkkie16c9df2018-12-29 08:04:16 +020061 pci_devfn_t dev = PCI_DEV(bus, slot, func);
Angel Pons2ead3632020-09-24 16:50:05 +020062
Lee Leahy26b7cd02017-03-16 18:47:55 -070063 val = pci_read_config32(dev, PCI_VENDOR_ID);
Duncan Lauriec88c54c2014-04-30 16:36:13 -070064
Lee Leahy26b7cd02017-03-16 18:47:55 -070065 if (val == 0xffffffff || val == 0x00000000 ||
Angel Pons2ead3632020-09-24 16:50:05 +020066 val == 0x0000ffff || val == 0xffff0000)
Lee Leahy26b7cd02017-03-16 18:47:55 -070067 continue;
Duncan Lauriec88c54c2014-04-30 16:36:13 -070068
Lee Leahy26b7cd02017-03-16 18:47:55 -070069 /* Disable Bus Mastering for this one device */
Angel Pons2ead3632020-09-24 16:50:05 +020070 pci_and_config16(dev, PCI_COMMAND, ~PCI_COMMAND_MASTER);
Duncan Lauriec88c54c2014-04-30 16:36:13 -070071
Lee Leahy26b7cd02017-03-16 18:47:55 -070072 /* If this is a bridge, then follow it. */
73 hdr = pci_read_config8(dev, PCI_HEADER_TYPE);
74 hdr &= 0x7f;
75 if (hdr == PCI_HEADER_TYPE_BRIDGE ||
Angel Pons2ead3632020-09-24 16:50:05 +020076 hdr == PCI_HEADER_TYPE_CARDBUS) {
Lee Leahy26b7cd02017-03-16 18:47:55 -070077 unsigned int buses;
78 buses = pci_read_config32(dev, PCI_PRIMARY_BUS);
79 busmaster_disable_on_bus((buses >> 8) & 0xff);
80 }
81 }
82 }
Duncan Lauriec88c54c2014-04-30 16:36:13 -070083}
84
Duncan Laurief3e0a132015-01-14 17:33:00 -080085/*
86 * Turn off the backlight if it is on, and wait for the specified
87 * backlight off delay. This will allow panel power timings to meet
88 * spec and prevent brief garbage on the screen when turned off
89 * during firmware with power button triggered SMI.
90 */
91static void backlight_off(void)
92{
93 void *reg_base;
94 uint32_t pp_ctrl;
95 uint32_t bl_off_delay;
96
Lee Leahy6ef51922017-03-17 10:56:08 -070097 reg_base = (void *)((uintptr_t)pci_read_config32(SA_DEV_IGD,
98 PCI_BASE_ADDRESS_0) & ~0xf);
Duncan Laurief3e0a132015-01-14 17:33:00 -080099
Patrick Rudolph9f8f1152020-05-06 11:58:45 +0200100 /* Validate pointer before using it */
101 if (smm_points_to_smram(reg_base, PCH_PP_OFF_DELAYS + sizeof(uint32_t)))
102 return;
103
Duncan Laurief3e0a132015-01-14 17:33:00 -0800104 /* Check if backlight is enabled */
105 pp_ctrl = read32(reg_base + PCH_PP_CONTROL);
106 if (!(pp_ctrl & EDP_BLC_ENABLE))
107 return;
108
109 /* Enable writes to this register */
110 pp_ctrl &= ~PANEL_UNLOCK_MASK;
111 pp_ctrl |= PANEL_UNLOCK_REGS;
112
113 /* Turn off backlight */
114 pp_ctrl &= ~EDP_BLC_ENABLE;
115
116 write32(reg_base + PCH_PP_CONTROL, pp_ctrl);
117 read32(reg_base + PCH_PP_CONTROL);
118
119 /* Read backlight off delay in 100us units */
120 bl_off_delay = read32(reg_base + PCH_PP_OFF_DELAYS);
121 bl_off_delay &= PANEL_LIGHT_OFF_DELAY_MASK;
122 bl_off_delay *= 100;
123
124 /* Wait for backlight to turn off */
125 udelay(bl_off_delay);
126
127 printk(BIOS_INFO, "Backlight turned off\n");
128}
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700129
130static void southbridge_smi_sleep(void)
131{
132 u8 reg8;
133 u32 reg32;
134 u8 slp_typ;
Nico Huber9faae2b2018-11-14 00:00:35 +0100135 u8 s5pwr = CONFIG_MAINBOARD_POWER_FAILURE_STATE;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700136
137 /* save and recover RTC port values */
138 u8 tmp70, tmp72;
139 tmp70 = inb(0x70);
140 tmp72 = inb(0x72);
141 get_option(&s5pwr, "power_on_after_fail");
142 outb(tmp70, 0x70);
143 outb(tmp72, 0x72);
144
145 /* First, disable further SMIs */
146 disable_smi(SLP_SMI_EN);
147
148 /* Figure out SLP_TYP */
149 reg32 = inl(ACPI_BASE_ADDRESS + PM1_CNT);
150 printk(BIOS_SPEW, "SMI#: SLP = 0x%08x\n", reg32);
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500151 slp_typ = acpi_sleep_from_pm1(reg32);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700152
153 /* Do any mainboard sleep handling */
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500154 mainboard_smi_sleep(slp_typ);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700155
156 /* USB sleep preparations */
157 usb_xhci_sleep_prepare(PCH_DEV_XHCI, slp_typ);
158
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700159 /* Log S3, S4, and S5 entry */
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500160 if (slp_typ >= ACPI_S3)
Kyösti Mälkki9dd1a122019-11-06 11:04:27 +0200161 elog_gsmi_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700162
Duncan Lauried775dda2014-10-25 01:49:32 -0700163 /* Clear pending GPE events */
164 clear_gpe_status();
165
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700166 /* Next, do the deed.
167 */
168
169 switch (slp_typ) {
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500170 case ACPI_S0:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700171 printk(BIOS_DEBUG, "SMI#: Entering S0 (On)\n");
172 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500173 case ACPI_S1:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700174 printk(BIOS_DEBUG, "SMI#: Entering S1 (Assert STPCLK#)\n");
175 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500176 case ACPI_S3:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700177 printk(BIOS_DEBUG, "SMI#: Entering S3 (Suspend-To-RAM)\n");
178
179 /* Invalidate the cache before going to S3 */
180 wbinvd();
181 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500182 case ACPI_S4:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700183 printk(BIOS_DEBUG, "SMI#: Entering S4 (Suspend-To-Disk)\n");
184 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500185 case ACPI_S5:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700186 printk(BIOS_DEBUG, "SMI#: Entering S5 (Soft Power off)\n");
187
Duncan Laurief3e0a132015-01-14 17:33:00 -0800188 /* Turn off backlight if needed */
189 backlight_off();
190
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700191 /* Disable all GPE */
192 disable_all_gpe();
193
194 /* Always set the flag in case CMOS was changed on runtime. For
195 * "KEEP", switch to "OFF" - KEEP is software emulated
196 */
197 reg8 = pci_read_config8(PCH_DEV_LPC, GEN_PMCON_3);
198 if (s5pwr == MAINBOARD_POWER_ON)
199 reg8 &= ~1;
200 else
201 reg8 |= 1;
202 pci_write_config8(PCH_DEV_LPC, GEN_PMCON_3, reg8);
203
204 /* also iterates over all bridges on bus 0 */
205 busmaster_disable_on_bus(0);
206 break;
207 default:
208 printk(BIOS_DEBUG, "SMI#: ERROR: SLP_TYP reserved\n");
209 break;
210 }
211
212 /*
213 * Write back to the SLP register to cause the originally intended
214 * event again. We need to set BIT13 (SLP_EN) though to make the
215 * sleep happen.
216 */
217 enable_pm1_control(SLP_EN);
218
219 /* Make sure to stop executing code here for S3/S4/S5 */
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500220 if (slp_typ >= ACPI_S3)
Patrick Georgi546953c2014-11-29 10:38:17 +0100221 halt();
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700222
223 /*
224 * In most sleep states, the code flow of this function ends at
225 * the line above. However, if we entered sleep state S1 and wake
226 * up again, we will continue to execute code in this function.
227 */
228 reg32 = inl(ACPI_BASE_ADDRESS + PM1_CNT);
229 if (reg32 & SCI_EN) {
230 /* The OS is not an ACPI OS, so we set the state to S0 */
231 disable_pm1_control(SLP_EN | SLP_TYP);
232 }
233}
234
235/*
236 * Look for Synchronous IO SMI and use save state from that
237 * core in case we are not running on the same core that
238 * initiated the IO transaction.
239 */
240static em64t101_smm_state_save_area_t *smi_apmc_find_state_save(u8 cmd)
241{
242 em64t101_smm_state_save_area_t *state;
243 int node;
244
245 /* Check all nodes looking for the one that issued the IO */
246 for (node = 0; node < CONFIG_MAX_CPUS; node++) {
247 state = smm_get_save_state(node);
248
Angel Pons2ead3632020-09-24 16:50:05 +0200249 /* Check for Synchronous IO (bit0 == 1) */
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700250 if (!(state->io_misc_info & (1 << 0)))
251 continue;
252
Angel Pons2ead3632020-09-24 16:50:05 +0200253 /* Make sure it was a write (bit4 == 0) */
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700254 if (state->io_misc_info & (1 << 4))
255 continue;
256
257 /* Check for APMC IO port */
258 if (((state->io_misc_info >> 16) & 0xff) != APM_CNT)
259 continue;
260
261 /* Check AX against the requested command */
262 if ((state->rax & 0xff) != cmd)
263 continue;
264
265 return state;
266 }
267
268 return NULL;
269}
270
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700271static void southbridge_smi_gsmi(void)
272{
273 u32 *ret, *param;
274 u8 sub_command;
275 em64t101_smm_state_save_area_t *io_smi =
Patrick Georgid61839c2018-12-03 16:10:33 +0100276 smi_apmc_find_state_save(APM_CNT_ELOG_GSMI);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700277
278 if (!io_smi)
279 return;
280
281 /* Command and return value in EAX */
Lee Leahy26b7cd02017-03-16 18:47:55 -0700282 ret = (u32 *)&io_smi->rax;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700283 sub_command = (u8)(*ret >> 8);
284
285 /* Parameter buffer in EBX */
Lee Leahy26b7cd02017-03-16 18:47:55 -0700286 param = (u32 *)&io_smi->rbx;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700287
288 /* drivers/elog/gsmi.c */
289 *ret = gsmi_exec(sub_command, param);
290}
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700291
Matt DeVillier3a7a3392018-12-25 22:22:47 -0600292static void southbridge_smi_store(void)
293{
294 u8 sub_command, ret;
295 em64t101_smm_state_save_area_t *io_smi =
296 smi_apmc_find_state_save(APM_CNT_SMMSTORE);
297 uint32_t reg_ebx;
298
299 if (!io_smi)
300 return;
301 /* Command and return value in EAX */
302 sub_command = (io_smi->rax >> 8) & 0xff;
303
304 /* Parameter buffer in EBX */
305 reg_ebx = io_smi->rbx;
306
307 /* drivers/smmstore/smi.c */
308 ret = smmstore_exec(sub_command, (void *)reg_ebx);
309 io_smi->rax = ret;
310}
311
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700312static void southbridge_smi_apmc(void)
313{
314 u8 reg8;
315 em64t101_smm_state_save_area_t *state;
316
317 /* Emulate B2 register as the FADT / Linux expects it */
318
319 reg8 = inb(APM_CNT);
320 switch (reg8) {
321 case APM_CNT_CST_CONTROL:
322 printk(BIOS_DEBUG, "C-state control\n");
323 break;
324 case APM_CNT_PST_CONTROL:
325 printk(BIOS_DEBUG, "P-state control\n");
326 break;
327 case APM_CNT_ACPI_DISABLE:
328 disable_pm1_control(SCI_EN);
329 printk(BIOS_DEBUG, "SMI#: ACPI disabled.\n");
330 break;
331 case APM_CNT_ACPI_ENABLE:
332 enable_pm1_control(SCI_EN);
333 printk(BIOS_DEBUG, "SMI#: ACPI enabled.\n");
334 break;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700335 case APM_CNT_GNVS_UPDATE:
336 if (smm_initialized) {
337 printk(BIOS_DEBUG,
338 "SMI#: SMM structures already initialized!\n");
339 return;
340 }
341 state = smi_apmc_find_state_save(reg8);
342 if (state) {
343 /* EBX in the state save contains the GNVS pointer */
Kyösti Mälkki0c1dd9c2020-06-17 23:37:49 +0300344 gnvs = (struct global_nvs *)((u32)state->rbx);
Patrick Rudolph9f8f1152020-05-06 11:58:45 +0200345 if (smm_points_to_smram(gnvs, sizeof(*gnvs))) {
346 printk(BIOS_ERR, "SMI#: ERROR: GNVS overlaps SMM\n");
347 return;
348 }
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700349 smm_initialized = 1;
350 printk(BIOS_DEBUG, "SMI#: Setting GNVS to %p\n", gnvs);
351 }
352 break;
Patrick Georgid61839c2018-12-03 16:10:33 +0100353 case APM_CNT_ELOG_GSMI:
Kyösti Mälkki9dd1a122019-11-06 11:04:27 +0200354 if (CONFIG(ELOG_GSMI))
355 southbridge_smi_gsmi();
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700356 break;
Matt DeVillier3a7a3392018-12-25 22:22:47 -0600357 case APM_CNT_SMMSTORE:
358 if (CONFIG(SMMSTORE))
359 southbridge_smi_store();
360 break;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700361 }
362
363 mainboard_smi_apmc(reg8);
364}
365
366static void southbridge_smi_pm1(void)
367{
368 u16 pm1_sts = clear_pm1_status();
369
370 /* While OSPM is not active, poweroff immediately
371 * on a power button event.
372 */
373 if (pm1_sts & PWRBTN_STS) {
374 /* power button pressed */
Kyösti Mälkki9dd1a122019-11-06 11:04:27 +0200375 elog_gsmi_add_event(ELOG_TYPE_POWER_BUTTON);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700376 disable_pm1_control(-1UL);
377 enable_pm1_control(SLP_EN | (SLP_TYP_S5 << 10));
378 }
379}
380
381static void southbridge_smi_gpe0(void)
382{
383 clear_gpe_status();
384}
385
386static void southbridge_smi_gpi(void)
387{
388 mainboard_smi_gpi(clear_alt_smi_status());
389
390 /* Clear again after mainboard handler */
391 clear_alt_smi_status();
392}
393
394static void southbridge_smi_mc(void)
395{
396 u32 reg32 = inl(ACPI_BASE_ADDRESS + SMI_EN);
397
398 /* Are microcontroller SMIs enabled? */
399 if ((reg32 & MCSMI_EN) == 0)
400 return;
401
402 printk(BIOS_DEBUG, "Microcontroller SMI.\n");
403}
404
405static void southbridge_smi_tco(void)
406{
407 u32 tco_sts = clear_tco_status();
408
409 /* Any TCO event? */
410 if (!tco_sts)
411 return;
412
Lee Leahy8a9c7dc2017-03-17 10:43:25 -0700413 // BIOSWR
414 if (tco_sts & (1 << 8)) {
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700415 u8 bios_cntl = pci_read_config16(PCH_DEV_LPC, BIOS_CNTL);
416
417 if (bios_cntl & 1) {
418 /*
419 * BWE is RW, so the SMI was caused by a
420 * write to BWE, not by a write to the BIOS
421 *
422 * This is the place where we notice someone
423 * is trying to tinker with the BIOS. We are
424 * trying to be nice and just ignore it. A more
425 * resolute answer would be to power down the
426 * box.
427 */
428 printk(BIOS_DEBUG, "Switching back to RO\n");
Angel Pons2ead3632020-09-24 16:50:05 +0200429 pci_write_config32(PCH_DEV_LPC, BIOS_CNTL, (bios_cntl & ~1));
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700430 } /* No else for now? */
431 } else if (tco_sts & (1 << 3)) { /* TIMEOUT */
432 /* Handle TCO timeout */
433 printk(BIOS_DEBUG, "TCO Timeout.\n");
434 }
435}
436
437static void southbridge_smi_periodic(void)
438{
439 u32 reg32 = inl(ACPI_BASE_ADDRESS + SMI_EN);
440
441 /* Are periodic SMIs enabled? */
442 if ((reg32 & PERIODIC_EN) == 0)
443 return;
444
445 printk(BIOS_DEBUG, "Periodic SMI.\n");
446}
447
448static void southbridge_smi_monitor(void)
449{
450#define IOTRAP(x) (trap_sts & (1 << x))
451 u32 trap_sts, trap_cycle;
Angel Pons2ead3632020-09-24 16:50:05 +0200452 u32 mask = 0;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700453 int i;
454
455 trap_sts = RCBA32(0x1e00); // TRSR - Trap Status Register
456 RCBA32(0x1e00) = trap_sts; // Clear trap(s) in TRSR
457
458 trap_cycle = RCBA32(0x1e10);
Lee Leahy26b7cd02017-03-16 18:47:55 -0700459 for (i = 16; i < 20; i++) {
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700460 if (trap_cycle & (1 << i))
461 mask |= (0xff << ((i - 16) << 2));
462 }
463
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700464 /* IOTRAP(3) SMI function call */
465 if (IOTRAP(3)) {
466 if (gnvs && gnvs->smif)
467 io_trap_handler(gnvs->smif); // call function smif
468 return;
469 }
470
471 /* IOTRAP(2) currently unused
472 * IOTRAP(1) currently unused */
473
474 /* IOTRAP(0) SMIC */
475 if (IOTRAP(0)) {
Lee Leahy8a9c7dc2017-03-17 10:43:25 -0700476 // It's a write
477 if (!(trap_cycle & (1 << 24))) {
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700478 printk(BIOS_DEBUG, "SMI1 command\n");
Angel Pons2ead3632020-09-24 16:50:05 +0200479 (void)RCBA32(0x1e18);
480 // data = RCBA32(0x1e18);
481 // data &= mask;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700482 // if (smi1)
Lee Leahy26b7cd02017-03-16 18:47:55 -0700483 // southbridge_smi_command(data);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700484 // return;
485 }
486 // Fall through to debug
487 }
488
489 printk(BIOS_DEBUG, " trapped io address = 0x%x\n",
490 trap_cycle & 0xfffc);
Lee Leahy26b7cd02017-03-16 18:47:55 -0700491 for (i = 0; i < 4; i++)
Lee Leahy8a9c7dc2017-03-17 10:43:25 -0700492 if (IOTRAP(i))
493 printk(BIOS_DEBUG, " TRAP = %d\n", i);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700494 printk(BIOS_DEBUG, " AHBE = %x\n", (trap_cycle >> 16) & 0xf);
495 printk(BIOS_DEBUG, " MASK = 0x%08x\n", mask);
496 printk(BIOS_DEBUG, " read/write: %s\n",
497 (trap_cycle & (1 << 24)) ? "read" : "write");
498
499 if (!(trap_cycle & (1 << 24))) {
500 /* Write Cycle */
Angel Pons2ead3632020-09-24 16:50:05 +0200501 printk(BIOS_DEBUG, " iotrap written data = 0x%08x\n", RCBA32(0x1e18));
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700502 }
503#undef IOTRAP
504}
505
506typedef void (*smi_handler_t)(void);
507
508static smi_handler_t southbridge_smi[32] = {
509 NULL, // [0] reserved
510 NULL, // [1] reserved
511 NULL, // [2] BIOS_STS
512 NULL, // [3] LEGACY_USB_STS
513 southbridge_smi_sleep, // [4] SLP_SMI_STS
514 southbridge_smi_apmc, // [5] APM_STS
515 NULL, // [6] SWSMI_TMR_STS
516 NULL, // [7] reserved
517 southbridge_smi_pm1, // [8] PM1_STS
518 southbridge_smi_gpe0, // [9] GPE0_STS
519 southbridge_smi_gpi, // [10] GPI_STS
520 southbridge_smi_mc, // [11] MCSMI_STS
521 NULL, // [12] DEVMON_STS
522 southbridge_smi_tco, // [13] TCO_STS
523 southbridge_smi_periodic, // [14] PERIODIC_STS
524 NULL, // [15] SERIRQ_SMI_STS
525 NULL, // [16] SMBUS_SMI_STS
526 NULL, // [17] LEGACY_USB2_STS
527 NULL, // [18] INTEL_USB2_STS
528 NULL, // [19] reserved
529 NULL, // [20] PCI_EXP_SMI_STS
530 southbridge_smi_monitor, // [21] MONITOR_STS
531 NULL, // [22] reserved
532 NULL, // [23] reserved
533 NULL, // [24] reserved
534 NULL, // [25] EL_SMI_STS
535 NULL, // [26] SPI_STS
536 NULL, // [27] reserved
537 NULL, // [28] reserved
538 NULL, // [29] reserved
539 NULL, // [30] reserved
540 NULL // [31] reserved
541};
542
543/**
544 * @brief Interrupt handler for SMI#
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700545 */
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700546void southbridge_smi_handler(void)
547{
548 int i;
549 u32 smi_sts;
550
551 /* We need to clear the SMI status registers, or we won't see what's
552 * happening in the following calls.
553 */
554 smi_sts = clear_smi_status();
555
556 /* Call SMI sub handler for each of the status bits */
557 for (i = 0; i < 31; i++) {
558 if (smi_sts & (1 << i)) {
559 if (southbridge_smi[i]) {
560 southbridge_smi[i]();
561 } else {
562 printk(BIOS_DEBUG,
Martin Rothde7ed6f2014-12-07 14:58:18 -0700563 "SMI_STS[%d] occurred, but no "
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700564 "handler available.\n", i);
565 }
566 }
567 }
568}