summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Rudolph <patrick.rudolph@9elements.com>2020-02-13 13:00:41 +0100
committerFelix Held <felix-coreboot@felixheld.de>2020-02-28 16:14:38 +0000
commit1ac2cc253b120e5fcd8d3cb477724c36b5f35cb5 (patch)
tree2e56fc890ac6a7c8929356250623a95ae36fd326
parent2f55726609bb27d550b58f735b1426065558fee0 (diff)
downloadcoreboot-1ac2cc253b120e5fcd8d3cb477724c36b5f35cb5.tar.xz
superio/common: Validate devicetree
As the SSDT generator for LDNs expects a "parent" PNP device for proper ACPI code generation, validate that it is present. Make sure the devicetree looks as expected and print a BUG message if that's not the case. Tested on HP Z220: No BUG message was printed. Change-Id: I6cbcba8ac86a2a837e23055fdd7e529f9b3277a2 Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/38863 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Held <felix-coreboot@felixheld.de> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
-rw-r--r--src/superio/common/ssdt.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/superio/common/ssdt.c b/src/superio/common/ssdt.c
index 7aa24ea794..e31660fad1 100644
--- a/src/superio/common/ssdt.c
+++ b/src/superio/common/ssdt.c
@@ -162,12 +162,33 @@ static const char *name_from_hid(const char *hid)
void superio_common_fill_ssdt_generator(struct device *dev)
{
+ if (!dev || !dev->bus || !dev->bus->dev) {
+ printk(BIOS_CRIT, "BUG: Invalid argument in %s!\n", __func__);
+ return;
+ }
+
const char *scope = acpi_device_scope(dev);
const char *name = acpi_device_name(dev);
const u8 ldn = dev->path.pnp.device & 0xff;
const u8 vldn = (dev->path.pnp.device >> 8) & 0x7;
const char *hid;
+ /* Validate devicetree settings */
+ bool bug = false;
+ if (dev->bus->dev->path.type != DEVICE_PATH_PNP) {
+ bug = true;
+ printk(BIOS_CRIT, "BUG: Parent of device %s is not a PNP device\n",
+ dev_path(dev));
+ } else if (dev->bus->dev->path.pnp.port != dev->path.pnp.port) {
+ bug = true;
+ printk(BIOS_CRIT, "BUG: Parent of device %s has wrong I/O port\n",
+ dev_path(dev));
+ }
+ if (bug) {
+ printk(BIOS_CRIT, "BUG: Check your devicetree!\n");
+ return;
+ }
+
if (!scope || !name) {
printk(BIOS_ERR, "%s: Missing ACPI path/scope\n", dev_path(dev));
return;