blob: 9690aee61ab78e6e6b0b92a9a687c8cb8e4410d3 [file] [log] [blame]
Stefan Reinauer155e9b52012-04-27 23:19:58 +02001/*
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 Reinauer155e9b52012-04-27 23:19:58 +020014 */
15
16#include <arch/io.h>
Stefan Reinauer155e9b52012-04-27 23:19:58 +020017#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 Reinauer155e9b52012-04-27 23:19:58 +020027static u8 mainboard_smi_ec(void)
28{
29 u8 cmd;
30 u32 pm1_cnt;
Stefan Reinauer155e9b52012-04-27 23:19:58 +020031
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 Laurie7f3d4422012-10-03 19:01:57 -070039 pm1_cnt = inl(smm_get_pmbase() + PM1_CNT);
Stefan Reinauer155e9b52012-04-27 23:19:58 +020040 pm1_cnt |= (0xf << 10);
Duncan Laurie7f3d4422012-10-03 19:01:57 -070041 outl(pm1_cnt, smm_get_pmbase() + PM1_CNT);
Stefan Reinauer155e9b52012-04-27 23:19:58 +020042 break;
43 }
44
45 return cmd;
46}
47
Duncan Laurie0edc2242013-04-29 15:04:30 -070048void mainboard_smi_gpi(u32 gpi_sts)
Stefan Reinauer155e9b52012-04-27 23:19:58 +020049{
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 Reinauer155e9b52012-04-27 23:19:58 +020063int 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 Reinauer155e9b52012-04-27 23:19:58 +020077 }
78 return 0;
79}