From patchwork Sun Sep 6 21:43:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1358467 X-Patchwork-Delegate: bmeng.cn@gmail.com 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=OVqQVaUL; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4Bl4kQ1FcGz9sSn for ; Mon, 7 Sep 2020 07:46:54 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3DE398240E; Sun, 6 Sep 2020 23:44:43 +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="OVqQVaUL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7734A823F3; Sun, 6 Sep 2020 23:44:33 +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-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) (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 83FE0823E3 for ; Sun, 6 Sep 2020 23:44:29 +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-x141.google.com with SMTP id l4so10923076ilq.2 for ; Sun, 06 Sep 2020 14:44:29 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=jntw5j6Z2jTFWvGAcXXgWEOitmqp5OTGeOuczqshKQg=; b=OVqQVaULUHZNMw/e6oRNxA7UVF3T0swLCVqjcyglAeepbRy3SRtWpUwoSHNYSIEbHj zomPlHJhldGmFStzROlrec+vbUL44/zImR/jE8XRufG/leWnDmukada89RDBrTUJuUYe eYoNHRcoYnWES4P68PesrNaHi9NcS+18eTXXQ= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=jntw5j6Z2jTFWvGAcXXgWEOitmqp5OTGeOuczqshKQg=; b=dt163mtNWjCp2P8QWaWgbM8s3esbG+SVJTH/4Uz90XQb5pCbnFU6vW2MbUELuv1rgK kGHXTnYOPs9n7BSGB4YWD9aPhWVUAS7kCPJs0sObLz53rUrBLSAGT+OaQe9yR3Bwl/HW iCfbGXxkW+gnif6PlKqQOu0KJOTvBpTtVGM8ao20+yY/vPfe+eF9sTsqgGnL9kClSSxJ eBENlD2jgI0pAd9mJturBKN7xs0Pa28VlZI47Zqs80NuPx6PRI/WbWzS67/4FV3kshDn GKodJWZB4vVNXbO+ALeIS6FKbYqp2kpyyKIJ3sBgLsBjf38nnn6+6TUIlGH5oJk3tix6 WSuQ== X-Gm-Message-State: AOAM530vwG29qH318mnYo7Ht8qJbS6mEHUohgHcyNULfQDHs/M1GVddO Y1hkPnPipXLHf7GpIPBX1WBWHfWOmU3EmNLH X-Google-Smtp-Source: ABdhPJymcePqH/MWWMAYhxDT1XZgICrCMWkWIfLQvyDBfe2SiTYC+/cmDLNqnFhn2JGzmSmjc1LhXg== X-Received: by 2002:a92:c7c5:: with SMTP id g5mr2803127ilk.89.1599428668183; Sun, 06 Sep 2020 14:44:28 -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 w13sm6232663iox.10.2020.09.06.14.44.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Sep 2020 14:44:27 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Bernhard Messerklinger , Andy Shevchenko , Simon Glass Subject: [PATCH v3 11/57] acpi: Add support for writing a _PRW Date: Sun, 6 Sep 2020 15:43:19 -0600 Message-Id: <20200906214405.71632-2-sjg@chromium.org> X-Mailer: git-send-email 2.28.0.526.ge36021eeef-goog In-Reply-To: <20200906214405.71632-1-sjg@chromium.org> References: <20200906214405.71632-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.3 at phobos.denx.de X-Virus-Status: Clean A 'Power Resource for Wake' list the resources a device depends on for wake. Add a function to generate this. Signed-off-by: Simon Glass --- (no changes since v1) include/acpi/acpigen.h | 10 ++++++++++ lib/acpi/acpigen.c | 10 ++++++++++ test/dm/acpigen.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/include/acpi/acpigen.h b/include/acpi/acpigen.h index 228ac9c404b..a9b70123c0a 100644 --- a/include/acpi/acpigen.h +++ b/include/acpi/acpigen.h @@ -563,4 +563,14 @@ int acpigen_set_enable_tx_gpio(struct acpi_ctx *ctx, u32 tx_state_val, const char *dw0_read, const char *dw0_write, struct acpi_gpio *gpio, bool enable); +/** + * acpigen_write_prw() - Write a power resource for wake (_PRW) + * + * @ctx: ACPI context pointer + * @wake: GPE that wakes up the device + * @level: Deepest power system sleeping state that can be entered while still + * providing wake functionality + */ +void acpigen_write_prw(struct acpi_ctx *ctx, uint wake, uint level); + #endif diff --git a/lib/acpi/acpigen.c b/lib/acpi/acpigen.c index c609ef4daa4..527de89b1e1 100644 --- a/lib/acpi/acpigen.c +++ b/lib/acpi/acpigen.c @@ -426,6 +426,16 @@ void acpigen_write_register_resource(struct acpi_ctx *ctx, acpigen_write_resourcetemplate_footer(ctx); } +void acpigen_write_prw(struct acpi_ctx *ctx, uint wake, uint level) +{ + /* Name (_PRW, Package () { wake, level } */ + acpigen_write_name(ctx, "_PRW"); + acpigen_write_package(ctx, 2); + acpigen_write_integer(ctx, wake); + acpigen_write_integer(ctx, level); + acpigen_pop_len(ctx); +} + /* * ToUUID(uuid) * diff --git a/test/dm/acpigen.c b/test/dm/acpigen.c index 1b2767e732d..16ae7025856 100644 --- a/test/dm/acpigen.c +++ b/test/dm/acpigen.c @@ -1097,3 +1097,33 @@ static int dm_test_acpi_write_name(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_acpi_write_name, 0); + +/* Test emitting a string */ +static int dm_test_acpi_write_prw(struct unit_test_state *uts) +{ + struct acpi_ctx *ctx; + u8 *ptr; + + ut_assertok(alloc_context(&ctx)); + + ptr = acpigen_get_current(ctx); + acpigen_write_prw(ctx, 5, 3); + ut_asserteq(NAME_OP, *ptr++); + + ut_asserteq_strn("_PRW", (char *)ptr); + ptr += 4; + ut_asserteq(PACKAGE_OP, *ptr++); + ut_asserteq(8, acpi_test_get_length(ptr)); + ptr += 3; + ut_asserteq(2, *ptr++); + ut_asserteq(BYTE_PREFIX, *ptr++); + ut_asserteq(5, *ptr++); + ut_asserteq(BYTE_PREFIX, *ptr++); + ut_asserteq(3, *ptr++); + ut_asserteq_ptr(ptr, ctx->current); + + free_context(&ctx); + + return 0; +} +DM_TEST(dm_test_acpi_write_prw, 0);