2008-10-29 05:46:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; version 2 of
|
|
|
|
* the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2009-07-21 23:50:34 +02:00
|
|
|
#include <types.h>
|
2008-10-29 05:46:52 +01:00
|
|
|
#include <console/console.h>
|
|
|
|
#include <cpu/x86/smm.h>
|
2010-01-17 14:49:07 +01:00
|
|
|
#include <device/pci_def.h>
|
2018-04-10 12:56:19 +02:00
|
|
|
#include <southbridge/intel/common/pmutil.h>
|
2009-07-21 23:50:34 +02:00
|
|
|
#include "i82801gx.h"
|
2008-10-29 05:46:52 +01:00
|
|
|
|
|
|
|
/* I945 */
|
|
|
|
#define SMRAM 0x9d
|
|
|
|
#define D_OPEN (1 << 6)
|
|
|
|
#define D_CLS (1 << 5)
|
|
|
|
#define D_LCK (1 << 4)
|
|
|
|
#define G_SMRANE (1 << 3)
|
|
|
|
#define C_BASE_SEG ((0 << 2) | (1 << 1) | (0 << 0))
|
|
|
|
|
2010-12-08 06:42:47 +01:00
|
|
|
#include "nvs.h"
|
2008-10-29 05:46:52 +01:00
|
|
|
|
|
|
|
/* While we read PMBASE dynamically in case it changed, let's
|
|
|
|
* initialize it with a sane value
|
|
|
|
*/
|
2009-07-21 23:50:34 +02:00
|
|
|
u16 pmbase = DEFAULT_PMBASE;
|
2009-10-26 18:12:21 +01:00
|
|
|
u8 smm_initialized = 0;
|
2009-07-21 23:50:34 +02:00
|
|
|
|
|
|
|
/* GNVS needs to be updated by an 0xEA PM Trap (B2) after it has been located
|
|
|
|
* by coreboot.
|
|
|
|
*/
|
|
|
|
global_nvs_t *gnvs = (global_nvs_t *)0x0;
|
2008-10-29 05:46:52 +01:00
|
|
|
|
2018-04-10 12:56:19 +02:00
|
|
|
void southbridge_update_gnvs(u8 apm_cnt, int *smm_done)
|
2014-12-29 10:32:27 +01:00
|
|
|
{
|
2018-04-10 12:56:19 +02:00
|
|
|
gnvs = *(global_nvs_t **)0x500;
|
|
|
|
*smm_done = 1;
|
2008-10-29 05:46:52 +01:00
|
|
|
}
|
|
|
|
|
2009-03-06 20:52:36 +01:00
|
|
|
int southbridge_io_trap_handler(int smif)
|
2008-10-29 05:46:52 +01:00
|
|
|
{
|
|
|
|
switch (smif) {
|
|
|
|
case 0x32:
|
2010-03-22 12:42:32 +01:00
|
|
|
printk(BIOS_DEBUG, "OS Init\n");
|
2009-10-26 18:12:21 +01:00
|
|
|
/* gnvs->smif:
|
|
|
|
* On success, the IO Trap Handler returns 0
|
|
|
|
* On failure, the IO Trap Handler returns a value != 0
|
|
|
|
*/
|
2009-07-21 23:50:34 +02:00
|
|
|
gnvs->smif = 0;
|
2009-10-26 18:12:21 +01:00
|
|
|
return 1; /* IO trap handled */
|
2008-10-29 05:46:52 +01:00
|
|
|
}
|
|
|
|
|
2009-10-26 18:12:21 +01:00
|
|
|
/* Not handled */
|
|
|
|
return 0;
|
2008-10-29 05:46:52 +01:00
|
|
|
}
|
|
|
|
|
2018-04-10 12:56:19 +02:00
|
|
|
void southbridge_smi_monitor(void)
|
2009-07-21 23:50:34 +02:00
|
|
|
{
|
|
|
|
#define IOTRAP(x) (trap_sts & (1 << x))
|
|
|
|
u32 trap_sts, trap_cycle;
|
|
|
|
u32 data, mask = 0;
|
|
|
|
int i;
|
2008-10-29 05:46:52 +01:00
|
|
|
|
2009-07-21 23:50:34 +02:00
|
|
|
trap_sts = RCBA32(0x1e00); // TRSR - Trap Status Register
|
|
|
|
RCBA32(0x1e00) = trap_sts; // Clear trap(s) in TRSR
|
|
|
|
|
|
|
|
trap_cycle = RCBA32(0x1e10);
|
2017-03-09 12:02:52 +01:00
|
|
|
for (i = 16; i < 20; i++) {
|
2009-07-21 23:50:34 +02:00
|
|
|
if (trap_cycle & (1 << i))
|
|
|
|
mask |= (0xff << ((i - 16) << 2));
|
2008-10-29 05:46:52 +01:00
|
|
|
}
|
|
|
|
|
2009-07-21 23:50:34 +02:00
|
|
|
|
|
|
|
/* IOTRAP(3) SMI function call */
|
|
|
|
if (IOTRAP(3)) {
|
|
|
|
if (gnvs && gnvs->smif)
|
|
|
|
io_trap_handler(gnvs->smif); // call function smif
|
|
|
|
return;
|
2008-10-29 05:46:52 +01:00
|
|
|
}
|
|
|
|
|
2009-07-21 23:50:34 +02:00
|
|
|
/* IOTRAP(2) currently unused
|
|
|
|
* IOTRAP(1) currently unused */
|
|
|
|
|
2014-08-31 01:09:12 +02:00
|
|
|
/* IOTRAP(0) SMIC: currently unused */
|
2008-10-29 05:46:52 +01:00
|
|
|
|
2010-03-22 12:42:32 +01:00
|
|
|
printk(BIOS_DEBUG, " trapped io address = 0x%x\n", trap_cycle & 0xfffc);
|
2017-03-09 12:02:52 +01:00
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
if (IOTRAP(i))
|
|
|
|
printk(BIOS_DEBUG, " TRAP = %d\n", i);
|
2010-03-22 12:42:32 +01:00
|
|
|
printk(BIOS_DEBUG, " AHBE = %x\n", (trap_cycle >> 16) & 0xf);
|
|
|
|
printk(BIOS_DEBUG, " MASK = 0x%08x\n", mask);
|
|
|
|
printk(BIOS_DEBUG, " read/write: %s\n", (trap_cycle & (1 << 24)) ? "read" : "write");
|
2009-01-20 23:53:10 +01:00
|
|
|
|
2009-07-21 23:50:34 +02:00
|
|
|
if (!(trap_cycle & (1 << 24))) {
|
|
|
|
/* Write Cycle */
|
|
|
|
data = RCBA32(0x1e18);
|
2010-03-22 12:42:32 +01:00
|
|
|
printk(BIOS_DEBUG, " iotrap written data = 0x%08x\n", data);
|
2009-07-21 23:50:34 +02:00
|
|
|
}
|
|
|
|
#undef IOTRAP
|
|
|
|
}
|
2009-01-20 23:53:10 +01:00
|
|
|
|
2018-04-10 12:56:19 +02:00
|
|
|
void southbridge_finalize_all(void)
|
2009-07-21 23:50:34 +02:00
|
|
|
{
|
2008-10-29 05:46:52 +01:00
|
|
|
}
|