blob: 82b776ff65f69e3e775c574c065af8b56e84f744 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Bin Meng483b5482016-05-25 19:19:11 -07002/*
3 * Copyright (C) 2016, Bin Meng <bmeng.cn@gmail.com>
Bin Meng483b5482016-05-25 19:19:11 -07004 */
5
6#include <common.h>
Simon Glass858fed12020-04-08 16:57:36 -06007#include <acpi/acpi_table.h>
Simon Glass3ba929a2020-10-30 21:38:53 -06008#include <asm/processor.h>
Bin Meng483b5482016-05-25 19:19:11 -07009#include <asm/tables.h>
Bin Meng0562f0d2016-06-17 02:13:15 -070010#include <asm/arch/global_nvs.h>
Bin Meng483b5482016-05-25 19:19:11 -070011#include <asm/arch/iomap.h>
12
Andy Shevchenko33e030b2022-03-30 18:49:18 +030013void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs,
14 void *dsdt)
Bin Meng483b5482016-05-25 19:19:11 -070015{
Andy Shevchenko33e030b2022-03-30 18:49:18 +030016 struct acpi_table_header *header = &(fadt->header);
Bin Meng483b5482016-05-25 19:19:11 -070017 u16 pmbase = ACPI_PM1_BASE_ADDRESS;
18
Andy Shevchenko33e030b2022-03-30 18:49:18 +030019 memset((void *)fadt, 0, sizeof(struct acpi_fadt));
Bin Meng483b5482016-05-25 19:19:11 -070020
21 acpi_fill_header(header, "FACP");
22 header->length = sizeof(struct acpi_fadt);
23 header->revision = 4;
24
Andy Shevchenko33e030b2022-03-30 18:49:18 +030025 fadt->firmware_ctrl = (u32)facs;
26 fadt->dsdt = (u32)dsdt;
Bin Meng483b5482016-05-25 19:19:11 -070027 fadt->preferred_pm_profile = ACPI_PM_UNSPECIFIED;
28 fadt->sci_int = 9;
29 fadt->smi_cmd = 0;
30 fadt->acpi_enable = 0;
31 fadt->acpi_disable = 0;
32 fadt->s4bios_req = 0;
33 fadt->pstate_cnt = 0;
34 fadt->pm1a_evt_blk = pmbase;
35 fadt->pm1b_evt_blk = 0x0;
36 fadt->pm1a_cnt_blk = pmbase + 0x4;
37 fadt->pm1b_cnt_blk = 0x0;
38 fadt->pm2_cnt_blk = 0x0;
39 fadt->pm_tmr_blk = pmbase + 0x8;
40 fadt->gpe0_blk = ACPI_GPE0_BASE_ADDRESS;
41 fadt->gpe1_blk = 0;
42 fadt->pm1_evt_len = 4;
43 fadt->pm1_cnt_len = 2;
44 fadt->pm2_cnt_len = 0;
45 fadt->pm_tmr_len = 4;
46 fadt->gpe0_blk_len = 8;
47 fadt->gpe1_blk_len = 0;
48 fadt->gpe1_base = 0;
49 fadt->cst_cnt = 0;
50 fadt->p_lvl2_lat = ACPI_FADT_C2_NOT_SUPPORTED;
51 fadt->p_lvl3_lat = ACPI_FADT_C3_NOT_SUPPORTED;
52 fadt->flush_size = 0;
53 fadt->flush_stride = 0;
54 fadt->duty_offset = 1;
55 fadt->duty_width = 3;
56 fadt->day_alrm = 0x00;
57 fadt->mon_alrm = 0x00;
58 fadt->century = 0x00;
59 fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES;
60 fadt->flags = ACPI_FADT_WBINVD | ACPI_FADT_C1_SUPPORTED |
61 ACPI_FADT_POWER_BUTTON | ACPI_FADT_SLEEP_BUTTON |
62 ACPI_FADT_S4_RTC_WAKE | ACPI_FADT_RESET_REGISTER |
63 ACPI_FADT_PLATFORM_CLOCK;
64
65 fadt->reset_reg.space_id = ACPI_ADDRESS_SPACE_IO;
66 fadt->reset_reg.bit_width = 8;
67 fadt->reset_reg.bit_offset = 0;
68 fadt->reset_reg.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
69 fadt->reset_reg.addrl = IO_PORT_RESET;
70 fadt->reset_reg.addrh = 0;
Bin Meng54d55a42018-07-03 02:48:39 -070071 fadt->reset_value = SYS_RST | RST_CPU | FULL_RST;
Bin Meng483b5482016-05-25 19:19:11 -070072
Andy Shevchenko33e030b2022-03-30 18:49:18 +030073 fadt->x_firmware_ctl_l = (u32)facs;
Bin Meng483b5482016-05-25 19:19:11 -070074 fadt->x_firmware_ctl_h = 0;
Andy Shevchenko33e030b2022-03-30 18:49:18 +030075 fadt->x_dsdt_l = (u32)dsdt;
Bin Meng483b5482016-05-25 19:19:11 -070076 fadt->x_dsdt_h = 0;
77
78 fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
79 fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
80 fadt->x_pm1a_evt_blk.bit_offset = 0;
81 fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
82 fadt->x_pm1a_evt_blk.addrl = fadt->pm1a_evt_blk;
83 fadt->x_pm1a_evt_blk.addrh = 0x0;
84
85 fadt->x_pm1b_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
86 fadt->x_pm1b_evt_blk.bit_width = 0;
87 fadt->x_pm1b_evt_blk.bit_offset = 0;
88 fadt->x_pm1b_evt_blk.access_size = 0;
89 fadt->x_pm1b_evt_blk.addrl = 0x0;
90 fadt->x_pm1b_evt_blk.addrh = 0x0;
91
92 fadt->x_pm1a_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
93 fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
94 fadt->x_pm1a_cnt_blk.bit_offset = 0;
95 fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS;
96 fadt->x_pm1a_cnt_blk.addrl = fadt->pm1a_cnt_blk;
97 fadt->x_pm1a_cnt_blk.addrh = 0x0;
98
99 fadt->x_pm1b_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
100 fadt->x_pm1b_cnt_blk.bit_width = 0;
101 fadt->x_pm1b_cnt_blk.bit_offset = 0;
102 fadt->x_pm1b_cnt_blk.access_size = 0;
103 fadt->x_pm1b_cnt_blk.addrl = 0x0;
104 fadt->x_pm1b_cnt_blk.addrh = 0x0;
105
106 fadt->x_pm2_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
107 fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8;
108 fadt->x_pm2_cnt_blk.bit_offset = 0;
109 fadt->x_pm2_cnt_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
110 fadt->x_pm2_cnt_blk.addrl = fadt->pm2_cnt_blk;
111 fadt->x_pm2_cnt_blk.addrh = 0x0;
112
113 fadt->x_pm_tmr_blk.space_id = ACPI_ADDRESS_SPACE_IO;
114 fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8;
115 fadt->x_pm_tmr_blk.bit_offset = 0;
116 fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
117 fadt->x_pm_tmr_blk.addrl = fadt->pm_tmr_blk;
118 fadt->x_pm_tmr_blk.addrh = 0x0;
119
120 fadt->x_gpe0_blk.space_id = ACPI_ADDRESS_SPACE_IO;
121 fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8;
122 fadt->x_gpe0_blk.bit_offset = 0;
123 fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
124 fadt->x_gpe0_blk.addrl = fadt->gpe0_blk;
125 fadt->x_gpe0_blk.addrh = 0x0;
126
127 fadt->x_gpe1_blk.space_id = ACPI_ADDRESS_SPACE_IO;
128 fadt->x_gpe1_blk.bit_width = 0;
129 fadt->x_gpe1_blk.bit_offset = 0;
130 fadt->x_gpe1_blk.access_size = 0;
131 fadt->x_gpe1_blk.addrl = 0x0;
132 fadt->x_gpe1_blk.addrh = 0x0;
133
134 header->checksum = table_compute_checksum(fadt, header->length);
135}
136
Simon Glass9ed41e72020-07-07 21:32:05 -0600137int acpi_create_gnvs(struct acpi_global_nvs *gnvs)
Bin Meng0562f0d2016-06-17 02:13:15 -0700138{
139 /* quark is a uni-processor */
140 gnvs->pcnt = 1;
Simon Glass9ed41e72020-07-07 21:32:05 -0600141
142 return 0;
Bin Meng0562f0d2016-06-17 02:13:15 -0700143}