blob: 3240221effd079ec88e1104a06e792cb073e04e7 [file] [log] [blame]
Patrick Georgi02363b52020-05-05 20:48:50 +02001/* This file is part of the coreboot project. */
Tobias Diedriche87c38e2010-11-27 09:40:16 +00002/*
Tobias Diedriche87c38e2010-11-27 09:40:16 +00003 * Based on src/southbridge/via/vt8237r/vt8237_fadt.c
4 *
Tobias Diedriche87c38e2010-11-27 09:40:16 +00005 *
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; either version 2 of the License, or
9 * (at your option) any later version.
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.
Tobias Diedriche87c38e2010-11-27 09:40:16 +000015 */
16
17#include <string.h>
Furquan Shaikh76cedd22020-05-02 10:24:23 -070018#include <acpi/acpi.h>
Tobias Diedriche87c38e2010-11-27 09:40:16 +000019#include <device/device.h>
20#include <device/pci.h>
Elyes HAOUAS26071aa2019-02-15 08:21:33 +010021#include <version.h>
22
Tobias Diedriche87c38e2010-11-27 09:40:16 +000023#include "i82371eb.h"
24
25/**
26 * Create the Fixed ACPI Description Tables (FADT) for any board with this SB.
27 * Reference: ACPIspec40a, 5.2.9, page 118
28 */
29void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt)
30{
31 acpi_header_t *header = &(fadt->header);
Tobias Diedriche87c38e2010-11-27 09:40:16 +000032
33 /* Power management controller */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000034
35 memset((void *) fadt, 0, sizeof(acpi_fadt_t));
36 memcpy(header->signature, "FACP", 4);
Himanshu Sahdevfa6024e2019-09-23 16:29:30 +053037 header->length = sizeof(acpi_fadt_t);
Himanshu Sahdev15062532019-09-23 15:43:28 +053038 header->revision = ACPI_FADT_REV_ACPI_1_0;
Stefan Reinauer03f82bd2011-09-20 22:36:32 +020039 memcpy(header->oem_id, OEM_ID, 6);
40 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
41 memcpy(header->asl_compiler_id, ASLC, 4);
Elyes HAOUAS26071aa2019-02-15 08:21:33 +010042 header->asl_compiler_revision = asl_revision;
Tobias Diedriche87c38e2010-11-27 09:40:16 +000043
Patrick Rudolph0fa793c2019-02-18 19:21:17 +010044 fadt->firmware_ctrl = (uintptr_t)facs;
45 fadt->dsdt = (uintptr_t)dsdt;
Tobias Diedriche87c38e2010-11-27 09:40:16 +000046 fadt->preferred_pm_profile = 0; /* unspecified */
47 fadt->sci_int = 9;
48 fadt->smi_cmd = 0; /* smi command port */
49 fadt->acpi_enable = 0; /* acpi enable smi command */
50 fadt->acpi_disable = 0; /* acpi disable smi command */
51 fadt->s4bios_req = 0x0;
52 fadt->pstate_cnt = 0x0;
53
54 fadt->pm1a_evt_blk = DEFAULT_PMBASE;
55 fadt->pm1b_evt_blk = 0x0;
56 fadt->pm1a_cnt_blk = DEFAULT_PMBASE + PMCNTRL;
57 fadt->pm1b_cnt_blk = 0x0;
58
59 fadt->pm2_cnt_blk = 0;
60 fadt->pm_tmr_blk = DEFAULT_PMBASE + PMTMR;
61 fadt->gpe0_blk = DEFAULT_PMBASE + GPSTS;
62 fadt->gpe1_blk = 0x0;
63 fadt->gpe1_base = 0;
64 fadt->gpe1_blk_len = 0;
65
66 /* *_len define register width in bytes */
67 fadt->pm1_evt_len = 4;
68 fadt->pm1_cnt_len = 2;
69 fadt->pm2_cnt_len = 0; /* not supported */
70 fadt->pm_tmr_len = 4;
71 fadt->gpe0_blk_len = 4;
72
73 fadt->cst_cnt = 0; /* smi command to indicate c state changed notification */
74 fadt->p_lvl2_lat = 101; /* >100 means c2 not supported */
75 fadt->p_lvl3_lat = 1001; /* >1000 means c3 not supported */
Elyes HAOUAS1bcd7fc2016-07-28 21:20:04 +020076 fadt->flush_size = 0; /* only needed if CPU wbinvd is broken */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000077 fadt->flush_stride = 0;
78 fadt->duty_offset = 1; /* bit 1:3 in PCNTRL reg (pmbase+0x10) */
79 fadt->duty_width = 3; /* this width is in bits */
Elyes HAOUAS2119d0b2020-02-16 10:01:33 +010080 fadt->day_alrm = 0x0d; /* rtc CMOS RAM offset */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000081 fadt->mon_alrm = 0x0; /* not supported */
82 fadt->century = 0x0; /* not supported */
83 /*
84 * bit meaning
85 * 0 1: We have user-visible legacy devices
86 * 1 1: 8042
87 * 2 0: VGA is ok to probe
88 * 3 1: MSI are not supported
89 */
90 fadt->iapc_boot_arch = 0xb;
91 /*
92 * bit meaning
93 * 0 WBINVD
94 * Processors in new ACPI-compatible systems are required to
95 * support this function and indicate this to OSPM by setting
96 * this field.
97 * 1 WBINVD_FLUSH
98 * If set, indicates that the hardware flushes all caches on the
99 * WBINVD instruction and maintains memory coherency, but does
100 * not guarantee the caches are invalidated.
101 * 2 PROC_C1
102 * C1 power state (x86 hlt instruction) is supported on all cpus
103 * 3 P_LVL2_UP
104 * 0: C2 only on uniprocessor, 1: C2 on uni- and multiprocessor
105 * 4 PWR_BUTTON
106 * 0: pwr button is fixed feature
107 * 1: pwr button has control method device if present
108 * 5 SLP_BUTTON
109 * 0: sleep button is fixed feature
110 * 1: sleep button has control method device if present
111 * 6 FIX_RTC
112 * 0: RTC wake status supported in fixed register spce
113 * 7 RTC_S4
114 * 1: RTC can wake from S4
115 * 8 TMR_VAL_EXT
116 * 1: pmtimer is 32bit, 0: pmtimer is 24bit
117 * 9 DCK_CAP
118 * 1: system supports docking station
119 * 10 RESET_REG_SUPPORT
120 * 1: fadt describes reset register for system reset
121 * 11 SEALED_CASE
122 * 1: No expansion possible, sealed case
123 * 12 HEADLESS
124 * 1: Video output, keyboard and mouse are not connected
125 * 13 CPU_SW_SLP
126 * 1: Special processor instruction needs to be executed
127 * after writing SLP_TYP
128 * 14 PCI_EXP_WAK
129 * 1: PM1 regs support PCIEXP_WAKE_(STS|EN), must be set
130 * on platforms with pci express support
131 * 15 USE_PLATFORM_CLOCK
132 * 1: OS should prefer platform clock over processor internal
133 * clock.
134 * 16 S4_RTC_STS_VALID
135 * 17 REMOTE_POWER_ON_CAPABLE
136 * 1: platform correctly supports OSPM leaving GPE wake events
137 * armed prior to an S5 transition.
138 * 18 FORCE_APIC_CLUSTER_MODEL
139 * 19 FORCE_APIC_PHYSICAL_DESTINATION_MODE
140 */
141 fadt->flags = 0xa5;
142
143 fadt->reset_reg.space_id = 0;
144 fadt->reset_reg.bit_width = 0;
145 fadt->reset_reg.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100146 fadt->reset_reg.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000147 fadt->reset_reg.addrl = 0x0;
148 fadt->reset_reg.addrh = 0x0;
149 fadt->reset_value = 0;
150
Patrick Rudolph0fa793c2019-02-18 19:21:17 +0100151 fadt->x_firmware_ctl_l = (uintptr_t)facs;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000152 fadt->x_firmware_ctl_h = 0;
Patrick Rudolph0fa793c2019-02-18 19:21:17 +0100153 fadt->x_dsdt_l = (uintptr_t)dsdt;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000154 fadt->x_dsdt_h = 0;
155
156 fadt->x_pm1a_evt_blk.space_id = 1;
157 fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
158 fadt->x_pm1a_evt_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100159 fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000160 fadt->x_pm1a_evt_blk.addrl = fadt->pm1a_evt_blk;
161 fadt->x_pm1a_evt_blk.addrh = 0x0;
162
163 fadt->x_pm1b_evt_blk.space_id = 1;
164 fadt->x_pm1b_evt_blk.bit_width = fadt->pm1_evt_len * 8;
165 fadt->x_pm1b_evt_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100166 fadt->x_pm1b_evt_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000167 fadt->x_pm1b_evt_blk.addrl = fadt->pm1b_evt_blk;
168 fadt->x_pm1b_evt_blk.addrh = 0x0;
169
170 fadt->x_pm1a_cnt_blk.space_id = 1;
171 fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
172 fadt->x_pm1a_cnt_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100173 fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000174 fadt->x_pm1a_cnt_blk.addrl = fadt->pm1a_cnt_blk;
175 fadt->x_pm1a_cnt_blk.addrh = 0x0;
176
177 fadt->x_pm1b_cnt_blk.space_id = 1;
178 fadt->x_pm1b_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
179 fadt->x_pm1b_cnt_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100180 fadt->x_pm1b_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000181 fadt->x_pm1b_cnt_blk.addrl = fadt->pm1b_cnt_blk;
182 fadt->x_pm1b_cnt_blk.addrh = 0x0;
183
184 fadt->x_pm2_cnt_blk.space_id = 1;
185 fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8;
186 fadt->x_pm2_cnt_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100187 fadt->x_pm2_cnt_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000188 fadt->x_pm2_cnt_blk.addrl = fadt->pm2_cnt_blk;
189 fadt->x_pm2_cnt_blk.addrh = 0x0;
190
191 fadt->x_pm_tmr_blk.space_id = 1;
192 fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8;
193 fadt->x_pm_tmr_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100194 fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000195 fadt->x_pm_tmr_blk.addrl = fadt->pm_tmr_blk;
196 fadt->x_pm_tmr_blk.addrh = 0x0;
197
198 fadt->x_gpe0_blk.space_id = 1;
199 fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8;
200 fadt->x_gpe0_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100201 fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000202 fadt->x_gpe0_blk.addrl = fadt->gpe0_blk;
203 fadt->x_gpe0_blk.addrh = 0x0;
204
205 fadt->x_gpe1_blk.space_id = 1;
Idwer Volleringd26da9c2013-12-22 21:38:18 +0000206 fadt->x_gpe1_blk.bit_width = fadt->gpe1_blk_len * 8;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000207 fadt->x_gpe1_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100208 fadt->x_gpe1_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000209 fadt->x_gpe1_blk.addrl = fadt->gpe1_blk;
210 fadt->x_gpe1_blk.addrh = 0x0;
211
212 header->checksum = acpi_checksum((void *) fadt, sizeof(acpi_fadt_t));
213}