Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 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 modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <arch/io.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 17 | #include <console/console.h> |
| 18 | #include <cpu/x86/smm.h> |
| 19 | #include <southbridge/intel/bd82x6x/nvs.h> |
| 20 | #include <southbridge/intel/bd82x6x/pch.h> |
| 21 | #include <southbridge/intel/bd82x6x/me.h> |
| 22 | #include <northbridge/intel/sandybridge/sandybridge.h> |
| 23 | #include <cpu/intel/model_206ax/model_206ax.h> |
| 24 | #include <ec/smsc/mec1308/ec.h> |
| 25 | #include "ec.h" |
| 26 | |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 27 | static u8 mainboard_smi_ec(void) |
| 28 | { |
| 29 | u8 cmd; |
| 30 | u32 pm1_cnt; |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 31 | |
| 32 | cmd = read_ec_command_byte(EC_GET_SMI_CAUSE); |
| 33 | |
| 34 | switch (cmd) { |
| 35 | case EC_LID_CLOSE: |
| 36 | printk(BIOS_DEBUG, "LID CLOSED, SHUTDOWN\n"); |
| 37 | |
| 38 | /* Go to S5 */ |
Duncan Laurie | 7f3d442 | 2012-10-03 19:01:57 -0700 | [diff] [blame] | 39 | pm1_cnt = inl(smm_get_pmbase() + PM1_CNT); |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 40 | pm1_cnt |= (0xf << 10); |
Duncan Laurie | 7f3d442 | 2012-10-03 19:01:57 -0700 | [diff] [blame] | 41 | outl(pm1_cnt, smm_get_pmbase() + PM1_CNT); |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 42 | break; |
| 43 | } |
| 44 | |
| 45 | return cmd; |
| 46 | } |
| 47 | |
Duncan Laurie | 0edc224 | 2013-04-29 15:04:30 -0700 | [diff] [blame] | 48 | void mainboard_smi_gpi(u32 gpi_sts) |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 49 | { |
| 50 | if (gpi_sts & (1 << EC_SMI_GPI)) { |
| 51 | /* Process all pending EC requests */ |
| 52 | ec_set_ports(EC_MAILBOX_PORT, EC_MAILBOX_PORT+1); |
| 53 | while (mainboard_smi_ec() != 0xff); |
| 54 | |
| 55 | /* The EC may keep asserting SMI# for some |
| 56 | * period unless we kick it here. |
| 57 | */ |
| 58 | send_ec_command(EC_SMI_DISABLE); |
| 59 | send_ec_command(EC_SMI_ENABLE); |
| 60 | } |
| 61 | } |
| 62 | |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 63 | int mainboard_smi_apmc(u8 apmc) |
| 64 | { |
| 65 | ec_set_ports(EC_MAILBOX_PORT, EC_MAILBOX_PORT+1); |
| 66 | |
| 67 | switch (apmc) { |
| 68 | case 0xe1: /* ACPI ENABLE */ |
| 69 | send_ec_command(EC_SMI_DISABLE); |
| 70 | send_ec_command(EC_ACPI_ENABLE); |
| 71 | break; |
| 72 | |
| 73 | case 0x1e: /* ACPI DISABLE */ |
| 74 | send_ec_command(EC_SMI_ENABLE); |
| 75 | send_ec_command(EC_ACPI_DISABLE); |
| 76 | break; |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 77 | } |
| 78 | return 0; |
| 79 | } |