public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 5/7] x86: acpi: Deduplicate acpi_fill_madt() implementation
Date: Fri, 21 Jul 2017 22:32:04 +0300	[thread overview]
Message-ID: <20170721193206.586-6-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20170721193206.586-1-andriy.shevchenko@linux.intel.com>

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 <andriy.shevchenko@linux.intel.com>
---
 arch/x86/cpu/baytrail/acpi.c | 29 -----------------------------
 arch/x86/cpu/quark/acpi.c    | 29 -----------------------------
 arch/x86/lib/acpi_table.c    | 29 +++++++++++++++++++++++++++++
 3 files changed, 29 insertions(+), 58 deletions(-)

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 <asm/acpi_s3.h>
 #include <asm/acpi_table.h>
 #include <asm/io.h>
-#include <asm/ioapic.h>
-#include <asm/mpspec.h>
 #include <asm/tables.h>
 #include <asm/arch/global_nvs.h>
 #include <asm/arch/iomap.h>
@@ -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 <common.h>
 #include <asm/acpi_table.h>
-#include <asm/ioapic.h>
-#include <asm/mpspec.h>
 #include <asm/tables.h>
 #include <asm/arch/global_nvs.h>
 #include <asm/arch/iomap.h>
@@ -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 <asm/acpi/global_nvs.h>
 #include <asm/acpi_table.h>
 #include <asm/io.h>
+#include <asm/ioapic.h>
 #include <asm/lapic.h>
+#include <asm/mpspec.h>
 #include <asm/tables.h>
 #include <asm/arch/global_nvs.h>
 
@@ -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);
-- 
2.13.2

  parent reply	other threads:[~2017-07-21 19:32 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-21 19:31 [U-Boot] [PATCH v1 0/7] x86: acpi: Few enhancements and improvements Andy Shevchenko
2017-07-21 19:32 ` [U-Boot] [PATCH v1 1/7] Makefile: Don't shadow actual error when compile ASL Andy Shevchenko
2017-07-22 12:59   ` Bin Meng
2017-07-22 16:38     ` Andy Shevchenko
2017-07-22 16:47       ` Bin Meng
2017-07-28 13:46         ` Bin Meng
2017-07-21 19:32 ` [U-Boot] [PATCH v1 2/7] Makefile: Export build date as integer Andy Shevchenko
2017-07-22 13:11   ` Bin Meng
2017-07-28 13:46     ` Bin Meng
2017-07-21 19:32 ` [U-Boot] [PATCH v1 3/7] x86: acpi: Fill OEM revision Andy Shevchenko
2017-07-22 13:12   ` Bin Meng
2017-07-28 13:46     ` Bin Meng
2017-07-21 19:32 ` [U-Boot] [PATCH v1 4/7] x86: acpi: Name fields in FADT in accordance with specification Andy Shevchenko
2017-07-22 13:14   ` Bin Meng
2017-07-28 13:46     ` Bin Meng
2017-07-21 19:32 ` Andy Shevchenko [this message]
2017-07-22 13:33   ` [U-Boot] [PATCH v1 5/7] x86: acpi: Deduplicate acpi_fill_madt() implementation Bin Meng
2017-07-28 13:46     ` Bin Meng
2017-07-21 19:32 ` [U-Boot] [PATCH v1 6/7] x86: acpi: Export acpi_fill_mcfg() with __weak attribute Andy Shevchenko
2017-07-22 13:34   ` Bin Meng
2017-07-28 13:46     ` Bin Meng
2017-07-21 19:32 ` [U-Boot] [PATCH v1 7/7] x86: acpi: Don't touch hardware on HW reduced platforms Andy Shevchenko
2017-07-22 13:45   ` Bin Meng
2017-07-22 16:43     ` Andy Shevchenko
2017-07-22 16:51       ` Bin Meng
2017-07-23  0:48       ` Bin Meng
2017-07-25 18:12         ` Andy Shevchenko
2017-07-28 13:46     ` Bin Meng
2017-07-21 19:34 ` [U-Boot] [PATCH v1 0/7] x86: acpi: Few enhancements and improvements Andy Shevchenko

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=20170721193206.586-6-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --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