From patchwork Mon May 16 09:11:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lv Zheng X-Patchwork-Id: 9099251 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F18609F30C for ; Mon, 16 May 2016 09:11:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0A8DE201B4 for ; Mon, 16 May 2016 09:11:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B1092028D for ; Mon, 16 May 2016 09:11:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753359AbcEPJL3 (ORCPT ); Mon, 16 May 2016 05:11:29 -0400 Received: from mga01.intel.com ([192.55.52.88]:16504 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752432AbcEPJLW (ORCPT ); Mon, 16 May 2016 05:11:22 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 16 May 2016 02:11:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,626,1455004800"; d="scan'208";a="977738114" Received: from lvzheng-z530.sh.intel.com ([10.239.159.67]) by orsmga002.jf.intel.com with ESMTP; 16 May 2016 02:11:19 -0700 From: Lv Zheng To: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Len Brown Cc: Lv Zheng , Lv Zheng , , linux-acpi@vger.kernel.org Subject: [PATCH 2/3] ACPI / sys: Update /sys/firmware/acpi/interrupts/gpexx using new GPE forced disabling/enabling mechanism Date: Mon, 16 May 2016 17:11:18 +0800 Message-Id: X-Mailer: git-send-email 1.7.10 In-Reply-To: References: Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now GPE can be forced enabling/disabling through GPE management APIs, this patch modifies /sys/firmware/acpi/interrupts/gpexx to use this new facility. The "block" command is implemented to invoke acpi_block_gpe() and the "unblock" command is implemented to invoke acpi_unblock_gpe(). The "force-poll"/"force-irq"/"unforce" command is implemented to invoke acpi_control_gpe_handling() to switch GPE handling mode (for EC driver only). "EN STS" is returned to display the current hardware register status, along with "!" flag to indicate the register bit unset and "*" flag to indicate the managed state. Signed-off-by: Lv Zheng --- drivers/acpi/sleep.c | 2 +- drivers/acpi/sysfs.c | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 7a2e4d4..d00544c 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c @@ -555,7 +555,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state) acpi_get_event_status(ACPI_EVENT_POWER_BUTTON, &pwr_btn_status); - if (pwr_btn_status & ACPI_EVENT_FLAG_SET) { + if (pwr_btn_status & ACPI_EVENT_FLAG_STATUS_SET) { acpi_clear_event(ACPI_EVENT_POWER_BUTTON); /* Flag for later */ pwr_btn_event_pending = true; diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index 4b3a9e2..7f33c90 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c @@ -599,6 +599,19 @@ static ssize_t counter_show(struct kobject *kobj, if (result) goto end; + if (status & ACPI_EVENT_FLAG_ENABLE_SET) + size += sprintf(buf + size, " EN"); + else + size += sprintf(buf + size, " !EN"); + if (status & ACPI_EVENT_FLAG_MANAGED) + size += sprintf(buf + size, "*"); + else + size += sprintf(buf + size, " "); + if (status & ACPI_EVENT_FLAG_STATUS_SET) + size += sprintf(buf + size, " STS"); + else + size += sprintf(buf + size, " !STS"); + if (!(status & ACPI_EVENT_FLAG_HAS_HANDLER)) size += sprintf(buf + size, " invalid"); else if (status & ACPI_EVENT_FLAG_ENABLED) @@ -656,8 +669,23 @@ static ssize_t counter_set(struct kobject *kobj, else if (!strcmp(buf, "enable\n") && !(status & ACPI_EVENT_FLAG_ENABLED)) result = acpi_enable_gpe(handle, index); + else if (!strcmp(buf, "block\n")) + result = acpi_block_gpe(handle, index); + else if (!strcmp(buf, "unblock\n") && + (status & ACPI_EVENT_FLAG_MANAGED)) + result = acpi_unblock_gpe(handle, index); + else if (!strcmp(buf, "force-poll\n")) + result = acpi_control_gpe_handling(handle, index, + TRUE, FALSE); + else if (!strcmp(buf, "force-irq\n")) + result = acpi_control_gpe_handling(handle, index, + FALSE, TRUE); + else if (!strcmp(buf, "unforce\n") && + (status & ACPI_EVENT_FLAG_MANAGED)) + result = acpi_control_gpe_handling(handle, index, + TRUE, TRUE); else if (!strcmp(buf, "clear\n") && - (status & ACPI_EVENT_FLAG_SET)) + (status & ACPI_EVENT_FLAG_STATUS_SET)) result = acpi_clear_gpe(handle, index); else if (!kstrtoul(buf, 0, &tmp)) all_counters[index].count = tmp; @@ -666,13 +694,13 @@ static ssize_t counter_set(struct kobject *kobj, } else if (index < num_gpes + ACPI_NUM_FIXED_EVENTS) { int event = index - num_gpes; if (!strcmp(buf, "disable\n") && - (status & ACPI_EVENT_FLAG_ENABLED)) + (status & ACPI_EVENT_FLAG_ENABLE_SET)) result = acpi_disable_event(event, ACPI_NOT_ISR); else if (!strcmp(buf, "enable\n") && - !(status & ACPI_EVENT_FLAG_ENABLED)) + !(status & ACPI_EVENT_FLAG_ENABLE_SET)) result = acpi_enable_event(event, ACPI_NOT_ISR); else if (!strcmp(buf, "clear\n") && - (status & ACPI_EVENT_FLAG_SET)) + (status & ACPI_EVENT_FLAG_STATUS_SET)) result = acpi_clear_event(event); else if (!kstrtoul(buf, 0, &tmp)) all_counters[index].count = tmp;