blob: 6985ef4ba530ee42f09338d974a3280749e565fb [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Saket Sinha331141a2015-08-22 12:20:55 +05302/*
3 * Based on acpi.c from coreboot
4 *
5 * Copyright (C) 2015, Saket Sinha <saket.sinha89@gmail.com>
Bin Meng44256b02016-05-07 07:46:25 -07006 * Copyright (C) 2016, Bin Meng <bmeng.cn@gmail.com>
Saket Sinha331141a2015-08-22 12:20:55 +05307 */
8
9#include <common.h>
10#include <cpu.h>
11#include <dm.h>
Simon Glass0f2af882020-05-10 11:40:05 -060012#include <log.h>
Saket Sinha331141a2015-08-22 12:20:55 +053013#include <dm/uclass-internal.h>
Simon Glass0e113842020-04-26 09:19:47 -060014#include <mapmem.h>
Andy Shevchenko4ca48c92018-11-20 23:52:38 +020015#include <serial.h>
Andy Shevchenko87e95372017-07-21 22:32:02 +030016#include <version.h>
Simon Glass858fed12020-04-08 16:57:36 -060017#include <acpi/acpi_table.h>
Bin Mengd9050c62016-06-17 02:13:16 -070018#include <asm/acpi/global_nvs.h>
Andy Shevchenko13a5d872017-07-21 22:32:04 +030019#include <asm/ioapic.h>
Saket Sinha331141a2015-08-22 12:20:55 +053020#include <asm/lapic.h>
Andy Shevchenko13a5d872017-07-21 22:32:04 +030021#include <asm/mpspec.h>
Saket Sinha331141a2015-08-22 12:20:55 +053022#include <asm/tables.h>
Bin Mengd9050c62016-06-17 02:13:16 -070023#include <asm/arch/global_nvs.h>
Simon Glass0e113842020-04-26 09:19:47 -060024#include <dm/acpi.h>
Saket Sinha331141a2015-08-22 12:20:55 +053025
26/*
Bin Mengb063d5f2016-05-07 07:46:24 -070027 * IASL compiles the dsdt entries and writes the hex values
28 * to a C array AmlCode[] (see dsdt.c).
Saket Sinha331141a2015-08-22 12:20:55 +053029 */
30extern const unsigned char AmlCode[];
31
Andy Shevchenko66d3e632018-01-10 19:40:15 +020032/* ACPI RSDP address to be used in boot parameters */
Bin Menge1029252018-01-30 05:01:16 -080033static ulong acpi_rsdp_addr;
Andy Shevchenko66d3e632018-01-10 19:40:15 +020034
Bin Meng44256b02016-05-07 07:46:25 -070035static void acpi_create_facs(struct acpi_facs *facs)
36{
37 memset((void *)facs, 0, sizeof(struct acpi_facs));
38
39 memcpy(facs->signature, "FACS", 4);
40 facs->length = sizeof(struct acpi_facs);
41 facs->hardware_signature = 0;
42 facs->firmware_waking_vector = 0;
43 facs->global_lock = 0;
44 facs->flags = 0;
45 facs->x_firmware_waking_vector_l = 0;
46 facs->x_firmware_waking_vector_h = 0;
47 facs->version = 1;
48}
49
Saket Sinha331141a2015-08-22 12:20:55 +053050static int acpi_create_madt_lapic(struct acpi_madt_lapic *lapic,
Bin Meng44256b02016-05-07 07:46:25 -070051 u8 cpu, u8 apic)
Saket Sinha331141a2015-08-22 12:20:55 +053052{
Bin Meng44256b02016-05-07 07:46:25 -070053 lapic->type = ACPI_APIC_LAPIC;
Saket Sinha331141a2015-08-22 12:20:55 +053054 lapic->length = sizeof(struct acpi_madt_lapic);
Bin Meng44256b02016-05-07 07:46:25 -070055 lapic->flags = LOCAL_APIC_FLAG_ENABLED;
Saket Sinha331141a2015-08-22 12:20:55 +053056 lapic->processor_id = cpu;
57 lapic->apic_id = apic;
58
59 return lapic->length;
60}
61
Bin Meng3c5234e2016-05-07 07:46:30 -070062int acpi_create_madt_lapics(u32 current)
Saket Sinha331141a2015-08-22 12:20:55 +053063{
64 struct udevice *dev;
George McCollister5a49f872016-06-07 13:40:18 -050065 int total_length = 0;
Saket Sinha331141a2015-08-22 12:20:55 +053066
67 for (uclass_find_first_device(UCLASS_CPU, &dev);
68 dev;
69 uclass_find_next_device(&dev)) {
70 struct cpu_platdata *plat = dev_get_parent_platdata(dev);
George McCollister5a49f872016-06-07 13:40:18 -050071 int length = acpi_create_madt_lapic(
72 (struct acpi_madt_lapic *)current,
73 plat->cpu_id, plat->cpu_id);
Bin Meng3c5234e2016-05-07 07:46:30 -070074 current += length;
George McCollister5a49f872016-06-07 13:40:18 -050075 total_length += length;
Bin Meng44256b02016-05-07 07:46:25 -070076 }
77
George McCollister5a49f872016-06-07 13:40:18 -050078 return total_length;
Saket Sinha331141a2015-08-22 12:20:55 +053079}
80
Bin Meng44256b02016-05-07 07:46:25 -070081int acpi_create_madt_ioapic(struct acpi_madt_ioapic *ioapic, u8 id,
82 u32 addr, u32 gsi_base)
Saket Sinha331141a2015-08-22 12:20:55 +053083{
Bin Meng6a421582016-05-07 07:46:21 -070084 ioapic->type = ACPI_APIC_IOAPIC;
Saket Sinha331141a2015-08-22 12:20:55 +053085 ioapic->length = sizeof(struct acpi_madt_ioapic);
86 ioapic->reserved = 0x00;
87 ioapic->gsi_base = gsi_base;
88 ioapic->ioapic_id = id;
89 ioapic->ioapic_addr = addr;
90
91 return ioapic->length;
92}
93
94int acpi_create_madt_irqoverride(struct acpi_madt_irqoverride *irqoverride,
Bin Meng44256b02016-05-07 07:46:25 -070095 u8 bus, u8 source, u32 gsirq, u16 flags)
Saket Sinha331141a2015-08-22 12:20:55 +053096{
Bin Meng6a421582016-05-07 07:46:21 -070097 irqoverride->type = ACPI_APIC_IRQ_SRC_OVERRIDE;
Saket Sinha331141a2015-08-22 12:20:55 +053098 irqoverride->length = sizeof(struct acpi_madt_irqoverride);
99 irqoverride->bus = bus;
100 irqoverride->source = source;
101 irqoverride->gsirq = gsirq;
102 irqoverride->flags = flags;
103
104 return irqoverride->length;
105}
106
107int acpi_create_madt_lapic_nmi(struct acpi_madt_lapic_nmi *lapic_nmi,
Bin Meng44256b02016-05-07 07:46:25 -0700108 u8 cpu, u16 flags, u8 lint)
Saket Sinha331141a2015-08-22 12:20:55 +0530109{
Bin Meng6a421582016-05-07 07:46:21 -0700110 lapic_nmi->type = ACPI_APIC_LAPIC_NMI;
Saket Sinha331141a2015-08-22 12:20:55 +0530111 lapic_nmi->length = sizeof(struct acpi_madt_lapic_nmi);
112 lapic_nmi->flags = flags;
113 lapic_nmi->processor_id = cpu;
114 lapic_nmi->lint = lint;
115
116 return lapic_nmi->length;
117}
118
Andy Shevchenko13a5d872017-07-21 22:32:04 +0300119static int acpi_create_madt_irq_overrides(u32 current)
120{
121 struct acpi_madt_irqoverride *irqovr;
122 u16 sci_flags = MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_HIGH;
123 int length = 0;
124
125 irqovr = (void *)current;
126 length += acpi_create_madt_irqoverride(irqovr, 0, 0, 2, 0);
127
128 irqovr = (void *)(current + length);
129 length += acpi_create_madt_irqoverride(irqovr, 0, 9, 9, sci_flags);
130
131 return length;
132}
133
134__weak u32 acpi_fill_madt(u32 current)
135{
136 current += acpi_create_madt_lapics(current);
137
138 current += acpi_create_madt_ioapic((struct acpi_madt_ioapic *)current,
139 io_apic_read(IO_APIC_ID) >> 24, IO_APIC_ADDR, 0);
140
141 current += acpi_create_madt_irq_overrides(current);
142
143 return current;
144}
145
Saket Sinha331141a2015-08-22 12:20:55 +0530146static void acpi_create_madt(struct acpi_madt *madt)
147{
Bin Meng6a421582016-05-07 07:46:21 -0700148 struct acpi_table_header *header = &(madt->header);
Bin Menga1ec7db2016-05-07 07:46:26 -0700149 u32 current = (u32)madt + sizeof(struct acpi_madt);
Saket Sinha331141a2015-08-22 12:20:55 +0530150
151 memset((void *)madt, 0, sizeof(struct acpi_madt));
152
153 /* Fill out header fields */
Bin Mengb063d5f2016-05-07 07:46:24 -0700154 acpi_fill_header(header, "APIC");
Saket Sinha331141a2015-08-22 12:20:55 +0530155 header->length = sizeof(struct acpi_madt);
Bin Mengf662fe42016-05-07 07:46:28 -0700156 header->revision = 4;
Saket Sinha331141a2015-08-22 12:20:55 +0530157
158 madt->lapic_addr = LAPIC_DEFAULT_BASE;
Bin Meng6a421582016-05-07 07:46:21 -0700159 madt->flags = ACPI_MADT_PCAT_COMPAT;
Saket Sinha331141a2015-08-22 12:20:55 +0530160
161 current = acpi_fill_madt(current);
162
163 /* (Re)calculate length and checksum */
Bin Menga1ec7db2016-05-07 07:46:26 -0700164 header->length = current - (u32)madt;
Saket Sinha331141a2015-08-22 12:20:55 +0530165
166 header->checksum = table_compute_checksum((void *)madt, header->length);
167}
168
Andy Shevchenkoc1ae9802017-07-21 22:32:05 +0300169int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base,
170 u16 seg_nr, u8 start, u8 end)
Saket Sinha331141a2015-08-22 12:20:55 +0530171{
172 memset(mmconfig, 0, sizeof(*mmconfig));
Bin Meng6a421582016-05-07 07:46:21 -0700173 mmconfig->base_address_l = base;
174 mmconfig->base_address_h = 0;
Saket Sinha331141a2015-08-22 12:20:55 +0530175 mmconfig->pci_segment_group_number = seg_nr;
176 mmconfig->start_bus_number = start;
177 mmconfig->end_bus_number = end;
178
179 return sizeof(struct acpi_mcfg_mmconfig);
180}
181
Andy Shevchenkoc1ae9802017-07-21 22:32:05 +0300182__weak u32 acpi_fill_mcfg(u32 current)
Saket Sinha331141a2015-08-22 12:20:55 +0530183{
184 current += acpi_create_mcfg_mmconfig
185 ((struct acpi_mcfg_mmconfig *)current,
Bin Meng44256b02016-05-07 07:46:25 -0700186 CONFIG_PCIE_ECAM_BASE, 0x0, 0x0, 255);
Saket Sinha331141a2015-08-22 12:20:55 +0530187
188 return current;
189}
190
191/* MCFG is defined in the PCI Firmware Specification 3.0 */
192static void acpi_create_mcfg(struct acpi_mcfg *mcfg)
193{
Bin Meng6a421582016-05-07 07:46:21 -0700194 struct acpi_table_header *header = &(mcfg->header);
Bin Menga1ec7db2016-05-07 07:46:26 -0700195 u32 current = (u32)mcfg + sizeof(struct acpi_mcfg);
Saket Sinha331141a2015-08-22 12:20:55 +0530196
197 memset((void *)mcfg, 0, sizeof(struct acpi_mcfg));
198
199 /* Fill out header fields */
Bin Mengb063d5f2016-05-07 07:46:24 -0700200 acpi_fill_header(header, "MCFG");
Saket Sinha331141a2015-08-22 12:20:55 +0530201 header->length = sizeof(struct acpi_mcfg);
Bin Mengf662fe42016-05-07 07:46:28 -0700202 header->revision = 1;
Saket Sinha331141a2015-08-22 12:20:55 +0530203
204 current = acpi_fill_mcfg(current);
205
206 /* (Re)calculate length and checksum */
Bin Menga1ec7db2016-05-07 07:46:26 -0700207 header->length = current - (u32)mcfg;
Saket Sinha331141a2015-08-22 12:20:55 +0530208 header->checksum = table_compute_checksum((void *)mcfg, header->length);
209}
210
Andy Shevchenko607dbd12019-07-14 19:23:57 +0300211__weak u32 acpi_fill_csrt(u32 current)
212{
213 return current;
214}
215
216static void acpi_create_csrt(struct acpi_csrt *csrt)
217{
218 struct acpi_table_header *header = &(csrt->header);
219 u32 current = (u32)csrt + sizeof(struct acpi_csrt);
220
221 memset((void *)csrt, 0, sizeof(struct acpi_csrt));
222
223 /* Fill out header fields */
224 acpi_fill_header(header, "CSRT");
225 header->length = sizeof(struct acpi_csrt);
226 header->revision = 0;
227
228 current = acpi_fill_csrt(current);
229
230 /* (Re)calculate length and checksum */
231 header->length = current - (u32)csrt;
232 header->checksum = table_compute_checksum((void *)csrt, header->length);
233}
234
Andy Shevchenko4ca48c92018-11-20 23:52:38 +0200235static void acpi_create_spcr(struct acpi_spcr *spcr)
236{
237 struct acpi_table_header *header = &(spcr->header);
238 struct serial_device_info serial_info = {0};
239 ulong serial_address, serial_offset;
Simon Glassdaaff932018-12-28 14:23:08 -0700240 struct udevice *dev;
Andy Shevchenko4ca48c92018-11-20 23:52:38 +0200241 uint serial_config;
242 uint serial_width;
243 int access_size;
244 int space_id;
Andy Shevchenkobf9c8e32019-02-28 17:19:54 +0200245 int ret = -ENODEV;
Andy Shevchenko4ca48c92018-11-20 23:52:38 +0200246
247 /* Fill out header fields */
248 acpi_fill_header(header, "SPCR");
249 header->length = sizeof(struct acpi_spcr);
250 header->revision = 2;
251
Simon Glass896c1642018-12-28 14:23:10 -0700252 /* Read the device once, here. It is reused below */
Andy Shevchenkobf9c8e32019-02-28 17:19:54 +0200253 dev = gd->cur_serial_dev;
254 if (dev)
Simon Glass896c1642018-12-28 14:23:10 -0700255 ret = serial_getinfo(dev, &serial_info);
Andy Shevchenko4ca48c92018-11-20 23:52:38 +0200256 if (ret)
257 serial_info.type = SERIAL_CHIP_UNKNOWN;
258
259 /* Encode chip type */
260 switch (serial_info.type) {
261 case SERIAL_CHIP_16550_COMPATIBLE:
262 spcr->interface_type = ACPI_DBG2_16550_COMPATIBLE;
263 break;
264 case SERIAL_CHIP_UNKNOWN:
265 default:
266 spcr->interface_type = ACPI_DBG2_UNKNOWN;
267 break;
268 }
269
270 /* Encode address space */
271 switch (serial_info.addr_space) {
272 case SERIAL_ADDRESS_SPACE_MEMORY:
273 space_id = ACPI_ADDRESS_SPACE_MEMORY;
274 break;
275 case SERIAL_ADDRESS_SPACE_IO:
276 default:
277 space_id = ACPI_ADDRESS_SPACE_IO;
278 break;
279 }
280
281 serial_width = serial_info.reg_width * 8;
282 serial_offset = serial_info.reg_offset << serial_info.reg_shift;
283 serial_address = serial_info.addr + serial_offset;
284
285 /* Encode register access size */
286 switch (serial_info.reg_shift) {
287 case 0:
288 access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
289 break;
290 case 1:
291 access_size = ACPI_ACCESS_SIZE_WORD_ACCESS;
292 break;
293 case 2:
294 access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
295 break;
296 case 3:
297 access_size = ACPI_ACCESS_SIZE_QWORD_ACCESS;
298 break;
299 default:
300 access_size = ACPI_ACCESS_SIZE_UNDEFINED;
301 break;
302 }
303
304 debug("UART type %u @ %lx\n", spcr->interface_type, serial_address);
305
306 /* Fill GAS */
307 spcr->serial_port.space_id = space_id;
308 spcr->serial_port.bit_width = serial_width;
309 spcr->serial_port.bit_offset = 0;
310 spcr->serial_port.access_size = access_size;
311 spcr->serial_port.addrl = lower_32_bits(serial_address);
312 spcr->serial_port.addrh = upper_32_bits(serial_address);
313
314 /* Encode baud rate */
315 switch (serial_info.baudrate) {
316 case 9600:
317 spcr->baud_rate = 3;
318 break;
319 case 19200:
320 spcr->baud_rate = 4;
321 break;
322 case 57600:
323 spcr->baud_rate = 6;
324 break;
325 case 115200:
326 spcr->baud_rate = 7;
327 break;
328 default:
329 spcr->baud_rate = 0;
330 break;
331 }
332
Simon Glass896c1642018-12-28 14:23:10 -0700333 serial_config = SERIAL_DEFAULT_CONFIG;
334 if (dev)
Simon Glassdaaff932018-12-28 14:23:08 -0700335 ret = serial_getconfig(dev, &serial_config);
Andy Shevchenko4ca48c92018-11-20 23:52:38 +0200336
337 spcr->parity = SERIAL_GET_PARITY(serial_config);
338 spcr->stop_bits = SERIAL_GET_STOP(serial_config);
339
340 /* No PCI devices for now */
341 spcr->pci_device_id = 0xffff;
342 spcr->pci_vendor_id = 0xffff;
343
Andy Shevchenko225cc8a2020-02-27 17:21:56 +0200344 /*
345 * SPCR has no clue if the UART base clock speed is different
346 * to the default one. However, the SPCR 1.04 defines baud rate
347 * 0 as a preconfigured state of UART and OS is supposed not
348 * to touch the configuration of the serial device.
349 */
350 if (serial_info.clock != SERIAL_DEFAULT_CLOCK)
351 spcr->baud_rate = 0;
352
Andy Shevchenko4ca48c92018-11-20 23:52:38 +0200353 /* Fix checksum */
354 header->checksum = table_compute_checksum((void *)spcr, header->length);
355}
356
Miao Yan3b68c522016-01-20 01:57:06 -0800357/*
Andy Shevchenko4b05bac2018-01-10 19:33:10 +0200358 * QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c
Miao Yan3b68c522016-01-20 01:57:06 -0800359 */
Simon Glass0e113842020-04-26 09:19:47 -0600360ulong write_acpi_tables(ulong start_addr)
Saket Sinha331141a2015-08-22 12:20:55 +0530361{
Simon Glass0e113842020-04-26 09:19:47 -0600362 struct acpi_ctx sctx, *ctx = &sctx;
Saket Sinha331141a2015-08-22 12:20:55 +0530363 struct acpi_facs *facs;
Bin Meng6a421582016-05-07 07:46:21 -0700364 struct acpi_table_header *dsdt;
Saket Sinha331141a2015-08-22 12:20:55 +0530365 struct acpi_fadt *fadt;
366 struct acpi_mcfg *mcfg;
367 struct acpi_madt *madt;
Andy Shevchenko607dbd12019-07-14 19:23:57 +0300368 struct acpi_csrt *csrt;
Andy Shevchenko4ca48c92018-11-20 23:52:38 +0200369 struct acpi_spcr *spcr;
Simon Glass0e113842020-04-26 09:19:47 -0600370 void *start;
371 ulong addr;
Bin Mengd9050c62016-06-17 02:13:16 -0700372 int i;
Saket Sinha331141a2015-08-22 12:20:55 +0530373
Simon Glass0e113842020-04-26 09:19:47 -0600374 start = map_sysmem(start_addr, 0);
Saket Sinha331141a2015-08-22 12:20:55 +0530375
Simon Glass0e113842020-04-26 09:19:47 -0600376 debug("ACPI: Writing ACPI tables at %lx\n", start_addr);
Saket Sinha331141a2015-08-22 12:20:55 +0530377
Simon Glass9c442a62020-04-26 09:19:51 -0600378 acpi_setup_base_tables(ctx, start);
Saket Sinha331141a2015-08-22 12:20:55 +0530379
380 debug("ACPI: * FACS\n");
Simon Glass0e113842020-04-26 09:19:47 -0600381 facs = ctx->current;
382 acpi_inc_align(ctx, sizeof(struct acpi_facs));
Saket Sinha331141a2015-08-22 12:20:55 +0530383
384 acpi_create_facs(facs);
385
386 debug("ACPI: * DSDT\n");
Simon Glass0e113842020-04-26 09:19:47 -0600387 dsdt = ctx->current;
Bin Meng6a421582016-05-07 07:46:21 -0700388 memcpy(dsdt, &AmlCode, sizeof(struct acpi_table_header));
Simon Glass0e113842020-04-26 09:19:47 -0600389 acpi_inc(ctx, sizeof(struct acpi_table_header));
390 memcpy(ctx->current,
Bin Mengd90434b2016-05-11 07:45:05 -0700391 (char *)&AmlCode + sizeof(struct acpi_table_header),
392 dsdt->length - sizeof(struct acpi_table_header));
Simon Glass0e113842020-04-26 09:19:47 -0600393 acpi_inc_align(ctx, dsdt->length - sizeof(struct acpi_table_header));
Saket Sinha331141a2015-08-22 12:20:55 +0530394
Bin Mengd9050c62016-06-17 02:13:16 -0700395 /* Pack GNVS into the ACPI table area */
396 for (i = 0; i < dsdt->length; i++) {
397 u32 *gnvs = (u32 *)((u32)dsdt + i);
398 if (*gnvs == ACPI_GNVS_ADDR) {
Simon Glass0e113842020-04-26 09:19:47 -0600399 ulong addr = (ulong)map_to_sysmem(ctx->current);
400
401 debug("Fix up global NVS in DSDT to %#08lx\n", addr);
402 *gnvs = addr;
Bin Mengd9050c62016-06-17 02:13:16 -0700403 break;
404 }
405 }
406
407 /* Update DSDT checksum since we patched the GNVS address */
408 dsdt->checksum = 0;
409 dsdt->checksum = table_compute_checksum((void *)dsdt, dsdt->length);
410
411 /* Fill in platform-specific global NVS variables */
Simon Glass0e113842020-04-26 09:19:47 -0600412 acpi_create_gnvs(ctx->current);
413 acpi_inc_align(ctx, sizeof(struct acpi_global_nvs));
Bin Mengd9050c62016-06-17 02:13:16 -0700414
Saket Sinha331141a2015-08-22 12:20:55 +0530415 debug("ACPI: * FADT\n");
Simon Glass0e113842020-04-26 09:19:47 -0600416 fadt = ctx->current;
417 acpi_inc_align(ctx, sizeof(struct acpi_fadt));
Saket Sinha331141a2015-08-22 12:20:55 +0530418 acpi_create_fadt(fadt, facs, dsdt);
Simon Glass575a5472020-04-26 09:19:50 -0600419 acpi_add_table(ctx, fadt);
Saket Sinha331141a2015-08-22 12:20:55 +0530420
Saket Sinha331141a2015-08-22 12:20:55 +0530421 debug("ACPI: * MADT\n");
Simon Glass0e113842020-04-26 09:19:47 -0600422 madt = ctx->current;
Saket Sinha331141a2015-08-22 12:20:55 +0530423 acpi_create_madt(madt);
Simon Glass0e113842020-04-26 09:19:47 -0600424 acpi_inc_align(ctx, madt->header.length);
Simon Glass575a5472020-04-26 09:19:50 -0600425 acpi_add_table(ctx, madt);
Saket Sinha331141a2015-08-22 12:20:55 +0530426
Bin Meng44256b02016-05-07 07:46:25 -0700427 debug("ACPI: * MCFG\n");
Simon Glass0e113842020-04-26 09:19:47 -0600428 mcfg = ctx->current;
Bin Meng44256b02016-05-07 07:46:25 -0700429 acpi_create_mcfg(mcfg);
Simon Glass0e113842020-04-26 09:19:47 -0600430 acpi_inc_align(ctx, mcfg->header.length);
Simon Glass575a5472020-04-26 09:19:50 -0600431 acpi_add_table(ctx, mcfg);
Bin Meng44256b02016-05-07 07:46:25 -0700432
Andy Shevchenko607dbd12019-07-14 19:23:57 +0300433 debug("ACPI: * CSRT\n");
Simon Glass0e113842020-04-26 09:19:47 -0600434 csrt = ctx->current;
Andy Shevchenko607dbd12019-07-14 19:23:57 +0300435 acpi_create_csrt(csrt);
Simon Glass0e113842020-04-26 09:19:47 -0600436 acpi_inc_align(ctx, csrt->header.length);
Simon Glass575a5472020-04-26 09:19:50 -0600437 acpi_add_table(ctx, csrt);
Andy Shevchenko607dbd12019-07-14 19:23:57 +0300438
Andy Shevchenko4ca48c92018-11-20 23:52:38 +0200439 debug("ACPI: * SPCR\n");
Simon Glass0e113842020-04-26 09:19:47 -0600440 spcr = ctx->current;
Andy Shevchenko4ca48c92018-11-20 23:52:38 +0200441 acpi_create_spcr(spcr);
Simon Glass0e113842020-04-26 09:19:47 -0600442 acpi_inc_align(ctx, spcr->header.length);
Simon Glass575a5472020-04-26 09:19:50 -0600443 acpi_add_table(ctx, spcr);
Andy Shevchenko4ca48c92018-11-20 23:52:38 +0200444
Simon Glass179fb822020-04-26 09:19:48 -0600445 acpi_write_dev_tables(ctx);
446
Simon Glass0e113842020-04-26 09:19:47 -0600447 addr = map_to_sysmem(ctx->current);
448 debug("current = %lx\n", addr);
Saket Sinha331141a2015-08-22 12:20:55 +0530449
Simon Glass575a5472020-04-26 09:19:50 -0600450 acpi_rsdp_addr = (unsigned long)ctx->rsdp;
Bin Mengd2d22182016-05-07 07:46:12 -0700451 debug("ACPI: done\n");
Saket Sinha331141a2015-08-22 12:20:55 +0530452
Simon Glass0e113842020-04-26 09:19:47 -0600453 return addr;
Saket Sinha331141a2015-08-22 12:20:55 +0530454}
Bin Meng34bc74a2017-04-21 07:24:36 -0700455
Bin Menge1029252018-01-30 05:01:16 -0800456ulong acpi_get_rsdp_addr(void)
457{
458 return acpi_rsdp_addr;
459}