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 | |
| 3 | |
| 4 | /* |
| 5 | * ACPI - create the Fixed ACPI Description Tables (FADT) |
| 6 | */ |
| 7 | |
| 8 | |
| 9 | #include <string.h> |
| 10 | #include <console/console.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 11 | #include <acpi/acpi.h> |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 12 | #include <arch/io.h> |
| 13 | #include <device/device.h> |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame] | 14 | #include <version.h> |
| 15 | |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 16 | #include "SBPLATFORM.h" |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 17 | |
Marc Jones | 7c9ef4f | 2012-05-10 11:02:32 -0600 | [diff] [blame] | 18 | #ifndef FADT_BOOT_ARCH |
| 19 | #if LEGACY_FREE |
Marc Jones | 7c9ef4f | 2012-05-10 11:02:32 -0600 | [diff] [blame] | 20 | #define FADT_BOOT_ARCH ACPI_FADT_LEGACY_FREE |
Marc Jones | ba3711c | 2012-05-12 09:56:45 -0600 | [diff] [blame] | 21 | #else |
| 22 | #define FADT_BOOT_ARCH (ACPI_FADT_LEGACY_DEVICES | ACPI_FADT_8042) |
Marc Jones | 7c9ef4f | 2012-05-10 11:02:32 -0600 | [diff] [blame] | 23 | #endif |
| 24 | #endif |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 25 | |
| 26 | /* |
| 27 | * Reference section 5.2.9 Fixed ACPI Description Table (FADT) |
| 28 | * in the ACPI 3.0b specification. |
| 29 | */ |
Kyösti Mälkki | ab51629 | 2020-05-30 19:38:04 +0300 | [diff] [blame] | 30 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 31 | { |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 32 | u16 val = 0; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 33 | |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 34 | printk(BIOS_DEBUG, "ACPI_BLK_BASE: 0x%04x\n", ACPI_BLK_BASE); |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 35 | |
Martin Roth | 0cd338e | 2016-07-29 14:07:30 -0600 | [diff] [blame] | 36 | fadt->sci_int = 9; /* HUDSON 1 - IRQ 09 - ACPI SCI */ |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 37 | |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 38 | val = PM1_EVT_BLK_ADDRESS; |
| 39 | WritePMIO(SB_PMIOA_REG60, AccWidthUint16, &val); |
| 40 | val = PM1_CNT_BLK_ADDRESS; |
| 41 | WritePMIO(SB_PMIOA_REG62, AccWidthUint16, &val); |
| 42 | val = PM1_TMR_BLK_ADDRESS; |
| 43 | WritePMIO(SB_PMIOA_REG64, AccWidthUint16, &val); |
| 44 | val = GPE0_BLK_ADDRESS; |
| 45 | WritePMIO(SB_PMIOA_REG68, AccWidthUint16, &val); |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 46 | |
Timothy Pearson | 033bb4b | 2015-02-10 22:21:39 -0600 | [diff] [blame] | 47 | /* CpuControl is in \_PR.CP00, 6 bytes */ |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 48 | val = CPU_CNT_BLK_ADDRESS; |
| 49 | WritePMIO(SB_PMIOA_REG66, AccWidthUint16, &val); |
| 50 | val = 0; |
| 51 | WritePMIO(SB_PMIOA_REG6A, AccWidthUint16, &val); |
| 52 | val = ACPI_PMA_CNT_BLK_ADDRESS; |
Martin Roth | 9aa4389 | 2012-05-25 12:23:32 -0600 | [diff] [blame] | 53 | WritePMIO(SB_PMIOA_REG6E, AccWidthUint16, &val); |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 54 | |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 55 | /* AcpiDecodeEnable, When set, SB uses the contents of the |
| 56 | * PM registers at index 60-6B to decode ACPI I/O address. |
| 57 | * AcpiSmiEn & SmiCmdEn*/ |
| 58 | val = BIT0 | BIT1 | BIT2 | BIT4; |
| 59 | WritePMIO(SB_PMIOA_REG74, AccWidthUint16, &val); |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 60 | |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 61 | /* RTC_En_En, TMR_En_En, GBL_EN_EN */ |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 62 | outl(0x1, PM1_CNT_BLK_ADDRESS); /* set SCI_EN */ |
| 63 | fadt->pm1a_evt_blk = PM1_EVT_BLK_ADDRESS; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 64 | fadt->pm1b_evt_blk = 0x0000; |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 65 | fadt->pm1a_cnt_blk = PM1_CNT_BLK_ADDRESS; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 66 | fadt->pm1b_cnt_blk = 0x0000; |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 67 | fadt->pm2_cnt_blk = ACPI_PMA_CNT_BLK_ADDRESS; |
| 68 | fadt->pm_tmr_blk = PM1_TMR_BLK_ADDRESS; |
| 69 | fadt->gpe0_blk = GPE0_BLK_ADDRESS; |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 70 | fadt->gpe1_blk = 0; /* No gpe1 block in hudson1 */ |
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->pm1_evt_len = 4; /* 32 bits */ |
| 73 | fadt->pm1_cnt_len = 2; /* 16 bits */ |
| 74 | fadt->pm2_cnt_len = 1; /* 8 bits */ |
| 75 | fadt->pm_tmr_len = 4; /* 32 bits */ |
| 76 | fadt->gpe0_blk_len = 8; /* 64 bits */ |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 77 | fadt->gpe1_blk_len = 0; |
| 78 | fadt->gpe1_base = 0; |
| 79 | |
Martin Roth | 9aa4389 | 2012-05-25 12:23:32 -0600 | [diff] [blame] | 80 | fadt->p_lvl2_lat = ACPI_FADT_C2_NOT_SUPPORTED; |
| 81 | fadt->p_lvl3_lat = ACPI_FADT_C3_NOT_SUPPORTED; |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 82 | fadt->flush_size = 0; /* set to 0 if WBINVD is 1 in flags */ |
| 83 | fadt->flush_stride = 0; /* set to 0 if WBINVD is 1 in flags */ |
Martin Roth | 9aa4389 | 2012-05-25 12:23:32 -0600 | [diff] [blame] | 84 | fadt->duty_offset = 1; /* CLK_VAL bits 3:1 */ |
| 85 | fadt->duty_width = 3; /* CLK_VAL bits 3:1 */ |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 86 | fadt->day_alrm = 0; /* 0x7d these have to be */ |
| 87 | fadt->mon_alrm = 0; /* 0x7e added to cmos.layout */ |
Martin Roth | 3c3a50c | 2014-12-16 20:50:26 -0700 | [diff] [blame] | 88 | fadt->century = 0; /* 0x7f to make rtc alarm work */ |
Marc Jones | 7c9ef4f | 2012-05-10 11:02:32 -0600 | [diff] [blame] | 89 | fadt->iapc_boot_arch = FADT_BOOT_ARCH; /* See table 5-10 */ |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 90 | fadt->res2 = 0; /* reserved, MUST be 0 ACPI 3.0 */ |
| 91 | fadt->flags = ACPI_FADT_WBINVD | /* See table 5-10 ACPI 3.0a spec */ |
| 92 | ACPI_FADT_C1_SUPPORTED | |
| 93 | ACPI_FADT_SLEEP_BUTTON | |
| 94 | ACPI_FADT_S4_RTC_WAKE | |
| 95 | ACPI_FADT_32BIT_TIMER | |
| 96 | ACPI_FADT_RESET_REGISTER | |
| 97 | ACPI_FADT_PCI_EXPRESS_WAKE | |
| 98 | ACPI_FADT_S4_RTC_VALID | |
| 99 | ACPI_FADT_REMOTE_POWER_ON; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 100 | |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 101 | /* Format is from 5.2.3.1: Generic Address Structure */ |
| 102 | /* reset_reg: see section 4.7.3.6 ACPI 3.0a spec */ |
| 103 | /* 8 bit write of value 0x06 to 0xCF9 in IO space */ |
| 104 | fadt->reset_reg.space_id = ACPI_ADDRESS_SPACE_IO; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 105 | fadt->reset_reg.bit_width = 8; |
| 106 | fadt->reset_reg.bit_offset = 0; |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 107 | fadt->reset_reg.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 108 | fadt->reset_reg.addrl = 0xcf9; |
| 109 | fadt->reset_reg.addrh = 0x0; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 110 | fadt->reset_value = 6; |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 111 | |
Elyes HAOUAS | f5b974e | 2018-11-10 20:29:08 +0100 | [diff] [blame] | 112 | fadt->ARM_boot_arch = 0; /* MUST be 0 ACPI 3.0 */ |
| 113 | fadt->FADT_MinorVersion = 0; /* MUST be 0 ACPI 3.0 */ |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 114 | |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 115 | fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 116 | fadt->x_pm1a_evt_blk.bit_width = 32; |
| 117 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
Martin Roth | 9aa4389 | 2012-05-25 12:23:32 -0600 | [diff] [blame] | 118 | fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 119 | fadt->x_pm1a_evt_blk.addrl = PM1_EVT_BLK_ADDRESS; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 120 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 121 | |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 122 | fadt->x_pm1b_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 123 | fadt->x_pm1b_evt_blk.bit_width = 0; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 124 | fadt->x_pm1b_evt_blk.bit_offset = 0; |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 125 | fadt->x_pm1b_evt_blk.access_size = 0; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 126 | fadt->x_pm1b_evt_blk.addrl = 0x0; |
| 127 | fadt->x_pm1b_evt_blk.addrh = 0x0; |
| 128 | |
| 129 | |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 130 | fadt->x_pm1a_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 131 | fadt->x_pm1a_cnt_blk.bit_width = 16; |
| 132 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 133 | fadt->x_pm1a_cnt_blk.access_size = 0; |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 134 | fadt->x_pm1a_cnt_blk.addrl = PM1_CNT_BLK_ADDRESS; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 135 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 136 | |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 137 | fadt->x_pm1b_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 138 | fadt->x_pm1b_cnt_blk.bit_width = 0; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 139 | fadt->x_pm1b_cnt_blk.bit_offset = 0; |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 140 | fadt->x_pm1b_cnt_blk.access_size = 0; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 141 | fadt->x_pm1b_cnt_blk.addrl = 0x0; |
| 142 | fadt->x_pm1b_cnt_blk.addrh = 0x0; |
| 143 | |
| 144 | |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 145 | fadt->x_pm2_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 146 | fadt->x_pm2_cnt_blk.bit_width = 8; /* Hudson 1 Pm2Control is 8 bits */ |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 147 | fadt->x_pm2_cnt_blk.bit_offset = 0; |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 148 | fadt->x_pm2_cnt_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 149 | fadt->x_pm2_cnt_blk.addrl = ACPI_PMA_CNT_BLK_ADDRESS; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 150 | fadt->x_pm2_cnt_blk.addrh = 0x0; |
| 151 | |
| 152 | |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 153 | fadt->x_pm_tmr_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 154 | fadt->x_pm_tmr_blk.bit_width = 32; |
| 155 | fadt->x_pm_tmr_blk.bit_offset = 0; |
Martin Roth | 9aa4389 | 2012-05-25 12:23:32 -0600 | [diff] [blame] | 156 | fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 157 | fadt->x_pm_tmr_blk.addrl = PM1_TMR_BLK_ADDRESS; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 158 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 159 | |
| 160 | |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 161 | fadt->x_gpe0_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Martin Roth | 9aa4389 | 2012-05-25 12:23:32 -0600 | [diff] [blame] | 162 | fadt->x_gpe0_blk.bit_width = 64; /* EventStatus + Event Enable */ |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 163 | fadt->x_gpe0_blk.bit_offset = 0; |
Angel Pons | a23aff3 | 2020-06-21 20:47:54 +0200 | [diff] [blame^] | 164 | fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 165 | fadt->x_gpe0_blk.addrl = GPE0_BLK_ADDRESS; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 166 | fadt->x_gpe0_blk.addrh = 0x0; |
| 167 | |
| 168 | |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 169 | fadt->x_gpe1_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 170 | fadt->x_gpe1_blk.bit_width = 0; |
| 171 | fadt->x_gpe1_blk.bit_offset = 0; |
Marc Jones | b547c4f | 2012-05-09 15:34:49 -0600 | [diff] [blame] | 172 | fadt->x_gpe1_blk.access_size = 0; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 173 | fadt->x_gpe1_blk.addrl = 0; |
| 174 | fadt->x_gpe1_blk.addrh = 0x0; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 175 | } |