bd82x6x: Merge common apmc finalize procedure.

Change-Id: I9c938b8a69479fae6b0eb99d1135f1caaf26d0e2
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
Reviewed-on: http://review.coreboot.org/10227
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Tested-by: build bot (Jenkins)
Reviewed-by: Nicolas Reinecke <nr@das-labor.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Vladimir Serbinenko 2015-05-16 13:48:10 +02:00
parent eec8dfb5e7
commit 4141b47b07
17 changed files with 17 additions and 327 deletions

View File

@ -49,41 +49,3 @@ int mainboard_io_trap_handler(int smif)
* On failure, the IO Trap Handler returns a value != 1 */ * On failure, the IO Trap Handler returns a value != 1 */
return 1; return 1;
} }
static int mainboard_finalized = 0;
int mainboard_smi_apmc(u8 data)
{
u16 pmbase = pci_read_config16(PCI_DEV(0, 0x1f, 0), 0x40) & 0xfffc;
printk(BIOS_DEBUG, "%s: pmbase %04X, data %02X\n", __func__, pmbase,
data);
if (!pmbase)
return 0;
switch (data) {
case APM_CNT_ACPI_ENABLE:
break;
case APM_CNT_ACPI_DISABLE:
break;
case APM_CNT_FINALIZE:
printk(BIOS_DEBUG, "APMC: FINALIZE\n");
if (mainboard_finalized) {
printk(BIOS_DEBUG, "APMC#: Already finalized\n");
return 0;
}
intel_me_finalize_smm();
intel_pch_finalize_smm();
intel_sandybridge_finalize_smm();
intel_model_206ax_finalize_smm();
mainboard_finalized = 1;
break;
default:
break;
}
return 0;
}

View File

@ -49,41 +49,3 @@ int mainboard_io_trap_handler(int smif)
* On failure, the IO Trap Handler returns a value != 1 */ * On failure, the IO Trap Handler returns a value != 1 */
return 1; return 1;
} }
static int mainboard_finalized = 0;
int mainboard_smi_apmc(u8 data)
{
u16 pmbase = pci_read_config16(PCI_DEV(0, 0x1f, 0), 0x40) & 0xfffc;
printk(BIOS_DEBUG, "%s: pmbase %04X, data %02X\n", __func__, pmbase,
data);
if (!pmbase)
return 0;
switch (data) {
case APM_CNT_ACPI_ENABLE:
break;
case APM_CNT_ACPI_DISABLE:
break;
case APM_CNT_FINALIZE:
printk(BIOS_DEBUG, "APMC: FINALIZE\n");
if (mainboard_finalized) {
printk(BIOS_DEBUG, "APMC#: Already finalized\n");
return 0;
}
intel_me_finalize_smm();
intel_pch_finalize_smm();
intel_sandybridge_finalize_smm();
intel_model_206ax_finalize_smm();
mainboard_finalized = 1;
break;
default:
break;
}
return 0;
}

View File

@ -54,27 +54,10 @@ void mainboard_smi_sleep(u8 slp_typ)
#define APMC_ACPI_EN 0xe1 #define APMC_ACPI_EN 0xe1
#define APMC_ACPI_DIS 0x1e #define APMC_ACPI_DIS 0x1e
static int mainboard_finalized = 0;
int mainboard_smi_apmc(u8 apmc) int mainboard_smi_apmc(u8 apmc)
{ {
printk(BIOS_DEBUG, "mainboard_smi_apmc: %x\n", apmc); printk(BIOS_DEBUG, "mainboard_smi_apmc: %x\n", apmc);
switch (apmc) { switch (apmc) {
case APM_CNT_FINALIZE:
printk(BIOS_DEBUG, "APMC: FINALIZE\n");
if (mainboard_finalized) {
printk(BIOS_DEBUG, "APMC#: Already finalized\n");
return 0;
}
intel_me_finalize_smm();
intel_pch_finalize_smm();
intel_sandybridge_finalize_smm();
intel_model_206ax_finalize_smm();
mainboard_finalized = 1;
break;
case APMC_ACPI_EN: case APMC_ACPI_EN:
printk(BIOS_DEBUG, "APMC: ACPI_EN\n"); printk(BIOS_DEBUG, "APMC: ACPI_EN\n");
/* Clear all pending events and enable SCI */ /* Clear all pending events and enable SCI */

View File

@ -100,24 +100,9 @@ void mainboard_smi_sleep(u8 slp_typ)
#define APMC_ACPI_EN 0xe1 #define APMC_ACPI_EN 0xe1
#define APMC_ACPI_DIS 0x1e #define APMC_ACPI_DIS 0x1e
static int mainboard_finalized = 0;
int mainboard_smi_apmc(u8 apmc) int mainboard_smi_apmc(u8 apmc)
{ {
switch (apmc) { switch (apmc) {
case APM_CNT_FINALIZE:
if (mainboard_finalized) {
printk(BIOS_DEBUG, "SMI#: Already finalized\n");
return 0;
}
intel_me_finalize_smm();
intel_pch_finalize_smm();
intel_sandybridge_finalize_smm();
intel_model_206ax_finalize_smm();
mainboard_finalized = 1;
break;
case APMC_ACPI_EN: case APMC_ACPI_EN:
google_chromeec_set_smi_mask(0); google_chromeec_set_smi_mask(0);
/* Clear all pending events */ /* Clear all pending events */

View File

@ -110,26 +110,10 @@ void mainboard_smi_sleep(u8 slp_typ)
#define APMC_ACPI_EN 0xe1 #define APMC_ACPI_EN 0xe1
#define APMC_ACPI_DIS 0x1e #define APMC_ACPI_DIS 0x1e
static int mainboard_finalized = 0;
int mainboard_smi_apmc(u8 apmc) int mainboard_smi_apmc(u8 apmc)
{ {
printk(BIOS_DEBUG, "mainboard_smi_apmc: %x\n", apmc); printk(BIOS_DEBUG, "mainboard_smi_apmc: %x\n", apmc);
switch (apmc) { switch (apmc) {
case APM_CNT_FINALIZE:
printk(BIOS_DEBUG, "APMC: FINALIZE\n");
if (mainboard_finalized) {
printk(BIOS_DEBUG, "APMC#: Already finalized\n");
return 0;
}
intel_me_finalize_smm();
intel_pch_finalize_smm();
intel_sandybridge_finalize_smm();
intel_model_206ax_finalize_smm();
mainboard_finalized = 1;
break;
case APMC_ACPI_EN: case APMC_ACPI_EN:
printk(BIOS_DEBUG, "APMC: ACPI_EN\n"); printk(BIOS_DEBUG, "APMC: ACPI_EN\n");
/* Clear all pending events */ /* Clear all pending events */

View File

@ -92,24 +92,11 @@ void mainboard_smi_sleep(u8 slp_typ)
#define APMC_ACPI_EN 0xe1 #define APMC_ACPI_EN 0xe1
#define APMC_ACPI_DIS 0x1e #define APMC_ACPI_DIS 0x1e
static int mainboard_finalized = 0;
int mainboard_smi_apmc(u8 apmc) int mainboard_smi_apmc(u8 apmc)
{ {
switch (apmc) { switch (apmc) {
case APM_CNT_FINALIZE: case APM_CNT_FINALIZE:
if (mainboard_finalized) {
printk(BIOS_DEBUG, "SMI#: Already finalized\n");
return 0;
}
printk(BIOS_DEBUG, "SMI#: finalize\n");
intel_me_finalize_smm();
intel_pch_finalize_smm();
intel_sandybridge_finalize_smm();
intel_model_206ax_finalize_smm();
stout_ec_finalize_smm(); stout_ec_finalize_smm();
mainboard_finalized = 1;
break; break;
case APMC_ACPI_EN: case APMC_ACPI_EN:
/* /*

View File

@ -49,26 +49,3 @@ void mainboard_smi_sleep(u8 slp_typ)
break; break;
} }
} }
static int mainboard_finalized = 0;
int mainboard_smi_apmc(u8 apmc)
{
switch (apmc) {
case APM_CNT_FINALIZE:
if (mainboard_finalized) {
printk(BIOS_DEBUG, "SMI#: Already finalized\n");
return 0;
}
intel_me_finalize_smm();
intel_pch_finalize_smm();
intel_sandybridge_finalize_smm();
intel_model_206ax_finalize_smm();
mainboard_finalized = 1;
break;
}
return 0;
}

View File

@ -30,28 +30,3 @@ void mainboard_smi_gpi(u32 gpi_sts)
{ {
printk(BIOS_DEBUG, "warn: unknown mainboard_smi_gpi: %x\n", gpi_sts); printk(BIOS_DEBUG, "warn: unknown mainboard_smi_gpi: %x\n", gpi_sts);
} }
static int mainboard_finalized = 0;
int mainboard_smi_apmc(u8 apmc)
{
printk(BIOS_DEBUG, "mainboard_smi_apmc: %x\n", apmc);
switch (apmc) {
case APM_CNT_FINALIZE:
printk(BIOS_DEBUG, "APMC: FINALIZE\n");
if (mainboard_finalized) {
printk(BIOS_DEBUG, "APMC#: Already finalized\n");
return 0;
}
intel_me_finalize_smm();
intel_pch_finalize_smm();
intel_sandybridge_finalize_smm();
intel_model_206ax_finalize_smm();
mainboard_finalized = 1;
break;
}
return 0;
}

View File

@ -110,8 +110,6 @@ void mainboard_smi_gpi(u32 gpi_sts)
mainboard_smi_handle_ec_sci(); mainboard_smi_handle_ec_sci();
} }
static int mainboard_finalized = 0;
int mainboard_smi_apmc(u8 data) int mainboard_smi_apmc(u8 data)
{ {
switch (data) { switch (data) {
@ -132,21 +130,6 @@ int mainboard_smi_apmc(u8 data)
/* discard all events, and enable attention */ /* discard all events, and enable attention */
ec_write(0x80, 0x01); ec_write(0x80, 0x01);
break; break;
case APM_CNT_FINALIZE:
printk(BIOS_DEBUG, "APMC: FINALIZE\n");
if (mainboard_finalized) {
printk(BIOS_DEBUG, "APMC#: Already finalized\n");
return 0;
}
intel_me_finalize_smm();
intel_pch_finalize_smm();
intel_sandybridge_finalize_smm();
intel_model_206ax_finalize_smm();
mainboard_finalized = 1;
break;
default: default:
break; break;
} }

View File

@ -108,8 +108,6 @@ void mainboard_smi_gpi(u32 gpi_sts)
mainboard_smi_handle_ec_sci(); mainboard_smi_handle_ec_sci();
} }
static int mainboard_finalized = 0;
int mainboard_smi_apmc(u8 data) int mainboard_smi_apmc(u8 data)
{ {
switch (data) { switch (data) {
@ -130,21 +128,6 @@ int mainboard_smi_apmc(u8 data)
/* discard all events, and enable attention */ /* discard all events, and enable attention */
ec_write(0x80, 0x01); ec_write(0x80, 0x01);
break; break;
case APM_CNT_FINALIZE:
printk(BIOS_DEBUG, "APMC: FINALIZE\n");
if (mainboard_finalized) {
printk(BIOS_DEBUG, "APMC#: Already finalized\n");
return 0;
}
intel_me_finalize_smm();
intel_pch_finalize_smm();
intel_sandybridge_finalize_smm();
intel_model_206ax_finalize_smm();
mainboard_finalized = 1;
break;
default: default:
break; break;
} }

View File

@ -105,8 +105,6 @@ void mainboard_smi_gpi(u32 gpi_sts)
mainboard_smi_handle_ec_sci(); mainboard_smi_handle_ec_sci();
} }
static int mainboard_finalized = 0;
int mainboard_smi_apmc(u8 data) int mainboard_smi_apmc(u8 data)
{ {
switch (data) { switch (data) {
@ -127,21 +125,6 @@ int mainboard_smi_apmc(u8 data)
/* discard all events, and enable attention */ /* discard all events, and enable attention */
ec_write(0x80, 0x01); ec_write(0x80, 0x01);
break; break;
case APM_CNT_FINALIZE:
printk(BIOS_DEBUG, "APMC: FINALIZE\n");
if (mainboard_finalized) {
printk(BIOS_DEBUG, "APMC#: Already finalized\n");
return 0;
}
intel_me_finalize_smm();
intel_pch_finalize_smm();
intel_sandybridge_finalize_smm();
intel_model_206ax_finalize_smm();
mainboard_finalized = 1;
break;
default: default:
break; break;
} }

View File

@ -110,8 +110,6 @@ void mainboard_smi_gpi(u32 gpi_sts)
mainboard_smi_handle_ec_sci(); mainboard_smi_handle_ec_sci();
} }
static int mainboard_finalized = 0;
int mainboard_smi_apmc(u8 data) int mainboard_smi_apmc(u8 data)
{ {
switch (data) { switch (data) {
@ -132,21 +130,6 @@ int mainboard_smi_apmc(u8 data)
/* discard all events, and enable attention */ /* discard all events, and enable attention */
ec_write(0x80, 0x01); ec_write(0x80, 0x01);
break; break;
case APM_CNT_FINALIZE:
printk(BIOS_DEBUG, "APMC: FINALIZE\n");
if (mainboard_finalized) {
printk(BIOS_DEBUG, "APMC#: Already finalized\n");
return 0;
}
intel_me_finalize_smm();
intel_pch_finalize_smm();
intel_sandybridge_finalize_smm();
intel_model_206ax_finalize_smm();
mainboard_finalized = 1;
break;
default: default:
break; break;
} }

View File

@ -110,8 +110,6 @@ void mainboard_smi_gpi(u32 gpi_sts)
mainboard_smi_handle_ec_sci(); mainboard_smi_handle_ec_sci();
} }
static int mainboard_finalized = 0;
int mainboard_smi_apmc(u8 data) int mainboard_smi_apmc(u8 data)
{ {
switch (data) { switch (data) {
@ -132,21 +130,6 @@ int mainboard_smi_apmc(u8 data)
/* discard all events, and enable attention */ /* discard all events, and enable attention */
ec_write(0x80, 0x01); ec_write(0x80, 0x01);
break; break;
case APM_CNT_FINALIZE:
printk(BIOS_DEBUG, "APMC: FINALIZE\n");
if (mainboard_finalized) {
printk(BIOS_DEBUG, "APMC#: Already finalized\n");
return 0;
}
intel_me_finalize_smm();
intel_pch_finalize_smm();
intel_sandybridge_finalize_smm();
intel_model_206ax_finalize_smm();
mainboard_finalized = 1;
break;
default: default:
break; break;
} }

View File

@ -80,8 +80,6 @@ void mainboard_smi_gpi(u32 gpi_sts)
mainboard_smi_handle_ec_sci(); mainboard_smi_handle_ec_sci();
} }
static int mainboard_finalized = 0;
int mainboard_smi_apmc(u8 data) int mainboard_smi_apmc(u8 data)
{ {
switch (data) { switch (data) {
@ -102,21 +100,6 @@ int mainboard_smi_apmc(u8 data)
/* discard all events, and enable attention */ /* discard all events, and enable attention */
ec_write(0x80, 0x01); ec_write(0x80, 0x01);
break; break;
case APM_CNT_FINALIZE:
printk(BIOS_DEBUG, "APMC: FINALIZE\n");
if (mainboard_finalized) {
printk(BIOS_DEBUG, "APMC#: Already finalized\n");
return 0;
}
intel_me_finalize_smm();
intel_pch_finalize_smm();
intel_sandybridge_finalize_smm();
intel_model_206ax_finalize_smm();
mainboard_finalized = 1;
break;
default: default:
break; break;
} }

View File

@ -64,9 +64,6 @@ void mainboard_smi_gpi(u32 gpi_sts)
} }
} }
static int mainboard_finalized = 0;
int mainboard_smi_apmc(u8 apmc) int mainboard_smi_apmc(u8 apmc)
{ {
ec_set_ports(EC_MAILBOX_PORT, EC_MAILBOX_PORT+1); ec_set_ports(EC_MAILBOX_PORT, EC_MAILBOX_PORT+1);
@ -81,20 +78,6 @@ int mainboard_smi_apmc(u8 apmc)
send_ec_command(EC_SMI_ENABLE); send_ec_command(EC_SMI_ENABLE);
send_ec_command(EC_ACPI_DISABLE); send_ec_command(EC_ACPI_DISABLE);
break; break;
case APM_CNT_FINALIZE:
if (mainboard_finalized) {
printk(BIOS_DEBUG, "SMI#: Already finalized\n");
return 0;
}
intel_me_finalize_smm();
intel_pch_finalize_smm();
intel_sandybridge_finalize_smm();
intel_model_206ax_finalize_smm();
mainboard_finalized = 1;
break;
} }
return 0; return 0;
} }

View File

@ -67,26 +67,3 @@ void mainboard_smi_sleep(u8 slp_typ)
break; break;
} }
} }
static int mainboard_finalized = 0;
int mainboard_smi_apmc(u8 apmc)
{
switch (apmc) {
case APM_CNT_FINALIZE:
if (mainboard_finalized) {
printk(BIOS_DEBUG, "SMI#: Already finalized\n");
return 0;
}
intel_me_finalize_smm();
intel_pch_finalize_smm();
intel_sandybridge_finalize_smm();
intel_model_206ax_finalize_smm();
mainboard_finalized = 1;
break;
}
return 0;
}

View File

@ -38,6 +38,8 @@
*/ */
#include <northbridge/intel/sandybridge/sandybridge.h> #include <northbridge/intel/sandybridge/sandybridge.h>
#include <arch/pci_mmio_cfg.h> #include <arch/pci_mmio_cfg.h>
#include <southbridge/intel/bd82x6x/me.h>
#include <cpu/intel/model_206ax/model_206ax.h>
/* While we read PMBASE dynamically in case it changed, let's /* While we read PMBASE dynamically in case it changed, let's
* initialize it with a sane value * initialize it with a sane value
@ -584,6 +586,8 @@ static void southbridge_smi_gsmi(void)
} }
#endif #endif
static int mainboard_finalized = 0;
static void southbridge_smi_apmc(unsigned int node, smm_state_save_area_t *state_save) static void southbridge_smi_apmc(unsigned int node, smm_state_save_area_t *state_save)
{ {
u32 pmctrl; u32 pmctrl;
@ -634,6 +638,19 @@ static void southbridge_smi_apmc(unsigned int node, smm_state_save_area_t *state
printk(BIOS_DEBUG, "SMI#: Setting GNVS to %p\n", gnvs); printk(BIOS_DEBUG, "SMI#: Setting GNVS to %p\n", gnvs);
} }
break; break;
case APM_CNT_FINALIZE:
if (mainboard_finalized) {
printk(BIOS_DEBUG, "SMI#: Already finalized\n");
return;
}
intel_me_finalize_smm();
intel_pch_finalize_smm();
intel_sandybridge_finalize_smm();
intel_model_206ax_finalize_smm();
mainboard_finalized = 1;
break;
#if CONFIG_ELOG_GSMI #if CONFIG_ELOG_GSMI
case ELOG_GSMI_APM_CNT: case ELOG_GSMI_APM_CNT:
southbridge_smi_gsmi(); southbridge_smi_gsmi();