Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Bin Meng | 483b548 | 2016-05-25 19:19:11 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2016, Bin Meng <bmeng.cn@gmail.com> |
Bin Meng | 483b548 | 2016-05-25 19:19:11 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Heinrich Schuchardt | ec95806 | 2023-12-16 09:11:57 +0100 | [diff] [blame^] | 7 | #include <mapmem.h> |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 8 | #include <acpi/acpi_table.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 9 | #include <asm/processor.h> |
Bin Meng | 483b548 | 2016-05-25 19:19:11 -0700 | [diff] [blame] | 10 | #include <asm/tables.h> |
Bin Meng | 0562f0d | 2016-06-17 02:13:15 -0700 | [diff] [blame] | 11 | #include <asm/arch/global_nvs.h> |
Bin Meng | 483b548 | 2016-05-25 19:19:11 -0700 | [diff] [blame] | 12 | #include <asm/arch/iomap.h> |
| 13 | |
Simon Glass | 9bd6b62 | 2023-09-01 11:27:09 -0600 | [diff] [blame] | 14 | static int quark_write_fadt(struct acpi_ctx *ctx, |
| 15 | const struct acpi_writer *entry) |
Bin Meng | 483b548 | 2016-05-25 19:19:11 -0700 | [diff] [blame] | 16 | { |
Bin Meng | 483b548 | 2016-05-25 19:19:11 -0700 | [diff] [blame] | 17 | u16 pmbase = ACPI_PM1_BASE_ADDRESS; |
Simon Glass | 9bd6b62 | 2023-09-01 11:27:09 -0600 | [diff] [blame] | 18 | struct acpi_table_header *header; |
| 19 | struct acpi_fadt *fadt; |
Bin Meng | 483b548 | 2016-05-25 19:19:11 -0700 | [diff] [blame] | 20 | |
Simon Glass | 9bd6b62 | 2023-09-01 11:27:09 -0600 | [diff] [blame] | 21 | fadt = ctx->current; |
| 22 | header = &fadt->header; |
| 23 | |
| 24 | memset(fadt, '\0', sizeof(struct acpi_fadt)); |
Bin Meng | 483b548 | 2016-05-25 19:19:11 -0700 | [diff] [blame] | 25 | |
| 26 | acpi_fill_header(header, "FACP"); |
| 27 | header->length = sizeof(struct acpi_fadt); |
| 28 | header->revision = 4; |
| 29 | |
Bin Meng | 483b548 | 2016-05-25 19:19:11 -0700 | [diff] [blame] | 30 | fadt->preferred_pm_profile = ACPI_PM_UNSPECIFIED; |
| 31 | fadt->sci_int = 9; |
| 32 | fadt->smi_cmd = 0; |
| 33 | fadt->acpi_enable = 0; |
| 34 | fadt->acpi_disable = 0; |
| 35 | fadt->s4bios_req = 0; |
| 36 | fadt->pstate_cnt = 0; |
| 37 | fadt->pm1a_evt_blk = pmbase; |
| 38 | fadt->pm1b_evt_blk = 0x0; |
| 39 | fadt->pm1a_cnt_blk = pmbase + 0x4; |
| 40 | fadt->pm1b_cnt_blk = 0x0; |
| 41 | fadt->pm2_cnt_blk = 0x0; |
| 42 | fadt->pm_tmr_blk = pmbase + 0x8; |
| 43 | fadt->gpe0_blk = ACPI_GPE0_BASE_ADDRESS; |
| 44 | fadt->gpe1_blk = 0; |
| 45 | fadt->pm1_evt_len = 4; |
| 46 | fadt->pm1_cnt_len = 2; |
| 47 | fadt->pm2_cnt_len = 0; |
| 48 | fadt->pm_tmr_len = 4; |
| 49 | fadt->gpe0_blk_len = 8; |
| 50 | fadt->gpe1_blk_len = 0; |
| 51 | fadt->gpe1_base = 0; |
| 52 | fadt->cst_cnt = 0; |
| 53 | fadt->p_lvl2_lat = ACPI_FADT_C2_NOT_SUPPORTED; |
| 54 | fadt->p_lvl3_lat = ACPI_FADT_C3_NOT_SUPPORTED; |
| 55 | fadt->flush_size = 0; |
| 56 | fadt->flush_stride = 0; |
| 57 | fadt->duty_offset = 1; |
| 58 | fadt->duty_width = 3; |
| 59 | fadt->day_alrm = 0x00; |
| 60 | fadt->mon_alrm = 0x00; |
| 61 | fadt->century = 0x00; |
| 62 | fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES; |
| 63 | fadt->flags = ACPI_FADT_WBINVD | ACPI_FADT_C1_SUPPORTED | |
| 64 | ACPI_FADT_POWER_BUTTON | ACPI_FADT_SLEEP_BUTTON | |
| 65 | ACPI_FADT_S4_RTC_WAKE | ACPI_FADT_RESET_REGISTER | |
| 66 | ACPI_FADT_PLATFORM_CLOCK; |
| 67 | |
| 68 | fadt->reset_reg.space_id = ACPI_ADDRESS_SPACE_IO; |
| 69 | fadt->reset_reg.bit_width = 8; |
| 70 | fadt->reset_reg.bit_offset = 0; |
| 71 | fadt->reset_reg.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
| 72 | fadt->reset_reg.addrl = IO_PORT_RESET; |
| 73 | fadt->reset_reg.addrh = 0; |
Bin Meng | 54d55a4 | 2018-07-03 02:48:39 -0700 | [diff] [blame] | 74 | fadt->reset_value = SYS_RST | RST_CPU | FULL_RST; |
Bin Meng | 483b548 | 2016-05-25 19:19:11 -0700 | [diff] [blame] | 75 | |
Heinrich Schuchardt | ec95806 | 2023-12-16 09:11:57 +0100 | [diff] [blame^] | 76 | fadt->x_firmware_ctrl = map_to_sysmem(ctx->facs); |
| 77 | fadt->x_dsdt = map_to_sysmem(ctx->dsdt); |
Bin Meng | 483b548 | 2016-05-25 19:19:11 -0700 | [diff] [blame] | 78 | |
| 79 | fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 80 | fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8; |
| 81 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
| 82 | fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
| 83 | fadt->x_pm1a_evt_blk.addrl = fadt->pm1a_evt_blk; |
| 84 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 85 | |
| 86 | fadt->x_pm1b_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 87 | fadt->x_pm1b_evt_blk.bit_width = 0; |
| 88 | fadt->x_pm1b_evt_blk.bit_offset = 0; |
| 89 | fadt->x_pm1b_evt_blk.access_size = 0; |
| 90 | fadt->x_pm1b_evt_blk.addrl = 0x0; |
| 91 | fadt->x_pm1b_evt_blk.addrh = 0x0; |
| 92 | |
| 93 | fadt->x_pm1a_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 94 | fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8; |
| 95 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
| 96 | fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
| 97 | fadt->x_pm1a_cnt_blk.addrl = fadt->pm1a_cnt_blk; |
| 98 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 99 | |
| 100 | fadt->x_pm1b_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 101 | fadt->x_pm1b_cnt_blk.bit_width = 0; |
| 102 | fadt->x_pm1b_cnt_blk.bit_offset = 0; |
| 103 | fadt->x_pm1b_cnt_blk.access_size = 0; |
| 104 | fadt->x_pm1b_cnt_blk.addrl = 0x0; |
| 105 | fadt->x_pm1b_cnt_blk.addrh = 0x0; |
| 106 | |
| 107 | fadt->x_pm2_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 108 | fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8; |
| 109 | fadt->x_pm2_cnt_blk.bit_offset = 0; |
| 110 | fadt->x_pm2_cnt_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
| 111 | fadt->x_pm2_cnt_blk.addrl = fadt->pm2_cnt_blk; |
| 112 | fadt->x_pm2_cnt_blk.addrh = 0x0; |
| 113 | |
| 114 | fadt->x_pm_tmr_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 115 | fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8; |
| 116 | fadt->x_pm_tmr_blk.bit_offset = 0; |
| 117 | fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
| 118 | fadt->x_pm_tmr_blk.addrl = fadt->pm_tmr_blk; |
| 119 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 120 | |
| 121 | fadt->x_gpe0_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 122 | fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8; |
| 123 | fadt->x_gpe0_blk.bit_offset = 0; |
| 124 | fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
| 125 | fadt->x_gpe0_blk.addrl = fadt->gpe0_blk; |
| 126 | fadt->x_gpe0_blk.addrh = 0x0; |
| 127 | |
| 128 | fadt->x_gpe1_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 129 | fadt->x_gpe1_blk.bit_width = 0; |
| 130 | fadt->x_gpe1_blk.bit_offset = 0; |
| 131 | fadt->x_gpe1_blk.access_size = 0; |
| 132 | fadt->x_gpe1_blk.addrl = 0x0; |
| 133 | fadt->x_gpe1_blk.addrh = 0x0; |
| 134 | |
| 135 | header->checksum = table_compute_checksum(fadt, header->length); |
Simon Glass | 9bd6b62 | 2023-09-01 11:27:09 -0600 | [diff] [blame] | 136 | |
Andy Shevchenko | 6f15ab7 | 2023-09-01 11:27:10 -0600 | [diff] [blame] | 137 | return acpi_add_fadt(ctx, fadt); |
Bin Meng | 483b548 | 2016-05-25 19:19:11 -0700 | [diff] [blame] | 138 | } |
Simon Glass | 9bd6b62 | 2023-09-01 11:27:09 -0600 | [diff] [blame] | 139 | ACPI_WRITER(5fadt, "FADT", quark_write_fadt, 0); |
Bin Meng | 483b548 | 2016-05-25 19:19:11 -0700 | [diff] [blame] | 140 | |
Simon Glass | 9ed41e7 | 2020-07-07 21:32:05 -0600 | [diff] [blame] | 141 | int acpi_create_gnvs(struct acpi_global_nvs *gnvs) |
Bin Meng | 0562f0d | 2016-06-17 02:13:15 -0700 | [diff] [blame] | 142 | { |
| 143 | /* quark is a uni-processor */ |
| 144 | gnvs->pcnt = 1; |
Simon Glass | 9ed41e7 | 2020-07-07 21:32:05 -0600 | [diff] [blame] | 145 | |
| 146 | return 0; |
Bin Meng | 0562f0d | 2016-06-17 02:13:15 -0700 | [diff] [blame] | 147 | } |