From patchwork Thu Oct 11 08:48:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 982347 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42W4PV582Bz9s3T; Thu, 11 Oct 2018 19:48:30 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1gAWdw-00046R-2N; Thu, 11 Oct 2018 08:48:28 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1gAWdv-00046G-GP for fwts-devel@lists.ubuntu.com; Thu, 11 Oct 2018 08:48:27 +0000 Received: from 1.general.alexhung.us.vpn ([10.172.65.254] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1gAWdu-0001fi-Mg; Thu, 11 Oct 2018 08:48:27 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH] acpi: button: check fixed hardware & control method power buttons Date: Thu, 11 Oct 2018 16:48:22 +0800 Message-Id: <20181011084822.29362-1-alex.hung@canonical.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" Accordingly to ACPI spec, fixed hardware power button and control method power button should be mutually exclusive. Signed-off-by: Alex Hung Acked-by: Colin Ian King Acked-by: Ivan Hu --- src/acpi/devices/buttons/power_button.c | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/acpi/devices/buttons/power_button.c b/src/acpi/devices/buttons/power_button.c index 4df65ea7..feea5bb4 100644 --- a/src/acpi/devices/buttons/power_button.c +++ b/src/acpi/devices/buttons/power_button.c @@ -137,6 +137,31 @@ static int method_test_UID(fwts_framework *fw) return fwts_method_test_UID(fw, &device); } +static int facp_test_pwrbutton(fwts_framework *fw) +{ + fwts_acpi_table_fadt *fadt; + fwts_acpi_table_info *table; + + if (fwts_acpi_find_table(fw, "FACP", 0, &table) != FWTS_OK) + return FWTS_SKIP; + + if (table == NULL) + return FWTS_SKIP; + + fadt = (fwts_acpi_table_fadt *)table->data; + + /* check PWR_BUTTON as in Table 4-13 Power Button Support */ + if (fadt->flags & 0x10) + fwts_passed(fw, "Fixed hardware power button does not exist."); + else + fwts_failed(fw, LOG_LEVEL_HIGH, + "PWRBFixedHardwareError", + "PWR_Button field in FACP should not be zero " + "with ACPI PNP0C0C device."); + + return FWTS_OK; +} + static fwts_framework_minor_test power_button_tests[] = { /* Device Specific Objects */ { method_test_HID, "Test _HID (Hardware ID)." }, @@ -152,6 +177,8 @@ static fwts_framework_minor_test power_button_tests[] = { { method_test_SUN, "Test _SUN (Slot User Number)." }, { method_test_STR, "Test _STR (String)." }, { method_test_UID, "Test _UID (Unique ID)." }, + /* Check against fixed hardware in FACP */ + { facp_test_pwrbutton, "Test FACP PWR_BUTTON." }, { NULL, NULL } };