From patchwork Mon Nov 2 19:17:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 314883 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0DF7C00A89 for ; Mon, 2 Nov 2020 19:17:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AAC7422280 for ; Mon, 2 Nov 2020 19:17:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726162AbgKBTR6 (ORCPT ); Mon, 2 Nov 2020 14:17:58 -0500 Received: from mga01.intel.com ([192.55.52.88]:31019 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726088AbgKBTR6 (ORCPT ); Mon, 2 Nov 2020 14:17:58 -0500 IronPort-SDR: NRQUmyBAsSzeE2kOm3d59fw5wv0jxRRN0q0yRlXl/Q5AnxBBtbcrqBce5rkTR+EDcx4QqeYWdH 4Y+vD3/hpSWg== X-IronPort-AV: E=McAfee;i="6000,8403,9793"; a="186776808" X-IronPort-AV: E=Sophos;i="5.77,445,1596524400"; d="scan'208";a="186776808" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2020 11:17:57 -0800 IronPort-SDR: qGHFfzCDJqPumeXzWbDOsQTj9yuo9HmDzp9h1bVAhEj53sAu0YIiEp2rMm22MJWLZ7IDLtUKnV G5+VASUPA09A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,445,1596524400"; d="scan'208";a="336268092" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 02 Nov 2020 11:17:55 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 139F2D2; Mon, 2 Nov 2020 21:17:54 +0200 (EET) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org Cc: Andy Shevchenko , Hans de Goede , Jamie McClymont , Mika Westerberg Subject: [PATCH v3 1/4] gpiolib: acpi: Respect bias settings for GpioInt() resource Date: Mon, 2 Nov 2020 21:17:19 +0200 Message-Id: <20201102191722.81502-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201102191722.81502-1-andriy.shevchenko@linux.intel.com> References: <20201102191722.81502-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org In some cases the GpioInt() resource is coming with bias settings which may affect system functioning. Respect bias settings for GpioInt() resource by calling acpi_gpio_update_gpiod_*flags() API in acpi_dev_gpio_irq_get(). Reported-by: Jamie McClymont Signed-off-by: Andy Shevchenko Reviewed-by: Mika Westerberg --- drivers/gpio/gpiolib-acpi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 834a12f3219e..3a39e8a93226 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -942,6 +942,7 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) if (info.gpioint && idx++ == index) { unsigned long lflags = GPIO_LOOKUP_FLAGS_DEFAULT; + enum gpiod_flags dflags = GPIOD_ASIS; char label[32]; int irq; @@ -952,8 +953,11 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) if (irq < 0) return irq; + acpi_gpio_update_gpiod_flags(&dflags, &info); + acpi_gpio_update_gpiod_lookup_flags(&lflags, &info); + snprintf(label, sizeof(label), "GpioInt() %d", index); - ret = gpiod_configure_flags(desc, label, lflags, info.flags); + ret = gpiod_configure_flags(desc, label, lflags, dflags); if (ret < 0) return ret; From patchwork Mon Nov 2 19:17:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 314882 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C6B8C2D0A3 for ; Mon, 2 Nov 2020 19:18:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31E2122268 for ; Mon, 2 Nov 2020 19:18:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726506AbgKBTSI (ORCPT ); Mon, 2 Nov 2020 14:18:08 -0500 Received: from mga05.intel.com ([192.55.52.43]:1502 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726014AbgKBTSI (ORCPT ); Mon, 2 Nov 2020 14:18:08 -0500 IronPort-SDR: 2mRbSwGeVBuyyZB25GmPmwybYJqVefS07SwwZJOab6HhtdTdUOc6L2fdjxWmIOYu7RR4JzH/8/ t0E8k/KfiV9w== X-IronPort-AV: E=McAfee;i="6000,8403,9793"; a="253646730" X-IronPort-AV: E=Sophos;i="5.77,445,1596524400"; d="scan'208";a="253646730" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2020 11:18:07 -0800 IronPort-SDR: aoV65kocGXKaIEGCG/MP+fcPKuHLlzPoTTgdXbv32mgoOmcaLAQN471aji+R23r+uMgiM5NNhz FFx8GkmsCnYg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,445,1596524400"; d="scan'208";a="320163610" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 02 Nov 2020 11:18:05 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A7436D2; Mon, 2 Nov 2020 21:18:04 +0200 (EET) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org Cc: Andy Shevchenko , Mika Westerberg , Coiby Xu , Hans de Goede Subject: [PATCH v3 3/4] gpiolib: acpi: Take into account debounce settings Date: Mon, 2 Nov 2020 21:17:21 +0200 Message-Id: <20201102191722.81502-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201102191722.81502-1-andriy.shevchenko@linux.intel.com> References: <20201102191722.81502-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org We didn't take into account the debounce settings supplied by ACPI. This change is targeting the mentioned gap. Reported-by: Coiby Xu Cc: Hans de Goede Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-acpi.c | 5 +++++ drivers/gpio/gpiolib-acpi.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index c127b410a7a2..ad245b2a536e 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -664,6 +664,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data) lookup->desc = acpi_get_gpiod(agpio->resource_source.string_ptr, agpio->pin_table[pin_index]); lookup->info.pin_config = agpio->pin_config; + lookup->info.debounce = agpio->debounce_timeout; lookup->info.gpioint = gpioint; /* @@ -961,6 +962,10 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) if (ret < 0) return ret; + ret = gpiod_set_debounce(desc, info.debounce); + if (ret) + return ret; + irq_flags = acpi_dev_get_irq_type(info.triggering, info.polarity); diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h index 1c6d65cf0629..e2edb632b2cc 100644 --- a/drivers/gpio/gpiolib-acpi.h +++ b/drivers/gpio/gpiolib-acpi.h @@ -18,6 +18,7 @@ struct acpi_device; * @pin_config: pin bias as provided by ACPI * @polarity: interrupt polarity as provided by ACPI * @triggering: triggering type as provided by ACPI + * @debounce: debounce timeout as provided by ACPI * @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping */ struct acpi_gpio_info { @@ -27,6 +28,7 @@ struct acpi_gpio_info { int pin_config; int polarity; int triggering; + unsigned int debounce; unsigned int quirks; };