From patchwork Sun Apr 26 15:25:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1277090 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=GDmHM96j; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 499Bb40W32z9sRY for ; Mon, 27 Apr 2020 01:26:39 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A1DA181D33; Sun, 26 Apr 2020 17:26:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="GDmHM96j"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D529181D34; Sun, 26 Apr 2020 17:26:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 379F981CF4 for ; Sun, 26 Apr 2020 17:26:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x144.google.com with SMTP id w6so14334774ilg.1 for ; Sun, 26 Apr 2020 08:26:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=N3D4sOku5mLxTJUwLh3g+KlOh/7CqWgtypQEsjEZCco=; b=GDmHM96jaokLKoeA0yHylLwzJxQZdzLFO0ixIBMAV38rNCuX1vbVNbigtz9vvJMI2f gI2lXJlcE4Oj6eBCF83I/8rPP33dioQxmPf4YSZ9iXnmoXsDlAmFt0sL2BfM2YBGMvhy YjSLI7iXYzyq38vmuGRT5udiDb54ghbl6aI+8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=N3D4sOku5mLxTJUwLh3g+KlOh/7CqWgtypQEsjEZCco=; b=H9YTfhi/usJ4e836WONgIGO/+aHhhuOfq5CKFcx/U2INofC6RIDrptujwizkLK+FyQ BicsIbUL8UC4rrNX7uvjV0zE6fB9ZfIWUlPgLR2BoakTHj9S6sXgidYB7CF5ABugpuav V/5kCkvrbJfuuTKIZHP77dXYaTksHnOlEKVGFUw1RAWUJYmm7n/XoamtfGxN5DbFD5Vb n/6LrNyU+QDq+fBPbQ+UNL3FpTOv02HNzq4KAA2Jr1RaBBwp5cMESQHqEmW3GPajfOVe +bFEF+/9ZL/V6SLolK4oSOuv9qbfN6seBLOhdq2j5TClDBB98KI17mu1EYMhrzQJFW7M W2yQ== X-Gm-Message-State: AGi0PuY8LQc6GcpZvSPnWC9c/1dO9DA/VSSbIYRm2crOTC92nwCGV4H3 whdjxi4i1t+tFWXiczr7TIAm7e6+eF4VJQ== X-Google-Smtp-Source: APiQypIO+W6qWMRBfXwj2T1PDPRVLFDhBexhEESgoPbAKXC+2UXuCcWl9X2Gs4rRn6RjnVGNg97x6Q== X-Received: by 2002:a92:984e:: with SMTP id l75mr5092385ili.284.1587914783050; Sun, 26 Apr 2020 08:26:23 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id r16sm4437069ilb.32.2020.04.26.08.26.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2020 08:26:22 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Simon Glass , AKASHI Takahiro , Alex Marginean , Dario Binacchi , Heiko Schocher , Jagan Teki , Jean-Jacques Hiblot , Lukasz Majewski , Marek Vasut , Patrick Delaunay , Pavel Herrmann Subject: [PATCH v8 00/35] dm: Add programmatic generation of ACPI tables (part B) Date: Sun, 26 Apr 2020 09:25:43 -0600 Message-Id: <20200426152618.125646-1-sjg@chromium.org> X-Mailer: git-send-email 2.26.2.303.gf8c07b1a785-goog MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean This is split from the original series in an attempt to get things applied in chunks. This part includes: - writing basic ACPI code for integers, strings, names, packages - writing descriptors for GPIO, I2C, interrupts, SPI - writing code to enable/disable ACPI peripherals via GPIOs - writing SSDT and DSDT tables - additional ways to determine ACPI device names Much of this code is taken from coreboot and I have tried to avoid changing the original code for no reason. Changes include: - splitting the acpi_dp functions into their own file - adding tests - adding (lots of) comments - using a context pointer instead of global variables - tidying up some code where couldn't resist (e.g. acpigen_emit_namestring()) Changes in v8: - Capitalise ACPI_OPS_PTR - Split into more patches for review - Add tests - Move header definitions into this patch - Update sandbox driver slightly for testing - Update ACPI_DSTATUS enum - Rename to acpi_device_infer_name() - Update newly created sandbox tests Changes in v3: - Fix 'the an' typo - Fix 'sentinal' and 'METHOD_FILL_SDDT' typos - Correct the commit subject - Use acpi,ddn instead of acpi,desc Changes in v2: - Switch parameter order of _acpi_fill_ssdt() and make it static - Generalise the ACPI function recursion with acpi_recurse_method() - Generalise the ACPI function recursion with acpi_recurse_method() - Use OEM_TABLE_ID instead of ACPI_TABLE_CREATOR - Generalise the ACPI function recursion with acpi_recurse_method() Simon Glass (35): dm: core: Add an ACPI name for the root node acpi: Add a function to get a device path and scope acpi: Add a way to check device status irq: Add a method to convert an interrupt to ACPI acpi: Support generation of ACPI code acpi: Support generation of interrupt descriptor gpio: Add a method to convert a GPIO to ACPI acpi: Support string output acpi: Support generation of GPIO descriptor acpi: Support generation of a GPIO/irq for a device acpi: Support generation of I2C descriptor acpi: Support generation of SPI descriptor acpigen: Support writing a length acpigen: Support writing a package acpi: Support writing an integer acpi: Support writing a string acpi: Support writing a name acpi: Support writing a UUID acpi: Support writing Device Properties objects via _DSD acpi: Support writing a GPIO acpi: Support copying properties from device tree to ACPI acpi: Add support for various misc ACPI opcodes acpi: Add support for writing a Power Resource acpi: Add support for writing a GPIO power sequence acpi: Add support for a generic power sequence acpi: Add support for SSDT generation x86: acpi: Move MADT down a bit acpi: Record the items added to SSDT acpi: Support ordering SSDT data by device x86: Allow devices to write an SSDT acpi: Add support for DSDT generation x86: Allow devices to write to DSDT pci: Avoid a crash in device_is_on_pci_bus() dm: acpi: Enhance acpi_get_name() acpi: Add an acpi split command arch/sandbox/dts/test.dts | 14 +- arch/x86/lib/acpi_table.c | 75 ++- cmd/acpi.c | 15 +- doc/device-tree-bindings/chosen.txt | 9 + doc/device-tree-bindings/device.txt | 13 + drivers/core/acpi.c | 207 ++++++- drivers/core/root.c | 13 + drivers/gpio/gpio-uclass.c | 21 + drivers/gpio/sandbox.c | 78 +++ drivers/i2c/sandbox_i2c.c | 1 + drivers/misc/irq-uclass.c | 18 +- drivers/misc/irq_sandbox.c | 16 + drivers/rtc/sandbox_rtc.c | 11 + drivers/spi/sandbox_spi.c | 1 + include/acpi/acpi_device.h | 400 +++++++++++++ include/acpi/acpi_dp.h | 283 +++++++++ include/acpi/acpi_table.h | 6 + include/acpi/acpigen.h | 347 +++++++++++ include/asm-generic/gpio.h | 27 + include/dm/acpi.h | 63 ++ include/dm/device.h | 2 +- include/irq.h | 43 ++ include/spi.h | 4 +- include/test/ut.h | 17 + lib/acpi/Makefile | 3 + lib/acpi/acpi_device.c | 808 ++++++++++++++++++++++++++ lib/acpi/acpi_dp.c | 395 +++++++++++++ lib/acpi/acpigen.c | 475 +++++++++++++++ test/dm/Makefile | 2 + test/dm/acpi.c | 277 ++++++++- test/dm/acpi_dp.c | 510 ++++++++++++++++ test/dm/acpigen.c | 861 ++++++++++++++++++++++++++++ test/dm/gpio.c | 62 ++ test/dm/irq.c | 23 + test/dm/pci.c | 14 + 35 files changed, 5081 insertions(+), 33 deletions(-) create mode 100644 include/acpi/acpi_device.h create mode 100644 include/acpi/acpi_dp.h create mode 100644 include/acpi/acpigen.h create mode 100644 lib/acpi/acpi_device.c create mode 100644 lib/acpi/acpi_dp.c create mode 100644 lib/acpi/acpigen.c create mode 100644 test/dm/acpi_dp.c create mode 100644 test/dm/acpigen.c