blob: 9a2d682451be89bde49708f8c9a05dc986c6f41c [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
Simon Glass9bd6b622023-09-01 11:27:09 -060013static int quark_write_fadt(struct acpi_ctx *ctx,
14 const struct acpi_writer *entry)
Bin Meng483b5482016-05-25 19:19:11 -070015{
Bin Meng483b5482016-05-25 19:19:11 -070016 u16 pmbase = ACPI_PM1_BASE_ADDRESS;
Simon Glass9bd6b622023-09-01 11:27:09 -060017 struct acpi_table_header *header;
18 struct acpi_fadt *fadt;
Bin Meng483b5482016-05-25 19:19:11 -070019
Simon Glass9bd6b622023-09-01 11:27:09 -060020 fadt = ctx->current;
21 header = &fadt->header;
22
23 memset(fadt, '\0', sizeof(struct acpi_fadt));
Bin Meng483b5482016-05-25 19:19:11 -070024
25 acpi_fill_header(header, "FACP");
26 header->length = sizeof(struct acpi_fadt);
27 header->revision = 4;
28
Simon Glass9bd6b622023-09-01 11:27:09 -060029 fadt->firmware_ctrl = (u32)ctx->facs;
30 fadt->dsdt = (u32)ctx->dsdt;
Bin Meng483b5482016-05-25 19:19:11 -070031 fadt->preferred_pm_profile = ACPI_PM_UNSPECIFIED;
32 fadt->sci_int = 9;
33 fadt->smi_cmd = 0;
34 fadt->acpi_enable = 0;
35 fadt->acpi_disable = 0;
36 fadt->s4bios_req = 0;
37 fadt->pstate_cnt = 0;
38 fadt->pm1a_evt_blk = pmbase;
39 fadt->pm1b_evt_blk = 0x0;
40 fadt->pm1a_cnt_blk = pmbase + 0x4;
41 fadt->pm1b_cnt_blk = 0x0;
42 fadt->pm2_cnt_blk = 0x0;
43 fadt->pm_tmr_blk = pmbase + 0x8;
44 fadt->gpe0_blk = ACPI_GPE0_BASE_ADDRESS;
45 fadt->gpe1_blk = 0;
46 fadt->pm1_evt_len = 4;
47 fadt->pm1_cnt_len = 2;
48 fadt->pm2_cnt_len = 0;
49 fadt->pm_tmr_len = 4;
50 fadt->gpe0_blk_len = 8;
51 fadt->gpe1_blk_len = 0;
52 fadt->gpe1_base = 0;
53 fadt->cst_cnt = 0;
54 fadt->p_lvl2_lat = ACPI_FADT_C2_NOT_SUPPORTED;
55 fadt->p_lvl3_lat = ACPI_FADT_C3_NOT_SUPPORTED;
56 fadt->flush_size = 0;
57 fadt->flush_stride = 0;
58 fadt->duty_offset = 1;
59 fadt->duty_width = 3;
60 fadt->day_alrm = 0x00;
61 fadt->mon_alrm = 0x00;
62 fadt->century = 0x00;
63 fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES;
64 fadt->flags = ACPI_FADT_WBINVD | ACPI_FADT_C1_SUPPORTED |
65 ACPI_FADT_POWER_BUTTON | ACPI_FADT_SLEEP_BUTTON |
66 ACPI_FADT_S4_RTC_WAKE | ACPI_FADT_RESET_REGISTER |
67 ACPI_FADT_PLATFORM_CLOCK;
68
69 fadt->reset_reg.space_id = ACPI_ADDRESS_SPACE_IO;
70 fadt->reset_reg.bit_width = 8;
71 fadt->reset_reg.bit_offset = 0;
72 fadt->reset_reg.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
73 fadt->reset_reg.addrl = IO_PORT_RESET;
74 fadt->reset_reg.addrh = 0;
Bin Meng54d55a42018-07-03 02:48:39 -070075 fadt->reset_value = SYS_RST | RST_CPU | FULL_RST;
Bin Meng483b5482016-05-25 19:19:11 -070076
Simon Glass9bd6b622023-09-01 11:27:09 -060077 fadt->x_firmware_ctl_l = (u32)ctx->facs;
Bin Meng483b5482016-05-25 19:19:11 -070078 fadt->x_firmware_ctl_h = 0;
Simon Glass9bd6b622023-09-01 11:27:09 -060079 fadt->x_dsdt_l = (u32)ctx->dsdt;
Bin Meng483b5482016-05-25 19:19:11 -070080 fadt->x_dsdt_h = 0;
81
82 fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
83 fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
84 fadt->x_pm1a_evt_blk.bit_offset = 0;
85 fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
86 fadt->x_pm1a_evt_blk.addrl = fadt->pm1a_evt_blk;
87 fadt->x_pm1a_evt_blk.addrh = 0x0;
88
89 fadt->x_pm1b_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
90 fadt->x_pm1b_evt_blk.bit_width = 0;
91 fadt->x_pm1b_evt_blk.bit_offset = 0;
92 fadt->x_pm1b_evt_blk.access_size = 0;
93 fadt->x_pm1b_evt_blk.addrl = 0x0;
94 fadt->x_pm1b_evt_blk.addrh = 0x0;
95
96 fadt->x_pm1a_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
97 fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
98 fadt->x_pm1a_cnt_blk.bit_offset = 0;
99 fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS;
100 fadt->x_pm1a_cnt_blk.addrl = fadt->pm1a_cnt_blk;
101 fadt->x_pm1a_cnt_blk.addrh = 0x0;
102
103 fadt->x_pm1b_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
104 fadt->x_pm1b_cnt_blk.bit_width = 0;
105 fadt->x_pm1b_cnt_blk.bit_offset = 0;
106 fadt->x_pm1b_cnt_blk.access_size = 0;
107 fadt->x_pm1b_cnt_blk.addrl = 0x0;
108 fadt->x_pm1b_cnt_blk.addrh = 0x0;
109
110 fadt->x_pm2_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
111 fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8;
112 fadt->x_pm2_cnt_blk.bit_offset = 0;
113 fadt->x_pm2_cnt_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
114 fadt->x_pm2_cnt_blk.addrl = fadt->pm2_cnt_blk;
115 fadt->x_pm2_cnt_blk.addrh = 0x0;
116
117 fadt->x_pm_tmr_blk.space_id = ACPI_ADDRESS_SPACE_IO;
118 fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8;
119 fadt->x_pm_tmr_blk.bit_offset = 0;
120 fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
121 fadt->x_pm_tmr_blk.addrl = fadt->pm_tmr_blk;
122 fadt->x_pm_tmr_blk.addrh = 0x0;
123
124 fadt->x_gpe0_blk.space_id = ACPI_ADDRESS_SPACE_IO;
125 fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8;
126 fadt->x_gpe0_blk.bit_offset = 0;
127 fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
128 fadt->x_gpe0_blk.addrl = fadt->gpe0_blk;
129 fadt->x_gpe0_blk.addrh = 0x0;
130
131 fadt->x_gpe1_blk.space_id = ACPI_ADDRESS_SPACE_IO;
132 fadt->x_gpe1_blk.bit_width = 0;
133 fadt->x_gpe1_blk.bit_offset = 0;
134 fadt->x_gpe1_blk.access_size = 0;
135 fadt->x_gpe1_blk.addrl = 0x0;
136 fadt->x_gpe1_blk.addrh = 0x0;
137
138 header->checksum = table_compute_checksum(fadt, header->length);
Simon Glass9bd6b622023-09-01 11:27:09 -0600139
Andy Shevchenko6f15ab72023-09-01 11:27:10 -0600140 return acpi_add_fadt(ctx, fadt);
Bin Meng483b5482016-05-25 19:19:11 -0700141}
Simon Glass9bd6b622023-09-01 11:27:09 -0600142ACPI_WRITER(5fadt, "FADT", quark_write_fadt, 0);
Bin Meng483b5482016-05-25 19:19:11 -0700143
Simon Glass9ed41e72020-07-07 21:32:05 -0600144int acpi_create_gnvs(struct acpi_global_nvs *gnvs)
Bin Meng0562f0d2016-06-17 02:13:15 -0700145{
146 /* quark is a uni-processor */
147 gnvs->pcnt = 1;
Simon Glass9ed41e72020-07-07 21:32:05 -0600148
149 return 0;
Bin Meng0562f0d2016-06-17 02:13:15 -0700150}