xref: /aosp_15_r20/external/coreboot/src/arch/x86/acpi.c (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <acpi/acpi.h>
4 #include <arch/ioapic.h>
5 #include <cf9_reset.h>
6 #include <cpu/x86/smm.h>
7 #include <pc80/mc146818rtc.h>
8 
acpi_sci_int(void)9 static u16 acpi_sci_int(void)
10 {
11 	u8 gsi, irq, flags;
12 
13 	ioapic_get_sci_pin(&gsi, &irq, &flags);
14 
15 	/* In systems without 8259, the SCI_INT field in the FADT contains the SCI GSI number
16 	   instead of the 8259 IRQ number */
17 	if (!CONFIG(ACPI_HAVE_PCAT_8259))
18 		return gsi;
19 
20 	assert(irq < 16);
21 	return irq;
22 }
23 
24 
arch_fill_fadt(acpi_fadt_t * fadt)25 void arch_fill_fadt(acpi_fadt_t *fadt)
26 {
27 	fadt->sci_int = acpi_sci_int();
28 
29 	if (CONFIG(HAVE_CF9_RESET)) {
30 		fadt->reset_reg.space_id = ACPI_ADDRESS_SPACE_IO;
31 		fadt->reset_reg.bit_width = 8;
32 		fadt->reset_reg.bit_offset = 0;
33 		fadt->reset_reg.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
34 		fadt->reset_reg.addrl = RST_CNT;
35 		fadt->reset_reg.addrh = 0;
36 
37 		fadt->reset_value = RST_CPU | SYS_RST;
38 
39 		fadt->flags |= ACPI_FADT_RESET_REGISTER;
40 	}
41 
42 	if (permanent_smi_handler()) {
43 		fadt->smi_cmd = pm_acpi_smi_cmd_port();
44 		fadt->acpi_enable = APM_CNT_ACPI_ENABLE;
45 		fadt->acpi_disable = APM_CNT_ACPI_DISABLE;
46 	}
47 
48 	if (CONFIG(PC80_SYSTEM)) {
49 		/* Currently these are defined to support date alarm only. */
50 		fadt->day_alrm = RTC_DATE_ALARM;
51 		fadt->mon_alrm = RTC_MONTH_ALARM;
52 	}
53 
54 	/* Careful with USE_OPTION_TABLE. */
55 	if (CONFIG(USE_PC_CMOS_ALTCENTURY))
56 		fadt->century = RTC_CLK_ALTCENTURY;
57 }
58