From patchwork Wed May 20 21:19:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1294791 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=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49S5H02ZFnz9sTS for ; Thu, 21 May 2020 07:19:24 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727835AbgETVTW (ORCPT ); Wed, 20 May 2020 17:19:22 -0400 Received: from mga17.intel.com ([192.55.52.151]:7202 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727897AbgETVTV (ORCPT ); Wed, 20 May 2020 17:19:21 -0400 IronPort-SDR: gV+tEyQrELzZOIWn8qvgZAc7g7AqvkP+snVeMpU7dok45E7hw9xnYWrKNuQwGeI2nM2FRXmOc6 MKvCAfEEOokg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2020 14:19:20 -0700 IronPort-SDR: ov3bWESxsQAO61JMwzRb+UO7/a/M6qej7pLhyDRhPgTCjmoPapbsMep5I7PyMdA7aOFPH6kOiA IlKeu79FFkrQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,415,1583222400"; d="scan'208";a="466673558" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 20 May 2020 14:19:18 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id BC2C9101; Thu, 21 May 2020 00:19:17 +0300 (EEST) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, Mika Westerberg , linux-acpi@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 1/5] gpiolib: acpi: Introduce opaque data field for quirks Date: Thu, 21 May 2020 00:19:12 +0300 Message-Id: <20200520211916.25727-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Some quirks may need an additional data to be provided. Introduce special quirks data field. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-acpi.c | 13 +++++++------ drivers/gpio/gpiolib-acpi.h | 2 ++ include/linux/gpio/consumer.h | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 9276051663da..3aa976f9ad1a 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -502,7 +502,7 @@ EXPORT_SYMBOL_GPL(devm_acpi_dev_remove_driver_gpios); static bool acpi_get_driver_gpio_data(struct acpi_device *adev, const char *name, int index, struct fwnode_reference_args *args, - unsigned int *quirks) + struct acpi_gpio_info *info) { const struct acpi_gpio_mapping *gm; @@ -519,7 +519,8 @@ static bool acpi_get_driver_gpio_data(struct acpi_device *adev, args->args[2] = par->active_low; args->nargs = 3; - *quirks = gm->quirks; + info->quirks = gm->quirks; + info->quirks_data = gm->quirks_data; return true; } @@ -716,7 +717,7 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode, struct acpi_gpio_lookup *lookup) { struct fwnode_reference_args args; - unsigned int quirks = 0; + struct acpi_gpio_info info = {}; int ret; memset(&args, 0, sizeof(args)); @@ -728,8 +729,7 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode, if (!adev) return ret; - if (!acpi_get_driver_gpio_data(adev, propname, index, &args, - &quirks)) + if (!acpi_get_driver_gpio_data(adev, propname, index, &args, &info)) return ret; } /* @@ -746,7 +746,8 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode, lookup->active_low = !!args.args[2]; lookup->info.adev = to_acpi_device_node(args.fwnode); - lookup->info.quirks = quirks; + lookup->info.quirks = info.quirks; + lookup->info.quirks_data = info.quirks_data; return 0; } diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h index 1c6d65cf0629..44cf55c9d35d 100644 --- a/drivers/gpio/gpiolib-acpi.h +++ b/drivers/gpio/gpiolib-acpi.h @@ -19,6 +19,7 @@ struct acpi_device; * @polarity: interrupt polarity as provided by ACPI * @triggering: triggering type as provided by ACPI * @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping + * @quirks_data: optional data for the specific @quirks */ struct acpi_gpio_info { struct acpi_device *adev; @@ -28,6 +29,7 @@ struct acpi_gpio_info { int polarity; int triggering; unsigned int quirks; + unsigned long quirks_data; }; #ifdef CONFIG_ACPI diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 901aab89d025..49743a499fda 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -676,6 +676,7 @@ struct acpi_gpio_mapping { #define ACPI_GPIO_QUIRK_ONLY_GPIOIO BIT(1) unsigned int quirks; + unsigned long quirks_data; }; #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_ACPI) From patchwork Wed May 20 21:19:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1294790 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=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49S5Gz6w8yz9sTR for ; Thu, 21 May 2020 07:19:23 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728007AbgETVTV (ORCPT ); Wed, 20 May 2020 17:19:21 -0400 Received: from mga03.intel.com ([134.134.136.65]:48520 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727835AbgETVTV (ORCPT ); Wed, 20 May 2020 17:19:21 -0400 IronPort-SDR: LtL66iIpzujCmj+BaHTayxod5AiA0ybTuKl1ZnBsWLJNABBOpZhFUC7iNkPGu5fQfkWrS1T3X4 do2oDqE/EyRQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2020 14:19:20 -0700 IronPort-SDR: IP3AoAyugHNk0b4bG3RfmhYQNL4HqzmBcTUqurzcE8+SeEPIblgyF3WYnIimzVx8f4B6slN1DU I0zc0WtMRuEw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,415,1583222400"; d="scan'208";a="440189894" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 20 May 2020 14:19:18 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C7A78D2; Thu, 21 May 2020 00:19:17 +0300 (EEST) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, Mika Westerberg , linux-acpi@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 2/5] gpiolib: acpi: Introduce a quirk to force GpioInt pin Date: Thu, 21 May 2020 00:19:13 +0300 Message-Id: <20200520211916.25727-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200520211916.25727-1-andriy.shevchenko@linux.intel.com> References: <20200520211916.25727-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Some ACPI tables have broken GpioInt() pin number, i.e. Intel Galileo gen 2 board, where it by some reason refers to the absolute one instead of being relative to the controller. In order to work around, introduce a new quirk to force this number. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-acpi.c | 9 +++++++-- include/linux/gpio/consumer.h | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 3aa976f9ad1a..93f3c833f3c7 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -651,6 +651,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data) const struct acpi_resource_gpio *agpio = &ares->data.gpio; bool gpioint = agpio->connection_type == ACPI_RESOURCE_GPIO_TYPE_INT; int pin_index; + u16 pin; if (lookup->info.quirks & ACPI_GPIO_QUIRK_ONLY_GPIOIO && gpioint) lookup->index++; @@ -662,8 +663,12 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data) if (pin_index >= agpio->pin_table_length) return 1; - lookup->desc = acpi_get_gpiod(agpio->resource_source.string_ptr, - agpio->pin_table[pin_index]); + if (lookup->info.quirks & ACPI_GPIO_QUIRK_FORCE_PIN) + pin = lookup->info.quirks_data; + else + pin = agpio->pin_table[pin_index]; + + lookup->desc = acpi_get_gpiod(agpio->resource_source.string_ptr, pin); lookup->info.pin_config = agpio->pin_config; lookup->info.gpioint = gpioint; diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 49743a499fda..e6bacebcecb7 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -674,6 +674,12 @@ struct acpi_gpio_mapping { * get GpioIo type explicitly, this quirk may be used. */ #define ACPI_GPIO_QUIRK_ONLY_GPIOIO BIT(1) +/* + * Some ACPI tables may have wrong pin defined. Allow to force the pin + * number if quirk is provided. New pin number should be provided via + * @quirks_data field. + */ +#define ACPI_GPIO_QUIRK_FORCE_PIN BIT(2) unsigned int quirks; unsigned long quirks_data; From patchwork Wed May 20 21:19:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1294789 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=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49S5Gy5bYhz9sSc for ; Thu, 21 May 2020 07:19:22 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727947AbgETVTV (ORCPT ); Wed, 20 May 2020 17:19:21 -0400 Received: from mga17.intel.com ([192.55.52.151]:7202 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727083AbgETVTV (ORCPT ); Wed, 20 May 2020 17:19:21 -0400 IronPort-SDR: JMY2KxPrHelOdHjFKH09R6S03Oc44Oy4V6WnV4dyolD+/DzZLXmrap0vhwVxkbX5svTb93Zgfh 79qp4Glj+qDg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2020 14:19:20 -0700 IronPort-SDR: b1zvrwV+JVBpTD1IzUBKm297bpY7NPFn9ws2U9MwPdsmirPn1aYYzVGQ+xaeWRa2V9Qw6w3U5O 1po8kFLUmUBw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,415,1583222400"; d="scan'208";a="264823758" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 20 May 2020 14:19:18 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id D57E517E; Thu, 21 May 2020 00:19:17 +0300 (EEST) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, Mika Westerberg , linux-acpi@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 3/5] gpio: pca953x: Drop unneeded ACPI_PTR() Date: Thu, 21 May 2020 00:19:14 +0300 Message-Id: <20200520211916.25727-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200520211916.25727-1-andriy.shevchenko@linux.intel.com> References: <20200520211916.25727-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org ACPI_PTR() becomes a no-op when !CONFIG_ACPI. This is not needed since we always have ID table enabled. Moreover, in the mentioned case compiler will complain about defined but not used variable. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpio-pca953x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 4bb3d3524bc7..1fca8dd7824f 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -1176,7 +1176,7 @@ static struct i2c_driver pca953x_driver = { .name = "pca953x", .pm = &pca953x_pm_ops, .of_match_table = pca953x_dt_ids, - .acpi_match_table = ACPI_PTR(pca953x_acpi_ids), + .acpi_match_table = pca953x_acpi_ids, }, .probe = pca953x_probe, .remove = pca953x_remove, From patchwork Wed May 20 21:19:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1294792 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=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49S5H11gw6z9sTX for ; Thu, 21 May 2020 07:19:25 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728046AbgETVTW (ORCPT ); Wed, 20 May 2020 17:19:22 -0400 Received: from mga03.intel.com ([134.134.136.65]:48520 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727083AbgETVTV (ORCPT ); Wed, 20 May 2020 17:19:21 -0400 IronPort-SDR: h0GKZKT3q3PUDuJwMn7/RK/Y1LupwB7ePn5vZcHNF3I8knlr8OeleK0EaceDKX3FRMBU6NQ8tf qTdX3yPZ6okw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2020 14:19:20 -0700 IronPort-SDR: wVimzsYJ+INLkSeU7CbcyCsyC+IHEyTQxED0fx8aunrGyE6+5IHbY2P32zWVvw+xzAQcv7G/0d m5Hd6rhf27xw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,415,1583222400"; d="scan'208";a="268400199" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 20 May 2020 14:19:18 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id DA79F14E; Thu, 21 May 2020 00:19:17 +0300 (EEST) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, Mika Westerberg , linux-acpi@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 4/5] gpio: pca935x: Allow IRQ support for driver built as a module Date: Thu, 21 May 2020 00:19:15 +0300 Message-Id: <20200520211916.25727-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200520211916.25727-1-andriy.shevchenko@linux.intel.com> References: <20200520211916.25727-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Perhaps by some historical reasons the IRQ support has been allowed only for built-in driver. However, there is nothing prevents us to build it as module an use as IRQ chip. Signed-off-by: Andy Shevchenko --- drivers/gpio/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 03c01f4aa316..eff454eed9a7 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -952,7 +952,7 @@ config GPIO_PCA953X config GPIO_PCA953X_IRQ bool "Interrupt controller support for PCA953x" - depends on GPIO_PCA953X=y + depends on GPIO_PCA953X select GPIOLIB_IRQCHIP help Say yes here to enable the pca953x to be used as an interrupt From patchwork Wed May 20 21:19:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1294793 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=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49S5H20rZnz9sSc for ; Thu, 21 May 2020 07:19:26 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728064AbgETVTZ (ORCPT ); Wed, 20 May 2020 17:19:25 -0400 Received: from mga14.intel.com ([192.55.52.115]:62119 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727083AbgETVTZ (ORCPT ); Wed, 20 May 2020 17:19:25 -0400 IronPort-SDR: RJC3jIs/lfqrMKXnWXA7/xApBSk2Te93GAyVS/MabAvmHS6/52mXRMeE4n5126lMotPOX0aS5u 8IluGkQE4nng== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2020 14:19:23 -0700 IronPort-SDR: bzpDiYVGjg1C84wFwOLdYXtwQZpqqrBrQQFurl4/mkkJHJitwmDeloWbm1V774Vs9fHGlCc0uY cqLHz9sv3/+A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,415,1583222400"; d="scan'208";a="253740025" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 20 May 2020 14:19:18 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E8AE21ED; Thu, 21 May 2020 00:19:17 +0300 (EEST) From: Andy Shevchenko To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, Mika Westerberg , linux-acpi@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 5/5] gpio: pca953x: Override GpioInt() pin for Intel Galileo Gen 2 Date: Thu, 21 May 2020 00:19:16 +0300 Message-Id: <20200520211916.25727-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200520211916.25727-1-andriy.shevchenko@linux.intel.com> References: <20200520211916.25727-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org ACPI table on Intel Galileo Gen 2 has wrong pin number for IRQ resource of one of the I²C GPIO expanders. ACPI GPIO library provides a special quirk which we may use in this case. With help of it, override GpioInt() pin for the affected platform. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpio-pca953x.c | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 1fca8dd7824f..2014563309be 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -113,6 +114,39 @@ static const struct acpi_device_id pca953x_acpi_ids[] = { }; MODULE_DEVICE_TABLE(acpi, pca953x_acpi_ids); +#ifdef CONFIG_GPIO_PCA953X_IRQ +static const struct acpi_gpio_params pca953x_interrupt_gpios = { 0, 0, true }; + +static const struct acpi_gpio_mapping pca953x_acpi_interrupt_gpios[] = { + { "interrupt-gpios", &pca953x_interrupt_gpios, 1, ACPI_GPIO_QUIRK_FORCE_PIN, 1 }, + { } +}; + +static int pca953x_acpi_interrupt_get_irq(struct device *dev) +{ + struct gpio_desc *desc; + + if (devm_acpi_dev_add_driver_gpios(dev, pca953x_acpi_interrupt_gpios)) + dev_warn(dev, "can't add GPIO ACPI mapping\n"); + + desc = devm_gpiod_get(dev, "interrupt", GPIOD_IN); + if (IS_ERR(desc)) + return PTR_ERR(desc); + + return gpiod_to_irq(desc); +} + +static const struct dmi_system_id pca953x_dmi_acpi_interrupt_info[] = { + { + .ident = "Intel Galileo Gen 2", + .matches = { + DMI_EXACT_MATCH(DMI_BOARD_NAME, "GalileoGen2"), + }, + }, + {} +}; +#endif + #define MAX_BANK 5 #define BANK_SZ 8 #define MAX_LINE (MAX_BANK * BANK_SZ) @@ -750,8 +784,18 @@ static int pca953x_irq_setup(struct pca953x_chip *chip, int irq_base) struct irq_chip *irq_chip = &chip->irq_chip; DECLARE_BITMAP(reg_direction, MAX_LINE); DECLARE_BITMAP(irq_stat, MAX_LINE); + const struct dmi_system_id *id; int ret; + id = dmi_first_match(pca953x_dmi_acpi_interrupt_info); + if (id) { + dev_info(&client->dev, "Applying ACPI interrupt quirk\n"); + + ret = pca953x_acpi_interrupt_get_irq(&client->dev); + if (ret > 0) + client->irq = ret; + } + if (!client->irq) return 0;