From 7710379da9a5d06c7a6b2bcda29fa834575c551e Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Thu, 16 Apr 2015 02:03:26 +0200 Subject: 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 Reviewed-on: http://review.coreboot.org/9708 Tested-by: build bot (Jenkins) Reviewed-by: Philipp Deppenwiese Reviewed-by: Peter Stuge --- src/Kconfig | 2 ++ src/acpi/Kconfig | 6 +++++ src/acpi/Makefile.inc | 1 + src/acpi/sata.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/acpi/sata.h | 3 +++ 5 files changed, 76 insertions(+) create mode 100644 src/acpi/Kconfig create mode 100644 src/acpi/Makefile.inc create mode 100644 src/acpi/sata.c create mode 100644 src/acpi/sata.h (limited to 'src') diff --git a/src/Kconfig b/src/Kconfig index 5aa76fbc78..f685cc3969 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -330,6 +330,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 0000000000..e025f99d2a --- /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 0000000000..53ac6797ea --- /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 0000000000..60c7992102 --- /dev/null +++ b/src/acpi/sata.c @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2015 Alexander Couzens + * + * 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 +#include + +/* e.g. + * generate_sata_ssdt_ports("\_SB.PCI0.SATA", 0x3); + * generates: + * Scope (\_SB.PCI0.SATA) + * { + * Device (PR00) + * { + * Name (_ADR, 0x0000FFFF) // _ADR: Address + * } + * + * Device (PR01) + * { + * Name (_ADR, 0x0001FFFF) // _ADR: Address + * } + * } + * + */ +void generate_sata_ssdt_ports(const char *scope, uint32_t enable_map) +{ + int i; + uint32_t bit; + char port_name[4] = "PR00"; + + acpigen_write_scope(scope); + + /* generate a device for every enabled port */ + for (i = 0; i < 32; i++) { + bit = 1 << i; + if (!(bit & enable_map)) + continue; + + port_name[2] = '0' + i / 10; + port_name[3] = '0' + i % 10; + + 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 0000000000..af4b03dc12 --- /dev/null +++ b/src/acpi/sata.h @@ -0,0 +1,3 @@ +#include + +void generate_sata_ssdt_ports(const char *scope, uint32_t enable_map); -- cgit v1.2.3