blob: 03bbdccb768cc7a14fc8e45ceaf53edaea4e2a27 [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 *
Tobias Diedriche87c38e2010-11-27 09:40:16 +00006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Tobias Diedriche87c38e2010-11-27 09:40:16 +000016 */
17
18#include <string.h>
Furquan Shaikh76cedd22020-05-02 10:24:23 -070019#include <acpi/acpi.h>
Tobias Diedriche87c38e2010-11-27 09:40:16 +000020#include <device/device.h>
21#include <device/pci.h>
Elyes HAOUAS26071aa2019-02-15 08:21:33 +010022#include <version.h>
23
Tobias Diedriche87c38e2010-11-27 09:40:16 +000024#include "i82371eb.h"
25
26/**
27 * Create the Fixed ACPI Description Tables (FADT) for any board with this SB.
28 * Reference: ACPIspec40a, 5.2.9, page 118
29 */
30void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt)
31{
32 acpi_header_t *header = &(fadt->header);
Tobias Diedriche87c38e2010-11-27 09:40:16 +000033
34 /* Power management controller */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000035
36 memset((void *) fadt, 0, sizeof(acpi_fadt_t));
37 memcpy(header->signature, "FACP", 4);
Himanshu Sahdevfa6024e2019-09-23 16:29:30 +053038 header->length = sizeof(acpi_fadt_t);
Himanshu Sahdev15062532019-09-23 15:43:28 +053039 header->revision = ACPI_FADT_REV_ACPI_1_0;
Stefan Reinauer03f82bd2011-09-20 22:36:32 +020040 memcpy(header->oem_id, OEM_ID, 6);
41 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
42 memcpy(header->asl_compiler_id, ASLC, 4);
Elyes HAOUAS26071aa2019-02-15 08:21:33 +010043 header->asl_compiler_revision = asl_revision;
Tobias Diedriche87c38e2010-11-27 09:40:16 +000044
Patrick Rudolph0fa793c2019-02-18 19:21:17 +010045 fadt->firmware_ctrl = (uintptr_t)facs;
46 fadt->dsdt = (uintptr_t)dsdt;
Tobias Diedriche87c38e2010-11-27 09:40:16 +000047 fadt->preferred_pm_profile = 0; /* unspecified */
48 fadt->sci_int = 9;
49 fadt->smi_cmd = 0; /* smi command port */
50 fadt->acpi_enable = 0; /* acpi enable smi command */
51 fadt->acpi_disable = 0; /* acpi disable smi command */
52 fadt->s4bios_req = 0x0;
53 fadt->pstate_cnt = 0x0;
54
55 fadt->pm1a_evt_blk = DEFAULT_PMBASE;
56 fadt->pm1b_evt_blk = 0x0;
57 fadt->pm1a_cnt_blk = DEFAULT_PMBASE + PMCNTRL;
58 fadt->pm1b_cnt_blk = 0x0;
59
60 fadt->pm2_cnt_blk = 0;
61 fadt->pm_tmr_blk = DEFAULT_PMBASE + PMTMR;
62 fadt->gpe0_blk = DEFAULT_PMBASE + GPSTS;
63 fadt->gpe1_blk = 0x0;
64 fadt->gpe1_base = 0;
65 fadt->gpe1_blk_len = 0;
66
67 /* *_len define register width in bytes */
68 fadt->pm1_evt_len = 4;
69 fadt->pm1_cnt_len = 2;
70 fadt->pm2_cnt_len = 0; /* not supported */
71 fadt->pm_tmr_len = 4;
72 fadt->gpe0_blk_len = 4;
73
74 fadt->cst_cnt = 0; /* smi command to indicate c state changed notification */
75 fadt->p_lvl2_lat = 101; /* >100 means c2 not supported */
76 fadt->p_lvl3_lat = 1001; /* >1000 means c3 not supported */
Elyes HAOUAS1bcd7fc2016-07-28 21:20:04 +020077 fadt->flush_size = 0; /* only needed if CPU wbinvd is broken */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000078 fadt->flush_stride = 0;
79 fadt->duty_offset = 1; /* bit 1:3 in PCNTRL reg (pmbase+0x10) */
80 fadt->duty_width = 3; /* this width is in bits */
Elyes HAOUAS2119d0b2020-02-16 10:01:33 +010081 fadt->day_alrm = 0x0d; /* rtc CMOS RAM offset */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000082 fadt->mon_alrm = 0x0; /* not supported */
83 fadt->century = 0x0; /* not supported */
84 /*
85 * bit meaning
86 * 0 1: We have user-visible legacy devices
87 * 1 1: 8042
88 * 2 0: VGA is ok to probe
89 * 3 1: MSI are not supported
90 */
91 fadt->iapc_boot_arch = 0xb;
92 /*
93 * bit meaning
94 * 0 WBINVD
95 * Processors in new ACPI-compatible systems are required to
96 * support this function and indicate this to OSPM by setting
97 * this field.
98 * 1 WBINVD_FLUSH
99 * If set, indicates that the hardware flushes all caches on the
100 * WBINVD instruction and maintains memory coherency, but does
101 * not guarantee the caches are invalidated.
102 * 2 PROC_C1
103 * C1 power state (x86 hlt instruction) is supported on all cpus
104 * 3 P_LVL2_UP
105 * 0: C2 only on uniprocessor, 1: C2 on uni- and multiprocessor
106 * 4 PWR_BUTTON
107 * 0: pwr button is fixed feature
108 * 1: pwr button has control method device if present
109 * 5 SLP_BUTTON
110 * 0: sleep button is fixed feature
111 * 1: sleep button has control method device if present
112 * 6 FIX_RTC
113 * 0: RTC wake status supported in fixed register spce
114 * 7 RTC_S4
115 * 1: RTC can wake from S4
116 * 8 TMR_VAL_EXT
117 * 1: pmtimer is 32bit, 0: pmtimer is 24bit
118 * 9 DCK_CAP
119 * 1: system supports docking station
120 * 10 RESET_REG_SUPPORT
121 * 1: fadt describes reset register for system reset
122 * 11 SEALED_CASE
123 * 1: No expansion possible, sealed case
124 * 12 HEADLESS
125 * 1: Video output, keyboard and mouse are not connected
126 * 13 CPU_SW_SLP
127 * 1: Special processor instruction needs to be executed
128 * after writing SLP_TYP
129 * 14 PCI_EXP_WAK
130 * 1: PM1 regs support PCIEXP_WAKE_(STS|EN), must be set
131 * on platforms with pci express support
132 * 15 USE_PLATFORM_CLOCK
133 * 1: OS should prefer platform clock over processor internal
134 * clock.
135 * 16 S4_RTC_STS_VALID
136 * 17 REMOTE_POWER_ON_CAPABLE
137 * 1: platform correctly supports OSPM leaving GPE wake events
138 * armed prior to an S5 transition.
139 * 18 FORCE_APIC_CLUSTER_MODEL
140 * 19 FORCE_APIC_PHYSICAL_DESTINATION_MODE
141 */
142 fadt->flags = 0xa5;
143
144 fadt->reset_reg.space_id = 0;
145 fadt->reset_reg.bit_width = 0;
146 fadt->reset_reg.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100147 fadt->reset_reg.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000148 fadt->reset_reg.addrl = 0x0;
149 fadt->reset_reg.addrh = 0x0;
150 fadt->reset_value = 0;
151
Patrick Rudolph0fa793c2019-02-18 19:21:17 +0100152 fadt->x_firmware_ctl_l = (uintptr_t)facs;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000153 fadt->x_firmware_ctl_h = 0;
Patrick Rudolph0fa793c2019-02-18 19:21:17 +0100154 fadt->x_dsdt_l = (uintptr_t)dsdt;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000155 fadt->x_dsdt_h = 0;
156
157 fadt->x_pm1a_evt_blk.space_id = 1;
158 fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
159 fadt->x_pm1a_evt_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100160 fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000161 fadt->x_pm1a_evt_blk.addrl = fadt->pm1a_evt_blk;
162 fadt->x_pm1a_evt_blk.addrh = 0x0;
163
164 fadt->x_pm1b_evt_blk.space_id = 1;
165 fadt->x_pm1b_evt_blk.bit_width = fadt->pm1_evt_len * 8;
166 fadt->x_pm1b_evt_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100167 fadt->x_pm1b_evt_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000168 fadt->x_pm1b_evt_blk.addrl = fadt->pm1b_evt_blk;
169 fadt->x_pm1b_evt_blk.addrh = 0x0;
170
171 fadt->x_pm1a_cnt_blk.space_id = 1;
172 fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
173 fadt->x_pm1a_cnt_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100174 fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000175 fadt->x_pm1a_cnt_blk.addrl = fadt->pm1a_cnt_blk;
176 fadt->x_pm1a_cnt_blk.addrh = 0x0;
177
178 fadt->x_pm1b_cnt_blk.space_id = 1;
179 fadt->x_pm1b_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
180 fadt->x_pm1b_cnt_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100181 fadt->x_pm1b_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000182 fadt->x_pm1b_cnt_blk.addrl = fadt->pm1b_cnt_blk;
183 fadt->x_pm1b_cnt_blk.addrh = 0x0;
184
185 fadt->x_pm2_cnt_blk.space_id = 1;
186 fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8;
187 fadt->x_pm2_cnt_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100188 fadt->x_pm2_cnt_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000189 fadt->x_pm2_cnt_blk.addrl = fadt->pm2_cnt_blk;
190 fadt->x_pm2_cnt_blk.addrh = 0x0;
191
192 fadt->x_pm_tmr_blk.space_id = 1;
193 fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8;
194 fadt->x_pm_tmr_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100195 fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000196 fadt->x_pm_tmr_blk.addrl = fadt->pm_tmr_blk;
197 fadt->x_pm_tmr_blk.addrh = 0x0;
198
199 fadt->x_gpe0_blk.space_id = 1;
200 fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8;
201 fadt->x_gpe0_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100202 fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000203 fadt->x_gpe0_blk.addrl = fadt->gpe0_blk;
204 fadt->x_gpe0_blk.addrh = 0x0;
205
206 fadt->x_gpe1_blk.space_id = 1;
Idwer Volleringd26da9c2013-12-22 21:38:18 +0000207 fadt->x_gpe1_blk.bit_width = fadt->gpe1_blk_len * 8;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000208 fadt->x_gpe1_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100209 fadt->x_gpe1_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000210 fadt->x_gpe1_blk.addrl = fadt->gpe1_blk;
211 fadt->x_gpe1_blk.addrh = 0x0;
212
213 header->checksum = acpi_checksum((void *) fadt, sizeof(acpi_fadt_t));
214}