diff mbox series

[093/108] x86: apl: Generate CPU tables

Message ID 20200126220508.93.I2a86b43205b9beb2d6a9a77e9baff15f52fcf97e@changeid
State New
Headers show
Series RFC: dm: Add programatic generation of ACPI tables | expand

Commit Message

Simon Glass Jan. 27, 2020, 5:06 a.m. UTC
Add ACPI generation to the APL CPU driver.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 arch/x86/cpu/apollolake/cpu.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/arch/x86/cpu/apollolake/cpu.c b/arch/x86/cpu/apollolake/cpu.c
index 3ae99ccf04..0af1b0c2cb 100644
--- a/arch/x86/cpu/apollolake/cpu.c
+++ b/arch/x86/cpu/apollolake/cpu.c
@@ -8,6 +8,9 @@ 
 #include <dm.h>
 #include <asm/cpu_common.h>
 #include <asm/cpu_x86.h>
+#include <asm/intel_acpi.h>
+#include <asm/msr.h>
+#include <dm/acpi.h>
 
 static int apl_get_info(const struct udevice *dev, struct cpu_info *info)
 {
@@ -19,6 +22,25 @@  static int apl_get_count(const struct udevice *dev)
 	return 4;
 }
 
+static int acpi_cpu_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx)
+{
+	struct cpu_platdata *plat = dev_get_parent_platdata(dev);
+	int ret;
+
+	/* Trigger off the first CPU */
+	if (!plat->cpu_id) {
+		ret = generate_cpu_entries(ctx, dev);
+		if (ret)
+			return log_msg_ret("generate", ret);
+	}
+
+	return 0;
+}
+
+struct acpi_ops apl_cpu_acpi_ops = {
+	.fill_ssdt	= acpi_cpu_fill_ssdt,
+};
+
 static const struct cpu_ops cpu_x86_apl_ops = {
 	.get_desc	= cpu_x86_get_desc,
 	.get_info	= apl_get_info,
@@ -37,5 +59,6 @@  U_BOOT_DRIVER(cpu_x86_apl_drv) = {
 	.of_match	= cpu_x86_apl_ids,
 	.bind		= cpu_x86_bind,
 	.ops		= &cpu_x86_apl_ops,
+	acpi_ops_ptr(&apl_cpu_acpi_ops)
 	.flags		= DM_FLAG_PRE_RELOC,
 };