blob: 09e027f40781dd0f8430204121d643db676d43d6 [file] [log] [blame]
Elyes HAOUAS132384a2020-05-07 07:19:50 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
2
Tobias Diedriche87c38e2010-11-27 09:40:16 +00003/*
Tobias Diedriche87c38e2010-11-27 09:40:16 +00004 * Based on src/southbridge/via/vt8237r/vt8237_fadt.c
Tobias Diedriche87c38e2010-11-27 09:40:16 +00005 */
6
7#include <string.h>
Furquan Shaikh76cedd22020-05-02 10:24:23 -07008#include <acpi/acpi.h>
Tobias Diedriche87c38e2010-11-27 09:40:16 +00009#include <device/device.h>
10#include <device/pci.h>
Elyes HAOUAS26071aa2019-02-15 08:21:33 +010011#include <version.h>
12
Tobias Diedriche87c38e2010-11-27 09:40:16 +000013#include "i82371eb.h"
14
15/**
16 * Create the Fixed ACPI Description Tables (FADT) for any board with this SB.
17 * Reference: ACPIspec40a, 5.2.9, page 118
18 */
19void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt)
20{
21 acpi_header_t *header = &(fadt->header);
Tobias Diedriche87c38e2010-11-27 09:40:16 +000022
23 /* Power management controller */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000024
25 memset((void *) fadt, 0, sizeof(acpi_fadt_t));
26 memcpy(header->signature, "FACP", 4);
Himanshu Sahdevfa6024e2019-09-23 16:29:30 +053027 header->length = sizeof(acpi_fadt_t);
Himanshu Sahdev15062532019-09-23 15:43:28 +053028 header->revision = ACPI_FADT_REV_ACPI_1_0;
Stefan Reinauer03f82bd2011-09-20 22:36:32 +020029 memcpy(header->oem_id, OEM_ID, 6);
30 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
31 memcpy(header->asl_compiler_id, ASLC, 4);
Elyes HAOUAS26071aa2019-02-15 08:21:33 +010032 header->asl_compiler_revision = asl_revision;
Tobias Diedriche87c38e2010-11-27 09:40:16 +000033
Patrick Rudolph0fa793c2019-02-18 19:21:17 +010034 fadt->firmware_ctrl = (uintptr_t)facs;
35 fadt->dsdt = (uintptr_t)dsdt;
Tobias Diedriche87c38e2010-11-27 09:40:16 +000036 fadt->preferred_pm_profile = 0; /* unspecified */
37 fadt->sci_int = 9;
Kyösti Mälkkic328a682019-11-23 07:23:40 +020038
39 if (CONFIG(HAVE_SMI_HANDLER)) {
40 /* TODO: SMI handler is not implemented. */
41 fadt->smi_cmd = 0x00;
42 }
Tobias Diedriche87c38e2010-11-27 09:40:16 +000043
44 fadt->pm1a_evt_blk = DEFAULT_PMBASE;
45 fadt->pm1b_evt_blk = 0x0;
46 fadt->pm1a_cnt_blk = DEFAULT_PMBASE + PMCNTRL;
47 fadt->pm1b_cnt_blk = 0x0;
48
49 fadt->pm2_cnt_blk = 0;
50 fadt->pm_tmr_blk = DEFAULT_PMBASE + PMTMR;
51 fadt->gpe0_blk = DEFAULT_PMBASE + GPSTS;
52 fadt->gpe1_blk = 0x0;
53 fadt->gpe1_base = 0;
54 fadt->gpe1_blk_len = 0;
55
56 /* *_len define register width in bytes */
57 fadt->pm1_evt_len = 4;
58 fadt->pm1_cnt_len = 2;
59 fadt->pm2_cnt_len = 0; /* not supported */
60 fadt->pm_tmr_len = 4;
61 fadt->gpe0_blk_len = 4;
62
Tobias Diedriche87c38e2010-11-27 09:40:16 +000063 fadt->p_lvl2_lat = 101; /* >100 means c2 not supported */
64 fadt->p_lvl3_lat = 1001; /* >1000 means c3 not supported */
Elyes HAOUAS1bcd7fc2016-07-28 21:20:04 +020065 fadt->flush_size = 0; /* only needed if CPU wbinvd is broken */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000066 fadt->flush_stride = 0;
67 fadt->duty_offset = 1; /* bit 1:3 in PCNTRL reg (pmbase+0x10) */
68 fadt->duty_width = 3; /* this width is in bits */
Elyes HAOUAS2119d0b2020-02-16 10:01:33 +010069 fadt->day_alrm = 0x0d; /* rtc CMOS RAM offset */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000070 fadt->mon_alrm = 0x0; /* not supported */
71 fadt->century = 0x0; /* not supported */
72 /*
73 * bit meaning
74 * 0 1: We have user-visible legacy devices
75 * 1 1: 8042
76 * 2 0: VGA is ok to probe
77 * 3 1: MSI are not supported
78 */
79 fadt->iapc_boot_arch = 0xb;
80 /*
81 * bit meaning
82 * 0 WBINVD
83 * Processors in new ACPI-compatible systems are required to
84 * support this function and indicate this to OSPM by setting
85 * this field.
86 * 1 WBINVD_FLUSH
87 * If set, indicates that the hardware flushes all caches on the
88 * WBINVD instruction and maintains memory coherency, but does
89 * not guarantee the caches are invalidated.
90 * 2 PROC_C1
91 * C1 power state (x86 hlt instruction) is supported on all cpus
92 * 3 P_LVL2_UP
93 * 0: C2 only on uniprocessor, 1: C2 on uni- and multiprocessor
94 * 4 PWR_BUTTON
95 * 0: pwr button is fixed feature
96 * 1: pwr button has control method device if present
97 * 5 SLP_BUTTON
98 * 0: sleep button is fixed feature
99 * 1: sleep button has control method device if present
100 * 6 FIX_RTC
101 * 0: RTC wake status supported in fixed register spce
102 * 7 RTC_S4
103 * 1: RTC can wake from S4
104 * 8 TMR_VAL_EXT
105 * 1: pmtimer is 32bit, 0: pmtimer is 24bit
106 * 9 DCK_CAP
107 * 1: system supports docking station
108 * 10 RESET_REG_SUPPORT
109 * 1: fadt describes reset register for system reset
110 * 11 SEALED_CASE
111 * 1: No expansion possible, sealed case
112 * 12 HEADLESS
113 * 1: Video output, keyboard and mouse are not connected
114 * 13 CPU_SW_SLP
115 * 1: Special processor instruction needs to be executed
116 * after writing SLP_TYP
117 * 14 PCI_EXP_WAK
118 * 1: PM1 regs support PCIEXP_WAKE_(STS|EN), must be set
119 * on platforms with pci express support
120 * 15 USE_PLATFORM_CLOCK
121 * 1: OS should prefer platform clock over processor internal
122 * clock.
123 * 16 S4_RTC_STS_VALID
124 * 17 REMOTE_POWER_ON_CAPABLE
125 * 1: platform correctly supports OSPM leaving GPE wake events
126 * armed prior to an S5 transition.
127 * 18 FORCE_APIC_CLUSTER_MODEL
128 * 19 FORCE_APIC_PHYSICAL_DESTINATION_MODE
129 */
130 fadt->flags = 0xa5;
131
132 fadt->reset_reg.space_id = 0;
133 fadt->reset_reg.bit_width = 0;
134 fadt->reset_reg.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100135 fadt->reset_reg.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000136 fadt->reset_reg.addrl = 0x0;
137 fadt->reset_reg.addrh = 0x0;
138 fadt->reset_value = 0;
139
Patrick Rudolph0fa793c2019-02-18 19:21:17 +0100140 fadt->x_firmware_ctl_l = (uintptr_t)facs;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000141 fadt->x_firmware_ctl_h = 0;
Patrick Rudolph0fa793c2019-02-18 19:21:17 +0100142 fadt->x_dsdt_l = (uintptr_t)dsdt;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000143 fadt->x_dsdt_h = 0;
144
145 fadt->x_pm1a_evt_blk.space_id = 1;
146 fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
147 fadt->x_pm1a_evt_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100148 fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000149 fadt->x_pm1a_evt_blk.addrl = fadt->pm1a_evt_blk;
150 fadt->x_pm1a_evt_blk.addrh = 0x0;
151
152 fadt->x_pm1b_evt_blk.space_id = 1;
153 fadt->x_pm1b_evt_blk.bit_width = fadt->pm1_evt_len * 8;
154 fadt->x_pm1b_evt_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100155 fadt->x_pm1b_evt_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000156 fadt->x_pm1b_evt_blk.addrl = fadt->pm1b_evt_blk;
157 fadt->x_pm1b_evt_blk.addrh = 0x0;
158
159 fadt->x_pm1a_cnt_blk.space_id = 1;
160 fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
161 fadt->x_pm1a_cnt_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100162 fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000163 fadt->x_pm1a_cnt_blk.addrl = fadt->pm1a_cnt_blk;
164 fadt->x_pm1a_cnt_blk.addrh = 0x0;
165
166 fadt->x_pm1b_cnt_blk.space_id = 1;
167 fadt->x_pm1b_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
168 fadt->x_pm1b_cnt_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100169 fadt->x_pm1b_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000170 fadt->x_pm1b_cnt_blk.addrl = fadt->pm1b_cnt_blk;
171 fadt->x_pm1b_cnt_blk.addrh = 0x0;
172
173 fadt->x_pm2_cnt_blk.space_id = 1;
174 fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8;
175 fadt->x_pm2_cnt_blk.bit_offset = 0;
Elyes HAOUAS8ee161d2019-03-03 12:49:56 +0100176 fadt->x_pm2_cnt_blk.access_size = 0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000177 fadt->x_pm2_cnt_blk.addrl = fadt->pm2_cnt_blk;
178 fadt->x_pm2_cnt_blk.addrh = 0x0;
179
180 fadt->x_pm_tmr_blk.space_id = 1;
181 fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8;
182 fadt->x_pm_tmr_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100183 fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000184 fadt->x_pm_tmr_blk.addrl = fadt->pm_tmr_blk;
185 fadt->x_pm_tmr_blk.addrh = 0x0;
186
187 fadt->x_gpe0_blk.space_id = 1;
188 fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8;
189 fadt->x_gpe0_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100190 fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000191 fadt->x_gpe0_blk.addrl = fadt->gpe0_blk;
192 fadt->x_gpe0_blk.addrh = 0x0;
193
194 fadt->x_gpe1_blk.space_id = 1;
Idwer Volleringd26da9c2013-12-22 21:38:18 +0000195 fadt->x_gpe1_blk.bit_width = fadt->gpe1_blk_len * 8;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000196 fadt->x_gpe1_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100197 fadt->x_gpe1_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000198 fadt->x_gpe1_blk.addrl = fadt->gpe1_blk;
199 fadt->x_gpe1_blk.addrh = 0x0;
200
201 header->checksum = acpi_checksum((void *) fadt, sizeof(acpi_fadt_t));
202}