blob: 542b330221db40ccd4f66160067f22ca938c0ba5 [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
Duncan Lauriec88c54c2014-04-30 16:36:13 -070026int southbridge_io_trap_handler(int smif)
27{
28 switch (smif) {
29 case 0x32:
30 printk(BIOS_DEBUG, "OS Init\n");
31 /* gnvs->smif:
32 * On success, the IO Trap Handler returns 0
33 * On failure, the IO Trap Handler returns a value != 0
34 */
35 gnvs->smif = 0;
36 return 1; /* IO trap handled */
37 }
38
39 /* Not handled */
40 return 0;
41}
42
43/**
44 * @brief Set the EOS bit
45 */
46void southbridge_smi_set_eos(void)
47{
48 enable_smi(EOS);
49}
50
51static void busmaster_disable_on_bus(int bus)
52{
Lee Leahy26b7cd02017-03-16 18:47:55 -070053 int slot, func;
54 unsigned int val;
55 unsigned char hdr;
Duncan Lauriec88c54c2014-04-30 16:36:13 -070056
Lee Leahy26b7cd02017-03-16 18:47:55 -070057 for (slot = 0; slot < 0x20; slot++) {
58 for (func = 0; func < 8; func++) {
Kyösti Mälkkie16c9df2018-12-29 08:04:16 +020059 pci_devfn_t dev = PCI_DEV(bus, slot, func);
Angel Pons2ead3632020-09-24 16:50:05 +020060
Lee Leahy26b7cd02017-03-16 18:47:55 -070061 val = pci_read_config32(dev, PCI_VENDOR_ID);
Duncan Lauriec88c54c2014-04-30 16:36:13 -070062
Lee Leahy26b7cd02017-03-16 18:47:55 -070063 if (val == 0xffffffff || val == 0x00000000 ||
Angel Pons2ead3632020-09-24 16:50:05 +020064 val == 0x0000ffff || val == 0xffff0000)
Lee Leahy26b7cd02017-03-16 18:47:55 -070065 continue;
Duncan Lauriec88c54c2014-04-30 16:36:13 -070066
Lee Leahy26b7cd02017-03-16 18:47:55 -070067 /* Disable Bus Mastering for this one device */
Angel Pons2ead3632020-09-24 16:50:05 +020068 pci_and_config16(dev, PCI_COMMAND, ~PCI_COMMAND_MASTER);
Duncan Lauriec88c54c2014-04-30 16:36:13 -070069
Lee Leahy26b7cd02017-03-16 18:47:55 -070070 /* If this is a bridge, then follow it. */
71 hdr = pci_read_config8(dev, PCI_HEADER_TYPE);
72 hdr &= 0x7f;
73 if (hdr == PCI_HEADER_TYPE_BRIDGE ||
Angel Pons2ead3632020-09-24 16:50:05 +020074 hdr == PCI_HEADER_TYPE_CARDBUS) {
Lee Leahy26b7cd02017-03-16 18:47:55 -070075 unsigned int buses;
76 buses = pci_read_config32(dev, PCI_PRIMARY_BUS);
77 busmaster_disable_on_bus((buses >> 8) & 0xff);
78 }
79 }
80 }
Duncan Lauriec88c54c2014-04-30 16:36:13 -070081}
82
Duncan Laurief3e0a132015-01-14 17:33:00 -080083/*
84 * Turn off the backlight if it is on, and wait for the specified
85 * backlight off delay. This will allow panel power timings to meet
86 * spec and prevent brief garbage on the screen when turned off
87 * during firmware with power button triggered SMI.
88 */
89static void backlight_off(void)
90{
91 void *reg_base;
92 uint32_t pp_ctrl;
93 uint32_t bl_off_delay;
94
Lee Leahy6ef51922017-03-17 10:56:08 -070095 reg_base = (void *)((uintptr_t)pci_read_config32(SA_DEV_IGD,
96 PCI_BASE_ADDRESS_0) & ~0xf);
Duncan Laurief3e0a132015-01-14 17:33:00 -080097
Patrick Rudolph9f8f1152020-05-06 11:58:45 +020098 /* Validate pointer before using it */
99 if (smm_points_to_smram(reg_base, PCH_PP_OFF_DELAYS + sizeof(uint32_t)))
100 return;
101
Duncan Laurief3e0a132015-01-14 17:33:00 -0800102 /* Check if backlight is enabled */
103 pp_ctrl = read32(reg_base + PCH_PP_CONTROL);
104 if (!(pp_ctrl & EDP_BLC_ENABLE))
105 return;
106
107 /* Enable writes to this register */
108 pp_ctrl &= ~PANEL_UNLOCK_MASK;
109 pp_ctrl |= PANEL_UNLOCK_REGS;
110
111 /* Turn off backlight */
112 pp_ctrl &= ~EDP_BLC_ENABLE;
113
114 write32(reg_base + PCH_PP_CONTROL, pp_ctrl);
115 read32(reg_base + PCH_PP_CONTROL);
116
117 /* Read backlight off delay in 100us units */
118 bl_off_delay = read32(reg_base + PCH_PP_OFF_DELAYS);
119 bl_off_delay &= PANEL_LIGHT_OFF_DELAY_MASK;
120 bl_off_delay *= 100;
121
122 /* Wait for backlight to turn off */
123 udelay(bl_off_delay);
124
125 printk(BIOS_INFO, "Backlight turned off\n");
126}
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700127
Kyösti Mälkki3c181862021-01-08 19:01:30 +0200128static int power_on_after_fail(void)
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700129{
Nico Huber9faae2b2018-11-14 00:00:35 +0100130 u8 s5pwr = CONFIG_MAINBOARD_POWER_FAILURE_STATE;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700131
132 /* save and recover RTC port values */
133 u8 tmp70, tmp72;
134 tmp70 = inb(0x70);
135 tmp72 = inb(0x72);
136 get_option(&s5pwr, "power_on_after_fail");
137 outb(tmp70, 0x70);
138 outb(tmp72, 0x72);
139
Kyösti Mälkki3c181862021-01-08 19:01:30 +0200140 /* For "KEEP", switch to "OFF" - KEEP is software emulated. */
141 return (s5pwr == MAINBOARD_POWER_ON);
142}
143
144static void southbridge_smi_sleep(void)
145{
146 u32 reg32;
147 u8 slp_typ;
148 u16 pmbase = get_pmbase();
149
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700150 /* First, disable further SMIs */
151 disable_smi(SLP_SMI_EN);
152
153 /* Figure out SLP_TYP */
Angel Ponsf92f2732020-09-25 00:44:52 +0200154 reg32 = inl(pmbase + PM1_CNT);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700155 printk(BIOS_SPEW, "SMI#: SLP = 0x%08x\n", reg32);
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500156 slp_typ = acpi_sleep_from_pm1(reg32);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700157
158 /* Do any mainboard sleep handling */
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500159 mainboard_smi_sleep(slp_typ);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700160
161 /* USB sleep preparations */
162 usb_xhci_sleep_prepare(PCH_DEV_XHCI, slp_typ);
163
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700164 /* Log S3, S4, and S5 entry */
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500165 if (slp_typ >= ACPI_S3)
Kyösti Mälkki9dd1a122019-11-06 11:04:27 +0200166 elog_gsmi_add_event_byte(ELOG_TYPE_ACPI_ENTER, slp_typ);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700167
Duncan Lauried775dda2014-10-25 01:49:32 -0700168 /* Clear pending GPE events */
169 clear_gpe_status();
170
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700171 /* Next, do the deed.
172 */
173
174 switch (slp_typ) {
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500175 case ACPI_S0:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700176 printk(BIOS_DEBUG, "SMI#: Entering S0 (On)\n");
177 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500178 case ACPI_S1:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700179 printk(BIOS_DEBUG, "SMI#: Entering S1 (Assert STPCLK#)\n");
180 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500181 case ACPI_S3:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700182 printk(BIOS_DEBUG, "SMI#: Entering S3 (Suspend-To-RAM)\n");
183
184 /* Invalidate the cache before going to S3 */
185 wbinvd();
186 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500187 case ACPI_S4:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700188 printk(BIOS_DEBUG, "SMI#: Entering S4 (Suspend-To-Disk)\n");
189 break;
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500190 case ACPI_S5:
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700191 printk(BIOS_DEBUG, "SMI#: Entering S5 (Soft Power off)\n");
192
Duncan Laurief3e0a132015-01-14 17:33:00 -0800193 /* Turn off backlight if needed */
194 backlight_off();
195
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700196 /* Disable all GPE */
197 disable_all_gpe();
198
Kyösti Mälkki3c181862021-01-08 19:01:30 +0200199 /* Always set the flag in case CMOS was changed on runtime. */
200 if (power_on_after_fail())
201 pci_and_config8(PCH_DEV_LPC, GEN_PMCON_3, ~1);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700202 else
Kyösti Mälkki3c181862021-01-08 19:01:30 +0200203 pci_or_config8(PCH_DEV_LPC, GEN_PMCON_3, 1);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700204
205 /* also iterates over all bridges on bus 0 */
206 busmaster_disable_on_bus(0);
207 break;
208 default:
209 printk(BIOS_DEBUG, "SMI#: ERROR: SLP_TYP reserved\n");
210 break;
211 }
212
213 /*
214 * Write back to the SLP register to cause the originally intended
215 * event again. We need to set BIT13 (SLP_EN) though to make the
216 * sleep happen.
217 */
218 enable_pm1_control(SLP_EN);
219
220 /* Make sure to stop executing code here for S3/S4/S5 */
Aaron Durbin9e6d1432016-07-13 23:21:41 -0500221 if (slp_typ >= ACPI_S3)
Patrick Georgi546953c2014-11-29 10:38:17 +0100222 halt();
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700223
224 /*
225 * In most sleep states, the code flow of this function ends at
226 * the line above. However, if we entered sleep state S1 and wake
227 * up again, we will continue to execute code in this function.
228 */
Angel Ponsf92f2732020-09-25 00:44:52 +0200229 reg32 = inl(pmbase + PM1_CNT);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700230 if (reg32 & SCI_EN) {
231 /* The OS is not an ACPI OS, so we set the state to S0 */
232 disable_pm1_control(SLP_EN | SLP_TYP);
233 }
234}
235
236/*
237 * Look for Synchronous IO SMI and use save state from that
238 * core in case we are not running on the same core that
239 * initiated the IO transaction.
240 */
241static em64t101_smm_state_save_area_t *smi_apmc_find_state_save(u8 cmd)
242{
243 em64t101_smm_state_save_area_t *state;
244 int node;
245
246 /* Check all nodes looking for the one that issued the IO */
247 for (node = 0; node < CONFIG_MAX_CPUS; node++) {
248 state = smm_get_save_state(node);
249
Angel Pons2ead3632020-09-24 16:50:05 +0200250 /* Check for Synchronous IO (bit0 == 1) */
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700251 if (!(state->io_misc_info & (1 << 0)))
252 continue;
253
Angel Pons2ead3632020-09-24 16:50:05 +0200254 /* Make sure it was a write (bit4 == 0) */
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700255 if (state->io_misc_info & (1 << 4))
256 continue;
257
258 /* Check for APMC IO port */
259 if (((state->io_misc_info >> 16) & 0xff) != APM_CNT)
260 continue;
261
262 /* Check AX against the requested command */
263 if ((state->rax & 0xff) != cmd)
264 continue;
265
266 return state;
267 }
268
269 return NULL;
270}
271
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700272static void southbridge_smi_gsmi(void)
273{
274 u32 *ret, *param;
275 u8 sub_command;
276 em64t101_smm_state_save_area_t *io_smi =
Patrick Georgid61839c2018-12-03 16:10:33 +0100277 smi_apmc_find_state_save(APM_CNT_ELOG_GSMI);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700278
279 if (!io_smi)
280 return;
281
282 /* Command and return value in EAX */
Lee Leahy26b7cd02017-03-16 18:47:55 -0700283 ret = (u32 *)&io_smi->rax;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700284 sub_command = (u8)(*ret >> 8);
285
286 /* Parameter buffer in EBX */
Lee Leahy26b7cd02017-03-16 18:47:55 -0700287 param = (u32 *)&io_smi->rbx;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700288
289 /* drivers/elog/gsmi.c */
290 *ret = gsmi_exec(sub_command, param);
291}
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700292
Matt DeVillier3a7a3392018-12-25 22:22:47 -0600293static void southbridge_smi_store(void)
294{
295 u8 sub_command, ret;
296 em64t101_smm_state_save_area_t *io_smi =
297 smi_apmc_find_state_save(APM_CNT_SMMSTORE);
298 uint32_t reg_ebx;
299
300 if (!io_smi)
301 return;
302 /* Command and return value in EAX */
303 sub_command = (io_smi->rax >> 8) & 0xff;
304
305 /* Parameter buffer in EBX */
306 reg_ebx = io_smi->rbx;
307
308 /* drivers/smmstore/smi.c */
309 ret = smmstore_exec(sub_command, (void *)reg_ebx);
310 io_smi->rax = ret;
311}
312
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700313static void southbridge_smi_apmc(void)
314{
315 u8 reg8;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700316
Kyösti Mälkki9a1620f2021-01-08 13:27:33 +0200317 reg8 = apm_get_apmc();
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700318 switch (reg8) {
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700319 case APM_CNT_ACPI_DISABLE:
320 disable_pm1_control(SCI_EN);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700321 break;
322 case APM_CNT_ACPI_ENABLE:
323 enable_pm1_control(SCI_EN);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700324 break;
Patrick Georgid61839c2018-12-03 16:10:33 +0100325 case APM_CNT_ELOG_GSMI:
Kyösti Mälkki9dd1a122019-11-06 11:04:27 +0200326 if (CONFIG(ELOG_GSMI))
327 southbridge_smi_gsmi();
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700328 break;
Matt DeVillier3a7a3392018-12-25 22:22:47 -0600329 case APM_CNT_SMMSTORE:
330 if (CONFIG(SMMSTORE))
331 southbridge_smi_store();
332 break;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700333 }
334
335 mainboard_smi_apmc(reg8);
336}
337
338static void southbridge_smi_pm1(void)
339{
340 u16 pm1_sts = clear_pm1_status();
341
342 /* While OSPM is not active, poweroff immediately
343 * on a power button event.
344 */
345 if (pm1_sts & PWRBTN_STS) {
346 /* power button pressed */
Kyösti Mälkki9dd1a122019-11-06 11:04:27 +0200347 elog_gsmi_add_event(ELOG_TYPE_POWER_BUTTON);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700348 disable_pm1_control(-1UL);
349 enable_pm1_control(SLP_EN | (SLP_TYP_S5 << 10));
350 }
351}
352
353static void southbridge_smi_gpe0(void)
354{
355 clear_gpe_status();
356}
357
358static void southbridge_smi_gpi(void)
359{
360 mainboard_smi_gpi(clear_alt_smi_status());
361
362 /* Clear again after mainboard handler */
363 clear_alt_smi_status();
364}
365
366static void southbridge_smi_mc(void)
367{
Angel Ponsf92f2732020-09-25 00:44:52 +0200368 u32 reg32 = inl(get_pmbase() + SMI_EN);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700369
370 /* Are microcontroller SMIs enabled? */
371 if ((reg32 & MCSMI_EN) == 0)
372 return;
373
374 printk(BIOS_DEBUG, "Microcontroller SMI.\n");
375}
376
377static void southbridge_smi_tco(void)
378{
379 u32 tco_sts = clear_tco_status();
380
381 /* Any TCO event? */
382 if (!tco_sts)
383 return;
384
Lee Leahy8a9c7dc2017-03-17 10:43:25 -0700385 // BIOSWR
386 if (tco_sts & (1 << 8)) {
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700387 u8 bios_cntl = pci_read_config16(PCH_DEV_LPC, BIOS_CNTL);
388
389 if (bios_cntl & 1) {
390 /*
391 * BWE is RW, so the SMI was caused by a
392 * write to BWE, not by a write to the BIOS
393 *
394 * This is the place where we notice someone
395 * is trying to tinker with the BIOS. We are
396 * trying to be nice and just ignore it. A more
397 * resolute answer would be to power down the
398 * box.
399 */
400 printk(BIOS_DEBUG, "Switching back to RO\n");
Angel Pons2ead3632020-09-24 16:50:05 +0200401 pci_write_config32(PCH_DEV_LPC, BIOS_CNTL, (bios_cntl & ~1));
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700402 } /* No else for now? */
403 } else if (tco_sts & (1 << 3)) { /* TIMEOUT */
404 /* Handle TCO timeout */
405 printk(BIOS_DEBUG, "TCO Timeout.\n");
406 }
407}
408
409static void southbridge_smi_periodic(void)
410{
Angel Ponsf92f2732020-09-25 00:44:52 +0200411 u32 reg32 = inl(get_pmbase() + SMI_EN);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700412
413 /* Are periodic SMIs enabled? */
414 if ((reg32 & PERIODIC_EN) == 0)
415 return;
416
417 printk(BIOS_DEBUG, "Periodic SMI.\n");
418}
419
420static void southbridge_smi_monitor(void)
421{
422#define IOTRAP(x) (trap_sts & (1 << x))
423 u32 trap_sts, trap_cycle;
Angel Pons2ead3632020-09-24 16:50:05 +0200424 u32 mask = 0;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700425 int i;
426
427 trap_sts = RCBA32(0x1e00); // TRSR - Trap Status Register
428 RCBA32(0x1e00) = trap_sts; // Clear trap(s) in TRSR
429
430 trap_cycle = RCBA32(0x1e10);
Lee Leahy26b7cd02017-03-16 18:47:55 -0700431 for (i = 16; i < 20; i++) {
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700432 if (trap_cycle & (1 << i))
433 mask |= (0xff << ((i - 16) << 2));
434 }
435
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700436 /* 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)) {
Lee Leahy8a9c7dc2017-03-17 10:43:25 -0700448 // It's a write
449 if (!(trap_cycle & (1 << 24))) {
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700450 printk(BIOS_DEBUG, "SMI1 command\n");
Angel Pons2ead3632020-09-24 16:50:05 +0200451 (void)RCBA32(0x1e18);
452 // data = RCBA32(0x1e18);
453 // data &= mask;
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700454 // if (smi1)
Lee Leahy26b7cd02017-03-16 18:47:55 -0700455 // southbridge_smi_command(data);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700456 // return;
457 }
458 // Fall through to debug
459 }
460
461 printk(BIOS_DEBUG, " trapped io address = 0x%x\n",
462 trap_cycle & 0xfffc);
Lee Leahy26b7cd02017-03-16 18:47:55 -0700463 for (i = 0; i < 4; i++)
Lee Leahy8a9c7dc2017-03-17 10:43:25 -0700464 if (IOTRAP(i))
465 printk(BIOS_DEBUG, " TRAP = %d\n", i);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700466 printk(BIOS_DEBUG, " AHBE = %x\n", (trap_cycle >> 16) & 0xf);
467 printk(BIOS_DEBUG, " MASK = 0x%08x\n", mask);
468 printk(BIOS_DEBUG, " read/write: %s\n",
469 (trap_cycle & (1 << 24)) ? "read" : "write");
470
471 if (!(trap_cycle & (1 << 24))) {
472 /* Write Cycle */
Angel Pons2ead3632020-09-24 16:50:05 +0200473 printk(BIOS_DEBUG, " iotrap written data = 0x%08x\n", RCBA32(0x1e18));
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700474 }
475#undef IOTRAP
476}
477
478typedef void (*smi_handler_t)(void);
479
480static smi_handler_t southbridge_smi[32] = {
481 NULL, // [0] reserved
482 NULL, // [1] reserved
483 NULL, // [2] BIOS_STS
484 NULL, // [3] LEGACY_USB_STS
485 southbridge_smi_sleep, // [4] SLP_SMI_STS
486 southbridge_smi_apmc, // [5] APM_STS
487 NULL, // [6] SWSMI_TMR_STS
488 NULL, // [7] reserved
489 southbridge_smi_pm1, // [8] PM1_STS
490 southbridge_smi_gpe0, // [9] GPE0_STS
491 southbridge_smi_gpi, // [10] GPI_STS
492 southbridge_smi_mc, // [11] MCSMI_STS
493 NULL, // [12] DEVMON_STS
494 southbridge_smi_tco, // [13] TCO_STS
495 southbridge_smi_periodic, // [14] PERIODIC_STS
496 NULL, // [15] SERIRQ_SMI_STS
497 NULL, // [16] SMBUS_SMI_STS
498 NULL, // [17] LEGACY_USB2_STS
499 NULL, // [18] INTEL_USB2_STS
500 NULL, // [19] reserved
501 NULL, // [20] PCI_EXP_SMI_STS
502 southbridge_smi_monitor, // [21] MONITOR_STS
503 NULL, // [22] reserved
504 NULL, // [23] reserved
505 NULL, // [24] reserved
506 NULL, // [25] EL_SMI_STS
507 NULL, // [26] SPI_STS
508 NULL, // [27] reserved
509 NULL, // [28] reserved
510 NULL, // [29] reserved
511 NULL, // [30] reserved
512 NULL // [31] reserved
513};
514
515/**
516 * @brief Interrupt handler for SMI#
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700517 */
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700518void southbridge_smi_handler(void)
519{
520 int i;
521 u32 smi_sts;
522
523 /* We need to clear the SMI status registers, or we won't see what's
524 * happening in the following calls.
525 */
526 smi_sts = clear_smi_status();
527
528 /* Call SMI sub handler for each of the status bits */
529 for (i = 0; i < 31; i++) {
530 if (smi_sts & (1 << i)) {
531 if (southbridge_smi[i]) {
532 southbridge_smi[i]();
533 } else {
534 printk(BIOS_DEBUG,
Martin Rothde7ed6f2014-12-07 14:58:18 -0700535 "SMI_STS[%d] occurred, but no "
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700536 "handler available.\n", i);
537 }
538 }
539 }
540}