Alexander Couzens (lynxis(a)fe80.eu) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/9708
-gerrit
commit 98d14808eacddc511705ee0fd2d1103d3d3f03ba
Author: Alexander Couzens <lynxis(a)fe80.eu>
Date: Thu Apr 16 02:03:26 2015 +0200
acpi/sata: add generic sata ssdt port generator
generate_sata_ssdt_ports() generates ports based on sata enable map
Change-Id: Ie68e19c93f093d6c61634c4adfde484b88f28a77
Signed-off-by: Alexander Couzens <lynxis(a)fe80.eu>
---
Makefile.inc | 2 +-
src/Kconfig | 2 ++
src/acpi/Kconfig | 6 +++++
src/acpi/Makefile.inc | 1 +
src/acpi/sata.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++
src/acpi/sata.h | 4 ++++
6 files changed, 75 insertions(+), 1 deletion(-)
diff --git a/Makefile.inc b/Makefile.inc
index 0c688f7..03b4489 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -52,7 +52,7 @@ PHONY+= clean-abuild coreboot lint lint-stable build-dirs
#######################################################################
# root source directories of coreboot
-subdirs-y := src/lib src/console src/device
+subdirs-y := src/lib src/console src/device src/acpi
subdirs-y += src/ec/acpi $(wildcard src/ec/*/*) $(wildcard src/southbridge/*/*)
subdirs-y += $(wildcard src/soc/*/*) $(wildcard src/northbridge/*/*)
subdirs-y += src/superio $(wildcard src/drivers/*) src/cpu src/vendorcode
diff --git a/src/Kconfig b/src/Kconfig
index 26e1194..fffe7a3 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -329,6 +329,8 @@ config RAM_CODE_SUPPORT
endmenu
+source "src/acpi/Kconfig"
+
source "src/mainboard/Kconfig"
source "src/arch/*/Kconfig"
diff --git a/src/acpi/Kconfig b/src/acpi/Kconfig
new file mode 100644
index 0000000..e025f99
--- /dev/null
+++ b/src/acpi/Kconfig
@@ -0,0 +1,6 @@
+
+config ACPI_SATA_GENERATOR
+ bool
+ default n
+ help
+ Use acpi sata port generator.
diff --git a/src/acpi/Makefile.inc b/src/acpi/Makefile.inc
new file mode 100644
index 0000000..53ac679
--- /dev/null
+++ b/src/acpi/Makefile.inc
@@ -0,0 +1 @@
+ramstage-$(CONFIG_ACPI_SATA_GENERATOR) += sata.c
diff --git a/src/acpi/sata.c b/src/acpi/sata.c
new file mode 100644
index 0000000..b488574
--- /dev/null
+++ b/src/acpi/sata.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2015 Alexander Couzens <lynxis(a)fe80.eu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc.
+ */
+
+#include "sata.h"
+
+#include <arch/acpi.h>
+#include <arch/acpigen.h>
+
+/* e.g.
+ * generate_sata_ssdt_ports("\_SB.PCI0.SATA", 0x3);
+ * generates:
+ * Scope (\_SB.PCI0.SATA)
+ * {
+ * Device (PRT0)
+ * {
+ * Name (_ADR, 0x0000FFFF) // _ADR: Address
+ * }
+ *
+ * Device (PRT1)
+ * {
+ * Name (_ADR, 0x0001FFFF) // _ADR: Address
+ * }
+ * }
+ */
+void generate_sata_ssdt_ports(const char *scope, uint8_t enable_map)
+{
+ int i;
+ int bit;
+ char port_name[4] = "PRT0";
+
+ acpigen_write_scope(scope);
+
+ /* generate a device for every enabled port */
+ for (i = 0; i < 8; i++) {
+ bit = 1 << i;
+ if (!(bit & enable_map))
+ continue;
+
+ port_name[3] = '0' + i;
+ acpigen_write_device(port_name);
+
+ acpigen_write_name_dword("_ADR", 0xffff + i * 0x10000);
+ acpigen_pop_len(); /* close PRT%d */
+ }
+
+ acpigen_pop_len(); /* close scope */
+}
diff --git a/src/acpi/sata.h b/src/acpi/sata.h
new file mode 100644
index 0000000..affaa34
--- /dev/null
+++ b/src/acpi/sata.h
@@ -0,0 +1,4 @@
+
+#include <stdint.h>
+
+void generate_sata_ssdt_ports(const char *scope, uint8_t enable_map);