blob: 26a15703408ed7b362f4670e3ed67cddd1ba0d5c [file] [log] [blame]
Tobias Diedriche87c38e2010-11-27 09:40:16 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Based on src/southbridge/via/vt8237r/vt8237_fadt.c
5 *
6 * Copyright (C) 2004 Nick Barker <nick.barker9@btinternet.com>
7 * Copyright (C) 2007, 2009 Rudolf Marek <r.marek@assembler.cz>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
Tobias Diedriche87c38e2010-11-27 09:40:16 +000018 */
19
20#include <string.h>
21#include <arch/acpi.h>
22#include <device/device.h>
23#include <device/pci.h>
24#include <device/pci_ids.h>
Elyes HAOUAS26071aa2019-02-15 08:21:33 +010025#include <version.h>
26
Tobias Diedriche87c38e2010-11-27 09:40:16 +000027#include "i82371eb.h"
28
29/**
30 * Create the Fixed ACPI Description Tables (FADT) for any board with this SB.
31 * Reference: ACPIspec40a, 5.2.9, page 118
32 */
33void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt)
34{
35 acpi_header_t *header = &(fadt->header);
Tobias Diedriche87c38e2010-11-27 09:40:16 +000036
37 /* Power management controller */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000038
39 memset((void *) fadt, 0, sizeof(acpi_fadt_t));
40 memcpy(header->signature, "FACP", 4);
41 header->length = 244;
Himanshu Sahdev15062532019-09-23 15:43:28 +053042 header->revision = ACPI_FADT_REV_ACPI_1_0;
Stefan Reinauer03f82bd2011-09-20 22:36:32 +020043 memcpy(header->oem_id, OEM_ID, 6);
44 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
45 memcpy(header->asl_compiler_id, ASLC, 4);
Elyes HAOUAS26071aa2019-02-15 08:21:33 +010046 header->asl_compiler_revision = asl_revision;
Tobias Diedriche87c38e2010-11-27 09:40:16 +000047
Patrick Rudolph0fa793c2019-02-18 19:21:17 +010048 fadt->firmware_ctrl = (uintptr_t)facs;
49 fadt->dsdt = (uintptr_t)dsdt;
Tobias Diedriche87c38e2010-11-27 09:40:16 +000050 fadt->preferred_pm_profile = 0; /* unspecified */
51 fadt->sci_int = 9;
52 fadt->smi_cmd = 0; /* smi command port */
53 fadt->acpi_enable = 0; /* acpi enable smi command */
54 fadt->acpi_disable = 0; /* acpi disable smi command */
55 fadt->s4bios_req = 0x0;
56 fadt->pstate_cnt = 0x0;
57
58 fadt->pm1a_evt_blk = DEFAULT_PMBASE;
59 fadt->pm1b_evt_blk = 0x0;
60 fadt->pm1a_cnt_blk = DEFAULT_PMBASE + PMCNTRL;
61 fadt->pm1b_cnt_blk = 0x0;
62
63 fadt->pm2_cnt_blk = 0;
64 fadt->pm_tmr_blk = DEFAULT_PMBASE + PMTMR;
65 fadt->gpe0_blk = DEFAULT_PMBASE + GPSTS;
66 fadt->gpe1_blk = 0x0;
67 fadt->gpe1_base = 0;
68 fadt->gpe1_blk_len = 0;
69
70 /* *_len define register width in bytes */
71 fadt->pm1_evt_len = 4;
72 fadt->pm1_cnt_len = 2;
73 fadt->pm2_cnt_len = 0; /* not supported */
74 fadt->pm_tmr_len = 4;
75 fadt->gpe0_blk_len = 4;
76
77 fadt->cst_cnt = 0; /* smi command to indicate c state changed notification */
78 fadt->p_lvl2_lat = 101; /* >100 means c2 not supported */
79 fadt->p_lvl3_lat = 1001; /* >1000 means c3 not supported */
Elyes HAOUAS1bcd7fc2016-07-28 21:20:04 +020080 fadt->flush_size = 0; /* only needed if CPU wbinvd is broken */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000081 fadt->flush_stride = 0;
82 fadt->duty_offset = 1; /* bit 1:3 in PCNTRL reg (pmbase+0x10) */
83 fadt->duty_width = 3; /* this width is in bits */
Elyes HAOUAS1bcd7fc2016-07-28 21:20:04 +020084 fadt->day_alrm = 0x0d; /* rtc cmos RAM offset */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000085 fadt->mon_alrm = 0x0; /* not supported */
86 fadt->century = 0x0; /* not supported */
87 /*
88 * bit meaning
89 * 0 1: We have user-visible legacy devices
90 * 1 1: 8042
91 * 2 0: VGA is ok to probe
92 * 3 1: MSI are not supported
93 */
94 fadt->iapc_boot_arch = 0xb;
95 /*
96 * bit meaning
97 * 0 WBINVD
98 * Processors in new ACPI-compatible systems are required to
99 * support this function and indicate this to OSPM by setting
100 * this field.
101 * 1 WBINVD_FLUSH
102 * If set, indicates that the hardware flushes all caches on the
103 * WBINVD instruction and maintains memory coherency, but does
104 * not guarantee the caches are invalidated.
105 * 2 PROC_C1
106 * C1 power state (x86 hlt instruction) is supported on all cpus
107 * 3 P_LVL2_UP
108 * 0: C2 only on uniprocessor, 1: C2 on uni- and multiprocessor
109 * 4 PWR_BUTTON
110 * 0: pwr button is fixed feature
111 * 1: pwr button has control method device if present
112 * 5 SLP_BUTTON
113 * 0: sleep button is fixed feature
114 * 1: sleep button has control method device if present
115 * 6 FIX_RTC
116 * 0: RTC wake status supported in fixed register spce
117 * 7 RTC_S4
118 * 1: RTC can wake from S4
119 * 8 TMR_VAL_EXT
120 * 1: pmtimer is 32bit, 0: pmtimer is 24bit
121 * 9 DCK_CAP
122 * 1: system supports docking station
123 * 10 RESET_REG_SUPPORT
124 * 1: fadt describes reset register for system reset
125 * 11 SEALED_CASE
126 * 1: No expansion possible, sealed case
127 * 12 HEADLESS
128 * 1: Video output, keyboard and mouse are not connected
129 * 13 CPU_SW_SLP
130 * 1: Special processor instruction needs to be executed
131 * after writing SLP_TYP
132 * 14 PCI_EXP_WAK
133 * 1: PM1 regs support PCIEXP_WAKE_(STS|EN), must be set
134 * on platforms with pci express support
135 * 15 USE_PLATFORM_CLOCK
136 * 1: OS should prefer platform clock over processor internal
137 * clock.
138 * 16 S4_RTC_STS_VALID
139 * 17 REMOTE_POWER_ON_CAPABLE
140 * 1: platform correctly supports OSPM leaving GPE wake events
141 * armed prior to an S5 transition.
142 * 18 FORCE_APIC_CLUSTER_MODEL
143 * 19 FORCE_APIC_PHYSICAL_DESTINATION_MODE
144 */
145 fadt->flags = 0xa5;
146
147 fadt->reset_reg.space_id = 0;
148 fadt->reset_reg.bit_width = 0;
149 fadt->reset_reg.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100150 fadt->reset_reg.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000151 fadt->reset_reg.addrl = 0x0;
152 fadt->reset_reg.addrh = 0x0;
153 fadt->reset_value = 0;
154
Patrick Rudolph0fa793c2019-02-18 19:21:17 +0100155 fadt->x_firmware_ctl_l = (uintptr_t)facs;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000156 fadt->x_firmware_ctl_h = 0;
Patrick Rudolph0fa793c2019-02-18 19:21:17 +0100157 fadt->x_dsdt_l = (uintptr_t)dsdt;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000158 fadt->x_dsdt_h = 0;
159
160 fadt->x_pm1a_evt_blk.space_id = 1;
161 fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
162 fadt->x_pm1a_evt_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100163 fadt->x_pm1a_evt_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000164 fadt->x_pm1a_evt_blk.addrl = fadt->pm1a_evt_blk;
165 fadt->x_pm1a_evt_blk.addrh = 0x0;
166
167 fadt->x_pm1b_evt_blk.space_id = 1;
168 fadt->x_pm1b_evt_blk.bit_width = fadt->pm1_evt_len * 8;
169 fadt->x_pm1b_evt_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100170 fadt->x_pm1b_evt_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000171 fadt->x_pm1b_evt_blk.addrl = fadt->pm1b_evt_blk;
172 fadt->x_pm1b_evt_blk.addrh = 0x0;
173
174 fadt->x_pm1a_cnt_blk.space_id = 1;
175 fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
176 fadt->x_pm1a_cnt_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100177 fadt->x_pm1a_cnt_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000178 fadt->x_pm1a_cnt_blk.addrl = fadt->pm1a_cnt_blk;
179 fadt->x_pm1a_cnt_blk.addrh = 0x0;
180
181 fadt->x_pm1b_cnt_blk.space_id = 1;
182 fadt->x_pm1b_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
183 fadt->x_pm1b_cnt_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100184 fadt->x_pm1b_cnt_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000185 fadt->x_pm1b_cnt_blk.addrl = fadt->pm1b_cnt_blk;
186 fadt->x_pm1b_cnt_blk.addrh = 0x0;
187
188 fadt->x_pm2_cnt_blk.space_id = 1;
189 fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8;
190 fadt->x_pm2_cnt_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100191 fadt->x_pm2_cnt_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000192 fadt->x_pm2_cnt_blk.addrl = fadt->pm2_cnt_blk;
193 fadt->x_pm2_cnt_blk.addrh = 0x0;
194
195 fadt->x_pm_tmr_blk.space_id = 1;
196 fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8;
197 fadt->x_pm_tmr_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100198 fadt->x_pm_tmr_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000199 fadt->x_pm_tmr_blk.addrl = fadt->pm_tmr_blk;
200 fadt->x_pm_tmr_blk.addrh = 0x0;
201
202 fadt->x_gpe0_blk.space_id = 1;
203 fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8;
204 fadt->x_gpe0_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100205 fadt->x_gpe0_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000206 fadt->x_gpe0_blk.addrl = fadt->gpe0_blk;
207 fadt->x_gpe0_blk.addrh = 0x0;
208
209 fadt->x_gpe1_blk.space_id = 1;
Idwer Volleringd26da9c2013-12-22 21:38:18 +0000210 fadt->x_gpe1_blk.bit_width = fadt->gpe1_blk_len * 8;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000211 fadt->x_gpe1_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100212 fadt->x_gpe1_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000213 fadt->x_gpe1_blk.addrl = fadt->gpe1_blk;
214 fadt->x_gpe1_blk.addrh = 0x0;
215
216 header->checksum = acpi_checksum((void *) fadt, sizeof(acpi_fadt_t));
217}