Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 2 | |
| 3 | /* |
| 4 | * ACPI - create the Fixed ACPI Description Tables (FADT) |
| 5 | */ |
| 6 | |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 7 | #include <console/console.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 8 | #include <acpi/acpi.h> |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 9 | #include <device/device.h> |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame] | 10 | #include <version.h> |
| 11 | |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 12 | #include "hudson.h" |
| 13 | #include "smi.h" |
| 14 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 15 | #if CONFIG(HUDSON_LEGACY_FREE) |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 16 | #define FADT_BOOT_ARCH ACPI_FADT_LEGACY_FREE |
| 17 | #else |
| 18 | #define FADT_BOOT_ARCH (ACPI_FADT_LEGACY_DEVICES | ACPI_FADT_8042) |
| 19 | #endif |
| 20 | |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 21 | /* |
| 22 | * Reference section 5.2.9 Fixed ACPI Description Table (FADT) |
| 23 | * in the ACPI 3.0b specification. |
| 24 | */ |
Kyösti Mälkki | ab51629 | 2020-05-30 19:38:04 +0300 | [diff] [blame] | 25 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 26 | { |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 27 | printk(BIOS_DEBUG, "pm_base: 0x%04x\n", HUDSON_ACPI_IO_BASE); |
| 28 | |
Martin Roth | 0cd338e | 2016-07-29 14:07:30 -0600 | [diff] [blame] | 29 | fadt->sci_int = 9; /* HUDSON - IRQ 09 - ACPI SCI */ |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 30 | |
Kyösti Mälkki | 0a9e72e | 2019-08-11 01:22:28 +0300 | [diff] [blame] | 31 | if (permanent_smi_handler()) { |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 32 | fadt->smi_cmd = ACPI_SMI_CTL_PORT; |
| 33 | fadt->acpi_enable = ACPI_SMI_CMD_ENABLE; |
| 34 | fadt->acpi_disable = ACPI_SMI_CMD_DISABLE; |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | fadt->pm1a_evt_blk = ACPI_PM_EVT_BLK; |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 38 | fadt->pm1a_cnt_blk = ACPI_PM1_CNT_BLK; |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 39 | fadt->pm_tmr_blk = ACPI_PM_TMR_BLK; |
| 40 | fadt->gpe0_blk = ACPI_GPE0_BLK; |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 41 | |
| 42 | fadt->pm1_evt_len = 4; /* 32 bits */ |
| 43 | fadt->pm1_cnt_len = 2; /* 16 bits */ |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 44 | fadt->pm_tmr_len = 4; /* 32 bits */ |
| 45 | fadt->gpe0_blk_len = 8; /* 64 bits */ |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 46 | |
| 47 | fadt->p_lvl2_lat = ACPI_FADT_C2_NOT_SUPPORTED; |
| 48 | fadt->p_lvl3_lat = ACPI_FADT_C3_NOT_SUPPORTED; |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 49 | fadt->duty_offset = 1; /* CLK_VAL bits 3:1 */ |
| 50 | fadt->duty_width = 3; /* CLK_VAL bits 3:1 */ |
| 51 | fadt->day_alrm = 0; /* 0x7d these have to be */ |
| 52 | fadt->mon_alrm = 0; /* 0x7e added to cmos.layout */ |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 53 | fadt->iapc_boot_arch = FADT_BOOT_ARCH; /* See table 5-10 */ |
| 54 | fadt->res2 = 0; /* reserved, MUST be 0 ACPI 3.0 */ |
Angel Pons | a208c6c | 2020-07-13 00:02:34 +0200 | [diff] [blame] | 55 | fadt->flags |= ACPI_FADT_WBINVD | /* See table 5-10 ACPI 3.0a spec */ |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 56 | ACPI_FADT_C1_SUPPORTED | |
| 57 | ACPI_FADT_SLEEP_BUTTON | |
| 58 | ACPI_FADT_S4_RTC_WAKE | |
| 59 | ACPI_FADT_32BIT_TIMER | |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 60 | ACPI_FADT_PCI_EXPRESS_WAKE | |
| 61 | ACPI_FADT_PLATFORM_CLOCK | |
| 62 | ACPI_FADT_S4_RTC_VALID | |
| 63 | ACPI_FADT_REMOTE_POWER_ON; |
| 64 | |
Elyes Haouas | b55ac09 | 2022-02-16 14:42:19 +0100 | [diff] [blame] | 65 | fadt->ARM_boot_arch = 0; /* Must be zero if ACPI Revision <= 5.0 */ |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 66 | |
| 67 | fadt->x_firmware_ctl_l = 0; /* set to 0 if firmware_ctrl is used */ |
| 68 | fadt->x_firmware_ctl_h = 0; |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 69 | |
| 70 | fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 71 | fadt->x_pm1a_evt_blk.bit_width = 32; |
| 72 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
| 73 | fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
| 74 | fadt->x_pm1a_evt_blk.addrl = ACPI_PM_EVT_BLK; |
| 75 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 76 | |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 77 | fadt->x_pm1a_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 78 | fadt->x_pm1a_cnt_blk.bit_width = 16; |
| 79 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
Elyes HAOUAS | eaa165d | 2020-08-17 11:40:09 +0200 | [diff] [blame] | 80 | fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_UNDEFINED; |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 81 | fadt->x_pm1a_cnt_blk.addrl = ACPI_PM1_CNT_BLK; |
| 82 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 83 | |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 84 | fadt->x_pm_tmr_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 85 | fadt->x_pm_tmr_blk.bit_width = 32; |
| 86 | fadt->x_pm_tmr_blk.bit_offset = 0; |
| 87 | fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
| 88 | fadt->x_pm_tmr_blk.addrl = ACPI_PM_TMR_BLK; |
| 89 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 90 | |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 91 | fadt->x_gpe0_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 92 | fadt->x_gpe0_blk.bit_width = 64; /* EventStatus + Event Enable */ |
| 93 | fadt->x_gpe0_blk.bit_offset = 0; |
Angel Pons | a23aff3 | 2020-06-21 20:47:54 +0200 | [diff] [blame] | 94 | fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 95 | fadt->x_gpe0_blk.addrl = ACPI_GPE0_BLK; |
| 96 | fadt->x_gpe0_blk.addrh = 0x0; |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 97 | } |