From patchwork Mon Nov 9 20:53:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 321488 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,URIBL_BLOCKED,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 151FFC55ABD for ; Mon, 9 Nov 2020 20:53:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BBC37206E3 for ; Mon, 9 Nov 2020 20:53:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730260AbgKIUxw (ORCPT ); Mon, 9 Nov 2020 15:53:52 -0500 Received: from mga02.intel.com ([134.134.136.20]:60885 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729817AbgKIUxw (ORCPT ); Mon, 9 Nov 2020 15:53:52 -0500 IronPort-SDR: VcGrCk3y4Z0+T+KBASCPAGRF9KJ5A+f64WfjPBhqMtBGmIy6h0o2m2A+2G+o8G3Pl4+2poqpRx KEq9834QAnug== X-IronPort-AV: E=McAfee;i="6000,8403,9800"; a="156876107" X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="156876107" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 12:53:51 -0800 IronPort-SDR: bYKvPhwNODVCHNAhYPF8vxKFjUWox1A853PUmY69BA7NaFaQ6G35QtdVZGMASIQdx8gLK7Jff+ R2Hl7eaMrFEQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="308142929" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 09 Nov 2020 12:53:48 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id EEC8E1CC; Mon, 9 Nov 2020 22:53:47 +0200 (EET) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org Cc: Mika Westerberg , Hans de Goede , Andy Shevchenko Subject: [PATCH v5 02/17] gpiolib: add missed break statement Date: Mon, 9 Nov 2020 22:53:17 +0200 Message-Id: <20201109205332.19592-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201109205332.19592-1-andriy.shevchenko@linux.intel.com> References: <20201109205332.19592-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org It's no difference in the functionality, but after the change the code is less error prone to various checkers. Signed-off-by: Andy Shevchenko Reviewed-by: Mika Westerberg --- drivers/gpio/gpiolib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index f94225d7817b..b45487aace7e 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2108,6 +2108,7 @@ static int gpio_set_config(struct gpio_desc *desc, enum pin_config_param mode) default: arg = 0; + break; } config = PIN_CONF_PACKED(mode, arg); From patchwork Mon Nov 9 20:53: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: 321486 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,URIBL_BLOCKED,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 AD215C61DD8 for ; Mon, 9 Nov 2020 20:53:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DB2B20731 for ; Mon, 9 Nov 2020 20:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730337AbgKIUxy (ORCPT ); Mon, 9 Nov 2020 15:53:54 -0500 Received: from mga07.intel.com ([134.134.136.100]:55716 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729817AbgKIUxy (ORCPT ); Mon, 9 Nov 2020 15:53:54 -0500 IronPort-SDR: Qn/3/k44ZVgy0ETgP8XH2JBjFiRNNBrq61X1ClZW65h6pDsCzMt7dZrhugiAxlMpocnuzqqUok zwGnRaHs5p2Q== X-IronPort-AV: E=McAfee;i="6000,8403,9800"; a="234037404" X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="234037404" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 12:53:52 -0800 IronPort-SDR: 86T1uVhyLVuFQ8xYnLHH8BPBNAeXhaWnDwFsoPCKbEaERY8EYDniAtHU+pyoodDF0nktwzRCnP TGS7BOxD3m6Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="541019888" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 09 Nov 2020 12:53:51 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 257714B0; Mon, 9 Nov 2020 22:53:48 +0200 (EET) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org Cc: Mika Westerberg , Hans de Goede , Andy Shevchenko Subject: [PATCH v5 06/17] gpiolib: move bias related code from gpio_set_config() to gpio_set_bias() Date: Mon, 9 Nov 2020 22:53:21 +0200 Message-Id: <20201109205332.19592-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201109205332.19592-1-andriy.shevchenko@linux.intel.com> References: <20201109205332.19592-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Move bias related code from gpio_set_config() to gpio_set_bias(). Signed-off-by: Andy Shevchenko Reviewed-by: Mika Westerberg --- drivers/gpio/gpiolib.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 1e545546fb09..0691ecbd9a16 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2107,25 +2107,13 @@ static int gpio_set_config_with_argument(struct gpio_desc *desc, static int gpio_set_config(struct gpio_desc *desc, enum pin_config_param mode) { - unsigned int arg; - - switch (mode) { - case PIN_CONFIG_BIAS_PULL_DOWN: - case PIN_CONFIG_BIAS_PULL_UP: - arg = 1; - break; - - default: - arg = 0; - break; - } - - return gpio_set_config_with_argument(desc, mode, arg); + return gpio_set_config_with_argument(desc, mode, 0); } static int gpio_set_bias(struct gpio_desc *desc) { enum pin_config_param bias; + unsigned int arg; int ret; if (test_bit(FLAG_BIAS_DISABLE, &desc->flags)) @@ -2137,7 +2125,18 @@ static int gpio_set_bias(struct gpio_desc *desc) else return 0; - ret = gpio_set_config(desc, bias); + switch (bias) { + case PIN_CONFIG_BIAS_PULL_DOWN: + case PIN_CONFIG_BIAS_PULL_UP: + arg = 1; + break; + + default: + arg = 0; + break; + } + + ret = gpio_set_config_with_argument(desc, bias, arg); if (ret != -ENOTSUPP) return ret; From patchwork Mon Nov 9 20:53:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 321484 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,URIBL_BLOCKED,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 D25D9C63777 for ; Mon, 9 Nov 2020 20:53:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8ADB12074F for ; Mon, 9 Nov 2020 20:53:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730408AbgKIUxz (ORCPT ); Mon, 9 Nov 2020 15:53:55 -0500 Received: from mga11.intel.com ([192.55.52.93]:33886 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730305AbgKIUxy (ORCPT ); Mon, 9 Nov 2020 15:53:54 -0500 IronPort-SDR: Ze6ylc3Qv2Sm96JUAzd5S3PrCLO/J+atGDwlIvu2Ku8pNABb7z0KUp8zCgjkRrKJgJChRyo6fU QBnuguT7rn5Q== X-IronPort-AV: E=McAfee;i="6000,8403,9800"; a="166360553" X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="166360553" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 12:53:53 -0800 IronPort-SDR: oy2CxVa8c2mWbc/qilhMJy9wHlv7LbEXIEVx63Bta9pVykmP2jFV8bAApfG0fz56rJjUMoksdS Cf4/GkN9wzFg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="365605629" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 09 Nov 2020 12:53:51 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2D6694C7; Mon, 9 Nov 2020 22:53:48 +0200 (EET) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org Cc: Mika Westerberg , Hans de Goede , Andy Shevchenko Subject: [PATCH v5 07/17] gpiolib: Extract gpio_set_config_with_argument_optional() helper Date: Mon, 9 Nov 2020 22:53:22 +0200 Message-Id: <20201109205332.19592-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201109205332.19592-1-andriy.shevchenko@linux.intel.com> References: <20201109205332.19592-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This function is useful for internal use in GPIO library. There will be new user coming, prepare a helper for the new comer and the existing ones. Signed-off-by: Andy Shevchenko Reviewed-by: Mika Westerberg --- drivers/gpio/gpiolib.c | 50 ++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 0691ecbd9a16..4558af08df23 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2105,6 +2105,30 @@ static int gpio_set_config_with_argument(struct gpio_desc *desc, return gpio_do_set_config(gc, gpio_chip_hwgpio(desc), config); } +static int gpio_set_config_with_argument_optional(struct gpio_desc *desc, + enum pin_config_param mode, + u32 argument) +{ + struct device *dev = &desc->gdev->dev; + int gpio = gpio_chip_hwgpio(desc); + int ret; + + ret = gpio_set_config_with_argument(desc, mode, argument); + if (ret != -ENOTSUPP) + return ret; + + switch (mode) { + case PIN_CONFIG_PERSIST_STATE: + if (ret) + dev_dbg(dev, "Persistence not supported for GPIO %d\n", gpio); + break; + default: + break; + } + + return 0; +} + static int gpio_set_config(struct gpio_desc *desc, enum pin_config_param mode) { return gpio_set_config_with_argument(desc, mode, 0); @@ -2114,7 +2138,6 @@ static int gpio_set_bias(struct gpio_desc *desc) { enum pin_config_param bias; unsigned int arg; - int ret; if (test_bit(FLAG_BIAS_DISABLE, &desc->flags)) bias = PIN_CONFIG_BIAS_DISABLE; @@ -2136,11 +2159,7 @@ static int gpio_set_bias(struct gpio_desc *desc) break; } - ret = gpio_set_config_with_argument(desc, bias, arg); - if (ret != -ENOTSUPP) - return ret; - - return 0; + return gpio_set_config_with_argument_optional(desc, bias, arg); } /** @@ -2382,10 +2401,6 @@ EXPORT_SYMBOL_GPL(gpiod_set_debounce); int gpiod_set_transitory(struct gpio_desc *desc, bool transitory) { enum pin_config_param mode = PIN_CONFIG_PERSIST_STATE; - struct gpio_chip *gc; - unsigned long packed; - int gpio; - int rc; VALIDATE_DESC(desc); /* @@ -2395,20 +2410,7 @@ int gpiod_set_transitory(struct gpio_desc *desc, bool transitory) assign_bit(FLAG_TRANSITORY, &desc->flags, transitory); /* If the driver supports it, set the persistence state now */ - gc = desc->gdev->chip; - if (!gc->set_config) - return 0; - - packed = pinconf_to_config_packed(mode, !transitory); - gpio = gpio_chip_hwgpio(desc); - rc = gpio_do_set_config(gc, gpio, packed); - if (rc == -ENOTSUPP) { - dev_dbg(&desc->gdev->dev, "Persistence not supported for GPIO %d\n", - gpio); - return 0; - } - - return rc; + return gpio_set_config_with_argument_optional(desc, mode, !transitory); } EXPORT_SYMBOL_GPL(gpiod_set_transitory); From patchwork Mon Nov 9 20:53:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 321481 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,URIBL_BLOCKED,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 E32BBC6369E for ; Mon, 9 Nov 2020 20:53:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A660E206E3 for ; Mon, 9 Nov 2020 20:53:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730469AbgKIUx6 (ORCPT ); Mon, 9 Nov 2020 15:53:58 -0500 Received: from mga03.intel.com ([134.134.136.65]:41852 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730272AbgKIUx5 (ORCPT ); Mon, 9 Nov 2020 15:53:57 -0500 IronPort-SDR: 8aKUoz8sx8qzX67Q6PUMh60HJiMlJM+DPbWgGgzqLyAywPoRQPqtXlOaGtHTe+ZpxrTtIJl9Pp zQtPQ9AvY3Vg== X-IronPort-AV: E=McAfee;i="6000,8403,9800"; a="169982901" X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="169982901" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 12:53:53 -0800 IronPort-SDR: i6jEOJcoZ3v944C9ha6n7awLURzg0+VOcF4crNTAQeHVuYaC4yZp+IaNPhVMCht4/zDAugp1ej dYJ4HvWfJTcg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="338482365" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 09 Nov 2020 12:53:51 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3E2A0580; Mon, 9 Nov 2020 22:53:48 +0200 (EET) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org Cc: Mika Westerberg , Hans de Goede , Andy Shevchenko , Jamie McClymont Subject: [PATCH v5 09/17] gpiolib: acpi: Respect bias settings for GpioInt() resource Date: Mon, 9 Nov 2020 22:53:24 +0200 Message-Id: <20201109205332.19592-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201109205332.19592-1-andriy.shevchenko@linux.intel.com> References: <20201109205332.19592-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 Acked-by: Linus Walleij 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 9 20:53:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 321483 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,URIBL_BLOCKED,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 A8A2AC63699 for ; Mon, 9 Nov 2020 20:53:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6553C206E3 for ; Mon, 9 Nov 2020 20:53:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730305AbgKIUxz (ORCPT ); Mon, 9 Nov 2020 15:53:55 -0500 Received: from mga09.intel.com ([134.134.136.24]:59643 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730267AbgKIUxz (ORCPT ); Mon, 9 Nov 2020 15:53:55 -0500 IronPort-SDR: KF3TpUCWdr6WlOyhsu5biokIxKOfkUgQe8YSPRNMWEuOGKmzEE1clLhEZ7sxrrIRelHsgyNKJU DYD689eBpZ9A== X-IronPort-AV: E=McAfee;i="6000,8403,9800"; a="170022472" X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="170022472" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 12:53:52 -0800 IronPort-SDR: PsLLLMhOVSsiU6HO2yLRApNEn/xYVbzlTQ8+BnLIw0Jv/YtMtmxXyZrEo2xUyAoFheT4zuu/kr toADRW2MGt1w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="355843048" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 09 Nov 2020 12:53:51 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 46F075D4; Mon, 9 Nov 2020 22:53:48 +0200 (EET) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org Cc: Mika Westerberg , Hans de Goede , Andy Shevchenko Subject: [PATCH v5 10/17] gpiolib: acpi: Use named item for enum gpiod_flags variable Date: Mon, 9 Nov 2020 22:53:25 +0200 Message-Id: <20201109205332.19592-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201109205332.19592-1-andriy.shevchenko@linux.intel.com> References: <20201109205332.19592-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Use named item instead of plain integer for enum gpiod_flags to make it clear that even 0 has its own meaning. Signed-off-by: Andy Shevchenko Acked-by: Linus Walleij Reviewed-by: Mika Westerberg --- drivers/gpio/gpiolib-acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 3a39e8a93226..c127b410a7a2 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -1136,7 +1136,7 @@ acpi_gpiochip_parse_own_gpio(struct acpi_gpio_chip *achip, int ret; *lflags = GPIO_LOOKUP_FLAGS_DEFAULT; - *dflags = 0; + *dflags = GPIOD_ASIS; *name = NULL; ret = fwnode_property_read_u32_array(fwnode, "gpios", gpios, From patchwork Mon Nov 9 20:53:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 321487 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,URIBL_BLOCKED,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 13F91C5517A for ; Mon, 9 Nov 2020 20:53:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C44B9206E3 for ; Mon, 9 Nov 2020 20:53:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730330AbgKIUxy (ORCPT ); Mon, 9 Nov 2020 15:53:54 -0500 Received: from mga09.intel.com ([134.134.136.24]:59643 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730187AbgKIUxy (ORCPT ); Mon, 9 Nov 2020 15:53:54 -0500 IronPort-SDR: 9nM5M65OK0KNRs6znjorzeJGh9PtgqPiw09e3ZptjlNWj765PkhJuWCnM+FwPmomX9LXocsqMD M3qJoE6j3y3A== X-IronPort-AV: E=McAfee;i="6000,8403,9800"; a="170022473" X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="170022473" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 12:53:53 -0800 IronPort-SDR: gvRkwhWL4B8Y5K5B7T7R6zgT9MDcGW0P4qwfv+Ho1+nfOxfwVOZcXr8oqB7rdXsAHiBeASc4Jz Zs7qusGTMhQw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="355843050" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 09 Nov 2020 12:53:51 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 58B275F0; Mon, 9 Nov 2020 22:53:48 +0200 (EET) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org Cc: Mika Westerberg , Hans de Goede , Andy Shevchenko Subject: [PATCH v5 12/17] gpiolib: acpi: Move acpi_gpio_to_gpiod_flags() upper in the code Date: Mon, 9 Nov 2020 22:53:27 +0200 Message-Id: <20201109205332.19592-13-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201109205332.19592-1-andriy.shevchenko@linux.intel.com> References: <20201109205332.19592-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Move acpi_gpio_to_gpiod_flags() upper in the code to allow further refactoring. Signed-off-by: Andy Shevchenko Reviewed-by: Mika Westerberg --- drivers/gpio/gpiolib-acpi.c | 66 ++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 6cbad96be866..999fd3816298 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -205,6 +205,39 @@ static void acpi_gpiochip_request_irqs(struct acpi_gpio_chip *acpi_gpio) acpi_gpiochip_request_irq(acpi_gpio, event); } +static enum gpiod_flags +acpi_gpio_to_gpiod_flags(const struct acpi_resource_gpio *agpio) +{ + switch (agpio->io_restriction) { + case ACPI_IO_RESTRICT_INPUT: + return GPIOD_IN; + case ACPI_IO_RESTRICT_OUTPUT: + /* + * ACPI GPIO resources don't contain an initial value for the + * GPIO. Therefore we deduce that value from the pull field + * instead. If the pin is pulled up we assume default to be + * high, if it is pulled down we assume default to be low, + * otherwise we leave pin untouched. + */ + switch (agpio->pin_config) { + case ACPI_PIN_CONFIG_PULLUP: + return GPIOD_OUT_HIGH; + case ACPI_PIN_CONFIG_PULLDOWN: + return GPIOD_OUT_LOW; + default: + break; + } + default: + break; + } + + /* + * Assume that the BIOS has configured the direction and pull + * accordingly. + */ + return GPIOD_ASIS; +} + static bool acpi_gpio_in_ignore_list(const char *controller_in, int pin_in) { const char *controller, *pin_str; @@ -530,39 +563,6 @@ static bool acpi_get_driver_gpio_data(struct acpi_device *adev, return false; } -static enum gpiod_flags -acpi_gpio_to_gpiod_flags(const struct acpi_resource_gpio *agpio) -{ - switch (agpio->io_restriction) { - case ACPI_IO_RESTRICT_INPUT: - return GPIOD_IN; - case ACPI_IO_RESTRICT_OUTPUT: - /* - * ACPI GPIO resources don't contain an initial value for the - * GPIO. Therefore we deduce that value from the pull field - * instead. If the pin is pulled up we assume default to be - * high, if it is pulled down we assume default to be low, - * otherwise we leave pin untouched. - */ - switch (agpio->pin_config) { - case ACPI_PIN_CONFIG_PULLUP: - return GPIOD_OUT_HIGH; - case ACPI_PIN_CONFIG_PULLDOWN: - return GPIOD_OUT_LOW; - default: - break; - } - default: - break; - } - - /* - * Assume that the BIOS has configured the direction and pull - * accordingly. - */ - return GPIOD_ASIS; -} - static int __acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, enum gpiod_flags update) { From patchwork Mon Nov 9 20:53:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 321482 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,URIBL_BLOCKED,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 5C8C1C56201 for ; Mon, 9 Nov 2020 20:53:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 23FE0206E3 for ; Mon, 9 Nov 2020 20:53:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730437AbgKIUx4 (ORCPT ); Mon, 9 Nov 2020 15:53:56 -0500 Received: from mga07.intel.com ([134.134.136.100]:55716 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729817AbgKIUxz (ORCPT ); Mon, 9 Nov 2020 15:53:55 -0500 IronPort-SDR: 3p5/weA4QlztWqJiE/Cs+gOL2Rs/dENg4HDZXt4Bxwjfg0VsjsbmQtBUM5cF7RAXlbkq2R31LE GfG7DG/LiywA== X-IronPort-AV: E=McAfee;i="6000,8403,9800"; a="234037411" X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="234037411" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 12:53:55 -0800 IronPort-SDR: l4GXwP0+fWAJNyJRxEmuKSkQdr0ErtWx1PBNuv9sMePomOUxXdvnrWR+MsLl47Iqzl0xoevAT3 bZm2dki8o5PA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="541019893" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 09 Nov 2020 12:53:53 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7F23D709; Mon, 9 Nov 2020 22:53:48 +0200 (EET) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org Cc: Mika Westerberg , Hans de Goede , Andy Shevchenko Subject: [PATCH v5 16/17] gpiolib: acpi: Use BIT() macro to increase readability Date: Mon, 9 Nov 2020 22:53:31 +0200 Message-Id: <20201109205332.19592-17-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201109205332.19592-1-andriy.shevchenko@linux.intel.com> References: <20201109205332.19592-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org We may use BIT() macro to increase readability in acpi_gpio_adr_space_handler(). Signed-off-by: Andy Shevchenko Reviewed-by: Mika Westerberg --- drivers/gpio/gpiolib-acpi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 31008b0aef77..b9c3140cbd6d 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -1097,8 +1097,7 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address, mutex_unlock(&achip->conn_lock); if (function == ACPI_WRITE) - gpiod_set_raw_value_cansleep(desc, - !!((1 << i) & *value)); + gpiod_set_raw_value_cansleep(desc, !!(*value & BIT(i))); else *value |= (u64)gpiod_get_raw_value_cansleep(desc) << i; } From patchwork Mon Nov 9 20:53:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 321485 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=-17.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 C7467C2D0A3 for ; Mon, 9 Nov 2020 20:53:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8730B206E3 for ; Mon, 9 Nov 2020 20:53:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729817AbgKIUx5 (ORCPT ); Mon, 9 Nov 2020 15:53:57 -0500 Received: from mga09.intel.com ([134.134.136.24]:59643 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730272AbgKIUxz (ORCPT ); Mon, 9 Nov 2020 15:53:55 -0500 IronPort-SDR: 6vrdtkOOy9eYs4LNGIaxxDV21roL5wHVzLYHjDtoxCrodkiCtFuefcUTvim4b0kjhdGn4IOuRT pqVJbK/ArbIg== X-IronPort-AV: E=McAfee;i="6000,8403,9800"; a="170022477" X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="170022477" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 12:53:54 -0800 IronPort-SDR: 6+Rsm0YuGlrET5ISCxnt+nScmKvZ38E1C47FKSGlbCR1bWJj2MHEHYoeoVqk43N3wECFLUHSIh jsd4P3YECBWg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="355843055" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 09 Nov 2020 12:53:53 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8A24C749; Mon, 9 Nov 2020 22:53:48 +0200 (EET) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org Cc: Mika Westerberg , Hans de Goede , Andy Shevchenko Subject: [PATCH v5 17/17] gpiolib: acpi: Make Intel GPIO tree official for GPIO ACPI work Date: Mon, 9 Nov 2020 22:53:32 +0200 Message-Id: <20201109205332.19592-18-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201109205332.19592-1-andriy.shevchenko@linux.intel.com> References: <20201109205332.19592-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Make Intel GPIO tree official for GPIO ACPI work. Signed-off-by: Andy Shevchenko Reviewed-by: Mika Westerberg --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index e73636b75f29..53236b2ea0af 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7483,6 +7483,7 @@ M: Andy Shevchenko L: linux-gpio@vger.kernel.org L: linux-acpi@vger.kernel.org S: Maintained +T: git git://git.kernel.org/pub/scm/linux/kernel/git/andy/linux-gpio-intel.git F: Documentation/firmware-guide/acpi/gpio-properties.rst F: drivers/gpio/gpiolib-acpi.c F: drivers/gpio/gpiolib-acpi.h