From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 21/26] x86: baytrail: Generate ACPI FADT/MADT tables
Date: Tue, 3 May 2016 14:52:52 +0200 [thread overview]
Message-ID: <57289F24.6050002@denx.de> (raw)
In-Reply-To: <1462174426-3470-22-git-send-email-bmeng.cn@gmail.com>
Hi Bin,
On 02.05.2016 09:33, Bin Meng wrote:
> FADT/MADT tables are platform specific. Generate them for BayTrail.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
> arch/x86/cpu/baytrail/Makefile | 1 +
> arch/x86/cpu/baytrail/acpi.c | 162 +++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 163 insertions(+)
> create mode 100644 arch/x86/cpu/baytrail/acpi.c
>
> diff --git a/arch/x86/cpu/baytrail/Makefile b/arch/x86/cpu/baytrail/Makefile
> index 5be5491..a0216f3 100644
> --- a/arch/x86/cpu/baytrail/Makefile
> +++ b/arch/x86/cpu/baytrail/Makefile
> @@ -8,3 +8,4 @@ obj-y += cpu.o
> obj-y += early_uart.o
> obj-y += fsp_configs.o
> obj-y += valleyview.o
> +obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi.o
> diff --git a/arch/x86/cpu/baytrail/acpi.c b/arch/x86/cpu/baytrail/acpi.c
> new file mode 100644
> index 0000000..a9c79f0
> --- /dev/null
> +++ b/arch/x86/cpu/baytrail/acpi.c
> @@ -0,0 +1,162 @@
> +/*
> + * Copyright (C) 2016, Bin Meng <bmeng.cn@gmail.com>
> + *
> + * SPDX-License-Identifier: GPL-2.0+
> + */
> +
> +#include <common.h>
> +#include <asm/acpi_table.h>
> +#include <asm/ioapic.h>
> +#include <asm/mpspec.h>
> +#include <asm/tables.h>
> +#include <asm/arch/iomap.h>
> +
> +void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs,
> + void *dsdt)
> +{
> + struct acpi_table_header *header = &(fadt->header);
> + u16 pmbase = ACPI_BASE_ADDRESS;
> +
> + memset((void *)fadt, 0, sizeof(struct acpi_fadt));
> +
> + acpi_fill_header(header, "FACP");
> + header->length = sizeof(struct acpi_fadt);
> + header->revision = 3;
> +
> + fadt->firmware_ctrl = (u32)facs;
> + fadt->dsdt = (u32)dsdt;
> + fadt->preferred_pm_profile = ACPI_PM_MOBILE;
> + fadt->sci_int = 9;
> + fadt->smi_cmd = 0;
> + fadt->acpi_enable = 0;
> + fadt->acpi_disable = 0;
> + fadt->s4bios_req = 0x0;
> + fadt->pstate_cnt = 0;
> + fadt->pm1a_evt_blk = pmbase;
> + fadt->pm1b_evt_blk = 0x0;
> + fadt->pm1a_cnt_blk = pmbase + 0x4;
> + fadt->pm1b_cnt_blk = 0x0;
> + fadt->pm2_cnt_blk = pmbase + 0x50;
> + fadt->pm_tmr_blk = pmbase + 0x8;
> + fadt->gpe0_blk = pmbase + 0x20;
> + fadt->gpe1_blk = 0;
> + fadt->pm1_evt_len = 4;
> + fadt->pm1_cnt_len = 2;
> + fadt->pm2_cnt_len = 1;
> + fadt->pm_tmr_len = 4;
> + fadt->gpe0_blk_len = 16;
> + fadt->gpe1_blk_len = 0;
> + fadt->gpe1_base = 0;
> + fadt->cst_cnt = 0;
> + fadt->p_lvl3_lat = 87;
> + fadt->flush_size = 1024;
> + fadt->flush_stride = 16;
> + fadt->duty_offset = 1;
> + fadt->day_alrm = 0xd;
> + fadt->mon_alrm = 0x00;
> + fadt->century = 0x00;
> + fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES | ACPI_FADT_8042;
> +
> + fadt->flags = ACPI_FADT_WBINVD |
> + ACPI_FADT_C1_SUPPORTED |
> + ACPI_FADT_SLEEP_BUTTON |
> + ACPI_FADT_RESET_REGISTER |
> + ACPI_FADT_SEALED_CASE |
> + ACPI_FADT_S4_RTC_WAKE |
> + ACPI_FADT_PLATFORM_CLOCK;
> + fadt->reset_reg.space_id = 1;
> + fadt->reset_reg.bit_width = 8;
> + fadt->reset_reg.bit_offset = 0;
> + fadt->reset_reg.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
> + fadt->reset_reg.addrl = 0xcf9;
> + fadt->reset_reg.addrh = 0;
> + fadt->reset_value = 6;
> + fadt->x_firmware_ctl_l = (u32)facs;
> + fadt->x_firmware_ctl_h = 0;
> + fadt->x_dsdt_l = (u32)dsdt;
> + fadt->x_dsdt_h = 0;
> +
> + fadt->x_pm1a_evt_blk.space_id = 1;
> + fadt->x_pm1a_evt_blk.bit_width = 32;
> + fadt->x_pm1a_evt_blk.bit_offset = 0;
> + fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
> + fadt->x_pm1a_evt_blk.addrl = pmbase;
> + fadt->x_pm1a_evt_blk.addrh = 0x0;
> +
> + fadt->x_pm1b_evt_blk.space_id = 1;
> + fadt->x_pm1b_evt_blk.bit_width = 0;
> + fadt->x_pm1b_evt_blk.bit_offset = 0;
> + fadt->x_pm1b_evt_blk.access_size = 0;
> + fadt->x_pm1b_evt_blk.addrl = 0x0;
> + fadt->x_pm1b_evt_blk.addrh = 0x0;
> +
> + fadt->x_pm1a_cnt_blk.space_id = 1;
> + fadt->x_pm1a_cnt_blk.bit_width = 16;
> + fadt->x_pm1a_cnt_blk.bit_offset = 0;
> + fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS;
> + fadt->x_pm1a_cnt_blk.addrl = pmbase + 0x4;
> + fadt->x_pm1a_cnt_blk.addrh = 0x0;
> +
> + fadt->x_pm1b_cnt_blk.space_id = 1;
> + fadt->x_pm1b_cnt_blk.bit_width = 0;
> + fadt->x_pm1b_cnt_blk.bit_offset = 0;
> + fadt->x_pm1b_cnt_blk.access_size = 0;
> + fadt->x_pm1b_cnt_blk.addrl = 0x0;
> + fadt->x_pm1b_cnt_blk.addrh = 0x0;
> +
> + fadt->x_pm2_cnt_blk.space_id = 1;
> + fadt->x_pm2_cnt_blk.bit_width = 8;
> + fadt->x_pm2_cnt_blk.bit_offset = 0;
> + fadt->x_pm2_cnt_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
> + fadt->x_pm2_cnt_blk.addrl = pmbase + 0x50;
> + fadt->x_pm2_cnt_blk.addrh = 0x0;
> +
> + fadt->x_pm_tmr_blk.space_id = 1;
> + fadt->x_pm_tmr_blk.bit_width = 32;
> + fadt->x_pm_tmr_blk.bit_offset = 0;
> + fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
> + fadt->x_pm_tmr_blk.addrl = pmbase + 0x8;
> + fadt->x_pm_tmr_blk.addrh = 0x0;
> +
> + fadt->x_gpe0_blk.space_id = 1;
> + fadt->x_gpe0_blk.bit_width = 128;
> + fadt->x_gpe0_blk.bit_offset = 0;
> + fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
> + fadt->x_gpe0_blk.addrl = pmbase + 0x20;
> + fadt->x_gpe0_blk.addrh = 0x0;
> +
> + fadt->x_gpe1_blk.space_id = 1;
> + fadt->x_gpe1_blk.bit_width = 0;
> + fadt->x_gpe1_blk.bit_offset = 0;
> + fadt->x_gpe1_blk.access_size = 0;
> + fadt->x_gpe1_blk.addrl = 0x0;
> + fadt->x_gpe1_blk.addrh = 0x0;
> +
> + header->checksum = table_compute_checksum(fadt, header->length);
> +}
> +
> +u32 acpi_madt_irq_overrides(u32 current)
> +{
> + struct acpi_madt_irqoverride *irqovr;
> + u16 sci_flags = MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_HIGH;
> +
> + irqovr = (void *)current;
> + current += acpi_create_madt_irqoverride(irqovr, 0, 0, 2, 0);
> +
> + irqovr = (void *)current;
> + current += acpi_create_madt_irqoverride(irqovr, 0, 9, 9, sci_flags);
> +
> + return current;
> +}
> +
> +u32 acpi_fill_madt(u32 current)
> +{
> + current = acpi_create_madt_lapics(current);
I'm not sure if you need '+=' here?
> +
> + current += acpi_create_madt_ioapic((struct acpi_madt_ioapic *)current,
> + 2, IO_APIC_ADDR, 0);
> +
> + current = acpi_madt_irq_overrides(current);
Here '+=' definitely seems to be necessary.
Thanks,
Stefan
next prev parent reply other threads:[~2016-05-03 12:52 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-02 7:33 [U-Boot] [PATCH 00/26] x86: Initial ACPI support for Intel BayTrail Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 01/26] x86: Drop asm/acpi.h Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 02/26] x86: Fix build warning in tables.c when CONFIG_SEABIOS Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 03/26] x86: acpi: Fix compiler warnings in write_acpi_tables() Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 04/26] x86: irq: Reserve IRQ9 for ACPI in PIC mode Bin Meng
2016-05-03 12:29 ` Stefan Roese
2016-05-03 12:46 ` Bin Meng
2016-05-03 13:04 ` Stefan Roese
2016-05-02 7:33 ` [U-Boot] [PATCH 05/26] x86: irq: Enable SCI on IRQ9 Bin Meng
2016-05-03 12:31 ` Stefan Roese
2016-05-07 14:06 ` Bin Meng
2016-05-07 15:42 ` Stefan Roese
2016-05-07 15:46 ` Bin Meng
2016-05-07 15:51 ` Stefan Roese
2016-05-07 18:46 ` Simon Glass
2016-05-02 7:33 ` [U-Boot] [PATCH 06/26] x86: dts: Update to include ACTL register details Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 07/26] acpi: Change build log for ASL files Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 08/26] acpi: Explicitly spell out dsdt.c in the make rule Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 09/26] acpi: Specify U-Boot include path for ASL files Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 10/26] acpi: Do not disable all errors/warnings/remarks when compiling ASL Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 11/26] x86: acpi: Remove unneeded codes Bin Meng
2016-05-03 12:33 ` Stefan Roese
2016-05-02 7:33 ` [U-Boot] [PATCH 12/26] x86: acpi: Various changes to acpi_table.h Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 13/26] x86: acpi: Reorder codes in acpi_table.h Bin Meng
2016-05-03 12:45 ` Stefan Roese
2016-05-02 7:33 ` [U-Boot] [PATCH 14/26] x86: acpi: Remove acpi_create_ssdt_generator() Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 15/26] x86: acpi: Change fill_header() Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 16/26] x86: acpi: Adjust orders in acpi_table.c Bin Meng
2016-05-03 12:48 ` Stefan Roese
2016-05-02 7:33 ` [U-Boot] [PATCH 17/26] x86: acpi: Change table write routine signature to use u32 Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 18/26] x86: acpi: Align FACS table to a 64 byte boundary Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 19/26] x86: acpi: Add some generic ASL libraries Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 20/26] x86: baytrail: Add platform ASL files Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 21/26] x86: baytrail: Generate ACPI FADT/MADT tables Bin Meng
2016-05-03 12:52 ` Stefan Roese [this message]
2016-05-07 5:48 ` Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 22/26] x86: baytrail: Enable ACPI table generation for all boards Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 23/26] x86: baytrail: Add .gitignore for ACPI enabled boards Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 24/26] x86: Remove acpi=off boot parameter when ACPI is on Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 25/26] x86: doc: Minor update for accuracy Bin Meng
2016-05-02 7:33 ` [U-Boot] [PATCH 26/26] x86: doc: Document ACPI support Bin Meng
2016-05-03 13:01 ` [U-Boot] [PATCH 00/26] x86: Initial ACPI support for Intel BayTrail Stefan Roese
2016-05-06 1:14 ` Bin Meng
2016-05-06 13:16 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57289F24.6050002@denx.de \
--to=sr@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox