Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Based on src/southbridge/via/vt8237r/vt8237_fadt.c |
| 5 | * |
| 6 | * Copyright (C) 2004 Nick Barker <nick.barker9@btinternet.com> |
| 7 | * Copyright (C) 2007, 2009 Rudolf Marek <r.marek@assembler.cz> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | #include <string.h> |
| 21 | #include <arch/acpi.h> |
| 22 | #include <device/device.h> |
| 23 | #include <device/pci.h> |
| 24 | #include <device/pci_ids.h> |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame^] | 25 | #include <version.h> |
| 26 | |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 27 | #include "i82371eb.h" |
| 28 | |
| 29 | /** |
| 30 | * Create the Fixed ACPI Description Tables (FADT) for any board with this SB. |
| 31 | * Reference: ACPIspec40a, 5.2.9, page 118 |
| 32 | */ |
| 33 | void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt) |
| 34 | { |
| 35 | acpi_header_t *header = &(fadt->header); |
Elyes HAOUAS | 07e77f1 | 2018-05-13 13:25:13 +0200 | [diff] [blame] | 36 | struct device *dev; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 37 | |
| 38 | /* Power management controller */ |
| 39 | dev = dev_find_device(PCI_VENDOR_ID_INTEL, |
| 40 | PCI_DEVICE_ID_INTEL_82371AB_SMB_ACPI, 0); |
| 41 | |
| 42 | memset((void *) fadt, 0, sizeof(acpi_fadt_t)); |
| 43 | memcpy(header->signature, "FACP", 4); |
| 44 | header->length = 244; |
| 45 | header->revision = 1; |
Stefan Reinauer | 03f82bd | 2011-09-20 22:36:32 +0200 | [diff] [blame] | 46 | memcpy(header->oem_id, OEM_ID, 6); |
| 47 | memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); |
| 48 | memcpy(header->asl_compiler_id, ASLC, 4); |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame^] | 49 | header->asl_compiler_revision = asl_revision; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 50 | |
Patrick Rudolph | 0fa793c | 2019-02-18 19:21:17 +0100 | [diff] [blame] | 51 | fadt->firmware_ctrl = (uintptr_t)facs; |
| 52 | fadt->dsdt = (uintptr_t)dsdt; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 53 | fadt->preferred_pm_profile = 0; /* unspecified */ |
| 54 | fadt->sci_int = 9; |
| 55 | fadt->smi_cmd = 0; /* smi command port */ |
| 56 | fadt->acpi_enable = 0; /* acpi enable smi command */ |
| 57 | fadt->acpi_disable = 0; /* acpi disable smi command */ |
| 58 | fadt->s4bios_req = 0x0; |
| 59 | fadt->pstate_cnt = 0x0; |
| 60 | |
| 61 | fadt->pm1a_evt_blk = DEFAULT_PMBASE; |
| 62 | fadt->pm1b_evt_blk = 0x0; |
| 63 | fadt->pm1a_cnt_blk = DEFAULT_PMBASE + PMCNTRL; |
| 64 | fadt->pm1b_cnt_blk = 0x0; |
| 65 | |
| 66 | fadt->pm2_cnt_blk = 0; |
| 67 | fadt->pm_tmr_blk = DEFAULT_PMBASE + PMTMR; |
| 68 | fadt->gpe0_blk = DEFAULT_PMBASE + GPSTS; |
| 69 | fadt->gpe1_blk = 0x0; |
| 70 | fadt->gpe1_base = 0; |
| 71 | fadt->gpe1_blk_len = 0; |
| 72 | |
| 73 | /* *_len define register width in bytes */ |
| 74 | fadt->pm1_evt_len = 4; |
| 75 | fadt->pm1_cnt_len = 2; |
| 76 | fadt->pm2_cnt_len = 0; /* not supported */ |
| 77 | fadt->pm_tmr_len = 4; |
| 78 | fadt->gpe0_blk_len = 4; |
| 79 | |
| 80 | fadt->cst_cnt = 0; /* smi command to indicate c state changed notification */ |
| 81 | fadt->p_lvl2_lat = 101; /* >100 means c2 not supported */ |
| 82 | fadt->p_lvl3_lat = 1001; /* >1000 means c3 not supported */ |
Elyes HAOUAS | 1bcd7fc | 2016-07-28 21:20:04 +0200 | [diff] [blame] | 83 | fadt->flush_size = 0; /* only needed if CPU wbinvd is broken */ |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 84 | fadt->flush_stride = 0; |
| 85 | fadt->duty_offset = 1; /* bit 1:3 in PCNTRL reg (pmbase+0x10) */ |
| 86 | fadt->duty_width = 3; /* this width is in bits */ |
Elyes HAOUAS | 1bcd7fc | 2016-07-28 21:20:04 +0200 | [diff] [blame] | 87 | fadt->day_alrm = 0x0d; /* rtc cmos RAM offset */ |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 88 | fadt->mon_alrm = 0x0; /* not supported */ |
| 89 | fadt->century = 0x0; /* not supported */ |
| 90 | /* |
| 91 | * bit meaning |
| 92 | * 0 1: We have user-visible legacy devices |
| 93 | * 1 1: 8042 |
| 94 | * 2 0: VGA is ok to probe |
| 95 | * 3 1: MSI are not supported |
| 96 | */ |
| 97 | fadt->iapc_boot_arch = 0xb; |
| 98 | /* |
| 99 | * bit meaning |
| 100 | * 0 WBINVD |
| 101 | * Processors in new ACPI-compatible systems are required to |
| 102 | * support this function and indicate this to OSPM by setting |
| 103 | * this field. |
| 104 | * 1 WBINVD_FLUSH |
| 105 | * If set, indicates that the hardware flushes all caches on the |
| 106 | * WBINVD instruction and maintains memory coherency, but does |
| 107 | * not guarantee the caches are invalidated. |
| 108 | * 2 PROC_C1 |
| 109 | * C1 power state (x86 hlt instruction) is supported on all cpus |
| 110 | * 3 P_LVL2_UP |
| 111 | * 0: C2 only on uniprocessor, 1: C2 on uni- and multiprocessor |
| 112 | * 4 PWR_BUTTON |
| 113 | * 0: pwr button is fixed feature |
| 114 | * 1: pwr button has control method device if present |
| 115 | * 5 SLP_BUTTON |
| 116 | * 0: sleep button is fixed feature |
| 117 | * 1: sleep button has control method device if present |
| 118 | * 6 FIX_RTC |
| 119 | * 0: RTC wake status supported in fixed register spce |
| 120 | * 7 RTC_S4 |
| 121 | * 1: RTC can wake from S4 |
| 122 | * 8 TMR_VAL_EXT |
| 123 | * 1: pmtimer is 32bit, 0: pmtimer is 24bit |
| 124 | * 9 DCK_CAP |
| 125 | * 1: system supports docking station |
| 126 | * 10 RESET_REG_SUPPORT |
| 127 | * 1: fadt describes reset register for system reset |
| 128 | * 11 SEALED_CASE |
| 129 | * 1: No expansion possible, sealed case |
| 130 | * 12 HEADLESS |
| 131 | * 1: Video output, keyboard and mouse are not connected |
| 132 | * 13 CPU_SW_SLP |
| 133 | * 1: Special processor instruction needs to be executed |
| 134 | * after writing SLP_TYP |
| 135 | * 14 PCI_EXP_WAK |
| 136 | * 1: PM1 regs support PCIEXP_WAKE_(STS|EN), must be set |
| 137 | * on platforms with pci express support |
| 138 | * 15 USE_PLATFORM_CLOCK |
| 139 | * 1: OS should prefer platform clock over processor internal |
| 140 | * clock. |
| 141 | * 16 S4_RTC_STS_VALID |
| 142 | * 17 REMOTE_POWER_ON_CAPABLE |
| 143 | * 1: platform correctly supports OSPM leaving GPE wake events |
| 144 | * armed prior to an S5 transition. |
| 145 | * 18 FORCE_APIC_CLUSTER_MODEL |
| 146 | * 19 FORCE_APIC_PHYSICAL_DESTINATION_MODE |
| 147 | */ |
| 148 | fadt->flags = 0xa5; |
| 149 | |
| 150 | fadt->reset_reg.space_id = 0; |
| 151 | fadt->reset_reg.bit_width = 0; |
| 152 | fadt->reset_reg.bit_offset = 0; |
| 153 | fadt->reset_reg.resv = 0; |
| 154 | fadt->reset_reg.addrl = 0x0; |
| 155 | fadt->reset_reg.addrh = 0x0; |
| 156 | fadt->reset_value = 0; |
| 157 | |
Patrick Rudolph | 0fa793c | 2019-02-18 19:21:17 +0100 | [diff] [blame] | 158 | fadt->x_firmware_ctl_l = (uintptr_t)facs; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 159 | fadt->x_firmware_ctl_h = 0; |
Patrick Rudolph | 0fa793c | 2019-02-18 19:21:17 +0100 | [diff] [blame] | 160 | fadt->x_dsdt_l = (uintptr_t)dsdt; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 161 | fadt->x_dsdt_h = 0; |
| 162 | |
| 163 | fadt->x_pm1a_evt_blk.space_id = 1; |
| 164 | fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8; |
| 165 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
| 166 | fadt->x_pm1a_evt_blk.resv = 0; |
| 167 | fadt->x_pm1a_evt_blk.addrl = fadt->pm1a_evt_blk; |
| 168 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 169 | |
| 170 | fadt->x_pm1b_evt_blk.space_id = 1; |
| 171 | fadt->x_pm1b_evt_blk.bit_width = fadt->pm1_evt_len * 8; |
| 172 | fadt->x_pm1b_evt_blk.bit_offset = 0; |
| 173 | fadt->x_pm1b_evt_blk.resv = 0; |
| 174 | fadt->x_pm1b_evt_blk.addrl = fadt->pm1b_evt_blk; |
| 175 | fadt->x_pm1b_evt_blk.addrh = 0x0; |
| 176 | |
| 177 | fadt->x_pm1a_cnt_blk.space_id = 1; |
| 178 | fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8; |
| 179 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
| 180 | fadt->x_pm1a_cnt_blk.resv = 0; |
| 181 | fadt->x_pm1a_cnt_blk.addrl = fadt->pm1a_cnt_blk; |
| 182 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 183 | |
| 184 | fadt->x_pm1b_cnt_blk.space_id = 1; |
| 185 | fadt->x_pm1b_cnt_blk.bit_width = fadt->pm1_cnt_len * 8; |
| 186 | fadt->x_pm1b_cnt_blk.bit_offset = 0; |
| 187 | fadt->x_pm1b_cnt_blk.resv = 0; |
| 188 | fadt->x_pm1b_cnt_blk.addrl = fadt->pm1b_cnt_blk; |
| 189 | fadt->x_pm1b_cnt_blk.addrh = 0x0; |
| 190 | |
| 191 | fadt->x_pm2_cnt_blk.space_id = 1; |
| 192 | fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8; |
| 193 | fadt->x_pm2_cnt_blk.bit_offset = 0; |
| 194 | fadt->x_pm2_cnt_blk.resv = 0; |
| 195 | fadt->x_pm2_cnt_blk.addrl = fadt->pm2_cnt_blk; |
| 196 | fadt->x_pm2_cnt_blk.addrh = 0x0; |
| 197 | |
| 198 | fadt->x_pm_tmr_blk.space_id = 1; |
| 199 | fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8; |
| 200 | fadt->x_pm_tmr_blk.bit_offset = 0; |
| 201 | fadt->x_pm_tmr_blk.resv = 0; |
| 202 | fadt->x_pm_tmr_blk.addrl = fadt->pm_tmr_blk; |
| 203 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 204 | |
| 205 | fadt->x_gpe0_blk.space_id = 1; |
| 206 | fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8; |
| 207 | fadt->x_gpe0_blk.bit_offset = 0; |
| 208 | fadt->x_gpe0_blk.resv = 0; |
| 209 | fadt->x_gpe0_blk.addrl = fadt->gpe0_blk; |
| 210 | fadt->x_gpe0_blk.addrh = 0x0; |
| 211 | |
| 212 | fadt->x_gpe1_blk.space_id = 1; |
Idwer Vollering | d26da9c | 2013-12-22 21:38:18 +0000 | [diff] [blame] | 213 | fadt->x_gpe1_blk.bit_width = fadt->gpe1_blk_len * 8; |
Tobias Diedrich | e87c38e | 2010-11-27 09:40:16 +0000 | [diff] [blame] | 214 | fadt->x_gpe1_blk.bit_offset = 0; |
| 215 | fadt->x_gpe1_blk.resv = 0; |
| 216 | fadt->x_gpe1_blk.addrl = fadt->gpe1_blk; |
| 217 | fadt->x_gpe1_blk.addrh = 0x0; |
| 218 | |
| 219 | header->checksum = acpi_checksum((void *) fadt, sizeof(acpi_fadt_t)); |
| 220 | } |