From: Andy Shevchenko Date: Fri, 21 Jul 2017 19:32:04 +0000 (+0300) Subject: x86: acpi: Deduplicate acpi_fill_madt() implementation X-Git-Tag: v2017.09-rc1~17 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b156da91fb1c266f140d49b0e79bb7c4071dae43;p=u-boot x86: acpi: Deduplicate acpi_fill_madt() implementation In Baytrail and Quark support code acpi_fill_madt() is identical. Deduplicate its implementation by moving to lib/acpi_tables.c. At the same time mark acpi_fill_madt() with __weak attribute to keep a possibility to override it in platform code Signed-off-by: Andy Shevchenko Reviewed-by: Bin Meng --- diff --git a/arch/x86/cpu/baytrail/acpi.c b/arch/x86/cpu/baytrail/acpi.c index 55ed7de781..cbefdf871d 100644 --- a/arch/x86/cpu/baytrail/acpi.c +++ b/arch/x86/cpu/baytrail/acpi.c @@ -11,8 +11,6 @@ #include #include #include -#include -#include #include #include #include @@ -141,33 +139,6 @@ void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, header->checksum = table_compute_checksum(fadt, header->length); } -static int acpi_create_madt_irq_overrides(u32 current) -{ - struct acpi_madt_irqoverride *irqovr; - u16 sci_flags = MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_HIGH; - int length = 0; - - irqovr = (void *)current; - length += acpi_create_madt_irqoverride(irqovr, 0, 0, 2, 0); - - irqovr = (void *)(current + length); - length += acpi_create_madt_irqoverride(irqovr, 0, 9, 9, sci_flags); - - return length; -} - -u32 acpi_fill_madt(u32 current) -{ - current += acpi_create_madt_lapics(current); - - current += acpi_create_madt_ioapic((struct acpi_madt_ioapic *)current, - io_apic_read(IO_APIC_ID) >> 24, IO_APIC_ADDR, 0); - - current += acpi_create_madt_irq_overrides(current); - - return current; -} - void acpi_create_gnvs(struct acpi_global_nvs *gnvs) { struct udevice *dev; diff --git a/arch/x86/cpu/quark/acpi.c b/arch/x86/cpu/quark/acpi.c index 3968f7a8bf..5717a620b5 100644 --- a/arch/x86/cpu/quark/acpi.c +++ b/arch/x86/cpu/quark/acpi.c @@ -6,8 +6,6 @@ #include #include -#include -#include #include #include #include @@ -136,33 +134,6 @@ void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, header->checksum = table_compute_checksum(fadt, header->length); } -static int acpi_create_madt_irq_overrides(u32 current) -{ - struct acpi_madt_irqoverride *irqovr; - u16 sci_flags = MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_HIGH; - int length = 0; - - irqovr = (void *)current; - length += acpi_create_madt_irqoverride(irqovr, 0, 0, 2, 0); - - irqovr = (void *)(current + length); - length += acpi_create_madt_irqoverride(irqovr, 0, 9, 9, sci_flags); - - return length; -} - -u32 acpi_fill_madt(u32 current) -{ - current += acpi_create_madt_lapics(current); - - current += acpi_create_madt_ioapic((struct acpi_madt_ioapic *)current, - io_apic_read(IO_APIC_ID) >> 24, IO_APIC_ADDR, 0); - - current += acpi_create_madt_irq_overrides(current); - - return current; -} - void acpi_create_gnvs(struct acpi_global_nvs *gnvs) { /* quark is a uni-processor */ diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index c6f4d8941c..14d10c34cd 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -15,7 +15,9 @@ #include #include #include +#include #include +#include #include #include @@ -241,6 +243,33 @@ int acpi_create_madt_lapic_nmi(struct acpi_madt_lapic_nmi *lapic_nmi, return lapic_nmi->length; } +static int acpi_create_madt_irq_overrides(u32 current) +{ + struct acpi_madt_irqoverride *irqovr; + u16 sci_flags = MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_HIGH; + int length = 0; + + irqovr = (void *)current; + length += acpi_create_madt_irqoverride(irqovr, 0, 0, 2, 0); + + irqovr = (void *)(current + length); + length += acpi_create_madt_irqoverride(irqovr, 0, 9, 9, sci_flags); + + return length; +} + +__weak u32 acpi_fill_madt(u32 current) +{ + current += acpi_create_madt_lapics(current); + + current += acpi_create_madt_ioapic((struct acpi_madt_ioapic *)current, + io_apic_read(IO_APIC_ID) >> 24, IO_APIC_ADDR, 0); + + current += acpi_create_madt_irq_overrides(current); + + return current; +} + static void acpi_create_madt(struct acpi_madt *madt) { struct acpi_table_header *header = &(madt->header);