Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3319655pxf; Mon, 15 Mar 2021 07:04:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxt3YrdrHXZ0OdEfjzJKqspEwqRtcYStnJDZ2jyF+5QD9QoePmJhP9pjfg2LmsIlQFmDD/7 X-Received: by 2002:aa7:c14a:: with SMTP id r10mr29055244edp.132.1615817081714; Mon, 15 Mar 2021 07:04:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615817081; cv=none; d=google.com; s=arc-20160816; b=BTEoh4rDogfnBgEohkMbekfmcGZB1Wg1IZuyHUeaL9lUJM6SbYwW6xUeW23fZ65fuf tu7R2jcvYUkV3HMbU/2XghqpIOyWelSmiZuyIwwj0yGP4eU5aSt4ZGhq/3nueVpP7liI Nsyv5FpeKQ2nUvDXmB1idyuH4jCJ18nxAW4bco+1X+jxA3Q7DCg1b+yepHXihbwTu0LU PF4N6jdKfov2Yf9zbmK2xj6Jwsu3Fqr+3LU/C3KepuLEZs6H9Q38qvaBtEYcXauCFKEp a8L3WM3+nvTvCLcd0qz9iRHWMwa4i0ahhzuDstft7eS5/Qdt77Cg/Ce6pOOaJSAu4Wlo maJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2nIumyUVwy1qmQFKLZrE8CbLp/sRF2QiTSQeGtRG7OM=; b=vR148A5q/agfHvefpfHfvr0Skz3FNDiJLVDHab+OPxBVy+xIxLJPPe/JuBh56kcJKZ lUJ7XWDdgS/to03WmNry+eZoH0cEfTYe4eXA7/nAG5eGAYBpHAr3RBcHl2HUf+7irN8Y 0m86vEIr5+Ab1ydYZhomHqk6iTCIhZoBuut1HsOr7PZX4L9GW6Po44laJHmERu54bb8p e0yDzh71rrILTmu2Ya95z4ub8wq5z6gRDZ+n6UwWabsCMTHR2hJ2LdYpYpUFXcoXAhge tnB6zjNbTSdTAnuSr2tcDKpz2Cud3GXxYuYuqtv0cib7QXpqJFTXDreHWYbcaPaa00vR iU4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SeRzBGmS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c15si10965950ede.264.2021.03.15.07.04.18; Mon, 15 Mar 2021 07:04:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SeRzBGmS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233800AbhCOOC2 (ORCPT + 99 others); Mon, 15 Mar 2021 10:02:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:33470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbhCON4x (ORCPT ); Mon, 15 Mar 2021 09:56:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AF58664EFD; Mon, 15 Mar 2021 13:56:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816601; bh=XGQ9QldgKn+CcqIUgzpvPJIyxkJgAlEbMRNodlLH8A4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SeRzBGmSkmS3kHtiRIUn7AwjTSIEoxs4Hgvk7CKyeuwMdv0ZgKcbnEZEUrRXqy8Qh NvAzg1sBmE7Kkfg8pB110KQPib+u/aqq1zGFILu8wVFw4BxtySZjdLx2X1r8/5ky+D 1EXFenYb/D7Vg/QaWandRn0WcWLa91up+WnFdtuo= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , Mika Westerberg , Linus Walleij Subject: [PATCH 5.11 014/306] gpiolib: acpi: Add ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER quirk Date: Mon, 15 Mar 2021 14:51:17 +0100 Message-Id: <20210315135508.099555684@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Andy Shevchenko commit 62d5247d239d4b48762192a251c647d7c997616a upstream. On some systems the ACPI tables has wrong pin number and instead of having a relative one it provides an absolute one in the global GPIO number space. Add ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER quirk to cope with such cases. Fixes: ba8c90c61847 ("gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2") Depends-on: 0ea683931adb ("gpio: dwapb: Convert driver to using the GPIO-lib-based IRQ-chip") Signed-off-by: Andy Shevchenko Acked-by: Mika Westerberg Acked-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpiolib-acpi.c | 7 ++++++- include/linux/gpio/consumer.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -677,6 +677,7 @@ static int acpi_populate_gpio_lookup(str if (!lookup->desc) { const struct acpi_resource_gpio *agpio = &ares->data.gpio; bool gpioint = agpio->connection_type == ACPI_RESOURCE_GPIO_TYPE_INT; + struct gpio_desc *desc; u16 pin_index; if (lookup->info.quirks & ACPI_GPIO_QUIRK_ONLY_GPIOIO && gpioint) @@ -689,8 +690,12 @@ static int acpi_populate_gpio_lookup(str if (pin_index >= agpio->pin_table_length) return 1; - lookup->desc = acpi_get_gpiod(agpio->resource_source.string_ptr, + if (lookup->info.quirks & ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER) + desc = gpio_to_desc(agpio->pin_table[pin_index]); + else + desc = acpi_get_gpiod(agpio->resource_source.string_ptr, agpio->pin_table[pin_index]); + lookup->desc = desc; lookup->info.pin_config = agpio->pin_config; lookup->info.debounce = agpio->debounce_timeout; lookup->info.gpioint = gpioint; --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -674,6 +674,8 @@ struct acpi_gpio_mapping { * get GpioIo type explicitly, this quirk may be used. */ #define ACPI_GPIO_QUIRK_ONLY_GPIOIO BIT(1) +/* Use given pin as an absolute GPIO number in the system */ +#define ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER BIT(2) unsigned int quirks; };