blob: 15ab0eec0d0076b151789b815249ff0e54344a99 [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>
Elyes HAOUAS26071aa2019-02-15 08:21:33 +010024#include <version.h>
25
Tobias Diedriche87c38e2010-11-27 09:40:16 +000026#include "i82371eb.h"
27
28/**
29 * Create the Fixed ACPI Description Tables (FADT) for any board with this SB.
30 * Reference: ACPIspec40a, 5.2.9, page 118
31 */
32void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt)
33{
34 acpi_header_t *header = &(fadt->header);
Tobias Diedriche87c38e2010-11-27 09:40:16 +000035
36 /* Power management controller */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000037
38 memset((void *) fadt, 0, sizeof(acpi_fadt_t));
39 memcpy(header->signature, "FACP", 4);
Himanshu Sahdevfa6024e2019-09-23 16:29:30 +053040 header->length = sizeof(acpi_fadt_t);
Himanshu Sahdev15062532019-09-23 15:43:28 +053041 header->revision = ACPI_FADT_REV_ACPI_1_0;
Stefan Reinauer03f82bd2011-09-20 22:36:32 +020042 memcpy(header->oem_id, OEM_ID, 6);
43 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
44 memcpy(header->asl_compiler_id, ASLC, 4);
Elyes HAOUAS26071aa2019-02-15 08:21:33 +010045 header->asl_compiler_revision = asl_revision;
Tobias Diedriche87c38e2010-11-27 09:40:16 +000046
Patrick Rudolph0fa793c2019-02-18 19:21:17 +010047 fadt->firmware_ctrl = (uintptr_t)facs;
48 fadt->dsdt = (uintptr_t)dsdt;
Tobias Diedriche87c38e2010-11-27 09:40:16 +000049 fadt->preferred_pm_profile = 0; /* unspecified */
50 fadt->sci_int = 9;
51 fadt->smi_cmd = 0; /* smi command port */
52 fadt->acpi_enable = 0; /* acpi enable smi command */
53 fadt->acpi_disable = 0; /* acpi disable smi command */
54 fadt->s4bios_req = 0x0;
55 fadt->pstate_cnt = 0x0;
56
57 fadt->pm1a_evt_blk = DEFAULT_PMBASE;
58 fadt->pm1b_evt_blk = 0x0;
59 fadt->pm1a_cnt_blk = DEFAULT_PMBASE + PMCNTRL;
60 fadt->pm1b_cnt_blk = 0x0;
61
62 fadt->pm2_cnt_blk = 0;
63 fadt->pm_tmr_blk = DEFAULT_PMBASE + PMTMR;
64 fadt->gpe0_blk = DEFAULT_PMBASE + GPSTS;
65 fadt->gpe1_blk = 0x0;
66 fadt->gpe1_base = 0;
67 fadt->gpe1_blk_len = 0;
68
69 /* *_len define register width in bytes */
70 fadt->pm1_evt_len = 4;
71 fadt->pm1_cnt_len = 2;
72 fadt->pm2_cnt_len = 0; /* not supported */
73 fadt->pm_tmr_len = 4;
74 fadt->gpe0_blk_len = 4;
75
76 fadt->cst_cnt = 0; /* smi command to indicate c state changed notification */
77 fadt->p_lvl2_lat = 101; /* >100 means c2 not supported */
78 fadt->p_lvl3_lat = 1001; /* >1000 means c3 not supported */
Elyes HAOUAS1bcd7fc2016-07-28 21:20:04 +020079 fadt->flush_size = 0; /* only needed if CPU wbinvd is broken */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000080 fadt->flush_stride = 0;
81 fadt->duty_offset = 1; /* bit 1:3 in PCNTRL reg (pmbase+0x10) */
82 fadt->duty_width = 3; /* this width is in bits */
Elyes HAOUAS2119d0b2020-02-16 10:01:33 +010083 fadt->day_alrm = 0x0d; /* rtc CMOS RAM offset */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000084 fadt->mon_alrm = 0x0; /* not supported */
85 fadt->century = 0x0; /* not supported */
86 /*
87 * bit meaning
88 * 0 1: We have user-visible legacy devices
89 * 1 1: 8042
90 * 2 0: VGA is ok to probe
91 * 3 1: MSI are not supported
92 */
93 fadt->iapc_boot_arch = 0xb;
94 /*
95 * bit meaning
96 * 0 WBINVD
97 * Processors in new ACPI-compatible systems are required to
98 * support this function and indicate this to OSPM by setting
99 * this field.
100 * 1 WBINVD_FLUSH
101 * If set, indicates that the hardware flushes all caches on the
102 * WBINVD instruction and maintains memory coherency, but does
103 * not guarantee the caches are invalidated.
104 * 2 PROC_C1
105 * C1 power state (x86 hlt instruction) is supported on all cpus
106 * 3 P_LVL2_UP
107 * 0: C2 only on uniprocessor, 1: C2 on uni- and multiprocessor
108 * 4 PWR_BUTTON
109 * 0: pwr button is fixed feature
110 * 1: pwr button has control method device if present
111 * 5 SLP_BUTTON
112 * 0: sleep button is fixed feature
113 * 1: sleep button has control method device if present
114 * 6 FIX_RTC
115 * 0: RTC wake status supported in fixed register spce
116 * 7 RTC_S4
117 * 1: RTC can wake from S4
118 * 8 TMR_VAL_EXT
119 * 1: pmtimer is 32bit, 0: pmtimer is 24bit
120 * 9 DCK_CAP
121 * 1: system supports docking station
122 * 10 RESET_REG_SUPPORT
123 * 1: fadt describes reset register for system reset
124 * 11 SEALED_CASE
125 * 1: No expansion possible, sealed case
126 * 12 HEADLESS
127 * 1: Video output, keyboard and mouse are not connected
128 * 13 CPU_SW_SLP
129 * 1: Special processor instruction needs to be executed
130 * after writing SLP_TYP
131 * 14 PCI_EXP_WAK
132 * 1: PM1 regs support PCIEXP_WAKE_(STS|EN), must be set
133 * on platforms with pci express support
134 * 15 USE_PLATFORM_CLOCK
135 * 1: OS should prefer platform clock over processor internal
136 * clock.
137 * 16 S4_RTC_STS_VALID
138 * 17 REMOTE_POWER_ON_CAPABLE
139 * 1: platform correctly supports OSPM leaving GPE wake events
140 * armed prior to an S5 transition.
141 * 18 FORCE_APIC_CLUSTER_MODEL
142 * 19 FORCE_APIC_PHYSICAL_DESTINATION_MODE
143 */
144 fadt->flags = 0xa5;
145
146 fadt->reset_reg.space_id = 0;
147 fadt->reset_reg.bit_width = 0;
148 fadt->reset_reg.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100149 fadt->reset_reg.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000150 fadt->reset_reg.addrl = 0x0;
151 fadt->reset_reg.addrh = 0x0;
152 fadt->reset_value = 0;
153
Patrick Rudolph0fa793c2019-02-18 19:21:17 +0100154 fadt->x_firmware_ctl_l = (uintptr_t)facs;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000155 fadt->x_firmware_ctl_h = 0;
Patrick Rudolph0fa793c2019-02-18 19:21:17 +0100156 fadt->x_dsdt_l = (uintptr_t)dsdt;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000157 fadt->x_dsdt_h = 0;
158
159 fadt->x_pm1a_evt_blk.space_id = 1;
160 fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
161 fadt->x_pm1a_evt_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100162 fadt->x_pm1a_evt_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000163 fadt->x_pm1a_evt_blk.addrl = fadt->pm1a_evt_blk;
164 fadt->x_pm1a_evt_blk.addrh = 0x0;
165
166 fadt->x_pm1b_evt_blk.space_id = 1;
167 fadt->x_pm1b_evt_blk.bit_width = fadt->pm1_evt_len * 8;
168 fadt->x_pm1b_evt_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100169 fadt->x_pm1b_evt_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000170 fadt->x_pm1b_evt_blk.addrl = fadt->pm1b_evt_blk;
171 fadt->x_pm1b_evt_blk.addrh = 0x0;
172
173 fadt->x_pm1a_cnt_blk.space_id = 1;
174 fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
175 fadt->x_pm1a_cnt_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100176 fadt->x_pm1a_cnt_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000177 fadt->x_pm1a_cnt_blk.addrl = fadt->pm1a_cnt_blk;
178 fadt->x_pm1a_cnt_blk.addrh = 0x0;
179
180 fadt->x_pm1b_cnt_blk.space_id = 1;
181 fadt->x_pm1b_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
182 fadt->x_pm1b_cnt_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100183 fadt->x_pm1b_cnt_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000184 fadt->x_pm1b_cnt_blk.addrl = fadt->pm1b_cnt_blk;
185 fadt->x_pm1b_cnt_blk.addrh = 0x0;
186
187 fadt->x_pm2_cnt_blk.space_id = 1;
188 fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8;
189 fadt->x_pm2_cnt_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100190 fadt->x_pm2_cnt_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000191 fadt->x_pm2_cnt_blk.addrl = fadt->pm2_cnt_blk;
192 fadt->x_pm2_cnt_blk.addrh = 0x0;
193
194 fadt->x_pm_tmr_blk.space_id = 1;
195 fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8;
196 fadt->x_pm_tmr_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100197 fadt->x_pm_tmr_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000198 fadt->x_pm_tmr_blk.addrl = fadt->pm_tmr_blk;
199 fadt->x_pm_tmr_blk.addrh = 0x0;
200
201 fadt->x_gpe0_blk.space_id = 1;
202 fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8;
203 fadt->x_gpe0_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100204 fadt->x_gpe0_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000205 fadt->x_gpe0_blk.addrl = fadt->gpe0_blk;
206 fadt->x_gpe0_blk.addrh = 0x0;
207
208 fadt->x_gpe1_blk.space_id = 1;
Idwer Volleringd26da9c2013-12-22 21:38:18 +0000209 fadt->x_gpe1_blk.bit_width = fadt->gpe1_blk_len * 8;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000210 fadt->x_gpe1_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100211 fadt->x_gpe1_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000212 fadt->x_gpe1_blk.addrl = fadt->gpe1_blk;
213 fadt->x_gpe1_blk.addrh = 0x0;
214
215 header->checksum = acpi_checksum((void *) fadt, sizeof(acpi_fadt_t));
216}