Add some more CONFIG_* prefixes that were missing.
[coreboot.git] / src / southbridge / intel / i82801gx / i82801gx_smihandler.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008-2009 coresystems GmbH
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; version 2 of
9  * 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.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
19  * MA 02110-1301 USA
20  */
21
22 #include <types.h>
23 #include <arch/io.h>
24 #include <arch/romcc_io.h>
25 #include <console/console.h>
26 #include <cpu/x86/cache.h>
27 #include <cpu/x86/smm.h>
28 #include "i82801gx.h"
29 #include "i82801gx_power.h"
30
31 #define DEBUG_SMI
32
33 #define APM_CNT         0xb2
34 #define   CST_CONTROL   0x85 // 0x85 crashes the box
35 #define   PST_CONTROL   0x80 // 0x80 crashes the box
36 #define   ACPI_DISABLE  0x1e
37 #define   ACPI_ENABLE   0xe1
38 #define   GNVS_UPDATE   0xea
39 #define APM_STS         0xb3
40
41 /* I945 */
42 #define SMRAM           0x9d
43 #define   D_OPEN        (1 << 6)
44 #define   D_CLS         (1 << 5)
45 #define   D_LCK         (1 << 4)
46 #define   G_SMRANE      (1 << 3)
47 #define   C_BASE_SEG    ((0 << 2) | (1 << 1) | (0 << 0))
48
49 /* ICH7 */
50 #define PM1_STS         0x00
51 #define PM1_EN          0x02
52 #define PM1_CNT         0x04
53 #define   SLP_EN        (1 << 13)
54 #define   SLP_TYP       (7 << 10)
55 #define   GBL_RLS       (1 << 2)
56 #define   BM_RLD        (1 << 1)
57 #define   SCI_EN        (1 << 0)
58 #define PM1_TMR         0x08
59 #define PROC_CNT        0x10
60 #define LV2             0x14
61 #define LV3             0x15
62 #define LV4             0x16
63 #define PM2_CNT         0x20 // mobile only
64 #define GPE0_STS        0x28
65 #define GPE0_EN         0x2c
66 #define   PME_B0_EN     (1 << 13)
67 #define SMI_EN          0x30
68 #define   EL_SMI_EN      (1 << 25) // Intel Quick Resume Technology
69 #define   INTEL_USB2_EN  (1 << 18) // Intel-Specific USB2 SMI logic
70 #define   LEGACY_USB2_EN (1 << 17) // Legacy USB2 SMI logic
71 #define   PERIODIC_EN    (1 << 14) // SMI on PERIODIC_STS in SMI_STS
72 #define   TCO_EN         (1 << 13) // Enable TCO Logic (BIOSWE et al)
73 #define   MCSMI_EN       (1 << 11) // Trap microcontroller range access
74 #define   BIOS_RLS       (1 <<  7) // asserts SCI on bit set
75 #define   SWSMI_TMR_EN   (1 <<  6) // start software smi timer on bit set
76 #define   APMC_EN        (1 <<  5) // Writes to APM_CNT cause SMI#
77 #define   SLP_SMI_EN     (1 <<  4) // Write to SLP_EN in PM1_CNT asserts SMI#
78 #define   LEGACY_USB_EN  (1 <<  3) // Legacy USB circuit SMI logic
79 #define   BIOS_EN        (1 <<  2) // Assert SMI# on setting GBL_RLS bit
80 #define   EOS            (1 <<  1) // End of SMI (deassert SMI#)
81 #define   GBL_SMI_EN     (1 <<  0) // SMI# generation at all?
82 #define SMI_STS         0x34
83 #define ALT_GP_SMI_EN   0x38
84 #define ALT_GP_SMI_STS  0x3a
85 #define GPE_CNTL        0x42
86 #define DEVACT_STS      0x44
87 #define SS_CNT          0x50
88 #define C3_RES          0x54
89
90 #include "i82801gx_nvs.h"
91
92 /* While we read PMBASE dynamically in case it changed, let's
93  * initialize it with a sane value
94  */
95 u16 pmbase = DEFAULT_PMBASE;
96
97 /* GNVS needs to be updated by an 0xEA PM Trap (B2) after it has been located
98  * by coreboot.
99  */
100 global_nvs_t *gnvs = (global_nvs_t *)0x0;
101 void *tcg = (void *)0x0;
102 void *smi1 = (void *)0x0;
103
104 /**
105  * @brief read and clear PM1_STS 
106  * @return PM1_STS register
107  */
108 static u16 reset_pm1_status(void)
109 {
110         u16 reg16;
111         
112         reg16 = inw(pmbase + PM1_STS);
113         /* set status bits are cleared by writing 1 to them */
114         outw(reg16, pmbase + PM1_STS);
115         
116         return reg16;
117 }
118
119 static void dump_pm1_status(u16 pm1_sts)
120 {
121         printk_debug("PM1_STS: ");
122         if (pm1_sts & (1 << 15)) printk_debug("WAK ");
123         if (pm1_sts & (1 << 14)) printk_debug("PCIEXPWAK ");
124         if (pm1_sts & (1 << 11)) printk_debug("PRBTNOR ");
125         if (pm1_sts & (1 << 10)) printk_debug("RTC ");
126         if (pm1_sts & (1 <<  8)) printk_debug("PWRBTN ");
127         if (pm1_sts & (1 <<  5)) printk_debug("GBL ");
128         if (pm1_sts & (1 <<  4)) printk_debug("BM ");
129         if (pm1_sts & (1 <<  0)) printk_debug("TMROF ");
130         printk_debug("\n");
131 }
132
133 /**
134  * @brief read and clear SMI_STS 
135  * @return SMI_STS register
136  */
137 static u32 reset_smi_status(void)
138 {
139         u32 reg32;
140         
141         reg32 = inl(pmbase + SMI_STS);
142         /* set status bits are cleared by writing 1 to them */
143         outl(reg32, pmbase + SMI_STS);
144         
145         return reg32;
146 }
147
148 static void dump_smi_status(u32 smi_sts)
149 {
150         printk_debug("SMI_STS: ");
151         if (smi_sts & (1 << 26)) printk_debug("SPI ");
152         if (smi_sts & (1 << 25)) printk_debug("EL_SMI ");
153         if (smi_sts & (1 << 21)) printk_debug("MONITOR ");
154         if (smi_sts & (1 << 20)) printk_debug("PCI_EXP_SMI ");
155         if (smi_sts & (1 << 18)) printk_debug("INTEL_USB2 ");
156         if (smi_sts & (1 << 17)) printk_debug("LEGACY_USB2 ");
157         if (smi_sts & (1 << 16)) printk_debug("SMBUS_SMI ");
158         if (smi_sts & (1 << 15)) printk_debug("SERIRQ_SMI ");
159         if (smi_sts & (1 << 14)) printk_debug("PERIODIC ");
160         if (smi_sts & (1 << 13)) printk_debug("TCO ");
161         if (smi_sts & (1 << 12)) printk_debug("DEVMON ");
162         if (smi_sts & (1 << 11)) printk_debug("MCSMI ");
163         if (smi_sts & (1 << 10)) printk_debug("GPI ");
164         if (smi_sts & (1 <<  9)) printk_debug("GPE0 ");
165         if (smi_sts & (1 <<  8)) printk_debug("PM1 ");
166         if (smi_sts & (1 <<  6)) printk_debug("SWSMI_TMR ");
167         if (smi_sts & (1 <<  5)) printk_debug("APM ");
168         if (smi_sts & (1 <<  4)) printk_debug("SLP_SMI ");
169         if (smi_sts & (1 <<  3)) printk_debug("LEGACY_USB ");
170         if (smi_sts & (1 <<  2)) printk_debug("BIOS ");
171         printk_debug("\n");
172 }
173
174
175 /**
176  * @brief read and clear GPE0_STS
177  * @return GPE0_STS register
178  */
179 static u32 reset_gpe0_status(void)
180 {
181         u32 reg32;
182         
183         reg32 = inl(pmbase + GPE0_STS);
184         /* set status bits are cleared by writing 1 to them */
185         outl(reg32, pmbase + GPE0_STS);
186         
187         return reg32;
188 }
189
190 static void dump_gpe0_status(u32 gpe0_sts)
191 {
192         int i;
193         printk_debug("GPE0_STS: ");
194         for (i=31; i<= 16; i--) {
195                 if (gpe0_sts & (1 << i)) printk_debug("GPIO%d ", (i-16));
196         }
197         if (gpe0_sts & (1 << 14)) printk_debug("USB4 ");
198         if (gpe0_sts & (1 << 13)) printk_debug("PME_B0 ");
199         if (gpe0_sts & (1 << 12)) printk_debug("USB3 ");
200         if (gpe0_sts & (1 << 11)) printk_debug("PME ");
201         if (gpe0_sts & (1 << 10)) printk_debug("EL_SCI/BATLOW ");
202         if (gpe0_sts & (1 <<  9)) printk_debug("PCI_EXP ");
203         if (gpe0_sts & (1 <<  8)) printk_debug("RI ");
204         if (gpe0_sts & (1 <<  7)) printk_debug("SMB_WAK ");
205         if (gpe0_sts & (1 <<  6)) printk_debug("TCO_SCI ");
206         if (gpe0_sts & (1 <<  5)) printk_debug("AC97 ");
207         if (gpe0_sts & (1 <<  4)) printk_debug("USB2 ");
208         if (gpe0_sts & (1 <<  3)) printk_debug("USB1 ");
209         if (gpe0_sts & (1 <<  2)) printk_debug("HOT_PLUG ");
210         if (gpe0_sts & (1 <<  0)) printk_debug("THRM ");
211         printk_debug("\n");
212 }
213
214
215 /**
216  * @brief read and clear TCOx_STS 
217  * @return TCOx_STS registers
218  */
219 static u32 reset_tco_status(void)
220 {
221         u32 tcobase = pmbase + 0x60;
222         u32 reg32;
223         
224         reg32 = inl(tcobase + 0x04);
225         /* set status bits are cleared by writing 1 to them */
226         outl(reg32 & ~(1<<18), tcobase + 0x04); //  Don't clear BOOT_STS before SECOND_TO_STS
227         if (reg32 & (1 << 18))
228                 outl(reg32 & (1<<18), tcobase + 0x04); // clear BOOT_STS
229         
230         return reg32;
231 }
232
233
234 static void dump_tco_status(u32 tco_sts)
235 {
236         printk_debug("TCO_STS: ");
237         if (tco_sts & (1 << 20)) printk_debug("SMLINK_SLV ");
238         if (tco_sts & (1 << 18)) printk_debug("BOOT ");
239         if (tco_sts & (1 << 17)) printk_debug("SECOND_TO ");
240         if (tco_sts & (1 << 16)) printk_debug("INTRD_DET ");
241         if (tco_sts & (1 << 12)) printk_debug("DMISERR ");
242         if (tco_sts & (1 << 10)) printk_debug("DMISMI ");
243         if (tco_sts & (1 <<  9)) printk_debug("DMISCI ");
244         if (tco_sts & (1 <<  8)) printk_debug("BIOSWR ");
245         if (tco_sts & (1 <<  7)) printk_debug("NEWCENTURY ");
246         if (tco_sts & (1 <<  3)) printk_debug("TIMEOUT ");
247         if (tco_sts & (1 <<  2)) printk_debug("TCO_INT ");
248         if (tco_sts & (1 <<  1)) printk_debug("SW_TCO ");
249         if (tco_sts & (1 <<  0)) printk_debug("NMI2SMI ");
250         printk_debug("\n");
251 }
252
253 /* We are using PCIe accesses for now
254  *  1. the chipset can do it
255  *  2. we don't need to worry about how we leave 0xcf8/0xcfc behind
256  */
257 #include "../../../northbridge/intel/i945/pcie_config.c"
258
259 int southbridge_io_trap_handler(int smif)
260 {
261         switch (smif) {
262         case 0x32:
263                 printk_debug("OS Init\n");
264                 gnvs->smif = 0;
265                 break;
266         default:
267                 /* Not handled */
268                 return 0;
269         }
270
271         /* On success, the IO Trap Handler returns 0
272          * On failure, the IO Trap Handler returns a value != 0
273          *
274          * For now, we force the return value to 0 and log all traps to
275          * see what's going on.
276          */
277         //gnvs->smif = 0;
278         return 1; /* IO trap handled */
279 }
280
281 /**
282  * @brief Set the EOS bit
283  */
284 void southbridge_smi_set_eos(void)
285 {
286         u8 reg8;
287
288         reg8 = inb(pmbase + SMI_EN);
289         reg8 |= EOS;
290         outb(reg8, pmbase + SMI_EN);
291 }
292
293
294 static void southbridge_smi_sleep(unsigned int node, smm_state_save_area_t *state_save)
295 {
296         u8 reg8;
297         u32 reg32;
298         u8 slp_typ;
299         /* FIXME: the power state on boot should be read from 
300          * CMOS or even better from GNVS. Right now it's hard
301          * coded at compile time.
302          */
303         u8 s5pwr = CONFIG_MAINBOARD_POWER_ON_AFTER_POWER_FAIL;
304
305         /* First, disable further SMIs */
306         reg8 = inb(pmbase + SMI_EN);
307         reg8 &= ~SLP_SMI_EN;
308         outb(reg8, pmbase + SMI_EN);
309
310         /* Figure out SLP_TYP */
311         reg32 = inl(pmbase + PM1_CNT);
312         printk_spew("SMI#: SLP = 0x%08x\n", reg32);
313         slp_typ = (reg32 >> 10) & 7;
314
315         /* Next, do the deed.
316          */
317
318         switch (slp_typ) {
319         case 0: printk_debug("SMI#: Entering S0 (On)\n"); break;
320         case 1: printk_debug("SMI#: Entering S1 (Assert STPCLK#)\n"); break;
321         case 5:
322                 printk_debug("SMI#: Entering S3 (Suspend-To-RAM)\n");
323                 /* Invalidate the cache before going to S3 */
324                 wbinvd();
325                 break;
326         case 6: printk_debug("SMI#: Entering S4 (Suspend-To-Disk)\n"); break;
327         case 7:
328                 printk_debug("SMI#: Entering S5 (Soft Power off)\n");
329 #if 0
330                 /* Set PME_B0_EN before going to S5 */
331                 reg32 = inl(pmbase + GPE0_EN);
332                 reg32 |= PME_B0_EN;
333                 outl(reg32, pmbase + GPE0_EN);
334 #endif
335                 /* Should we keep the power state after a power loss?
336                  * In case the setting is "ON" or "OFF" we don't have
337                  * to do anything. But if it's "KEEP" we have to switch
338                  * to "OFF" before entering S5.
339                  */
340                 if (s5pwr == MAINBOARD_POWER_KEEP) {
341                         reg8 = pcie_read_config8(PCI_DEV(0, 0x1f, 0), GEN_PMCON_3);
342                         reg8 |= 1;
343                         pcie_write_config8(PCI_DEV(0, 0x1f, 0), GEN_PMCON_3, reg8);
344                 }
345                 break;
346         default: printk_debug("SMI#: ERROR: SLP_TYP reserved\n"); break;
347         }
348
349         /* Write back to the SLP register to cause the originally intended
350          * event again. We need to set BIT13 (SLP_EN) though to make the 
351          * sleep happen.
352          */
353         outl(reg32 | SLP_EN, pmbase + PM1_CNT);
354
355         /* In most sleep states, the code flow of this function ends at
356          * the line above. However, if we entered sleep state S1 and wake
357          * up again, we will continue to execute code in this function.
358          */
359         reg32 = inl(pmbase + PM1_CNT);
360         if (reg32 & SCI_EN) {
361                 /* The OS is not an ACPI OS, so we set the state to S0 */
362                 reg32 &= ~(SLP_EN | SLP_TYP);
363                 outl(reg32, pmbase + PM1_CNT);
364         }
365 }
366
367 static void southbridge_smi_apmc(unsigned int node, smm_state_save_area_t *state_save)
368 {
369         u32 pmctrl;
370         u8 reg8;
371
372         /* Emulate B2 register as the FADT / Linux expects it */
373
374         reg8 = inb(APM_CNT);
375         switch (reg8) {
376         case CST_CONTROL:
377                 /* Calling this function seems to cause
378                  * some kind of race condition in Linux
379                  * and causes a kernel oops
380                  */
381                 printk_debug("C-state control\n");
382                 break;
383         case PST_CONTROL:
384                 /* Calling this function seems to cause
385                  * some kind of race condition in Linux
386                  * and causes a kernel oops
387                  */
388                 printk_debug("P-state control\n");
389                 break;
390         case ACPI_DISABLE:
391                 pmctrl = inl(pmbase + PM1_CNT);
392                 pmctrl &= ~SCI_EN;
393                 outl(pmctrl, pmbase + PM1_CNT);
394                 printk_debug("SMI#: ACPI disabled.\n");
395                 break;
396         case ACPI_ENABLE:
397                 pmctrl = inl(pmbase + PM1_CNT);
398                 pmctrl |= SCI_EN;
399                 outl(pmctrl, pmbase + PM1_CNT);
400                 printk_debug("SMI#: ACPI enabled.\n");
401                 break;
402         case GNVS_UPDATE:
403                 gnvs = *(global_nvs_t **)0x500;
404                 tcg  = *(void **)0x504;
405                 smi1 = *(void **)0x508;
406                 printk_debug("SMI#: Setting up structures to %p, %p, %p\n", gnvs, tcg, smi1);
407                 break;
408         default:
409                 printk_debug("SMI#: Unknown function APM_CNT=%02x\n", reg8);
410         }
411 }
412
413 static void southbridge_smi_pm1(unsigned int node, smm_state_save_area_t *state_save)
414 {
415         u16 pm1_sts;
416
417         pm1_sts = reset_pm1_status();
418         dump_pm1_status(pm1_sts);
419 }
420
421 static void southbridge_smi_gpe0(unsigned int node, smm_state_save_area_t *state_save)
422 {
423         u32 gpe0_sts;
424
425         gpe0_sts = reset_gpe0_status();
426         dump_gpe0_status(gpe0_sts);
427 }
428
429 static void southbridge_smi_mc(unsigned int node, smm_state_save_area_t *state_save)
430 {
431         u32 reg32;
432
433         reg32 = inl(pmbase + SMI_EN);
434
435         /* Are periodic SMIs enabled? */
436         if ((reg32 & MCSMI_EN) == 0)
437                 return;
438
439         printk_debug("Microcontroller SMI.\n");
440 }
441
442
443
444 static void southbridge_smi_tco(unsigned int node, smm_state_save_area_t *state_save)
445 {
446         u32 tco_sts;
447
448         tco_sts = reset_tco_status();
449
450         /* Any TCO event? */
451         if (!tco_sts)
452                 return;
453
454         if (tco_sts & (1 << 8)) { // BIOSWR
455                 u8 bios_cntl;
456
457                 bios_cntl = pcie_read_config16(PCI_DEV(0, 0x1f, 0), 0xdc);
458
459                 if (bios_cntl & 1) {
460                         /* BWE is RW, so the SMI was caused by a
461                          * write to BWE, not by a write to the BIOS
462                          */
463
464                         /* This is the place where we notice someone
465                          * is trying to tinker with the BIOS. We are
466                          * trying to be nice and just ignore it. A more
467                          * resolute answer would be to power down the
468                          * box.
469                          */
470                         printk_debug("Switching back to RO\n");
471                         pcie_write_config32(PCI_DEV(0, 0x1f, 0), 0xdc, (bios_cntl & ~1));
472                 } /* No else for now? */
473         } else if (tco_sts & (1 << 3)) { /* TIMEOUT */
474                 /* Handle TCO timeout */
475                 printk_debug("TCO Timeout.\n");
476         } else if (!tco_sts) {
477                 dump_tco_status(tco_sts);
478         }
479 }
480
481 static void southbridge_smi_periodic(unsigned int node, smm_state_save_area_t *state_save)
482 {
483         u32 reg32;
484
485         reg32 = inl(pmbase + SMI_EN);
486
487         /* Are periodic SMIs enabled? */
488         if ((reg32 & PERIODIC_EN) == 0)
489                 return;
490
491         printk_debug("Periodic SMI.\n");
492 }
493
494 static void southbridge_smi_monitor(unsigned int node, smm_state_save_area_t *state_save)
495 {
496 #define IOTRAP(x) (trap_sts & (1 << x))
497         u32 trap_sts, trap_cycle;
498         u32 data, mask = 0;
499         int i;
500
501         trap_sts = RCBA32(0x1e00); // TRSR - Trap Status Register
502         RCBA32(0x1e00) = trap_sts; // Clear trap(s) in TRSR
503
504         trap_cycle = RCBA32(0x1e10);
505         for (i=16; i<20; i++) {
506                 if (trap_cycle & (1 << i))
507                         mask |= (0xff << ((i - 16) << 2));
508         }
509
510
511         /* IOTRAP(3) SMI function call */
512         if (IOTRAP(3)) {
513                 if (gnvs && gnvs->smif)
514                         io_trap_handler(gnvs->smif); // call function smif
515                 return;
516         }
517
518         /* IOTRAP(2) currently unused
519          * IOTRAP(1) currently unused */
520
521         /* IOTRAP(0) SMIC */
522         if (IOTRAP(0)) {
523                 if (!(trap_cycle & (1 << 24))) { // It's a write
524                         printk_debug("SMI1 command\n");
525                         data = RCBA32(0x1e18);
526                         data &= mask;
527                         // if (smi1)
528                         //      southbridge_smi_command(data);
529                         // return;
530                 }
531                 // Fall through to debug
532         }
533
534         printk_debug("  trapped io address = 0x%x\n", trap_cycle & 0xfffc);
535         for (i=0; i < 4; i++) if(IOTRAP(i)) printk_debug("  TRAPĀ = %d\n", i);
536         printk_debug("  AHBE = %x\n", (trap_cycle >> 16) & 0xf);
537         printk_debug("  MASK = 0x%08x\n", mask);
538         printk_debug("  read/write: %s\n", (trap_cycle & (1 << 24)) ? "read" : "write");
539
540         if (!(trap_cycle & (1 << 24))) {
541                 /* Write Cycle */
542                 data = RCBA32(0x1e18);
543                 printk_debug("  iotrap written data = 0x%08x\n", data);
544         }
545 #undef IOTRAP
546 }
547
548 typedef void (*smi_handler)(unsigned int node, 
549                 smm_state_save_area_t *state_save);
550
551 smi_handler southbridge_smi[32] = {
552         NULL,                     //  [0] reserved
553         NULL,                     //  [1] reserved
554         NULL,                     //  [2] BIOS_STS
555         NULL,                     //  [3] LEGACY_USB_STS
556         southbridge_smi_sleep,    //  [4] SLP_SMI_STS
557         southbridge_smi_apmc,     //  [5] APM_STS
558         NULL,                     //  [6] SWSMI_TMR_STS
559         NULL,                     //  [7] reserved
560         southbridge_smi_pm1,      //  [8] PM1_STS
561         southbridge_smi_gpe0,     //  [9] GPE0_STS
562         NULL,                     // [10] GPI_STS
563         southbridge_smi_mc,       // [11] MCSMI_STS
564         NULL,                     // [12] DEVMON_STS
565         southbridge_smi_tco,      // [13] TCO_STS
566         southbridge_smi_periodic, // [14] PERIODIC_STS
567         NULL,                     // [15] SERIRQ_SMI_STS
568         NULL,                     // [16] SMBUS_SMI_STS
569         NULL,                     // [17] LEGACY_USB2_STS
570         NULL,                     // [18] INTEL_USB2_STS
571         NULL,                     // [19] reserved
572         NULL,                     // [20] PCI_EXP_SMI_STS
573         southbridge_smi_monitor,  // [21] MONITOR_STS
574         NULL,                     // [22] reserved
575         NULL,                     // [23] reserved
576         NULL,                     // [24] reserved
577         NULL,                     // [25] EL_SMI_STS
578         NULL,                     // [26] SPI_STS
579         NULL,                     // [27] reserved
580         NULL,                     // [28] reserved
581         NULL,                     // [29] reserved
582         NULL,                     // [30] reserved
583         NULL                      // [31] reserved 
584 };
585
586 /**
587  * @brief Interrupt handler for SMI#
588  *
589  * @param smm_revision revision of the smm state save map
590  */
591
592 void southbridge_smi_handler(unsigned int node, smm_state_save_area_t *state_save)
593 {
594         int i, dump = 0;
595         u32 smi_sts;
596
597         /* Update global variable pmbase */
598         pmbase = pcie_read_config16(PCI_DEV(0, 0x1f, 0), 0x40) & 0xfffc;
599
600         /* We need to clear the SMI status registers, or we won't see what's
601          * happening in the following calls.
602          */
603         smi_sts = reset_smi_status();
604         
605         /* Filter all non-enabled SMI events */
606         // FIXME Double check, this clears MONITOR
607         // smi_sts &= inl(pmbase + SMI_EN);
608
609         /* Call SMI sub handler for each of the status bits */
610         for (i = 0; i < 31; i++) {
611                 if (smi_sts & (1 << i)) { 
612                         if (southbridge_smi[i])
613                                 southbridge_smi[i](node, state_save);
614                         else {
615                                 printk_debug("SMI_STS[%d] occured, but no "
616                                                 "handler available.\n", i);
617                                 dump = 1;
618                         }
619                 }
620         }
621
622         if(dump) {
623                 dump_smi_status(smi_sts);
624         }
625
626 }