SMM: add defines for APM_CNT register
[coreboot.git] / src / mainboard / lenovo / t60 / fadt.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007-2008 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 <string.h>
23 #include <device/pci.h>
24 #include <arch/acpi.h>
25 #include <cpu/x86/smm.h>
26
27 /* FIXME: This needs to go into a separate .h file
28  * to be included by the ich7 smi handler, ich7 smi init
29  * code and the mainboard fadt.
30  */
31
32 void acpi_create_fadt(acpi_fadt_t * fadt, acpi_facs_t * facs, void *dsdt)
33 {
34         acpi_header_t *header = &(fadt->header);
35         u16 pmbase = pci_read_config16(dev_find_slot(0, PCI_DEVFN(0x1f,0)), 0x40) & 0xfffe;
36
37         memset((void *) fadt, 0, sizeof(acpi_fadt_t));
38         memcpy(header->signature, "FACP", 4);
39         header->length = sizeof(acpi_fadt_t);
40         header->revision = 3;
41         memcpy(header->oem_id, "CORE  ", 6);
42         memcpy(header->oem_table_id, "COREBOOT", 8);
43         memcpy(header->asl_compiler_id, "CORE", 4);
44         header->asl_compiler_revision = 0;
45
46         fadt->firmware_ctrl = (unsigned long) facs;
47         fadt->dsdt = (unsigned long) dsdt;
48         fadt->model = 0x00;
49         fadt->preferred_pm_profile = PM_MOBILE;
50         fadt->sci_int = 0x9;
51         fadt->smi_cmd = APM_CNT;
52         fadt->acpi_enable = APM_CNT_ACPI_ENABLE;
53         fadt->acpi_disable = APM_CNT_ACPI_DISABLE;
54         fadt->s4bios_req = 0x0;
55         fadt->pstate_cnt = APM_CNT_PST_CONTROL;
56
57         fadt->pm1a_evt_blk = pmbase;
58         fadt->pm1b_evt_blk = 0x0;
59         fadt->pm1a_cnt_blk = pmbase + 0x4;
60         fadt->pm1b_cnt_blk = 0x0;
61         fadt->pm2_cnt_blk = pmbase + 0x20;
62         fadt->pm_tmr_blk = pmbase + 0x8;
63         fadt->gpe0_blk = pmbase + 0x28;
64         fadt->gpe1_blk = 0;
65
66         fadt->pm1_evt_len = 4;
67         fadt->pm1_cnt_len = 2;
68         fadt->pm2_cnt_len = 1;
69         fadt->pm_tmr_len = 4;
70         fadt->gpe0_blk_len = 8;
71         fadt->gpe1_blk_len = 0;
72         fadt->gpe1_base = 0;
73         fadt->cst_cnt = APM_CNT_CST_CONTROL;
74         fadt->p_lvl2_lat = 1;
75         fadt->p_lvl3_lat = 0x23;
76         fadt->flush_size = 0;
77         fadt->flush_stride = 0;
78         fadt->duty_offset = 1;
79         fadt->duty_width = 3;
80         fadt->day_alrm = 0xd;
81         fadt->mon_alrm = 0x00;
82         fadt->century = 0x32;
83         fadt->iapc_boot_arch = 0x00;
84         fadt->flags = ACPI_FADT_WBINVD | ACPI_FADT_C1_SUPPORTED |
85                         ACPI_FADT_SLEEP_BUTTON | ACPI_FADT_S4_RTC_WAKE |
86                         ACPI_FADT_DOCKING_SUPPORTED;
87
88         fadt->reset_reg.space_id = 0;
89         fadt->reset_reg.bit_width = 0;
90         fadt->reset_reg.bit_offset = 0;
91         fadt->reset_reg.resv = 0;
92         fadt->reset_reg.addrl = 0x0;
93         fadt->reset_reg.addrh = 0x0;
94
95         fadt->reset_value = 0;
96         fadt->x_firmware_ctl_l = (unsigned long)facs;
97         fadt->x_firmware_ctl_h = 0;
98         fadt->x_dsdt_l = (unsigned long)dsdt;
99         fadt->x_dsdt_h = 0;
100
101         fadt->x_pm1a_evt_blk.space_id = 1;
102         fadt->x_pm1a_evt_blk.bit_width = 32;
103         fadt->x_pm1a_evt_blk.bit_offset = 0;
104         fadt->x_pm1a_evt_blk.resv = 0;
105         fadt->x_pm1a_evt_blk.addrl = pmbase;
106         fadt->x_pm1a_evt_blk.addrh = 0x0;
107
108         fadt->x_pm1b_evt_blk.space_id = 0;
109         fadt->x_pm1b_evt_blk.bit_width = 0;
110         fadt->x_pm1b_evt_blk.bit_offset = 0;
111         fadt->x_pm1b_evt_blk.resv = 0;
112         fadt->x_pm1b_evt_blk.addrl = 0x0;
113         fadt->x_pm1b_evt_blk.addrh = 0x0;
114
115         fadt->x_pm1a_cnt_blk.space_id = 1;
116         fadt->x_pm1a_cnt_blk.bit_width = 16;
117         fadt->x_pm1a_cnt_blk.bit_offset = 0;
118         fadt->x_pm1a_cnt_blk.resv = 0;
119         fadt->x_pm1a_cnt_blk.addrl = pmbase + 0x4;
120         fadt->x_pm1a_cnt_blk.addrh = 0x0;
121
122         fadt->x_pm1b_cnt_blk.space_id = 0;
123         fadt->x_pm1b_cnt_blk.bit_width = 0;
124         fadt->x_pm1b_cnt_blk.bit_offset = 0;
125         fadt->x_pm1b_cnt_blk.resv = 0;
126         fadt->x_pm1b_cnt_blk.addrl = 0x0;
127         fadt->x_pm1b_cnt_blk.addrh = 0x0;
128
129         fadt->x_pm2_cnt_blk.space_id = 1;
130         fadt->x_pm2_cnt_blk.bit_width = 8;
131         fadt->x_pm2_cnt_blk.bit_offset = 0;
132         fadt->x_pm2_cnt_blk.resv = 0;
133         fadt->x_pm2_cnt_blk.addrl = pmbase + 0x20;
134         fadt->x_pm2_cnt_blk.addrh = 0x0;
135
136         fadt->x_pm_tmr_blk.space_id = 1;
137         fadt->x_pm_tmr_blk.bit_width = 32;
138         fadt->x_pm_tmr_blk.bit_offset = 0;
139         fadt->x_pm_tmr_blk.resv = 0;
140         fadt->x_pm_tmr_blk.addrl = pmbase + 0x8;
141         fadt->x_pm_tmr_blk.addrh = 0x0;
142
143         fadt->x_gpe0_blk.space_id = 1;
144         fadt->x_gpe0_blk.bit_width = 64;
145         fadt->x_gpe0_blk.bit_offset = 0;
146         fadt->x_gpe0_blk.resv = 0;
147         fadt->x_gpe0_blk.addrl = pmbase + 0x28;
148         fadt->x_gpe0_blk.addrh = 0x0;
149
150         fadt->x_gpe1_blk.space_id = 0;
151         fadt->x_gpe1_blk.bit_width = 0;
152         fadt->x_gpe1_blk.bit_offset = 0;
153         fadt->x_gpe1_blk.resv = 0;
154         fadt->x_gpe1_blk.addrl = 0x0;
155         fadt->x_gpe1_blk.addrh = 0x0;
156
157         header->checksum =
158             acpi_checksum((void *) fadt, header->length);
159 }