Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 2 | |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 3 | /* |
| 4 | * ACPI - create the Fixed ACPI Description Tables (FADT) |
| 5 | */ |
| 6 | |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 7 | #include <console/console.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 8 | #include <acpi/acpi.h> |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 9 | #include <arch/io.h> |
| 10 | #include <device/device.h> |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame] | 11 | #include <version.h> |
| 12 | |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 13 | #include "SBPLATFORM.h" |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 14 | |
Marc Jones | 7c9ef4f | 2012-05-10 11:02:32 -0600 | [diff] [blame] | 15 | #ifndef FADT_BOOT_ARCH |
| 16 | #if LEGACY_FREE |
Marc Jones | 7c9ef4f | 2012-05-10 11:02:32 -0600 | [diff] [blame] | 17 | #define FADT_BOOT_ARCH ACPI_FADT_LEGACY_FREE |
Marc Jones | ba3711c | 2012-05-12 09:56:45 -0600 | [diff] [blame] | 18 | #else |
| 19 | #define FADT_BOOT_ARCH (ACPI_FADT_LEGACY_DEVICES | ACPI_FADT_8042) |
Marc Jones | 7c9ef4f | 2012-05-10 11:02:32 -0600 | [diff] [blame] | 20 | #endif |
| 21 | #endif |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 22 | |
| 23 | /* |
| 24 | * Reference section 5.2.9 Fixed ACPI Description Table (FADT) |
| 25 | * in the ACPI 3.0b specification. |
| 26 | */ |
Kyösti Mälkki | ab51629 | 2020-05-30 19:38:04 +0300 | [diff] [blame] | 27 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 28 | { |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 29 | u16 val = 0; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 30 | |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 31 | printk(BIOS_DEBUG, "ACPI_BLK_BASE: 0x%04x\n", ACPI_BLK_BASE); |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 32 | |
Martin Roth | 0cd338e | 2016-07-29 14:07:30 -0600 | [diff] [blame] | 33 | fadt->sci_int = 9; /* HUDSON 1 - IRQ 09 - ACPI SCI */ |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 34 | |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 35 | val = PM1_EVT_BLK_ADDRESS; |
| 36 | WritePMIO(SB_PMIOA_REG60, AccWidthUint16, &val); |
| 37 | val = PM1_CNT_BLK_ADDRESS; |
| 38 | WritePMIO(SB_PMIOA_REG62, AccWidthUint16, &val); |
| 39 | val = PM1_TMR_BLK_ADDRESS; |
| 40 | WritePMIO(SB_PMIOA_REG64, AccWidthUint16, &val); |
| 41 | val = GPE0_BLK_ADDRESS; |
| 42 | WritePMIO(SB_PMIOA_REG68, AccWidthUint16, &val); |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 43 | |
Timothy Pearson | 033bb4b | 2015-02-10 22:21:39 -0600 | [diff] [blame] | 44 | /* CpuControl is in \_PR.CP00, 6 bytes */ |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 45 | val = CPU_CNT_BLK_ADDRESS; |
| 46 | WritePMIO(SB_PMIOA_REG66, AccWidthUint16, &val); |
| 47 | val = 0; |
| 48 | WritePMIO(SB_PMIOA_REG6A, AccWidthUint16, &val); |
| 49 | val = ACPI_PMA_CNT_BLK_ADDRESS; |
Martin Roth | 9aa4389 | 2012-05-25 12:23:32 -0600 | [diff] [blame] | 50 | WritePMIO(SB_PMIOA_REG6E, AccWidthUint16, &val); |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 51 | |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 52 | /* AcpiDecodeEnable, When set, SB uses the contents of the |
| 53 | * PM registers at index 60-6B to decode ACPI I/O address. |
| 54 | * AcpiSmiEn & SmiCmdEn*/ |
| 55 | val = BIT0 | BIT1 | BIT2 | BIT4; |
| 56 | WritePMIO(SB_PMIOA_REG74, AccWidthUint16, &val); |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 57 | |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 58 | /* RTC_En_En, TMR_En_En, GBL_EN_EN */ |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 59 | outl(0x1, PM1_CNT_BLK_ADDRESS); /* set SCI_EN */ |
| 60 | fadt->pm1a_evt_blk = PM1_EVT_BLK_ADDRESS; |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 61 | fadt->pm1a_cnt_blk = PM1_CNT_BLK_ADDRESS; |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 62 | fadt->pm2_cnt_blk = ACPI_PMA_CNT_BLK_ADDRESS; |
| 63 | fadt->pm_tmr_blk = PM1_TMR_BLK_ADDRESS; |
| 64 | fadt->gpe0_blk = GPE0_BLK_ADDRESS; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 65 | |
Martin Roth | 9aa4389 | 2012-05-25 12:23:32 -0600 | [diff] [blame] | 66 | fadt->pm1_evt_len = 4; /* 32 bits */ |
| 67 | fadt->pm1_cnt_len = 2; /* 16 bits */ |
| 68 | fadt->pm2_cnt_len = 1; /* 8 bits */ |
| 69 | fadt->pm_tmr_len = 4; /* 32 bits */ |
| 70 | fadt->gpe0_blk_len = 8; /* 64 bits */ |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 71 | |
Martin Roth | 9aa4389 | 2012-05-25 12:23:32 -0600 | [diff] [blame] | 72 | fadt->p_lvl2_lat = ACPI_FADT_C2_NOT_SUPPORTED; |
| 73 | fadt->p_lvl3_lat = ACPI_FADT_C3_NOT_SUPPORTED; |
Martin Roth | 9aa4389 | 2012-05-25 12:23:32 -0600 | [diff] [blame] | 74 | fadt->duty_offset = 1; /* CLK_VAL bits 3:1 */ |
| 75 | fadt->duty_width = 3; /* CLK_VAL bits 3:1 */ |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 76 | fadt->day_alrm = 0; /* 0x7d these have to be */ |
| 77 | fadt->mon_alrm = 0; /* 0x7e added to cmos.layout */ |
Marc Jones | 7c9ef4f | 2012-05-10 11:02:32 -0600 | [diff] [blame] | 78 | fadt->iapc_boot_arch = FADT_BOOT_ARCH; /* See table 5-10 */ |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 79 | fadt->res2 = 0; /* reserved, MUST be 0 ACPI 3.0 */ |
Angel Pons | a208c6c | 2020-07-13 00:02:34 +0200 | [diff] [blame] | 80 | fadt->flags |= ACPI_FADT_WBINVD | /* See table 5-10 ACPI 3.0a spec */ |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 81 | ACPI_FADT_C1_SUPPORTED | |
| 82 | ACPI_FADT_SLEEP_BUTTON | |
| 83 | ACPI_FADT_S4_RTC_WAKE | |
| 84 | ACPI_FADT_32BIT_TIMER | |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 85 | ACPI_FADT_PCI_EXPRESS_WAKE | |
| 86 | ACPI_FADT_S4_RTC_VALID | |
| 87 | ACPI_FADT_REMOTE_POWER_ON; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 88 | |
Elyes Haouas | b55ac09 | 2022-02-16 14:42:19 +0100 | [diff] [blame] | 89 | fadt->ARM_boot_arch = 0; /* Must be zero if ACPI Revision <= 5.0 */ |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 90 | |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 91 | fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Elyes Haouas | a6e05382 | 2022-10-11 12:55:36 +0200 | [diff] [blame] | 92 | fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 93 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
Martin Roth | 9aa4389 | 2012-05-25 12:23:32 -0600 | [diff] [blame] | 94 | fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
Felix Held | 769b657 | 2022-10-14 18:32:52 +0200 | [diff] [blame^] | 95 | fadt->x_pm1a_evt_blk.addrl = fadt->pm1a_evt_blk; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 96 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 97 | |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 98 | fadt->x_pm1a_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Elyes Haouas | 7008085 | 2022-10-11 13:09:35 +0200 | [diff] [blame] | 99 | fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 100 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
Elyes HAOUAS | eaa165d | 2020-08-17 11:40:09 +0200 | [diff] [blame] | 101 | fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_UNDEFINED; |
Elyes Haouas | c60f3b2 | 2022-10-11 14:02:27 +0200 | [diff] [blame] | 102 | fadt->x_pm1a_cnt_blk.addrl = fadt->pm1a_cnt_blk; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 103 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 104 | |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 105 | fadt->x_pm2_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Elyes Haouas | 85f87e8 | 2022-10-11 13:45:44 +0200 | [diff] [blame] | 106 | fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 107 | fadt->x_pm2_cnt_blk.bit_offset = 0; |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 108 | fadt->x_pm2_cnt_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 109 | fadt->x_pm2_cnt_blk.addrl = ACPI_PMA_CNT_BLK_ADDRESS; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 110 | fadt->x_pm2_cnt_blk.addrh = 0x0; |
| 111 | |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 112 | fadt->x_pm_tmr_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Elyes Haouas | 501b71e | 2022-10-11 13:15:37 +0200 | [diff] [blame] | 113 | fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 114 | fadt->x_pm_tmr_blk.bit_offset = 0; |
Martin Roth | 9aa4389 | 2012-05-25 12:23:32 -0600 | [diff] [blame] | 115 | fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
Elyes Haouas | 987f1f4 | 2022-10-11 13:56:30 +0200 | [diff] [blame] | 116 | fadt->x_pm_tmr_blk.addrl = fadt->pm_tmr_blk; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 117 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 118 | |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 119 | fadt->x_gpe0_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Elyes Haouas | baec560 | 2022-10-11 13:20:43 +0200 | [diff] [blame] | 120 | fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8; /* EventStatus + Event Enable */ |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 121 | fadt->x_gpe0_blk.bit_offset = 0; |
Angel Pons | a23aff3 | 2020-06-21 20:47:54 +0200 | [diff] [blame] | 122 | fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
Elyes Haouas | c929f09 | 2022-10-11 13:40:51 +0200 | [diff] [blame] | 123 | fadt->x_gpe0_blk.addrl = fadt->gpe0_blk; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 124 | fadt->x_gpe0_blk.addrh = 0x0; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 125 | } |