blob: 77801e45b4f06685c0f56c157f6df5f6ccbd7fe4 [file] [log] [blame]
Patrick Georgi02363b52020-05-05 20:48:50 +02001/* This file is part of the coreboot project. */
Elyes HAOUAS132384a2020-05-07 07:19:50 +02002/* SPDX-License-Identifier: GPL-2.0-or-later */
3
Tobias Diedriche87c38e2010-11-27 09:40:16 +00004/*
Tobias Diedriche87c38e2010-11-27 09:40:16 +00005 * Based on src/southbridge/via/vt8237r/vt8237_fadt.c
Tobias Diedriche87c38e2010-11-27 09:40:16 +00006 */
7
8#include <string.h>
Furquan Shaikh76cedd22020-05-02 10:24:23 -07009#include <acpi/acpi.h>
Tobias Diedriche87c38e2010-11-27 09:40:16 +000010#include <device/device.h>
11#include <device/pci.h>
Elyes HAOUAS26071aa2019-02-15 08:21:33 +010012#include <version.h>
13
Tobias Diedriche87c38e2010-11-27 09:40:16 +000014#include "i82371eb.h"
15
16/**
17 * Create the Fixed ACPI Description Tables (FADT) for any board with this SB.
18 * Reference: ACPIspec40a, 5.2.9, page 118
19 */
20void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt)
21{
22 acpi_header_t *header = &(fadt->header);
Tobias Diedriche87c38e2010-11-27 09:40:16 +000023
24 /* Power management controller */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000025
26 memset((void *) fadt, 0, sizeof(acpi_fadt_t));
27 memcpy(header->signature, "FACP", 4);
Himanshu Sahdevfa6024e2019-09-23 16:29:30 +053028 header->length = sizeof(acpi_fadt_t);
Himanshu Sahdev15062532019-09-23 15:43:28 +053029 header->revision = ACPI_FADT_REV_ACPI_1_0;
Stefan Reinauer03f82bd2011-09-20 22:36:32 +020030 memcpy(header->oem_id, OEM_ID, 6);
31 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
32 memcpy(header->asl_compiler_id, ASLC, 4);
Elyes HAOUAS26071aa2019-02-15 08:21:33 +010033 header->asl_compiler_revision = asl_revision;
Tobias Diedriche87c38e2010-11-27 09:40:16 +000034
Patrick Rudolph0fa793c2019-02-18 19:21:17 +010035 fadt->firmware_ctrl = (uintptr_t)facs;
36 fadt->dsdt = (uintptr_t)dsdt;
Tobias Diedriche87c38e2010-11-27 09:40:16 +000037 fadt->preferred_pm_profile = 0; /* unspecified */
38 fadt->sci_int = 9;
39 fadt->smi_cmd = 0; /* smi command port */
40 fadt->acpi_enable = 0; /* acpi enable smi command */
41 fadt->acpi_disable = 0; /* acpi disable smi command */
42 fadt->s4bios_req = 0x0;
43 fadt->pstate_cnt = 0x0;
44
45 fadt->pm1a_evt_blk = DEFAULT_PMBASE;
46 fadt->pm1b_evt_blk = 0x0;
47 fadt->pm1a_cnt_blk = DEFAULT_PMBASE + PMCNTRL;
48 fadt->pm1b_cnt_blk = 0x0;
49
50 fadt->pm2_cnt_blk = 0;
51 fadt->pm_tmr_blk = DEFAULT_PMBASE + PMTMR;
52 fadt->gpe0_blk = DEFAULT_PMBASE + GPSTS;
53 fadt->gpe1_blk = 0x0;
54 fadt->gpe1_base = 0;
55 fadt->gpe1_blk_len = 0;
56
57 /* *_len define register width in bytes */
58 fadt->pm1_evt_len = 4;
59 fadt->pm1_cnt_len = 2;
60 fadt->pm2_cnt_len = 0; /* not supported */
61 fadt->pm_tmr_len = 4;
62 fadt->gpe0_blk_len = 4;
63
64 fadt->cst_cnt = 0; /* smi command to indicate c state changed notification */
65 fadt->p_lvl2_lat = 101; /* >100 means c2 not supported */
66 fadt->p_lvl3_lat = 1001; /* >1000 means c3 not supported */
Elyes HAOUAS1bcd7fc2016-07-28 21:20:04 +020067 fadt->flush_size = 0; /* only needed if CPU wbinvd is broken */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000068 fadt->flush_stride = 0;
69 fadt->duty_offset = 1; /* bit 1:3 in PCNTRL reg (pmbase+0x10) */
70 fadt->duty_width = 3; /* this width is in bits */
Elyes HAOUAS2119d0b2020-02-16 10:01:33 +010071 fadt->day_alrm = 0x0d; /* rtc CMOS RAM offset */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000072 fadt->mon_alrm = 0x0; /* not supported */
73 fadt->century = 0x0; /* not supported */
74 /*
75 * bit meaning
76 * 0 1: We have user-visible legacy devices
77 * 1 1: 8042
78 * 2 0: VGA is ok to probe
79 * 3 1: MSI are not supported
80 */
81 fadt->iapc_boot_arch = 0xb;
82 /*
83 * bit meaning
84 * 0 WBINVD
85 * Processors in new ACPI-compatible systems are required to
86 * support this function and indicate this to OSPM by setting
87 * this field.
88 * 1 WBINVD_FLUSH
89 * If set, indicates that the hardware flushes all caches on the
90 * WBINVD instruction and maintains memory coherency, but does
91 * not guarantee the caches are invalidated.
92 * 2 PROC_C1
93 * C1 power state (x86 hlt instruction) is supported on all cpus
94 * 3 P_LVL2_UP
95 * 0: C2 only on uniprocessor, 1: C2 on uni- and multiprocessor
96 * 4 PWR_BUTTON
97 * 0: pwr button is fixed feature
98 * 1: pwr button has control method device if present
99 * 5 SLP_BUTTON
100 * 0: sleep button is fixed feature
101 * 1: sleep button has control method device if present
102 * 6 FIX_RTC
103 * 0: RTC wake status supported in fixed register spce
104 * 7 RTC_S4
105 * 1: RTC can wake from S4
106 * 8 TMR_VAL_EXT
107 * 1: pmtimer is 32bit, 0: pmtimer is 24bit
108 * 9 DCK_CAP
109 * 1: system supports docking station
110 * 10 RESET_REG_SUPPORT
111 * 1: fadt describes reset register for system reset
112 * 11 SEALED_CASE
113 * 1: No expansion possible, sealed case
114 * 12 HEADLESS
115 * 1: Video output, keyboard and mouse are not connected
116 * 13 CPU_SW_SLP
117 * 1: Special processor instruction needs to be executed
118 * after writing SLP_TYP
119 * 14 PCI_EXP_WAK
120 * 1: PM1 regs support PCIEXP_WAKE_(STS|EN), must be set
121 * on platforms with pci express support
122 * 15 USE_PLATFORM_CLOCK
123 * 1: OS should prefer platform clock over processor internal
124 * clock.
125 * 16 S4_RTC_STS_VALID
126 * 17 REMOTE_POWER_ON_CAPABLE
127 * 1: platform correctly supports OSPM leaving GPE wake events
128 * armed prior to an S5 transition.
129 * 18 FORCE_APIC_CLUSTER_MODEL
130 * 19 FORCE_APIC_PHYSICAL_DESTINATION_MODE
131 */
132 fadt->flags = 0xa5;
133
134 fadt->reset_reg.space_id = 0;
135 fadt->reset_reg.bit_width = 0;
136 fadt->reset_reg.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100137 fadt->reset_reg.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000138 fadt->reset_reg.addrl = 0x0;
139 fadt->reset_reg.addrh = 0x0;
140 fadt->reset_value = 0;
141
Patrick Rudolph0fa793c2019-02-18 19:21:17 +0100142 fadt->x_firmware_ctl_l = (uintptr_t)facs;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000143 fadt->x_firmware_ctl_h = 0;
Patrick Rudolph0fa793c2019-02-18 19:21:17 +0100144 fadt->x_dsdt_l = (uintptr_t)dsdt;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000145 fadt->x_dsdt_h = 0;
146
147 fadt->x_pm1a_evt_blk.space_id = 1;
148 fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
149 fadt->x_pm1a_evt_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100150 fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000151 fadt->x_pm1a_evt_blk.addrl = fadt->pm1a_evt_blk;
152 fadt->x_pm1a_evt_blk.addrh = 0x0;
153
154 fadt->x_pm1b_evt_blk.space_id = 1;
155 fadt->x_pm1b_evt_blk.bit_width = fadt->pm1_evt_len * 8;
156 fadt->x_pm1b_evt_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100157 fadt->x_pm1b_evt_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000158 fadt->x_pm1b_evt_blk.addrl = fadt->pm1b_evt_blk;
159 fadt->x_pm1b_evt_blk.addrh = 0x0;
160
161 fadt->x_pm1a_cnt_blk.space_id = 1;
162 fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
163 fadt->x_pm1a_cnt_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100164 fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000165 fadt->x_pm1a_cnt_blk.addrl = fadt->pm1a_cnt_blk;
166 fadt->x_pm1a_cnt_blk.addrh = 0x0;
167
168 fadt->x_pm1b_cnt_blk.space_id = 1;
169 fadt->x_pm1b_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
170 fadt->x_pm1b_cnt_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100171 fadt->x_pm1b_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000172 fadt->x_pm1b_cnt_blk.addrl = fadt->pm1b_cnt_blk;
173 fadt->x_pm1b_cnt_blk.addrh = 0x0;
174
175 fadt->x_pm2_cnt_blk.space_id = 1;
176 fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8;
177 fadt->x_pm2_cnt_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100178 fadt->x_pm2_cnt_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000179 fadt->x_pm2_cnt_blk.addrl = fadt->pm2_cnt_blk;
180 fadt->x_pm2_cnt_blk.addrh = 0x0;
181
182 fadt->x_pm_tmr_blk.space_id = 1;
183 fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8;
184 fadt->x_pm_tmr_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100185 fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000186 fadt->x_pm_tmr_blk.addrl = fadt->pm_tmr_blk;
187 fadt->x_pm_tmr_blk.addrh = 0x0;
188
189 fadt->x_gpe0_blk.space_id = 1;
190 fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8;
191 fadt->x_gpe0_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100192 fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000193 fadt->x_gpe0_blk.addrl = fadt->gpe0_blk;
194 fadt->x_gpe0_blk.addrh = 0x0;
195
196 fadt->x_gpe1_blk.space_id = 1;
Idwer Volleringd26da9c2013-12-22 21:38:18 +0000197 fadt->x_gpe1_blk.bit_width = fadt->gpe1_blk_len * 8;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000198 fadt->x_gpe1_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100199 fadt->x_gpe1_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000200 fadt->x_gpe1_blk.addrl = fadt->gpe1_blk;
201 fadt->x_gpe1_blk.addrh = 0x0;
202
203 header->checksum = acpi_checksum((void *) fadt, sizeof(acpi_fadt_t));
204}