blob: 5add01ce762fbb28339416498a40e49b45ffc29a [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
Furquan Shaikh76cedd22020-05-02 10:24:23 -07007#include <acpi/acpi.h>
Tobias Diedriche87c38e2010-11-27 09:40:16 +00008#include <device/device.h>
9#include <device/pci.h>
Elyes HAOUAS26071aa2019-02-15 08:21:33 +010010#include <version.h>
11
Tobias Diedriche87c38e2010-11-27 09:40:16 +000012#include "i82371eb.h"
13
14/**
15 * Create the Fixed ACPI Description Tables (FADT) for any board with this SB.
16 * Reference: ACPIspec40a, 5.2.9, page 118
17 */
Kyösti Mälkki8ad52ff2020-05-30 14:50:50 +030018void acpi_fill_fadt(acpi_fadt_t *fadt)
Tobias Diedriche87c38e2010-11-27 09:40:16 +000019{
Tobias Diedriche87c38e2010-11-27 09:40:16 +000020 fadt->sci_int = 9;
Kyösti Mälkkic328a682019-11-23 07:23:40 +020021
Kyösti Mälkki0a9e72e2019-08-11 01:22:28 +030022 if (permanent_smi_handler()) {
Kyösti Mälkkic328a682019-11-23 07:23:40 +020023 /* TODO: SMI handler is not implemented. */
24 fadt->smi_cmd = 0x00;
25 }
Tobias Diedriche87c38e2010-11-27 09:40:16 +000026
27 fadt->pm1a_evt_blk = DEFAULT_PMBASE;
Tobias Diedriche87c38e2010-11-27 09:40:16 +000028 fadt->pm1a_cnt_blk = DEFAULT_PMBASE + PMCNTRL;
Tobias Diedriche87c38e2010-11-27 09:40:16 +000029
Tobias Diedriche87c38e2010-11-27 09:40:16 +000030 fadt->pm_tmr_blk = DEFAULT_PMBASE + PMTMR;
31 fadt->gpe0_blk = DEFAULT_PMBASE + GPSTS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +000032
33 /* *_len define register width in bytes */
34 fadt->pm1_evt_len = 4;
35 fadt->pm1_cnt_len = 2;
Tobias Diedriche87c38e2010-11-27 09:40:16 +000036 fadt->pm_tmr_len = 4;
37 fadt->gpe0_blk_len = 4;
38
Tobias Diedriche87c38e2010-11-27 09:40:16 +000039 fadt->p_lvl2_lat = 101; /* >100 means c2 not supported */
40 fadt->p_lvl3_lat = 1001; /* >1000 means c3 not supported */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000041 fadt->duty_offset = 1; /* bit 1:3 in PCNTRL reg (pmbase+0x10) */
42 fadt->duty_width = 3; /* this width is in bits */
Elyes HAOUAS2119d0b2020-02-16 10:01:33 +010043 fadt->day_alrm = 0x0d; /* rtc CMOS RAM offset */
Tobias Diedriche87c38e2010-11-27 09:40:16 +000044 fadt->mon_alrm = 0x0; /* not supported */
45 fadt->century = 0x0; /* not supported */
46 /*
47 * bit meaning
48 * 0 1: We have user-visible legacy devices
49 * 1 1: 8042
50 * 2 0: VGA is ok to probe
51 * 3 1: MSI are not supported
52 */
Elyes HAOUAS653eb152020-08-17 12:15:12 +020053 fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES | ACPI_FADT_8042 |
54 ACPI_FADT_MSI_NOT_SUPPORTED;
Tobias Diedriche87c38e2010-11-27 09:40:16 +000055 /*
56 * bit meaning
57 * 0 WBINVD
58 * Processors in new ACPI-compatible systems are required to
59 * support this function and indicate this to OSPM by setting
60 * this field.
61 * 1 WBINVD_FLUSH
62 * If set, indicates that the hardware flushes all caches on the
63 * WBINVD instruction and maintains memory coherency, but does
64 * not guarantee the caches are invalidated.
65 * 2 PROC_C1
66 * C1 power state (x86 hlt instruction) is supported on all cpus
67 * 3 P_LVL2_UP
68 * 0: C2 only on uniprocessor, 1: C2 on uni- and multiprocessor
69 * 4 PWR_BUTTON
70 * 0: pwr button is fixed feature
71 * 1: pwr button has control method device if present
72 * 5 SLP_BUTTON
73 * 0: sleep button is fixed feature
74 * 1: sleep button has control method device if present
75 * 6 FIX_RTC
76 * 0: RTC wake status supported in fixed register spce
77 * 7 RTC_S4
78 * 1: RTC can wake from S4
79 * 8 TMR_VAL_EXT
80 * 1: pmtimer is 32bit, 0: pmtimer is 24bit
81 * 9 DCK_CAP
82 * 1: system supports docking station
83 * 10 RESET_REG_SUPPORT
84 * 1: fadt describes reset register for system reset
85 * 11 SEALED_CASE
86 * 1: No expansion possible, sealed case
87 * 12 HEADLESS
88 * 1: Video output, keyboard and mouse are not connected
89 * 13 CPU_SW_SLP
90 * 1: Special processor instruction needs to be executed
91 * after writing SLP_TYP
92 * 14 PCI_EXP_WAK
93 * 1: PM1 regs support PCIEXP_WAKE_(STS|EN), must be set
94 * on platforms with pci express support
95 * 15 USE_PLATFORM_CLOCK
96 * 1: OS should prefer platform clock over processor internal
97 * clock.
98 * 16 S4_RTC_STS_VALID
99 * 17 REMOTE_POWER_ON_CAPABLE
100 * 1: platform correctly supports OSPM leaving GPE wake events
101 * armed prior to an S5 transition.
102 * 18 FORCE_APIC_CLUSTER_MODEL
103 * 19 FORCE_APIC_PHYSICAL_DESTINATION_MODE
104 */
Angel Pons79572e42020-07-13 00:17:43 +0200105 fadt->flags |= 0xa5;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000106
Elyes HAOUAS04071f42020-07-20 17:05:24 +0200107 fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000108 fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
109 fadt->x_pm1a_evt_blk.bit_offset = 0;
Angel Pons12a4d052020-07-14 01:31:27 +0200110 fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000111 fadt->x_pm1a_evt_blk.addrl = fadt->pm1a_evt_blk;
112 fadt->x_pm1a_evt_blk.addrh = 0x0;
113
Elyes HAOUAS04071f42020-07-20 17:05:24 +0200114 fadt->x_pm1a_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000115 fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
116 fadt->x_pm1a_cnt_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100117 fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000118 fadt->x_pm1a_cnt_blk.addrl = fadt->pm1a_cnt_blk;
119 fadt->x_pm1a_cnt_blk.addrh = 0x0;
120
Elyes HAOUAS04071f42020-07-20 17:05:24 +0200121 fadt->x_pm_tmr_blk.space_id = ACPI_ADDRESS_SPACE_IO;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000122 fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8;
123 fadt->x_pm_tmr_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100124 fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000125 fadt->x_pm_tmr_blk.addrl = fadt->pm_tmr_blk;
126 fadt->x_pm_tmr_blk.addrh = 0x0;
127
Elyes HAOUAS04071f42020-07-20 17:05:24 +0200128 fadt->x_gpe0_blk.space_id = ACPI_ADDRESS_SPACE_IO;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000129 fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8;
130 fadt->x_gpe0_blk.bit_offset = 0;
Patrick Rudolphc02bda02020-02-28 10:19:41 +0100131 fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000132 fadt->x_gpe0_blk.addrl = fadt->gpe0_blk;
133 fadt->x_gpe0_blk.addrh = 0x0;
Tobias Diedriche87c38e2010-11-27 09:40:16 +0000134}